babylon.module.d.ts 5.8 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865
  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 = nearest */
  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. * Class 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. * @param array defines the source array
  2701. * @param offset defines the offset in the source array
  2702. * @returns the new Vector3
  2703. * @deprecated Please use FromArray instead.
  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. * @param array defines the source array
  2716. * @param offset defines the offset in the source array
  2717. * @param result defines the Vector3 where to store the result
  2718. * @deprecated Please use FromArrayToRef instead.
  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. * Stores a left-handed perspective projection into a given matrix with depth reversed
  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 not used as infinity is used as far clip
  4496. * @param result defines the target matrix
  4497. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4498. */
  4499. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4500. /**
  4501. * Creates a right-handed perspective projection matrix
  4502. * @param fov defines the horizontal field of view
  4503. * @param aspect defines the aspect ratio
  4504. * @param znear defines the near clip plane
  4505. * @param zfar defines the far clip plane
  4506. * @returns a new matrix as a right-handed perspective projection matrix
  4507. */
  4508. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4509. /**
  4510. * Stores a right-handed perspective projection into a given matrix
  4511. * @param fov defines the horizontal field of view
  4512. * @param aspect defines the aspect ratio
  4513. * @param znear defines the near clip plane
  4514. * @param zfar defines the far clip plane
  4515. * @param result defines the target matrix
  4516. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4517. */
  4518. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4519. /**
  4520. * Stores a right-handed perspective projection into a given matrix
  4521. * @param fov defines the horizontal field of view
  4522. * @param aspect defines the aspect ratio
  4523. * @param znear defines the near clip plane
  4524. * @param zfar not used as infinity is used as far clip
  4525. * @param result defines the target matrix
  4526. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4527. */
  4528. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4529. /**
  4530. * Stores a perspective projection for WebVR info a given matrix
  4531. * @param fov defines the field of view
  4532. * @param znear defines the near clip plane
  4533. * @param zfar defines the far clip plane
  4534. * @param result defines the target matrix
  4535. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4536. */
  4537. static PerspectiveFovWebVRToRef(fov: {
  4538. upDegrees: number;
  4539. downDegrees: number;
  4540. leftDegrees: number;
  4541. rightDegrees: number;
  4542. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4543. /**
  4544. * Computes a complete transformation matrix
  4545. * @param viewport defines the viewport to use
  4546. * @param world defines the world matrix
  4547. * @param view defines the view matrix
  4548. * @param projection defines the projection matrix
  4549. * @param zmin defines the near clip plane
  4550. * @param zmax defines the far clip plane
  4551. * @returns the transformation matrix
  4552. */
  4553. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4554. /**
  4555. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4556. * @param matrix defines the matrix to use
  4557. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4558. */
  4559. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4560. /**
  4561. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4562. * @param matrix defines the matrix to use
  4563. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4564. */
  4565. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4566. /**
  4567. * Compute the transpose of a given matrix
  4568. * @param matrix defines the matrix to transpose
  4569. * @returns the new matrix
  4570. */
  4571. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4572. /**
  4573. * Compute the transpose of a matrix and store it in a target matrix
  4574. * @param matrix defines the matrix to transpose
  4575. * @param result defines the target matrix
  4576. */
  4577. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4578. /**
  4579. * Computes a reflection matrix from a plane
  4580. * @param plane defines the reflection plane
  4581. * @returns a new matrix
  4582. */
  4583. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4584. /**
  4585. * Computes a reflection matrix from a plane
  4586. * @param plane defines the reflection plane
  4587. * @param result defines the target matrix
  4588. */
  4589. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4590. /**
  4591. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4592. * @param xaxis defines the value of the 1st axis
  4593. * @param yaxis defines the value of the 2nd axis
  4594. * @param zaxis defines the value of the 3rd axis
  4595. * @param result defines the target matrix
  4596. */
  4597. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4598. /**
  4599. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4600. * @param quat defines the quaternion to use
  4601. * @param result defines the target matrix
  4602. */
  4603. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4604. }
  4605. /**
  4606. * @hidden
  4607. */
  4608. export class TmpVectors {
  4609. static Vector2: Vector2[];
  4610. static Vector3: Vector3[];
  4611. static Vector4: Vector4[];
  4612. static Quaternion: Quaternion[];
  4613. static Matrix: Matrix[];
  4614. }
  4615. }
  4616. declare module "babylonjs/Maths/math.path" {
  4617. import { DeepImmutable, Nullable } from "babylonjs/types";
  4618. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4619. /**
  4620. * Defines potential orientation for back face culling
  4621. */
  4622. export enum Orientation {
  4623. /**
  4624. * Clockwise
  4625. */
  4626. CW = 0,
  4627. /** Counter clockwise */
  4628. CCW = 1
  4629. }
  4630. /** Class used to represent a Bezier curve */
  4631. export class BezierCurve {
  4632. /**
  4633. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4634. * @param t defines the time
  4635. * @param x1 defines the left coordinate on X axis
  4636. * @param y1 defines the left coordinate on Y axis
  4637. * @param x2 defines the right coordinate on X axis
  4638. * @param y2 defines the right coordinate on Y axis
  4639. * @returns the interpolated value
  4640. */
  4641. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4642. }
  4643. /**
  4644. * Defines angle representation
  4645. */
  4646. export class Angle {
  4647. private _radians;
  4648. /**
  4649. * Creates an Angle object of "radians" radians (float).
  4650. * @param radians the angle in radians
  4651. */
  4652. constructor(radians: number);
  4653. /**
  4654. * Get value in degrees
  4655. * @returns the Angle value in degrees (float)
  4656. */
  4657. degrees(): number;
  4658. /**
  4659. * Get value in radians
  4660. * @returns the Angle value in radians (float)
  4661. */
  4662. radians(): number;
  4663. /**
  4664. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4665. * @param a defines first vector
  4666. * @param b defines second vector
  4667. * @returns a new Angle
  4668. */
  4669. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4670. /**
  4671. * Gets a new Angle object from the given float in radians
  4672. * @param radians defines the angle value in radians
  4673. * @returns a new Angle
  4674. */
  4675. static FromRadians(radians: number): Angle;
  4676. /**
  4677. * Gets a new Angle object from the given float in degrees
  4678. * @param degrees defines the angle value in degrees
  4679. * @returns a new Angle
  4680. */
  4681. static FromDegrees(degrees: number): Angle;
  4682. }
  4683. /**
  4684. * This represents an arc in a 2d space.
  4685. */
  4686. export class Arc2 {
  4687. /** Defines the start point of the arc */
  4688. startPoint: Vector2;
  4689. /** Defines the mid point of the arc */
  4690. midPoint: Vector2;
  4691. /** Defines the end point of the arc */
  4692. endPoint: Vector2;
  4693. /**
  4694. * Defines the center point of the arc.
  4695. */
  4696. centerPoint: Vector2;
  4697. /**
  4698. * Defines the radius of the arc.
  4699. */
  4700. radius: number;
  4701. /**
  4702. * Defines the angle of the arc (from mid point to end point).
  4703. */
  4704. angle: Angle;
  4705. /**
  4706. * Defines the start angle of the arc (from start point to middle point).
  4707. */
  4708. startAngle: Angle;
  4709. /**
  4710. * Defines the orientation of the arc (clock wise/counter clock wise).
  4711. */
  4712. orientation: Orientation;
  4713. /**
  4714. * Creates an Arc object from the three given points : start, middle and end.
  4715. * @param startPoint Defines the start point of the arc
  4716. * @param midPoint Defines the midlle point of the arc
  4717. * @param endPoint Defines the end point of the arc
  4718. */
  4719. constructor(
  4720. /** Defines the start point of the arc */
  4721. startPoint: Vector2,
  4722. /** Defines the mid point of the arc */
  4723. midPoint: Vector2,
  4724. /** Defines the end point of the arc */
  4725. endPoint: Vector2);
  4726. }
  4727. /**
  4728. * Represents a 2D path made up of multiple 2D points
  4729. */
  4730. export class Path2 {
  4731. private _points;
  4732. private _length;
  4733. /**
  4734. * If the path start and end point are the same
  4735. */
  4736. closed: boolean;
  4737. /**
  4738. * Creates a Path2 object from the starting 2D coordinates x and y.
  4739. * @param x the starting points x value
  4740. * @param y the starting points y value
  4741. */
  4742. constructor(x: number, y: number);
  4743. /**
  4744. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4745. * @param x the added points x value
  4746. * @param y the added points y value
  4747. * @returns the updated Path2.
  4748. */
  4749. addLineTo(x: number, y: number): Path2;
  4750. /**
  4751. * 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.
  4752. * @param midX middle point x value
  4753. * @param midY middle point y value
  4754. * @param endX end point x value
  4755. * @param endY end point y value
  4756. * @param numberOfSegments (default: 36)
  4757. * @returns the updated Path2.
  4758. */
  4759. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4760. /**
  4761. * Closes the Path2.
  4762. * @returns the Path2.
  4763. */
  4764. close(): Path2;
  4765. /**
  4766. * Gets the sum of the distance between each sequential point in the path
  4767. * @returns the Path2 total length (float).
  4768. */
  4769. length(): number;
  4770. /**
  4771. * Gets the points which construct the path
  4772. * @returns the Path2 internal array of points.
  4773. */
  4774. getPoints(): Vector2[];
  4775. /**
  4776. * Retreives the point at the distance aways from the starting point
  4777. * @param normalizedLengthPosition the length along the path to retreive the point from
  4778. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4779. */
  4780. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4781. /**
  4782. * Creates a new path starting from an x and y position
  4783. * @param x starting x value
  4784. * @param y starting y value
  4785. * @returns a new Path2 starting at the coordinates (x, y).
  4786. */
  4787. static StartingAt(x: number, y: number): Path2;
  4788. }
  4789. /**
  4790. * Represents a 3D path made up of multiple 3D points
  4791. */
  4792. export class Path3D {
  4793. /**
  4794. * an array of Vector3, the curve axis of the Path3D
  4795. */
  4796. path: Vector3[];
  4797. private _curve;
  4798. private _distances;
  4799. private _tangents;
  4800. private _normals;
  4801. private _binormals;
  4802. private _raw;
  4803. private _alignTangentsWithPath;
  4804. private readonly _pointAtData;
  4805. /**
  4806. * new Path3D(path, normal, raw)
  4807. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4808. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4809. * @param path an array of Vector3, the curve axis of the Path3D
  4810. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4811. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4812. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4813. */
  4814. constructor(
  4815. /**
  4816. * an array of Vector3, the curve axis of the Path3D
  4817. */
  4818. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4819. /**
  4820. * Returns the Path3D array of successive Vector3 designing its curve.
  4821. * @returns the Path3D array of successive Vector3 designing its curve.
  4822. */
  4823. getCurve(): Vector3[];
  4824. /**
  4825. * Returns the Path3D array of successive Vector3 designing its curve.
  4826. * @returns the Path3D array of successive Vector3 designing its curve.
  4827. */
  4828. getPoints(): Vector3[];
  4829. /**
  4830. * @returns the computed length (float) of the path.
  4831. */
  4832. length(): number;
  4833. /**
  4834. * Returns an array populated with tangent vectors on each Path3D curve point.
  4835. * @returns an array populated with tangent vectors on each Path3D curve point.
  4836. */
  4837. getTangents(): Vector3[];
  4838. /**
  4839. * Returns an array populated with normal vectors on each Path3D curve point.
  4840. * @returns an array populated with normal vectors on each Path3D curve point.
  4841. */
  4842. getNormals(): Vector3[];
  4843. /**
  4844. * Returns an array populated with binormal vectors on each Path3D curve point.
  4845. * @returns an array populated with binormal vectors on each Path3D curve point.
  4846. */
  4847. getBinormals(): Vector3[];
  4848. /**
  4849. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4850. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4851. */
  4852. getDistances(): number[];
  4853. /**
  4854. * Returns an interpolated point along this path
  4855. * @param position the position of the point along this path, from 0.0 to 1.0
  4856. * @returns a new Vector3 as the point
  4857. */
  4858. getPointAt(position: number): Vector3;
  4859. /**
  4860. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4861. * @param position the position of the point along this path, from 0.0 to 1.0
  4862. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4863. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4864. */
  4865. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4866. /**
  4867. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4868. * @param position the position of the point along this path, from 0.0 to 1.0
  4869. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4870. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4871. */
  4872. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4873. /**
  4874. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4875. * @param position the position of the point along this path, from 0.0 to 1.0
  4876. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4877. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4878. */
  4879. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4880. /**
  4881. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4882. * @param position the position of the point along this path, from 0.0 to 1.0
  4883. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4884. */
  4885. getDistanceAt(position: number): number;
  4886. /**
  4887. * Returns the array index of the previous point of an interpolated point along this path
  4888. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4889. * @returns the array index
  4890. */
  4891. getPreviousPointIndexAt(position: number): number;
  4892. /**
  4893. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  4894. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4895. * @returns the sub position
  4896. */
  4897. getSubPositionAt(position: number): number;
  4898. /**
  4899. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4900. * @param target the vector of which to get the closest position to
  4901. * @returns the position of the closest virtual point on this path to the target vector
  4902. */
  4903. getClosestPositionTo(target: Vector3): number;
  4904. /**
  4905. * Returns a sub path (slice) of this path
  4906. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4907. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4908. * @returns a sub path (slice) of this path
  4909. */
  4910. slice(start?: number, end?: number): Path3D;
  4911. /**
  4912. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4913. * @param path path which all values are copied into the curves points
  4914. * @param firstNormal which should be projected onto the curve
  4915. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4916. * @returns the same object updated.
  4917. */
  4918. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4919. private _compute;
  4920. private _getFirstNonNullVector;
  4921. private _getLastNonNullVector;
  4922. private _normalVector;
  4923. /**
  4924. * Updates the point at data for an interpolated point along this curve
  4925. * @param position the position of the point along this curve, from 0.0 to 1.0
  4926. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4927. * @returns the (updated) point at data
  4928. */
  4929. private _updatePointAtData;
  4930. /**
  4931. * Updates the point at data from the specified parameters
  4932. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4933. * @param point the interpolated point
  4934. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4935. */
  4936. private _setPointAtData;
  4937. /**
  4938. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4939. */
  4940. private _updateInterpolationMatrix;
  4941. }
  4942. /**
  4943. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4944. * A Curve3 is designed from a series of successive Vector3.
  4945. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4946. */
  4947. export class Curve3 {
  4948. private _points;
  4949. private _length;
  4950. /**
  4951. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4952. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4953. * @param v1 (Vector3) the control point
  4954. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4955. * @param nbPoints (integer) the wanted number of points in the curve
  4956. * @returns the created Curve3
  4957. */
  4958. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4959. /**
  4960. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4961. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4962. * @param v1 (Vector3) the first control point
  4963. * @param v2 (Vector3) the second control point
  4964. * @param v3 (Vector3) the end point of the Cubic Bezier
  4965. * @param nbPoints (integer) the wanted number of points in the curve
  4966. * @returns the created Curve3
  4967. */
  4968. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4969. /**
  4970. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4971. * @param p1 (Vector3) the origin point of the Hermite Spline
  4972. * @param t1 (Vector3) the tangent vector at the origin point
  4973. * @param p2 (Vector3) the end point of the Hermite Spline
  4974. * @param t2 (Vector3) the tangent vector at the end point
  4975. * @param nbPoints (integer) the wanted number of points in the curve
  4976. * @returns the created Curve3
  4977. */
  4978. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4979. /**
  4980. * Returns a Curve3 object along a CatmullRom Spline curve :
  4981. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4982. * @param nbPoints (integer) the wanted number of points between each curve control points
  4983. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4984. * @returns the created Curve3
  4985. */
  4986. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4987. /**
  4988. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4989. * A Curve3 is designed from a series of successive Vector3.
  4990. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4991. * @param points points which make up the curve
  4992. */
  4993. constructor(points: Vector3[]);
  4994. /**
  4995. * @returns the Curve3 stored array of successive Vector3
  4996. */
  4997. getPoints(): Vector3[];
  4998. /**
  4999. * @returns the computed length (float) of the curve.
  5000. */
  5001. length(): number;
  5002. /**
  5003. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5004. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5005. * curveA and curveB keep unchanged.
  5006. * @param curve the curve to continue from this curve
  5007. * @returns the newly constructed curve
  5008. */
  5009. continue(curve: DeepImmutable<Curve3>): Curve3;
  5010. private _computeLength;
  5011. }
  5012. }
  5013. declare module "babylonjs/Animations/easing" {
  5014. /**
  5015. * This represents the main contract an easing function should follow.
  5016. * Easing functions are used throughout the animation system.
  5017. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5018. */
  5019. export interface IEasingFunction {
  5020. /**
  5021. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5022. * of the easing function.
  5023. * The link below provides some of the most common examples of easing functions.
  5024. * @see https://easings.net/
  5025. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5026. * @returns the corresponding value on the curve defined by the easing function
  5027. */
  5028. ease(gradient: number): number;
  5029. }
  5030. /**
  5031. * Base class used for every default easing function.
  5032. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5033. */
  5034. export class EasingFunction implements IEasingFunction {
  5035. /**
  5036. * Interpolation follows the mathematical formula associated with the easing function.
  5037. */
  5038. static readonly EASINGMODE_EASEIN: number;
  5039. /**
  5040. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5041. */
  5042. static readonly EASINGMODE_EASEOUT: number;
  5043. /**
  5044. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5045. */
  5046. static readonly EASINGMODE_EASEINOUT: number;
  5047. private _easingMode;
  5048. /**
  5049. * Sets the easing mode of the current function.
  5050. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5051. */
  5052. setEasingMode(easingMode: number): void;
  5053. /**
  5054. * Gets the current easing mode.
  5055. * @returns the easing mode
  5056. */
  5057. getEasingMode(): number;
  5058. /**
  5059. * @hidden
  5060. */
  5061. easeInCore(gradient: number): number;
  5062. /**
  5063. * Given an input gradient between 0 and 1, this returns the corresponding value
  5064. * of the easing function.
  5065. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5066. * @returns the corresponding value on the curve defined by the easing function
  5067. */
  5068. ease(gradient: number): number;
  5069. }
  5070. /**
  5071. * Easing function with a circle shape (see link below).
  5072. * @see https://easings.net/#easeInCirc
  5073. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5074. */
  5075. export class CircleEase extends EasingFunction implements IEasingFunction {
  5076. /** @hidden */
  5077. easeInCore(gradient: number): number;
  5078. }
  5079. /**
  5080. * Easing function with a ease back shape (see link below).
  5081. * @see https://easings.net/#easeInBack
  5082. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5083. */
  5084. export class BackEase extends EasingFunction implements IEasingFunction {
  5085. /** Defines the amplitude of the function */
  5086. amplitude: number;
  5087. /**
  5088. * Instantiates a back ease easing
  5089. * @see https://easings.net/#easeInBack
  5090. * @param amplitude Defines the amplitude of the function
  5091. */
  5092. constructor(
  5093. /** Defines the amplitude of the function */
  5094. amplitude?: number);
  5095. /** @hidden */
  5096. easeInCore(gradient: number): number;
  5097. }
  5098. /**
  5099. * Easing function with a bouncing shape (see link below).
  5100. * @see https://easings.net/#easeInBounce
  5101. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5102. */
  5103. export class BounceEase extends EasingFunction implements IEasingFunction {
  5104. /** Defines the number of bounces */
  5105. bounces: number;
  5106. /** Defines the amplitude of the bounce */
  5107. bounciness: number;
  5108. /**
  5109. * Instantiates a bounce easing
  5110. * @see https://easings.net/#easeInBounce
  5111. * @param bounces Defines the number of bounces
  5112. * @param bounciness Defines the amplitude of the bounce
  5113. */
  5114. constructor(
  5115. /** Defines the number of bounces */
  5116. bounces?: number,
  5117. /** Defines the amplitude of the bounce */
  5118. bounciness?: number);
  5119. /** @hidden */
  5120. easeInCore(gradient: number): number;
  5121. }
  5122. /**
  5123. * Easing function with a power of 3 shape (see link below).
  5124. * @see https://easings.net/#easeInCubic
  5125. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5126. */
  5127. export class CubicEase extends EasingFunction implements IEasingFunction {
  5128. /** @hidden */
  5129. easeInCore(gradient: number): number;
  5130. }
  5131. /**
  5132. * Easing function with an elastic shape (see link below).
  5133. * @see https://easings.net/#easeInElastic
  5134. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5135. */
  5136. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5137. /** Defines the number of oscillations*/
  5138. oscillations: number;
  5139. /** Defines the amplitude of the oscillations*/
  5140. springiness: number;
  5141. /**
  5142. * Instantiates an elastic easing function
  5143. * @see https://easings.net/#easeInElastic
  5144. * @param oscillations Defines the number of oscillations
  5145. * @param springiness Defines the amplitude of the oscillations
  5146. */
  5147. constructor(
  5148. /** Defines the number of oscillations*/
  5149. oscillations?: number,
  5150. /** Defines the amplitude of the oscillations*/
  5151. springiness?: number);
  5152. /** @hidden */
  5153. easeInCore(gradient: number): number;
  5154. }
  5155. /**
  5156. * Easing function with an exponential shape (see link below).
  5157. * @see https://easings.net/#easeInExpo
  5158. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5159. */
  5160. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5161. /** Defines the exponent of the function */
  5162. exponent: number;
  5163. /**
  5164. * Instantiates an exponential easing function
  5165. * @see https://easings.net/#easeInExpo
  5166. * @param exponent Defines the exponent of the function
  5167. */
  5168. constructor(
  5169. /** Defines the exponent of the function */
  5170. exponent?: number);
  5171. /** @hidden */
  5172. easeInCore(gradient: number): number;
  5173. }
  5174. /**
  5175. * Easing function with a power shape (see link below).
  5176. * @see https://easings.net/#easeInQuad
  5177. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5178. */
  5179. export class PowerEase extends EasingFunction implements IEasingFunction {
  5180. /** Defines the power of the function */
  5181. power: number;
  5182. /**
  5183. * Instantiates an power base easing function
  5184. * @see https://easings.net/#easeInQuad
  5185. * @param power Defines the power of the function
  5186. */
  5187. constructor(
  5188. /** Defines the power of the function */
  5189. power?: number);
  5190. /** @hidden */
  5191. easeInCore(gradient: number): number;
  5192. }
  5193. /**
  5194. * Easing function with a power of 2 shape (see link below).
  5195. * @see https://easings.net/#easeInQuad
  5196. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5197. */
  5198. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5199. /** @hidden */
  5200. easeInCore(gradient: number): number;
  5201. }
  5202. /**
  5203. * Easing function with a power of 4 shape (see link below).
  5204. * @see https://easings.net/#easeInQuart
  5205. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5206. */
  5207. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5208. /** @hidden */
  5209. easeInCore(gradient: number): number;
  5210. }
  5211. /**
  5212. * Easing function with a power of 5 shape (see link below).
  5213. * @see https://easings.net/#easeInQuint
  5214. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5215. */
  5216. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5217. /** @hidden */
  5218. easeInCore(gradient: number): number;
  5219. }
  5220. /**
  5221. * Easing function with a sin shape (see link below).
  5222. * @see https://easings.net/#easeInSine
  5223. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5224. */
  5225. export class SineEase extends EasingFunction implements IEasingFunction {
  5226. /** @hidden */
  5227. easeInCore(gradient: number): number;
  5228. }
  5229. /**
  5230. * Easing function with a bezier shape (see link below).
  5231. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5232. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5233. */
  5234. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5235. /** Defines the x component of the start tangent in the bezier curve */
  5236. x1: number;
  5237. /** Defines the y component of the start tangent in the bezier curve */
  5238. y1: number;
  5239. /** Defines the x component of the end tangent in the bezier curve */
  5240. x2: number;
  5241. /** Defines the y component of the end tangent in the bezier curve */
  5242. y2: number;
  5243. /**
  5244. * Instantiates a bezier function
  5245. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5246. * @param x1 Defines the x component of the start tangent in the bezier curve
  5247. * @param y1 Defines the y component of the start tangent in the bezier curve
  5248. * @param x2 Defines the x component of the end tangent in the bezier curve
  5249. * @param y2 Defines the y component of the end tangent in the bezier curve
  5250. */
  5251. constructor(
  5252. /** Defines the x component of the start tangent in the bezier curve */
  5253. x1?: number,
  5254. /** Defines the y component of the start tangent in the bezier curve */
  5255. y1?: number,
  5256. /** Defines the x component of the end tangent in the bezier curve */
  5257. x2?: number,
  5258. /** Defines the y component of the end tangent in the bezier curve */
  5259. y2?: number);
  5260. /** @hidden */
  5261. easeInCore(gradient: number): number;
  5262. }
  5263. }
  5264. declare module "babylonjs/Maths/math.color" {
  5265. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5266. /**
  5267. * Class used to hold a RBG color
  5268. */
  5269. export class Color3 {
  5270. /**
  5271. * Defines the red component (between 0 and 1, default is 0)
  5272. */
  5273. r: number;
  5274. /**
  5275. * Defines the green component (between 0 and 1, default is 0)
  5276. */
  5277. g: number;
  5278. /**
  5279. * Defines the blue component (between 0 and 1, default is 0)
  5280. */
  5281. b: number;
  5282. /**
  5283. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5284. * @param r defines the red component (between 0 and 1, default is 0)
  5285. * @param g defines the green component (between 0 and 1, default is 0)
  5286. * @param b defines the blue component (between 0 and 1, default is 0)
  5287. */
  5288. constructor(
  5289. /**
  5290. * Defines the red component (between 0 and 1, default is 0)
  5291. */
  5292. r?: number,
  5293. /**
  5294. * Defines the green component (between 0 and 1, default is 0)
  5295. */
  5296. g?: number,
  5297. /**
  5298. * Defines the blue component (between 0 and 1, default is 0)
  5299. */
  5300. b?: number);
  5301. /**
  5302. * Creates a string with the Color3 current values
  5303. * @returns the string representation of the Color3 object
  5304. */
  5305. toString(): string;
  5306. /**
  5307. * Returns the string "Color3"
  5308. * @returns "Color3"
  5309. */
  5310. getClassName(): string;
  5311. /**
  5312. * Compute the Color3 hash code
  5313. * @returns an unique number that can be used to hash Color3 objects
  5314. */
  5315. getHashCode(): number;
  5316. /**
  5317. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5318. * @param array defines the array where to store the r,g,b components
  5319. * @param index defines an optional index in the target array to define where to start storing values
  5320. * @returns the current Color3 object
  5321. */
  5322. toArray(array: FloatArray, index?: number): Color3;
  5323. /**
  5324. * Returns a new Color4 object from the current Color3 and the given alpha
  5325. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5326. * @returns a new Color4 object
  5327. */
  5328. toColor4(alpha?: number): Color4;
  5329. /**
  5330. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5331. * @returns the new array
  5332. */
  5333. asArray(): number[];
  5334. /**
  5335. * Returns the luminance value
  5336. * @returns a float value
  5337. */
  5338. toLuminance(): number;
  5339. /**
  5340. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5341. * @param otherColor defines the second operand
  5342. * @returns the new Color3 object
  5343. */
  5344. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5345. /**
  5346. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5347. * @param otherColor defines the second operand
  5348. * @param result defines the Color3 object where to store the result
  5349. * @returns the current Color3
  5350. */
  5351. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5352. /**
  5353. * Determines equality between Color3 objects
  5354. * @param otherColor defines the second operand
  5355. * @returns true if the rgb values are equal to the given ones
  5356. */
  5357. equals(otherColor: DeepImmutable<Color3>): boolean;
  5358. /**
  5359. * Determines equality between the current Color3 object and a set of r,b,g values
  5360. * @param r defines the red component to check
  5361. * @param g defines the green component to check
  5362. * @param b defines the blue component to check
  5363. * @returns true if the rgb values are equal to the given ones
  5364. */
  5365. equalsFloats(r: number, g: number, b: number): boolean;
  5366. /**
  5367. * Multiplies in place each rgb value by scale
  5368. * @param scale defines the scaling factor
  5369. * @returns the updated Color3
  5370. */
  5371. scale(scale: number): Color3;
  5372. /**
  5373. * Multiplies the rgb values by scale and stores the result into "result"
  5374. * @param scale defines the scaling factor
  5375. * @param result defines the Color3 object where to store the result
  5376. * @returns the unmodified current Color3
  5377. */
  5378. scaleToRef(scale: number, result: Color3): Color3;
  5379. /**
  5380. * Scale the current Color3 values by a factor and add the result to a given Color3
  5381. * @param scale defines the scale factor
  5382. * @param result defines color to store the result into
  5383. * @returns the unmodified current Color3
  5384. */
  5385. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5386. /**
  5387. * Clamps the rgb values by the min and max values and stores the result into "result"
  5388. * @param min defines minimum clamping value (default is 0)
  5389. * @param max defines maximum clamping value (default is 1)
  5390. * @param result defines color to store the result into
  5391. * @returns the original Color3
  5392. */
  5393. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5394. /**
  5395. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5396. * @param otherColor defines the second operand
  5397. * @returns the new Color3
  5398. */
  5399. add(otherColor: DeepImmutable<Color3>): Color3;
  5400. /**
  5401. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5402. * @param otherColor defines the second operand
  5403. * @param result defines Color3 object to store the result into
  5404. * @returns the unmodified current Color3
  5405. */
  5406. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5407. /**
  5408. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5409. * @param otherColor defines the second operand
  5410. * @returns the new Color3
  5411. */
  5412. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5413. /**
  5414. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5415. * @param otherColor defines the second operand
  5416. * @param result defines Color3 object to store the result into
  5417. * @returns the unmodified current Color3
  5418. */
  5419. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5420. /**
  5421. * Copy the current object
  5422. * @returns a new Color3 copied the current one
  5423. */
  5424. clone(): Color3;
  5425. /**
  5426. * Copies the rgb values from the source in the current Color3
  5427. * @param source defines the source Color3 object
  5428. * @returns the updated Color3 object
  5429. */
  5430. copyFrom(source: DeepImmutable<Color3>): Color3;
  5431. /**
  5432. * Updates the Color3 rgb values from the given floats
  5433. * @param r defines the red component to read from
  5434. * @param g defines the green component to read from
  5435. * @param b defines the blue component to read from
  5436. * @returns the current Color3 object
  5437. */
  5438. copyFromFloats(r: number, g: number, b: number): Color3;
  5439. /**
  5440. * Updates the Color3 rgb values from the given floats
  5441. * @param r defines the red component to read from
  5442. * @param g defines the green component to read from
  5443. * @param b defines the blue component to read from
  5444. * @returns the current Color3 object
  5445. */
  5446. set(r: number, g: number, b: number): Color3;
  5447. /**
  5448. * Compute the Color3 hexadecimal code as a string
  5449. * @returns a string containing the hexadecimal representation of the Color3 object
  5450. */
  5451. toHexString(): string;
  5452. /**
  5453. * Computes a new Color3 converted from the current one to linear space
  5454. * @returns a new Color3 object
  5455. */
  5456. toLinearSpace(): Color3;
  5457. /**
  5458. * Converts current color in rgb space to HSV values
  5459. * @returns a new color3 representing the HSV values
  5460. */
  5461. toHSV(): Color3;
  5462. /**
  5463. * Converts current color in rgb space to HSV values
  5464. * @param result defines the Color3 where to store the HSV values
  5465. */
  5466. toHSVToRef(result: Color3): void;
  5467. /**
  5468. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5469. * @param convertedColor defines the Color3 object where to store the linear space version
  5470. * @returns the unmodified Color3
  5471. */
  5472. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5473. /**
  5474. * Computes a new Color3 converted from the current one to gamma space
  5475. * @returns a new Color3 object
  5476. */
  5477. toGammaSpace(): Color3;
  5478. /**
  5479. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5480. * @param convertedColor defines the Color3 object where to store the gamma space version
  5481. * @returns the unmodified Color3
  5482. */
  5483. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5484. private static _BlackReadOnly;
  5485. /**
  5486. * Convert Hue, saturation and value to a Color3 (RGB)
  5487. * @param hue defines the hue
  5488. * @param saturation defines the saturation
  5489. * @param value defines the value
  5490. * @param result defines the Color3 where to store the RGB values
  5491. */
  5492. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5493. /**
  5494. * Creates a new Color3 from the string containing valid hexadecimal values
  5495. * @param hex defines a string containing valid hexadecimal values
  5496. * @returns a new Color3 object
  5497. */
  5498. static FromHexString(hex: string): Color3;
  5499. /**
  5500. * Creates a new Color3 from the starting index of the given array
  5501. * @param array defines the source array
  5502. * @param offset defines an offset in the source array
  5503. * @returns a new Color3 object
  5504. */
  5505. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5506. /**
  5507. * Creates a new Color3 from integer values (< 256)
  5508. * @param r defines the red component to read from (value between 0 and 255)
  5509. * @param g defines the green component to read from (value between 0 and 255)
  5510. * @param b defines the blue component to read from (value between 0 and 255)
  5511. * @returns a new Color3 object
  5512. */
  5513. static FromInts(r: number, g: number, b: number): Color3;
  5514. /**
  5515. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5516. * @param start defines the start Color3 value
  5517. * @param end defines the end Color3 value
  5518. * @param amount defines the gradient value between start and end
  5519. * @returns a new Color3 object
  5520. */
  5521. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5522. /**
  5523. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5524. * @param left defines the start value
  5525. * @param right defines the end value
  5526. * @param amount defines the gradient factor
  5527. * @param result defines the Color3 object where to store the result
  5528. */
  5529. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5530. /**
  5531. * Returns a Color3 value containing a red color
  5532. * @returns a new Color3 object
  5533. */
  5534. static Red(): Color3;
  5535. /**
  5536. * Returns a Color3 value containing a green color
  5537. * @returns a new Color3 object
  5538. */
  5539. static Green(): Color3;
  5540. /**
  5541. * Returns a Color3 value containing a blue color
  5542. * @returns a new Color3 object
  5543. */
  5544. static Blue(): Color3;
  5545. /**
  5546. * Returns a Color3 value containing a black color
  5547. * @returns a new Color3 object
  5548. */
  5549. static Black(): Color3;
  5550. /**
  5551. * Gets a Color3 value containing a black color that must not be updated
  5552. */
  5553. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5554. /**
  5555. * Returns a Color3 value containing a white color
  5556. * @returns a new Color3 object
  5557. */
  5558. static White(): Color3;
  5559. /**
  5560. * Returns a Color3 value containing a purple color
  5561. * @returns a new Color3 object
  5562. */
  5563. static Purple(): Color3;
  5564. /**
  5565. * Returns a Color3 value containing a magenta color
  5566. * @returns a new Color3 object
  5567. */
  5568. static Magenta(): Color3;
  5569. /**
  5570. * Returns a Color3 value containing a yellow color
  5571. * @returns a new Color3 object
  5572. */
  5573. static Yellow(): Color3;
  5574. /**
  5575. * Returns a Color3 value containing a gray color
  5576. * @returns a new Color3 object
  5577. */
  5578. static Gray(): Color3;
  5579. /**
  5580. * Returns a Color3 value containing a teal color
  5581. * @returns a new Color3 object
  5582. */
  5583. static Teal(): Color3;
  5584. /**
  5585. * Returns a Color3 value containing a random color
  5586. * @returns a new Color3 object
  5587. */
  5588. static Random(): Color3;
  5589. }
  5590. /**
  5591. * Class used to hold a RBGA color
  5592. */
  5593. export class Color4 {
  5594. /**
  5595. * Defines the red component (between 0 and 1, default is 0)
  5596. */
  5597. r: number;
  5598. /**
  5599. * Defines the green component (between 0 and 1, default is 0)
  5600. */
  5601. g: number;
  5602. /**
  5603. * Defines the blue component (between 0 and 1, default is 0)
  5604. */
  5605. b: number;
  5606. /**
  5607. * Defines the alpha component (between 0 and 1, default is 1)
  5608. */
  5609. a: number;
  5610. /**
  5611. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5612. * @param r defines the red component (between 0 and 1, default is 0)
  5613. * @param g defines the green component (between 0 and 1, default is 0)
  5614. * @param b defines the blue component (between 0 and 1, default is 0)
  5615. * @param a defines the alpha component (between 0 and 1, default is 1)
  5616. */
  5617. constructor(
  5618. /**
  5619. * Defines the red component (between 0 and 1, default is 0)
  5620. */
  5621. r?: number,
  5622. /**
  5623. * Defines the green component (between 0 and 1, default is 0)
  5624. */
  5625. g?: number,
  5626. /**
  5627. * Defines the blue component (between 0 and 1, default is 0)
  5628. */
  5629. b?: number,
  5630. /**
  5631. * Defines the alpha component (between 0 and 1, default is 1)
  5632. */
  5633. a?: number);
  5634. /**
  5635. * Adds in place the given Color4 values to the current Color4 object
  5636. * @param right defines the second operand
  5637. * @returns the current updated Color4 object
  5638. */
  5639. addInPlace(right: DeepImmutable<Color4>): Color4;
  5640. /**
  5641. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5642. * @returns the new array
  5643. */
  5644. asArray(): number[];
  5645. /**
  5646. * Stores from the starting index in the given array the Color4 successive values
  5647. * @param array defines the array where to store the r,g,b components
  5648. * @param index defines an optional index in the target array to define where to start storing values
  5649. * @returns the current Color4 object
  5650. */
  5651. toArray(array: number[], index?: number): Color4;
  5652. /**
  5653. * Determines equality between Color4 objects
  5654. * @param otherColor defines the second operand
  5655. * @returns true if the rgba values are equal to the given ones
  5656. */
  5657. equals(otherColor: DeepImmutable<Color4>): boolean;
  5658. /**
  5659. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5660. * @param right defines the second operand
  5661. * @returns a new Color4 object
  5662. */
  5663. add(right: DeepImmutable<Color4>): Color4;
  5664. /**
  5665. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5666. * @param right defines the second operand
  5667. * @returns a new Color4 object
  5668. */
  5669. subtract(right: DeepImmutable<Color4>): Color4;
  5670. /**
  5671. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5672. * @param right defines the second operand
  5673. * @param result defines the Color4 object where to store the result
  5674. * @returns the current Color4 object
  5675. */
  5676. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5677. /**
  5678. * Creates a new Color4 with the current Color4 values multiplied by scale
  5679. * @param scale defines the scaling factor to apply
  5680. * @returns a new Color4 object
  5681. */
  5682. scale(scale: number): Color4;
  5683. /**
  5684. * Multiplies the current Color4 values by scale and stores the result in "result"
  5685. * @param scale defines the scaling factor to apply
  5686. * @param result defines the Color4 object where to store the result
  5687. * @returns the current unmodified Color4
  5688. */
  5689. scaleToRef(scale: number, result: Color4): Color4;
  5690. /**
  5691. * Scale the current Color4 values by a factor and add the result to a given Color4
  5692. * @param scale defines the scale factor
  5693. * @param result defines the Color4 object where to store the result
  5694. * @returns the unmodified current Color4
  5695. */
  5696. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5697. /**
  5698. * Clamps the rgb values by the min and max values and stores the result into "result"
  5699. * @param min defines minimum clamping value (default is 0)
  5700. * @param max defines maximum clamping value (default is 1)
  5701. * @param result defines color to store the result into.
  5702. * @returns the cuurent Color4
  5703. */
  5704. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5705. /**
  5706. * Multipy an Color4 value by another and return a new Color4 object
  5707. * @param color defines the Color4 value to multiply by
  5708. * @returns a new Color4 object
  5709. */
  5710. multiply(color: Color4): Color4;
  5711. /**
  5712. * Multipy a Color4 value by another and push the result in a reference value
  5713. * @param color defines the Color4 value to multiply by
  5714. * @param result defines the Color4 to fill the result in
  5715. * @returns the result Color4
  5716. */
  5717. multiplyToRef(color: Color4, result: Color4): Color4;
  5718. /**
  5719. * Creates a string with the Color4 current values
  5720. * @returns the string representation of the Color4 object
  5721. */
  5722. toString(): string;
  5723. /**
  5724. * Returns the string "Color4"
  5725. * @returns "Color4"
  5726. */
  5727. getClassName(): string;
  5728. /**
  5729. * Compute the Color4 hash code
  5730. * @returns an unique number that can be used to hash Color4 objects
  5731. */
  5732. getHashCode(): number;
  5733. /**
  5734. * Creates a new Color4 copied from the current one
  5735. * @returns a new Color4 object
  5736. */
  5737. clone(): Color4;
  5738. /**
  5739. * Copies the given Color4 values into the current one
  5740. * @param source defines the source Color4 object
  5741. * @returns the current updated Color4 object
  5742. */
  5743. copyFrom(source: Color4): Color4;
  5744. /**
  5745. * Copies the given float values into the current one
  5746. * @param r defines the red component to read from
  5747. * @param g defines the green component to read from
  5748. * @param b defines the blue component to read from
  5749. * @param a defines the alpha component to read from
  5750. * @returns the current updated Color4 object
  5751. */
  5752. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5753. /**
  5754. * Copies the given float values into the current one
  5755. * @param r defines the red component to read from
  5756. * @param g defines the green component to read from
  5757. * @param b defines the blue component to read from
  5758. * @param a defines the alpha component to read from
  5759. * @returns the current updated Color4 object
  5760. */
  5761. set(r: number, g: number, b: number, a: number): Color4;
  5762. /**
  5763. * Compute the Color4 hexadecimal code as a string
  5764. * @returns a string containing the hexadecimal representation of the Color4 object
  5765. */
  5766. toHexString(): string;
  5767. /**
  5768. * Computes a new Color4 converted from the current one to linear space
  5769. * @returns a new Color4 object
  5770. */
  5771. toLinearSpace(): Color4;
  5772. /**
  5773. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5774. * @param convertedColor defines the Color4 object where to store the linear space version
  5775. * @returns the unmodified Color4
  5776. */
  5777. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5778. /**
  5779. * Computes a new Color4 converted from the current one to gamma space
  5780. * @returns a new Color4 object
  5781. */
  5782. toGammaSpace(): Color4;
  5783. /**
  5784. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5785. * @param convertedColor defines the Color4 object where to store the gamma space version
  5786. * @returns the unmodified Color4
  5787. */
  5788. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5789. /**
  5790. * Creates a new Color4 from the string containing valid hexadecimal values
  5791. * @param hex defines a string containing valid hexadecimal values
  5792. * @returns a new Color4 object
  5793. */
  5794. static FromHexString(hex: string): Color4;
  5795. /**
  5796. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5797. * @param left defines the start value
  5798. * @param right defines the end value
  5799. * @param amount defines the gradient factor
  5800. * @returns a new Color4 object
  5801. */
  5802. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5803. /**
  5804. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5805. * @param left defines the start value
  5806. * @param right defines the end value
  5807. * @param amount defines the gradient factor
  5808. * @param result defines the Color4 object where to store data
  5809. */
  5810. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5811. /**
  5812. * Creates a new Color4 from a Color3 and an alpha value
  5813. * @param color3 defines the source Color3 to read from
  5814. * @param alpha defines the alpha component (1.0 by default)
  5815. * @returns a new Color4 object
  5816. */
  5817. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5818. /**
  5819. * Creates a new Color4 from the starting index element of the given array
  5820. * @param array defines the source array to read from
  5821. * @param offset defines the offset in the source array
  5822. * @returns a new Color4 object
  5823. */
  5824. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5825. /**
  5826. * Creates a new Color3 from integer values (< 256)
  5827. * @param r defines the red component to read from (value between 0 and 255)
  5828. * @param g defines the green component to read from (value between 0 and 255)
  5829. * @param b defines the blue component to read from (value between 0 and 255)
  5830. * @param a defines the alpha component to read from (value between 0 and 255)
  5831. * @returns a new Color3 object
  5832. */
  5833. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5834. /**
  5835. * Check the content of a given array and convert it to an array containing RGBA data
  5836. * If the original array was already containing count * 4 values then it is returned directly
  5837. * @param colors defines the array to check
  5838. * @param count defines the number of RGBA data to expect
  5839. * @returns an array containing count * 4 values (RGBA)
  5840. */
  5841. static CheckColors4(colors: number[], count: number): number[];
  5842. }
  5843. /**
  5844. * @hidden
  5845. */
  5846. export class TmpColors {
  5847. static Color3: Color3[];
  5848. static Color4: Color4[];
  5849. }
  5850. }
  5851. declare module "babylonjs/Animations/animationKey" {
  5852. /**
  5853. * Defines an interface which represents an animation key frame
  5854. */
  5855. export interface IAnimationKey {
  5856. /**
  5857. * Frame of the key frame
  5858. */
  5859. frame: number;
  5860. /**
  5861. * Value at the specifies key frame
  5862. */
  5863. value: any;
  5864. /**
  5865. * The input tangent for the cubic hermite spline
  5866. */
  5867. inTangent?: any;
  5868. /**
  5869. * The output tangent for the cubic hermite spline
  5870. */
  5871. outTangent?: any;
  5872. /**
  5873. * The animation interpolation type
  5874. */
  5875. interpolation?: AnimationKeyInterpolation;
  5876. }
  5877. /**
  5878. * Enum for the animation key frame interpolation type
  5879. */
  5880. export enum AnimationKeyInterpolation {
  5881. /**
  5882. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5883. */
  5884. STEP = 1
  5885. }
  5886. }
  5887. declare module "babylonjs/Animations/animationRange" {
  5888. /**
  5889. * Represents the range of an animation
  5890. */
  5891. export class AnimationRange {
  5892. /**The name of the animation range**/
  5893. name: string;
  5894. /**The starting frame of the animation */
  5895. from: number;
  5896. /**The ending frame of the animation*/
  5897. to: number;
  5898. /**
  5899. * Initializes the range of an animation
  5900. * @param name The name of the animation range
  5901. * @param from The starting frame of the animation
  5902. * @param to The ending frame of the animation
  5903. */
  5904. constructor(
  5905. /**The name of the animation range**/
  5906. name: string,
  5907. /**The starting frame of the animation */
  5908. from: number,
  5909. /**The ending frame of the animation*/
  5910. to: number);
  5911. /**
  5912. * Makes a copy of the animation range
  5913. * @returns A copy of the animation range
  5914. */
  5915. clone(): AnimationRange;
  5916. }
  5917. }
  5918. declare module "babylonjs/Animations/animationEvent" {
  5919. /**
  5920. * Composed of a frame, and an action function
  5921. */
  5922. export class AnimationEvent {
  5923. /** The frame for which the event is triggered **/
  5924. frame: number;
  5925. /** The event to perform when triggered **/
  5926. action: (currentFrame: number) => void;
  5927. /** Specifies if the event should be triggered only once**/
  5928. onlyOnce?: boolean | undefined;
  5929. /**
  5930. * Specifies if the animation event is done
  5931. */
  5932. isDone: boolean;
  5933. /**
  5934. * Initializes the animation event
  5935. * @param frame The frame for which the event is triggered
  5936. * @param action The event to perform when triggered
  5937. * @param onlyOnce Specifies if the event should be triggered only once
  5938. */
  5939. constructor(
  5940. /** The frame for which the event is triggered **/
  5941. frame: number,
  5942. /** The event to perform when triggered **/
  5943. action: (currentFrame: number) => void,
  5944. /** Specifies if the event should be triggered only once**/
  5945. onlyOnce?: boolean | undefined);
  5946. /** @hidden */
  5947. _clone(): AnimationEvent;
  5948. }
  5949. }
  5950. declare module "babylonjs/Behaviors/behavior" {
  5951. import { Nullable } from "babylonjs/types";
  5952. /**
  5953. * Interface used to define a behavior
  5954. */
  5955. export interface Behavior<T> {
  5956. /** gets or sets behavior's name */
  5957. name: string;
  5958. /**
  5959. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5960. */
  5961. init(): void;
  5962. /**
  5963. * Called when the behavior is attached to a target
  5964. * @param target defines the target where the behavior is attached to
  5965. */
  5966. attach(target: T): void;
  5967. /**
  5968. * Called when the behavior is detached from its target
  5969. */
  5970. detach(): void;
  5971. }
  5972. /**
  5973. * Interface implemented by classes supporting behaviors
  5974. */
  5975. export interface IBehaviorAware<T> {
  5976. /**
  5977. * Attach a behavior
  5978. * @param behavior defines the behavior to attach
  5979. * @returns the current host
  5980. */
  5981. addBehavior(behavior: Behavior<T>): T;
  5982. /**
  5983. * Remove a behavior from the current object
  5984. * @param behavior defines the behavior to detach
  5985. * @returns the current host
  5986. */
  5987. removeBehavior(behavior: Behavior<T>): T;
  5988. /**
  5989. * Gets a behavior using its name to search
  5990. * @param name defines the name to search
  5991. * @returns the behavior or null if not found
  5992. */
  5993. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5994. }
  5995. }
  5996. declare module "babylonjs/Misc/smartArray" {
  5997. /**
  5998. * Defines an array and its length.
  5999. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6000. */
  6001. export interface ISmartArrayLike<T> {
  6002. /**
  6003. * The data of the array.
  6004. */
  6005. data: Array<T>;
  6006. /**
  6007. * The active length of the array.
  6008. */
  6009. length: number;
  6010. }
  6011. /**
  6012. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6013. */
  6014. export class SmartArray<T> implements ISmartArrayLike<T> {
  6015. /**
  6016. * The full set of data from the array.
  6017. */
  6018. data: Array<T>;
  6019. /**
  6020. * The active length of the array.
  6021. */
  6022. length: number;
  6023. protected _id: number;
  6024. /**
  6025. * Instantiates a Smart Array.
  6026. * @param capacity defines the default capacity of the array.
  6027. */
  6028. constructor(capacity: number);
  6029. /**
  6030. * Pushes a value at the end of the active data.
  6031. * @param value defines the object to push in the array.
  6032. */
  6033. push(value: T): void;
  6034. /**
  6035. * Iterates over the active data and apply the lambda to them.
  6036. * @param func defines the action to apply on each value.
  6037. */
  6038. forEach(func: (content: T) => void): void;
  6039. /**
  6040. * Sorts the full sets of data.
  6041. * @param compareFn defines the comparison function to apply.
  6042. */
  6043. sort(compareFn: (a: T, b: T) => number): void;
  6044. /**
  6045. * Resets the active data to an empty array.
  6046. */
  6047. reset(): void;
  6048. /**
  6049. * Releases all the data from the array as well as the array.
  6050. */
  6051. dispose(): void;
  6052. /**
  6053. * Concats the active data with a given array.
  6054. * @param array defines the data to concatenate with.
  6055. */
  6056. concat(array: any): void;
  6057. /**
  6058. * Returns the position of a value in the active data.
  6059. * @param value defines the value to find the index for
  6060. * @returns the index if found in the active data otherwise -1
  6061. */
  6062. indexOf(value: T): number;
  6063. /**
  6064. * Returns whether an element is part of the active data.
  6065. * @param value defines the value to look for
  6066. * @returns true if found in the active data otherwise false
  6067. */
  6068. contains(value: T): boolean;
  6069. private static _GlobalId;
  6070. }
  6071. /**
  6072. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6073. * The data in this array can only be present once
  6074. */
  6075. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6076. private _duplicateId;
  6077. /**
  6078. * Pushes a value at the end of the active data.
  6079. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6080. * @param value defines the object to push in the array.
  6081. */
  6082. push(value: T): void;
  6083. /**
  6084. * Pushes a value at the end of the active data.
  6085. * If the data is already present, it won t be added again
  6086. * @param value defines the object to push in the array.
  6087. * @returns true if added false if it was already present
  6088. */
  6089. pushNoDuplicate(value: T): boolean;
  6090. /**
  6091. * Resets the active data to an empty array.
  6092. */
  6093. reset(): void;
  6094. /**
  6095. * Concats the active data with a given array.
  6096. * This ensures no dupplicate will be present in the result.
  6097. * @param array defines the data to concatenate with.
  6098. */
  6099. concatWithNoDuplicate(array: any): void;
  6100. }
  6101. }
  6102. declare module "babylonjs/Cameras/cameraInputsManager" {
  6103. import { Nullable } from "babylonjs/types";
  6104. import { Camera } from "babylonjs/Cameras/camera";
  6105. /**
  6106. * @ignore
  6107. * This is a list of all the different input types that are available in the application.
  6108. * Fo instance: ArcRotateCameraGamepadInput...
  6109. */
  6110. export var CameraInputTypes: {};
  6111. /**
  6112. * This is the contract to implement in order to create a new input class.
  6113. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6114. */
  6115. export interface ICameraInput<TCamera extends Camera> {
  6116. /**
  6117. * Defines the camera the input is attached to.
  6118. */
  6119. camera: Nullable<TCamera>;
  6120. /**
  6121. * Gets the class name of the current intput.
  6122. * @returns the class name
  6123. */
  6124. getClassName(): string;
  6125. /**
  6126. * Get the friendly name associated with the input class.
  6127. * @returns the input friendly name
  6128. */
  6129. getSimpleName(): string;
  6130. /**
  6131. * Attach the input controls to a specific dom element to get the input from.
  6132. * @param element Defines the element the controls should be listened from
  6133. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6134. */
  6135. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6136. /**
  6137. * Detach the current controls from the specified dom element.
  6138. * @param element Defines the element to stop listening the inputs from
  6139. */
  6140. detachControl(element: Nullable<HTMLElement>): void;
  6141. /**
  6142. * Update the current camera state depending on the inputs that have been used this frame.
  6143. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6144. */
  6145. checkInputs?: () => void;
  6146. }
  6147. /**
  6148. * Represents a map of input types to input instance or input index to input instance.
  6149. */
  6150. export interface CameraInputsMap<TCamera extends Camera> {
  6151. /**
  6152. * Accessor to the input by input type.
  6153. */
  6154. [name: string]: ICameraInput<TCamera>;
  6155. /**
  6156. * Accessor to the input by input index.
  6157. */
  6158. [idx: number]: ICameraInput<TCamera>;
  6159. }
  6160. /**
  6161. * This represents the input manager used within a camera.
  6162. * It helps dealing with all the different kind of input attached to a camera.
  6163. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6164. */
  6165. export class CameraInputsManager<TCamera extends Camera> {
  6166. /**
  6167. * Defines the list of inputs attahed to the camera.
  6168. */
  6169. attached: CameraInputsMap<TCamera>;
  6170. /**
  6171. * Defines the dom element the camera is collecting inputs from.
  6172. * This is null if the controls have not been attached.
  6173. */
  6174. attachedElement: Nullable<HTMLElement>;
  6175. /**
  6176. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6177. */
  6178. noPreventDefault: boolean;
  6179. /**
  6180. * Defined the camera the input manager belongs to.
  6181. */
  6182. camera: TCamera;
  6183. /**
  6184. * Update the current camera state depending on the inputs that have been used this frame.
  6185. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6186. */
  6187. checkInputs: () => void;
  6188. /**
  6189. * Instantiate a new Camera Input Manager.
  6190. * @param camera Defines the camera the input manager blongs to
  6191. */
  6192. constructor(camera: TCamera);
  6193. /**
  6194. * Add an input method to a camera
  6195. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6196. * @param input camera input method
  6197. */
  6198. add(input: ICameraInput<TCamera>): void;
  6199. /**
  6200. * Remove a specific input method from a camera
  6201. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6202. * @param inputToRemove camera input method
  6203. */
  6204. remove(inputToRemove: ICameraInput<TCamera>): void;
  6205. /**
  6206. * Remove a specific input type from a camera
  6207. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6208. * @param inputType the type of the input to remove
  6209. */
  6210. removeByType(inputType: string): void;
  6211. private _addCheckInputs;
  6212. /**
  6213. * Attach the input controls to the currently attached dom element to listen the events from.
  6214. * @param input Defines the input to attach
  6215. */
  6216. attachInput(input: ICameraInput<TCamera>): void;
  6217. /**
  6218. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6219. * @param element Defines the dom element to collect the events from
  6220. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6221. */
  6222. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6223. /**
  6224. * Detach the current manager inputs controls from a specific dom element.
  6225. * @param element Defines the dom element to collect the events from
  6226. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6227. */
  6228. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6229. /**
  6230. * Rebuild the dynamic inputCheck function from the current list of
  6231. * defined inputs in the manager.
  6232. */
  6233. rebuildInputCheck(): void;
  6234. /**
  6235. * Remove all attached input methods from a camera
  6236. */
  6237. clear(): void;
  6238. /**
  6239. * Serialize the current input manager attached to a camera.
  6240. * This ensures than once parsed,
  6241. * the input associated to the camera will be identical to the current ones
  6242. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6243. */
  6244. serialize(serializedCamera: any): void;
  6245. /**
  6246. * Parses an input manager serialized JSON to restore the previous list of inputs
  6247. * and states associated to a camera.
  6248. * @param parsedCamera Defines the JSON to parse
  6249. */
  6250. parse(parsedCamera: any): void;
  6251. }
  6252. }
  6253. declare module "babylonjs/Meshes/buffer" {
  6254. import { Nullable, DataArray } from "babylonjs/types";
  6255. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6256. /**
  6257. * Class used to store data that will be store in GPU memory
  6258. */
  6259. export class Buffer {
  6260. private _engine;
  6261. private _buffer;
  6262. /** @hidden */
  6263. _data: Nullable<DataArray>;
  6264. private _updatable;
  6265. private _instanced;
  6266. private _divisor;
  6267. /**
  6268. * Gets the byte stride.
  6269. */
  6270. readonly byteStride: number;
  6271. /**
  6272. * Constructor
  6273. * @param engine the engine
  6274. * @param data the data to use for this buffer
  6275. * @param updatable whether the data is updatable
  6276. * @param stride the stride (optional)
  6277. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6278. * @param instanced whether the buffer is instanced (optional)
  6279. * @param useBytes set to true if the stride in in bytes (optional)
  6280. * @param divisor sets an optional divisor for instances (1 by default)
  6281. */
  6282. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6283. /**
  6284. * Create a new VertexBuffer based on the current buffer
  6285. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6286. * @param offset defines offset in the buffer (0 by default)
  6287. * @param size defines the size in floats of attributes (position is 3 for instance)
  6288. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6289. * @param instanced defines if the vertex buffer contains indexed data
  6290. * @param useBytes defines if the offset and stride are in bytes *
  6291. * @param divisor sets an optional divisor for instances (1 by default)
  6292. * @returns the new vertex buffer
  6293. */
  6294. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6295. /**
  6296. * Gets a boolean indicating if the Buffer is updatable?
  6297. * @returns true if the buffer is updatable
  6298. */
  6299. isUpdatable(): boolean;
  6300. /**
  6301. * Gets current buffer's data
  6302. * @returns a DataArray or null
  6303. */
  6304. getData(): Nullable<DataArray>;
  6305. /**
  6306. * Gets underlying native buffer
  6307. * @returns underlying native buffer
  6308. */
  6309. getBuffer(): Nullable<DataBuffer>;
  6310. /**
  6311. * Gets the stride in float32 units (i.e. byte stride / 4).
  6312. * May not be an integer if the byte stride is not divisible by 4.
  6313. * @returns the stride in float32 units
  6314. * @deprecated Please use byteStride instead.
  6315. */
  6316. getStrideSize(): number;
  6317. /**
  6318. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6319. * @param data defines the data to store
  6320. */
  6321. create(data?: Nullable<DataArray>): void;
  6322. /** @hidden */
  6323. _rebuild(): void;
  6324. /**
  6325. * Update current buffer data
  6326. * @param data defines the data to store
  6327. */
  6328. update(data: DataArray): void;
  6329. /**
  6330. * Updates the data directly.
  6331. * @param data the new data
  6332. * @param offset the new offset
  6333. * @param vertexCount the vertex count (optional)
  6334. * @param useBytes set to true if the offset is in bytes
  6335. */
  6336. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6337. /**
  6338. * Release all resources
  6339. */
  6340. dispose(): void;
  6341. }
  6342. /**
  6343. * Specialized buffer used to store vertex data
  6344. */
  6345. export class VertexBuffer {
  6346. /** @hidden */
  6347. _buffer: Buffer;
  6348. private _kind;
  6349. private _size;
  6350. private _ownsBuffer;
  6351. private _instanced;
  6352. private _instanceDivisor;
  6353. /**
  6354. * The byte type.
  6355. */
  6356. static readonly BYTE: number;
  6357. /**
  6358. * The unsigned byte type.
  6359. */
  6360. static readonly UNSIGNED_BYTE: number;
  6361. /**
  6362. * The short type.
  6363. */
  6364. static readonly SHORT: number;
  6365. /**
  6366. * The unsigned short type.
  6367. */
  6368. static readonly UNSIGNED_SHORT: number;
  6369. /**
  6370. * The integer type.
  6371. */
  6372. static readonly INT: number;
  6373. /**
  6374. * The unsigned integer type.
  6375. */
  6376. static readonly UNSIGNED_INT: number;
  6377. /**
  6378. * The float type.
  6379. */
  6380. static readonly FLOAT: number;
  6381. /**
  6382. * Gets or sets the instance divisor when in instanced mode
  6383. */
  6384. instanceDivisor: number;
  6385. /**
  6386. * Gets the byte stride.
  6387. */
  6388. readonly byteStride: number;
  6389. /**
  6390. * Gets the byte offset.
  6391. */
  6392. readonly byteOffset: number;
  6393. /**
  6394. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6395. */
  6396. readonly normalized: boolean;
  6397. /**
  6398. * Gets the data type of each component in the array.
  6399. */
  6400. readonly type: number;
  6401. /**
  6402. * Constructor
  6403. * @param engine the engine
  6404. * @param data the data to use for this vertex buffer
  6405. * @param kind the vertex buffer kind
  6406. * @param updatable whether the data is updatable
  6407. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6408. * @param stride the stride (optional)
  6409. * @param instanced whether the buffer is instanced (optional)
  6410. * @param offset the offset of the data (optional)
  6411. * @param size the number of components (optional)
  6412. * @param type the type of the component (optional)
  6413. * @param normalized whether the data contains normalized data (optional)
  6414. * @param useBytes set to true if stride and offset are in bytes (optional)
  6415. * @param divisor defines the instance divisor to use (1 by default)
  6416. */
  6417. 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);
  6418. /** @hidden */
  6419. _rebuild(): void;
  6420. /**
  6421. * Returns the kind of the VertexBuffer (string)
  6422. * @returns a string
  6423. */
  6424. getKind(): string;
  6425. /**
  6426. * Gets a boolean indicating if the VertexBuffer is updatable?
  6427. * @returns true if the buffer is updatable
  6428. */
  6429. isUpdatable(): boolean;
  6430. /**
  6431. * Gets current buffer's data
  6432. * @returns a DataArray or null
  6433. */
  6434. getData(): Nullable<DataArray>;
  6435. /**
  6436. * Gets underlying native buffer
  6437. * @returns underlying native buffer
  6438. */
  6439. getBuffer(): Nullable<DataBuffer>;
  6440. /**
  6441. * Gets the stride in float32 units (i.e. byte stride / 4).
  6442. * May not be an integer if the byte stride is not divisible by 4.
  6443. * @returns the stride in float32 units
  6444. * @deprecated Please use byteStride instead.
  6445. */
  6446. getStrideSize(): number;
  6447. /**
  6448. * Returns the offset as a multiple of the type byte length.
  6449. * @returns the offset in bytes
  6450. * @deprecated Please use byteOffset instead.
  6451. */
  6452. getOffset(): number;
  6453. /**
  6454. * Returns the number of components per vertex attribute (integer)
  6455. * @returns the size in float
  6456. */
  6457. getSize(): number;
  6458. /**
  6459. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6460. * @returns true if this buffer is instanced
  6461. */
  6462. getIsInstanced(): boolean;
  6463. /**
  6464. * Returns the instancing divisor, zero for non-instanced (integer).
  6465. * @returns a number
  6466. */
  6467. getInstanceDivisor(): number;
  6468. /**
  6469. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6470. * @param data defines the data to store
  6471. */
  6472. create(data?: DataArray): void;
  6473. /**
  6474. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6475. * This function will create a new buffer if the current one is not updatable
  6476. * @param data defines the data to store
  6477. */
  6478. update(data: DataArray): void;
  6479. /**
  6480. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6481. * Returns the directly updated WebGLBuffer.
  6482. * @param data the new data
  6483. * @param offset the new offset
  6484. * @param useBytes set to true if the offset is in bytes
  6485. */
  6486. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6487. /**
  6488. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6489. */
  6490. dispose(): void;
  6491. /**
  6492. * Enumerates each value of this vertex buffer as numbers.
  6493. * @param count the number of values to enumerate
  6494. * @param callback the callback function called for each value
  6495. */
  6496. forEach(count: number, callback: (value: number, index: number) => void): void;
  6497. /**
  6498. * Positions
  6499. */
  6500. static readonly PositionKind: string;
  6501. /**
  6502. * Normals
  6503. */
  6504. static readonly NormalKind: string;
  6505. /**
  6506. * Tangents
  6507. */
  6508. static readonly TangentKind: string;
  6509. /**
  6510. * Texture coordinates
  6511. */
  6512. static readonly UVKind: string;
  6513. /**
  6514. * Texture coordinates 2
  6515. */
  6516. static readonly UV2Kind: string;
  6517. /**
  6518. * Texture coordinates 3
  6519. */
  6520. static readonly UV3Kind: string;
  6521. /**
  6522. * Texture coordinates 4
  6523. */
  6524. static readonly UV4Kind: string;
  6525. /**
  6526. * Texture coordinates 5
  6527. */
  6528. static readonly UV5Kind: string;
  6529. /**
  6530. * Texture coordinates 6
  6531. */
  6532. static readonly UV6Kind: string;
  6533. /**
  6534. * Colors
  6535. */
  6536. static readonly ColorKind: string;
  6537. /**
  6538. * Matrix indices (for bones)
  6539. */
  6540. static readonly MatricesIndicesKind: string;
  6541. /**
  6542. * Matrix weights (for bones)
  6543. */
  6544. static readonly MatricesWeightsKind: string;
  6545. /**
  6546. * Additional matrix indices (for bones)
  6547. */
  6548. static readonly MatricesIndicesExtraKind: string;
  6549. /**
  6550. * Additional matrix weights (for bones)
  6551. */
  6552. static readonly MatricesWeightsExtraKind: string;
  6553. /**
  6554. * Deduces the stride given a kind.
  6555. * @param kind The kind string to deduce
  6556. * @returns The deduced stride
  6557. */
  6558. static DeduceStride(kind: string): number;
  6559. /**
  6560. * Gets the byte length of the given type.
  6561. * @param type the type
  6562. * @returns the number of bytes
  6563. */
  6564. static GetTypeByteLength(type: number): number;
  6565. /**
  6566. * Enumerates each value of the given parameters as numbers.
  6567. * @param data the data to enumerate
  6568. * @param byteOffset the byte offset of the data
  6569. * @param byteStride the byte stride of the data
  6570. * @param componentCount the number of components per element
  6571. * @param componentType the type of the component
  6572. * @param count the number of values to enumerate
  6573. * @param normalized whether the data is normalized
  6574. * @param callback the callback function called for each value
  6575. */
  6576. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6577. private static _GetFloatValue;
  6578. }
  6579. }
  6580. declare module "babylonjs/Collisions/intersectionInfo" {
  6581. import { Nullable } from "babylonjs/types";
  6582. /**
  6583. * @hidden
  6584. */
  6585. export class IntersectionInfo {
  6586. bu: Nullable<number>;
  6587. bv: Nullable<number>;
  6588. distance: number;
  6589. faceId: number;
  6590. subMeshId: number;
  6591. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6592. }
  6593. }
  6594. declare module "babylonjs/Maths/math.plane" {
  6595. import { DeepImmutable } from "babylonjs/types";
  6596. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6597. /**
  6598. * Represens a plane by the equation ax + by + cz + d = 0
  6599. */
  6600. export class Plane {
  6601. private static _TmpMatrix;
  6602. /**
  6603. * Normal of the plane (a,b,c)
  6604. */
  6605. normal: Vector3;
  6606. /**
  6607. * d component of the plane
  6608. */
  6609. d: number;
  6610. /**
  6611. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6612. * @param a a component of the plane
  6613. * @param b b component of the plane
  6614. * @param c c component of the plane
  6615. * @param d d component of the plane
  6616. */
  6617. constructor(a: number, b: number, c: number, d: number);
  6618. /**
  6619. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6620. */
  6621. asArray(): number[];
  6622. /**
  6623. * @returns a new plane copied from the current Plane.
  6624. */
  6625. clone(): Plane;
  6626. /**
  6627. * @returns the string "Plane".
  6628. */
  6629. getClassName(): string;
  6630. /**
  6631. * @returns the Plane hash code.
  6632. */
  6633. getHashCode(): number;
  6634. /**
  6635. * Normalize the current Plane in place.
  6636. * @returns the updated Plane.
  6637. */
  6638. normalize(): Plane;
  6639. /**
  6640. * Applies a transformation the plane and returns the result
  6641. * @param transformation the transformation matrix to be applied to the plane
  6642. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6643. */
  6644. transform(transformation: DeepImmutable<Matrix>): Plane;
  6645. /**
  6646. * Calcualtte the dot product between the point and the plane normal
  6647. * @param point point to calculate the dot product with
  6648. * @returns the dot product (float) of the point coordinates and the plane normal.
  6649. */
  6650. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6651. /**
  6652. * Updates the current Plane from the plane defined by the three given points.
  6653. * @param point1 one of the points used to contruct the plane
  6654. * @param point2 one of the points used to contruct the plane
  6655. * @param point3 one of the points used to contruct the plane
  6656. * @returns the updated Plane.
  6657. */
  6658. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6659. /**
  6660. * Checks if the plane is facing a given direction
  6661. * @param direction the direction to check if the plane is facing
  6662. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6663. * @returns True is the vector "direction" is the same side than the plane normal.
  6664. */
  6665. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6666. /**
  6667. * Calculates the distance to a point
  6668. * @param point point to calculate distance to
  6669. * @returns the signed distance (float) from the given point to the Plane.
  6670. */
  6671. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6672. /**
  6673. * Creates a plane from an array
  6674. * @param array the array to create a plane from
  6675. * @returns a new Plane from the given array.
  6676. */
  6677. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6678. /**
  6679. * Creates a plane from three points
  6680. * @param point1 point used to create the plane
  6681. * @param point2 point used to create the plane
  6682. * @param point3 point used to create the plane
  6683. * @returns a new Plane defined by the three given points.
  6684. */
  6685. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6686. /**
  6687. * Creates a plane from an origin point and a normal
  6688. * @param origin origin of the plane to be constructed
  6689. * @param normal normal of the plane to be constructed
  6690. * @returns a new Plane the normal vector to this plane at the given origin point.
  6691. * Note : the vector "normal" is updated because normalized.
  6692. */
  6693. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6694. /**
  6695. * Calculates the distance from a plane and a point
  6696. * @param origin origin of the plane to be constructed
  6697. * @param normal normal of the plane to be constructed
  6698. * @param point point to calculate distance to
  6699. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6700. */
  6701. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6702. }
  6703. }
  6704. declare module "babylonjs/Culling/boundingSphere" {
  6705. import { DeepImmutable } from "babylonjs/types";
  6706. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6707. import { Plane } from "babylonjs/Maths/math.plane";
  6708. /**
  6709. * Class used to store bounding sphere information
  6710. */
  6711. export class BoundingSphere {
  6712. /**
  6713. * Gets the center of the bounding sphere in local space
  6714. */
  6715. readonly center: Vector3;
  6716. /**
  6717. * Radius of the bounding sphere in local space
  6718. */
  6719. radius: number;
  6720. /**
  6721. * Gets the center of the bounding sphere in world space
  6722. */
  6723. readonly centerWorld: Vector3;
  6724. /**
  6725. * Radius of the bounding sphere in world space
  6726. */
  6727. radiusWorld: number;
  6728. /**
  6729. * Gets the minimum vector in local space
  6730. */
  6731. readonly minimum: Vector3;
  6732. /**
  6733. * Gets the maximum vector in local space
  6734. */
  6735. readonly maximum: Vector3;
  6736. private _worldMatrix;
  6737. private static readonly TmpVector3;
  6738. /**
  6739. * Creates a new bounding sphere
  6740. * @param min defines the minimum vector (in local space)
  6741. * @param max defines the maximum vector (in local space)
  6742. * @param worldMatrix defines the new world matrix
  6743. */
  6744. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6745. /**
  6746. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6747. * @param min defines the new minimum vector (in local space)
  6748. * @param max defines the new maximum vector (in local space)
  6749. * @param worldMatrix defines the new world matrix
  6750. */
  6751. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6752. /**
  6753. * Scale the current bounding sphere by applying a scale factor
  6754. * @param factor defines the scale factor to apply
  6755. * @returns the current bounding box
  6756. */
  6757. scale(factor: number): BoundingSphere;
  6758. /**
  6759. * Gets the world matrix of the bounding box
  6760. * @returns a matrix
  6761. */
  6762. getWorldMatrix(): DeepImmutable<Matrix>;
  6763. /** @hidden */
  6764. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6765. /**
  6766. * Tests if the bounding sphere is intersecting the frustum planes
  6767. * @param frustumPlanes defines the frustum planes to test
  6768. * @returns true if there is an intersection
  6769. */
  6770. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6771. /**
  6772. * Tests if the bounding sphere center is in between the frustum planes.
  6773. * Used for optimistic fast inclusion.
  6774. * @param frustumPlanes defines the frustum planes to test
  6775. * @returns true if the sphere center is in between the frustum planes
  6776. */
  6777. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6778. /**
  6779. * Tests if a point is inside the bounding sphere
  6780. * @param point defines the point to test
  6781. * @returns true if the point is inside the bounding sphere
  6782. */
  6783. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6784. /**
  6785. * Checks if two sphere intersct
  6786. * @param sphere0 sphere 0
  6787. * @param sphere1 sphere 1
  6788. * @returns true if the speres intersect
  6789. */
  6790. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6791. }
  6792. }
  6793. declare module "babylonjs/Culling/boundingBox" {
  6794. import { DeepImmutable } from "babylonjs/types";
  6795. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6796. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6797. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6798. import { Plane } from "babylonjs/Maths/math.plane";
  6799. /**
  6800. * Class used to store bounding box information
  6801. */
  6802. export class BoundingBox implements ICullable {
  6803. /**
  6804. * Gets the 8 vectors representing the bounding box in local space
  6805. */
  6806. readonly vectors: Vector3[];
  6807. /**
  6808. * Gets the center of the bounding box in local space
  6809. */
  6810. readonly center: Vector3;
  6811. /**
  6812. * Gets the center of the bounding box in world space
  6813. */
  6814. readonly centerWorld: Vector3;
  6815. /**
  6816. * Gets the extend size in local space
  6817. */
  6818. readonly extendSize: Vector3;
  6819. /**
  6820. * Gets the extend size in world space
  6821. */
  6822. readonly extendSizeWorld: Vector3;
  6823. /**
  6824. * Gets the OBB (object bounding box) directions
  6825. */
  6826. readonly directions: Vector3[];
  6827. /**
  6828. * Gets the 8 vectors representing the bounding box in world space
  6829. */
  6830. readonly vectorsWorld: Vector3[];
  6831. /**
  6832. * Gets the minimum vector in world space
  6833. */
  6834. readonly minimumWorld: Vector3;
  6835. /**
  6836. * Gets the maximum vector in world space
  6837. */
  6838. readonly maximumWorld: Vector3;
  6839. /**
  6840. * Gets the minimum vector in local space
  6841. */
  6842. readonly minimum: Vector3;
  6843. /**
  6844. * Gets the maximum vector in local space
  6845. */
  6846. readonly maximum: Vector3;
  6847. private _worldMatrix;
  6848. private static readonly TmpVector3;
  6849. /**
  6850. * @hidden
  6851. */
  6852. _tag: number;
  6853. /**
  6854. * Creates a new bounding box
  6855. * @param min defines the minimum vector (in local space)
  6856. * @param max defines the maximum vector (in local space)
  6857. * @param worldMatrix defines the new world matrix
  6858. */
  6859. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6860. /**
  6861. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6862. * @param min defines the new minimum vector (in local space)
  6863. * @param max defines the new maximum vector (in local space)
  6864. * @param worldMatrix defines the new world matrix
  6865. */
  6866. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6867. /**
  6868. * Scale the current bounding box by applying a scale factor
  6869. * @param factor defines the scale factor to apply
  6870. * @returns the current bounding box
  6871. */
  6872. scale(factor: number): BoundingBox;
  6873. /**
  6874. * Gets the world matrix of the bounding box
  6875. * @returns a matrix
  6876. */
  6877. getWorldMatrix(): DeepImmutable<Matrix>;
  6878. /** @hidden */
  6879. _update(world: DeepImmutable<Matrix>): void;
  6880. /**
  6881. * Tests if the bounding box is intersecting the frustum planes
  6882. * @param frustumPlanes defines the frustum planes to test
  6883. * @returns true if there is an intersection
  6884. */
  6885. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6886. /**
  6887. * Tests if the bounding box is entirely inside the frustum planes
  6888. * @param frustumPlanes defines the frustum planes to test
  6889. * @returns true if there is an inclusion
  6890. */
  6891. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6892. /**
  6893. * Tests if a point is inside the bounding box
  6894. * @param point defines the point to test
  6895. * @returns true if the point is inside the bounding box
  6896. */
  6897. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6898. /**
  6899. * Tests if the bounding box intersects with a bounding sphere
  6900. * @param sphere defines the sphere to test
  6901. * @returns true if there is an intersection
  6902. */
  6903. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6904. /**
  6905. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6906. * @param min defines the min vector to use
  6907. * @param max defines the max vector to use
  6908. * @returns true if there is an intersection
  6909. */
  6910. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6911. /**
  6912. * Tests if two bounding boxes are intersections
  6913. * @param box0 defines the first box to test
  6914. * @param box1 defines the second box to test
  6915. * @returns true if there is an intersection
  6916. */
  6917. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6918. /**
  6919. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6920. * @param minPoint defines the minimum vector of the bounding box
  6921. * @param maxPoint defines the maximum vector of the bounding box
  6922. * @param sphereCenter defines the sphere center
  6923. * @param sphereRadius defines the sphere radius
  6924. * @returns true if there is an intersection
  6925. */
  6926. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6927. /**
  6928. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6929. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6930. * @param frustumPlanes defines the frustum planes to test
  6931. * @return true if there is an inclusion
  6932. */
  6933. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6934. /**
  6935. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6936. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6937. * @param frustumPlanes defines the frustum planes to test
  6938. * @return true if there is an intersection
  6939. */
  6940. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6941. }
  6942. }
  6943. declare module "babylonjs/Collisions/collider" {
  6944. import { Nullable, IndicesArray } from "babylonjs/types";
  6945. import { Vector3 } from "babylonjs/Maths/math.vector";
  6946. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6947. import { Plane } from "babylonjs/Maths/math.plane";
  6948. /** @hidden */
  6949. export class Collider {
  6950. /** Define if a collision was found */
  6951. collisionFound: boolean;
  6952. /**
  6953. * Define last intersection point in local space
  6954. */
  6955. intersectionPoint: Vector3;
  6956. /**
  6957. * Define last collided mesh
  6958. */
  6959. collidedMesh: Nullable<AbstractMesh>;
  6960. private _collisionPoint;
  6961. private _planeIntersectionPoint;
  6962. private _tempVector;
  6963. private _tempVector2;
  6964. private _tempVector3;
  6965. private _tempVector4;
  6966. private _edge;
  6967. private _baseToVertex;
  6968. private _destinationPoint;
  6969. private _slidePlaneNormal;
  6970. private _displacementVector;
  6971. /** @hidden */
  6972. _radius: Vector3;
  6973. /** @hidden */
  6974. _retry: number;
  6975. private _velocity;
  6976. private _basePoint;
  6977. private _epsilon;
  6978. /** @hidden */
  6979. _velocityWorldLength: number;
  6980. /** @hidden */
  6981. _basePointWorld: Vector3;
  6982. private _velocityWorld;
  6983. private _normalizedVelocity;
  6984. /** @hidden */
  6985. _initialVelocity: Vector3;
  6986. /** @hidden */
  6987. _initialPosition: Vector3;
  6988. private _nearestDistance;
  6989. private _collisionMask;
  6990. collisionMask: number;
  6991. /**
  6992. * Gets the plane normal used to compute the sliding response (in local space)
  6993. */
  6994. readonly slidePlaneNormal: Vector3;
  6995. /** @hidden */
  6996. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6997. /** @hidden */
  6998. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6999. /** @hidden */
  7000. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7001. /** @hidden */
  7002. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7003. /** @hidden */
  7004. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7005. /** @hidden */
  7006. _getResponse(pos: Vector3, vel: Vector3): void;
  7007. }
  7008. }
  7009. declare module "babylonjs/Culling/boundingInfo" {
  7010. import { DeepImmutable } from "babylonjs/types";
  7011. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7012. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7013. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7014. import { Plane } from "babylonjs/Maths/math.plane";
  7015. import { Collider } from "babylonjs/Collisions/collider";
  7016. /**
  7017. * Interface for cullable objects
  7018. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7019. */
  7020. export interface ICullable {
  7021. /**
  7022. * Checks if the object or part of the object is in the frustum
  7023. * @param frustumPlanes Camera near/planes
  7024. * @returns true if the object is in frustum otherwise false
  7025. */
  7026. isInFrustum(frustumPlanes: Plane[]): boolean;
  7027. /**
  7028. * Checks if a cullable object (mesh...) is in the camera frustum
  7029. * Unlike isInFrustum this cheks the full bounding box
  7030. * @param frustumPlanes Camera near/planes
  7031. * @returns true if the object is in frustum otherwise false
  7032. */
  7033. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7034. }
  7035. /**
  7036. * Info for a bounding data of a mesh
  7037. */
  7038. export class BoundingInfo implements ICullable {
  7039. /**
  7040. * Bounding box for the mesh
  7041. */
  7042. readonly boundingBox: BoundingBox;
  7043. /**
  7044. * Bounding sphere for the mesh
  7045. */
  7046. readonly boundingSphere: BoundingSphere;
  7047. private _isLocked;
  7048. private static readonly TmpVector3;
  7049. /**
  7050. * Constructs bounding info
  7051. * @param minimum min vector of the bounding box/sphere
  7052. * @param maximum max vector of the bounding box/sphere
  7053. * @param worldMatrix defines the new world matrix
  7054. */
  7055. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7056. /**
  7057. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7058. * @param min defines the new minimum vector (in local space)
  7059. * @param max defines the new maximum vector (in local space)
  7060. * @param worldMatrix defines the new world matrix
  7061. */
  7062. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7063. /**
  7064. * min vector of the bounding box/sphere
  7065. */
  7066. readonly minimum: Vector3;
  7067. /**
  7068. * max vector of the bounding box/sphere
  7069. */
  7070. readonly maximum: Vector3;
  7071. /**
  7072. * If the info is locked and won't be updated to avoid perf overhead
  7073. */
  7074. isLocked: boolean;
  7075. /**
  7076. * Updates the bounding sphere and box
  7077. * @param world world matrix to be used to update
  7078. */
  7079. update(world: DeepImmutable<Matrix>): void;
  7080. /**
  7081. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7082. * @param center New center of the bounding info
  7083. * @param extend New extend of the bounding info
  7084. * @returns the current bounding info
  7085. */
  7086. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7087. /**
  7088. * Scale the current bounding info by applying a scale factor
  7089. * @param factor defines the scale factor to apply
  7090. * @returns the current bounding info
  7091. */
  7092. scale(factor: number): BoundingInfo;
  7093. /**
  7094. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7095. * @param frustumPlanes defines the frustum to test
  7096. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7097. * @returns true if the bounding info is in the frustum planes
  7098. */
  7099. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7100. /**
  7101. * Gets the world distance between the min and max points of the bounding box
  7102. */
  7103. readonly diagonalLength: number;
  7104. /**
  7105. * Checks if a cullable object (mesh...) is in the camera frustum
  7106. * Unlike isInFrustum this cheks the full bounding box
  7107. * @param frustumPlanes Camera near/planes
  7108. * @returns true if the object is in frustum otherwise false
  7109. */
  7110. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7111. /** @hidden */
  7112. _checkCollision(collider: Collider): boolean;
  7113. /**
  7114. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7115. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7116. * @param point the point to check intersection with
  7117. * @returns if the point intersects
  7118. */
  7119. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7120. /**
  7121. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7122. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7123. * @param boundingInfo the bounding info to check intersection with
  7124. * @param precise if the intersection should be done using OBB
  7125. * @returns if the bounding info intersects
  7126. */
  7127. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7128. }
  7129. }
  7130. declare module "babylonjs/Maths/math.functions" {
  7131. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7132. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7133. /**
  7134. * Extracts minimum and maximum values from a list of indexed positions
  7135. * @param positions defines the positions to use
  7136. * @param indices defines the indices to the positions
  7137. * @param indexStart defines the start index
  7138. * @param indexCount defines the end index
  7139. * @param bias defines bias value to add to the result
  7140. * @return minimum and maximum values
  7141. */
  7142. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7143. minimum: Vector3;
  7144. maximum: Vector3;
  7145. };
  7146. /**
  7147. * Extracts minimum and maximum values from a list of positions
  7148. * @param positions defines the positions to use
  7149. * @param start defines the start index in the positions array
  7150. * @param count defines the number of positions to handle
  7151. * @param bias defines bias value to add to the result
  7152. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7153. * @return minimum and maximum values
  7154. */
  7155. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7156. minimum: Vector3;
  7157. maximum: Vector3;
  7158. };
  7159. }
  7160. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7161. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7162. /** @hidden */
  7163. export class WebGLDataBuffer extends DataBuffer {
  7164. private _buffer;
  7165. constructor(resource: WebGLBuffer);
  7166. readonly underlyingResource: any;
  7167. }
  7168. }
  7169. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7170. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7171. import { Nullable } from "babylonjs/types";
  7172. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7173. /** @hidden */
  7174. export class WebGLPipelineContext implements IPipelineContext {
  7175. engine: ThinEngine;
  7176. program: Nullable<WebGLProgram>;
  7177. context?: WebGLRenderingContext;
  7178. vertexShader?: WebGLShader;
  7179. fragmentShader?: WebGLShader;
  7180. isParallelCompiled: boolean;
  7181. onCompiled?: () => void;
  7182. transformFeedback?: WebGLTransformFeedback | null;
  7183. readonly isAsync: boolean;
  7184. readonly isReady: boolean;
  7185. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7186. }
  7187. }
  7188. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7189. import { FloatArray, Nullable } from "babylonjs/types";
  7190. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7191. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7192. module "babylonjs/Engines/thinEngine" {
  7193. interface ThinEngine {
  7194. /**
  7195. * Create an uniform buffer
  7196. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7197. * @param elements defines the content of the uniform buffer
  7198. * @returns the webGL uniform buffer
  7199. */
  7200. createUniformBuffer(elements: FloatArray): DataBuffer;
  7201. /**
  7202. * Create a dynamic uniform buffer
  7203. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7204. * @param elements defines the content of the uniform buffer
  7205. * @returns the webGL uniform buffer
  7206. */
  7207. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7208. /**
  7209. * Update an existing uniform buffer
  7210. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7211. * @param uniformBuffer defines the target uniform buffer
  7212. * @param elements defines the content to update
  7213. * @param offset defines the offset in the uniform buffer where update should start
  7214. * @param count defines the size of the data to update
  7215. */
  7216. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7217. /**
  7218. * Bind an uniform buffer to the current webGL context
  7219. * @param buffer defines the buffer to bind
  7220. */
  7221. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7222. /**
  7223. * Bind a buffer to the current webGL context at a given location
  7224. * @param buffer defines the buffer to bind
  7225. * @param location defines the index where to bind the buffer
  7226. */
  7227. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7228. /**
  7229. * Bind a specific block at a given index in a specific shader program
  7230. * @param pipelineContext defines the pipeline context to use
  7231. * @param blockName defines the block name
  7232. * @param index defines the index where to bind the block
  7233. */
  7234. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7235. }
  7236. }
  7237. }
  7238. declare module "babylonjs/Materials/uniformBuffer" {
  7239. import { Nullable, FloatArray } from "babylonjs/types";
  7240. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7241. import { Engine } from "babylonjs/Engines/engine";
  7242. import { Effect } from "babylonjs/Materials/effect";
  7243. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7244. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7245. import { Color3 } from "babylonjs/Maths/math.color";
  7246. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7247. /**
  7248. * Uniform buffer objects.
  7249. *
  7250. * Handles blocks of uniform on the GPU.
  7251. *
  7252. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7253. *
  7254. * For more information, please refer to :
  7255. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7256. */
  7257. export class UniformBuffer {
  7258. private _engine;
  7259. private _buffer;
  7260. private _data;
  7261. private _bufferData;
  7262. private _dynamic?;
  7263. private _uniformLocations;
  7264. private _uniformSizes;
  7265. private _uniformLocationPointer;
  7266. private _needSync;
  7267. private _noUBO;
  7268. private _currentEffect;
  7269. /** @hidden */
  7270. _alreadyBound: boolean;
  7271. private static _MAX_UNIFORM_SIZE;
  7272. private static _tempBuffer;
  7273. /**
  7274. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7275. * This is dynamic to allow compat with webgl 1 and 2.
  7276. * You will need to pass the name of the uniform as well as the value.
  7277. */
  7278. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7279. /**
  7280. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7281. * This is dynamic to allow compat with webgl 1 and 2.
  7282. * You will need to pass the name of the uniform as well as the value.
  7283. */
  7284. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7285. /**
  7286. * Lambda to Update a single float in a uniform buffer.
  7287. * This is dynamic to allow compat with webgl 1 and 2.
  7288. * You will need to pass the name of the uniform as well as the value.
  7289. */
  7290. updateFloat: (name: string, x: number) => void;
  7291. /**
  7292. * Lambda to Update a vec2 of float in a uniform buffer.
  7293. * This is dynamic to allow compat with webgl 1 and 2.
  7294. * You will need to pass the name of the uniform as well as the value.
  7295. */
  7296. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7297. /**
  7298. * Lambda to Update a vec3 of float in a uniform buffer.
  7299. * This is dynamic to allow compat with webgl 1 and 2.
  7300. * You will need to pass the name of the uniform as well as the value.
  7301. */
  7302. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7303. /**
  7304. * Lambda to Update a vec4 of float in a uniform buffer.
  7305. * This is dynamic to allow compat with webgl 1 and 2.
  7306. * You will need to pass the name of the uniform as well as the value.
  7307. */
  7308. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7309. /**
  7310. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7311. * This is dynamic to allow compat with webgl 1 and 2.
  7312. * You will need to pass the name of the uniform as well as the value.
  7313. */
  7314. updateMatrix: (name: string, mat: Matrix) => void;
  7315. /**
  7316. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7317. * This is dynamic to allow compat with webgl 1 and 2.
  7318. * You will need to pass the name of the uniform as well as the value.
  7319. */
  7320. updateVector3: (name: string, vector: Vector3) => void;
  7321. /**
  7322. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7323. * This is dynamic to allow compat with webgl 1 and 2.
  7324. * You will need to pass the name of the uniform as well as the value.
  7325. */
  7326. updateVector4: (name: string, vector: Vector4) => void;
  7327. /**
  7328. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7329. * This is dynamic to allow compat with webgl 1 and 2.
  7330. * You will need to pass the name of the uniform as well as the value.
  7331. */
  7332. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7333. /**
  7334. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7335. * This is dynamic to allow compat with webgl 1 and 2.
  7336. * You will need to pass the name of the uniform as well as the value.
  7337. */
  7338. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7339. /**
  7340. * Instantiates a new Uniform buffer objects.
  7341. *
  7342. * Handles blocks of uniform on the GPU.
  7343. *
  7344. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7345. *
  7346. * For more information, please refer to :
  7347. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7348. * @param engine Define the engine the buffer is associated with
  7349. * @param data Define the data contained in the buffer
  7350. * @param dynamic Define if the buffer is updatable
  7351. */
  7352. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7353. /**
  7354. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7355. * or just falling back on setUniformXXX calls.
  7356. */
  7357. readonly useUbo: boolean;
  7358. /**
  7359. * Indicates if the WebGL underlying uniform buffer is in sync
  7360. * with the javascript cache data.
  7361. */
  7362. readonly isSync: boolean;
  7363. /**
  7364. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7365. * Also, a dynamic UniformBuffer will disable cache verification and always
  7366. * update the underlying WebGL uniform buffer to the GPU.
  7367. * @returns if Dynamic, otherwise false
  7368. */
  7369. isDynamic(): boolean;
  7370. /**
  7371. * The data cache on JS side.
  7372. * @returns the underlying data as a float array
  7373. */
  7374. getData(): Float32Array;
  7375. /**
  7376. * The underlying WebGL Uniform buffer.
  7377. * @returns the webgl buffer
  7378. */
  7379. getBuffer(): Nullable<DataBuffer>;
  7380. /**
  7381. * std140 layout specifies how to align data within an UBO structure.
  7382. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7383. * for specs.
  7384. */
  7385. private _fillAlignment;
  7386. /**
  7387. * Adds an uniform in the buffer.
  7388. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7389. * for the layout to be correct !
  7390. * @param name Name of the uniform, as used in the uniform block in the shader.
  7391. * @param size Data size, or data directly.
  7392. */
  7393. addUniform(name: string, size: number | number[]): void;
  7394. /**
  7395. * Adds a Matrix 4x4 to the uniform buffer.
  7396. * @param name Name of the uniform, as used in the uniform block in the shader.
  7397. * @param mat A 4x4 matrix.
  7398. */
  7399. addMatrix(name: string, mat: Matrix): void;
  7400. /**
  7401. * Adds a vec2 to the uniform buffer.
  7402. * @param name Name of the uniform, as used in the uniform block in the shader.
  7403. * @param x Define the x component value of the vec2
  7404. * @param y Define the y component value of the vec2
  7405. */
  7406. addFloat2(name: string, x: number, y: number): void;
  7407. /**
  7408. * Adds a vec3 to the uniform buffer.
  7409. * @param name Name of the uniform, as used in the uniform block in the shader.
  7410. * @param x Define the x component value of the vec3
  7411. * @param y Define the y component value of the vec3
  7412. * @param z Define the z component value of the vec3
  7413. */
  7414. addFloat3(name: string, x: number, y: number, z: number): void;
  7415. /**
  7416. * Adds a vec3 to the uniform buffer.
  7417. * @param name Name of the uniform, as used in the uniform block in the shader.
  7418. * @param color Define the vec3 from a Color
  7419. */
  7420. addColor3(name: string, color: Color3): void;
  7421. /**
  7422. * Adds a vec4 to the uniform buffer.
  7423. * @param name Name of the uniform, as used in the uniform block in the shader.
  7424. * @param color Define the rgb components from a Color
  7425. * @param alpha Define the a component of the vec4
  7426. */
  7427. addColor4(name: string, color: Color3, alpha: number): void;
  7428. /**
  7429. * Adds a vec3 to the uniform buffer.
  7430. * @param name Name of the uniform, as used in the uniform block in the shader.
  7431. * @param vector Define the vec3 components from a Vector
  7432. */
  7433. addVector3(name: string, vector: Vector3): void;
  7434. /**
  7435. * Adds a Matrix 3x3 to the uniform buffer.
  7436. * @param name Name of the uniform, as used in the uniform block in the shader.
  7437. */
  7438. addMatrix3x3(name: string): void;
  7439. /**
  7440. * Adds a Matrix 2x2 to the uniform buffer.
  7441. * @param name Name of the uniform, as used in the uniform block in the shader.
  7442. */
  7443. addMatrix2x2(name: string): void;
  7444. /**
  7445. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7446. */
  7447. create(): void;
  7448. /** @hidden */
  7449. _rebuild(): void;
  7450. /**
  7451. * Updates the WebGL Uniform Buffer on the GPU.
  7452. * If the `dynamic` flag is set to true, no cache comparison is done.
  7453. * Otherwise, the buffer will be updated only if the cache differs.
  7454. */
  7455. update(): void;
  7456. /**
  7457. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7458. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7459. * @param data Define the flattened data
  7460. * @param size Define the size of the data.
  7461. */
  7462. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7463. private _valueCache;
  7464. private _cacheMatrix;
  7465. private _updateMatrix3x3ForUniform;
  7466. private _updateMatrix3x3ForEffect;
  7467. private _updateMatrix2x2ForEffect;
  7468. private _updateMatrix2x2ForUniform;
  7469. private _updateFloatForEffect;
  7470. private _updateFloatForUniform;
  7471. private _updateFloat2ForEffect;
  7472. private _updateFloat2ForUniform;
  7473. private _updateFloat3ForEffect;
  7474. private _updateFloat3ForUniform;
  7475. private _updateFloat4ForEffect;
  7476. private _updateFloat4ForUniform;
  7477. private _updateMatrixForEffect;
  7478. private _updateMatrixForUniform;
  7479. private _updateVector3ForEffect;
  7480. private _updateVector3ForUniform;
  7481. private _updateVector4ForEffect;
  7482. private _updateVector4ForUniform;
  7483. private _updateColor3ForEffect;
  7484. private _updateColor3ForUniform;
  7485. private _updateColor4ForEffect;
  7486. private _updateColor4ForUniform;
  7487. /**
  7488. * Sets a sampler uniform on the effect.
  7489. * @param name Define the name of the sampler.
  7490. * @param texture Define the texture to set in the sampler
  7491. */
  7492. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7493. /**
  7494. * Directly updates the value of the uniform in the cache AND on the GPU.
  7495. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7496. * @param data Define the flattened data
  7497. */
  7498. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7499. /**
  7500. * Binds this uniform buffer to an effect.
  7501. * @param effect Define the effect to bind the buffer to
  7502. * @param name Name of the uniform block in the shader.
  7503. */
  7504. bindToEffect(effect: Effect, name: string): void;
  7505. /**
  7506. * Disposes the uniform buffer.
  7507. */
  7508. dispose(): void;
  7509. }
  7510. }
  7511. declare module "babylonjs/Misc/iInspectable" {
  7512. /**
  7513. * Enum that determines the text-wrapping mode to use.
  7514. */
  7515. export enum InspectableType {
  7516. /**
  7517. * Checkbox for booleans
  7518. */
  7519. Checkbox = 0,
  7520. /**
  7521. * Sliders for numbers
  7522. */
  7523. Slider = 1,
  7524. /**
  7525. * Vector3
  7526. */
  7527. Vector3 = 2,
  7528. /**
  7529. * Quaternions
  7530. */
  7531. Quaternion = 3,
  7532. /**
  7533. * Color3
  7534. */
  7535. Color3 = 4,
  7536. /**
  7537. * String
  7538. */
  7539. String = 5
  7540. }
  7541. /**
  7542. * Interface used to define custom inspectable properties.
  7543. * This interface is used by the inspector to display custom property grids
  7544. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7545. */
  7546. export interface IInspectable {
  7547. /**
  7548. * Gets the label to display
  7549. */
  7550. label: string;
  7551. /**
  7552. * Gets the name of the property to edit
  7553. */
  7554. propertyName: string;
  7555. /**
  7556. * Gets the type of the editor to use
  7557. */
  7558. type: InspectableType;
  7559. /**
  7560. * Gets the minimum value of the property when using in "slider" mode
  7561. */
  7562. min?: number;
  7563. /**
  7564. * Gets the maximum value of the property when using in "slider" mode
  7565. */
  7566. max?: number;
  7567. /**
  7568. * Gets the setp to use when using in "slider" mode
  7569. */
  7570. step?: number;
  7571. }
  7572. }
  7573. declare module "babylonjs/Misc/timingTools" {
  7574. /**
  7575. * Class used to provide helper for timing
  7576. */
  7577. export class TimingTools {
  7578. /**
  7579. * Polyfill for setImmediate
  7580. * @param action defines the action to execute after the current execution block
  7581. */
  7582. static SetImmediate(action: () => void): void;
  7583. }
  7584. }
  7585. declare module "babylonjs/Misc/instantiationTools" {
  7586. /**
  7587. * Class used to enable instatition of objects by class name
  7588. */
  7589. export class InstantiationTools {
  7590. /**
  7591. * Use this object to register external classes like custom textures or material
  7592. * to allow the laoders to instantiate them
  7593. */
  7594. static RegisteredExternalClasses: {
  7595. [key: string]: Object;
  7596. };
  7597. /**
  7598. * Tries to instantiate a new object from a given class name
  7599. * @param className defines the class name to instantiate
  7600. * @returns the new object or null if the system was not able to do the instantiation
  7601. */
  7602. static Instantiate(className: string): any;
  7603. }
  7604. }
  7605. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7606. /**
  7607. * Define options used to create a depth texture
  7608. */
  7609. export class DepthTextureCreationOptions {
  7610. /** Specifies whether or not a stencil should be allocated in the texture */
  7611. generateStencil?: boolean;
  7612. /** Specifies whether or not bilinear filtering is enable on the texture */
  7613. bilinearFiltering?: boolean;
  7614. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7615. comparisonFunction?: number;
  7616. /** Specifies if the created texture is a cube texture */
  7617. isCube?: boolean;
  7618. }
  7619. }
  7620. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7621. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7622. import { Nullable } from "babylonjs/types";
  7623. import { Scene } from "babylonjs/scene";
  7624. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7625. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7626. module "babylonjs/Engines/thinEngine" {
  7627. interface ThinEngine {
  7628. /**
  7629. * Creates a depth stencil cube texture.
  7630. * This is only available in WebGL 2.
  7631. * @param size The size of face edge in the cube texture.
  7632. * @param options The options defining the cube texture.
  7633. * @returns The cube texture
  7634. */
  7635. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7636. /**
  7637. * Creates a cube texture
  7638. * @param rootUrl defines the url where the files to load is located
  7639. * @param scene defines the current scene
  7640. * @param files defines the list of files to load (1 per face)
  7641. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7642. * @param onLoad defines an optional callback raised when the texture is loaded
  7643. * @param onError defines an optional callback raised if there is an issue to load the texture
  7644. * @param format defines the format of the data
  7645. * @param forcedExtension defines the extension to use to pick the right loader
  7646. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7647. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7648. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7649. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7650. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7651. * @returns the cube texture as an InternalTexture
  7652. */
  7653. 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;
  7654. /**
  7655. * Creates a cube texture
  7656. * @param rootUrl defines the url where the files to load is located
  7657. * @param scene defines the current scene
  7658. * @param files defines the list of files to load (1 per face)
  7659. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7660. * @param onLoad defines an optional callback raised when the texture is loaded
  7661. * @param onError defines an optional callback raised if there is an issue to load the texture
  7662. * @param format defines the format of the data
  7663. * @param forcedExtension defines the extension to use to pick the right loader
  7664. * @returns the cube texture as an InternalTexture
  7665. */
  7666. 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;
  7667. /**
  7668. * Creates a cube texture
  7669. * @param rootUrl defines the url where the files to load is located
  7670. * @param scene defines the current scene
  7671. * @param files defines the list of files to load (1 per face)
  7672. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7673. * @param onLoad defines an optional callback raised when the texture is loaded
  7674. * @param onError defines an optional callback raised if there is an issue to load the texture
  7675. * @param format defines the format of the data
  7676. * @param forcedExtension defines the extension to use to pick the right loader
  7677. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7678. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7679. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7680. * @returns the cube texture as an InternalTexture
  7681. */
  7682. 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;
  7683. /** @hidden */
  7684. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7685. /** @hidden */
  7686. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7687. /** @hidden */
  7688. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7689. /** @hidden */
  7690. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7691. /**
  7692. * @hidden
  7693. */
  7694. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7695. }
  7696. }
  7697. }
  7698. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7699. import { Nullable } from "babylonjs/types";
  7700. import { Scene } from "babylonjs/scene";
  7701. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7702. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7703. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7704. /**
  7705. * Class for creating a cube texture
  7706. */
  7707. export class CubeTexture extends BaseTexture {
  7708. private _delayedOnLoad;
  7709. /**
  7710. * The url of the texture
  7711. */
  7712. url: string;
  7713. /**
  7714. * Gets or sets the center of the bounding box associated with the cube texture.
  7715. * It must define where the camera used to render the texture was set
  7716. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7717. */
  7718. boundingBoxPosition: Vector3;
  7719. private _boundingBoxSize;
  7720. /**
  7721. * Gets or sets the size of the bounding box associated with the cube texture
  7722. * When defined, the cubemap will switch to local mode
  7723. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7724. * @example https://www.babylonjs-playground.com/#RNASML
  7725. */
  7726. /**
  7727. * Returns the bounding box size
  7728. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7729. */
  7730. boundingBoxSize: Vector3;
  7731. protected _rotationY: number;
  7732. /**
  7733. * Sets texture matrix rotation angle around Y axis in radians.
  7734. */
  7735. /**
  7736. * Gets texture matrix rotation angle around Y axis radians.
  7737. */
  7738. rotationY: number;
  7739. /**
  7740. * Are mip maps generated for this texture or not.
  7741. */
  7742. readonly noMipmap: boolean;
  7743. private _noMipmap;
  7744. private _files;
  7745. protected _forcedExtension: Nullable<string>;
  7746. private _extensions;
  7747. private _textureMatrix;
  7748. private _format;
  7749. private _createPolynomials;
  7750. /** @hidden */
  7751. _prefiltered: boolean;
  7752. /**
  7753. * Creates a cube texture from an array of image urls
  7754. * @param files defines an array of image urls
  7755. * @param scene defines the hosting scene
  7756. * @param noMipmap specifies if mip maps are not used
  7757. * @returns a cube texture
  7758. */
  7759. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7760. /**
  7761. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7762. * @param url defines the url of the prefiltered texture
  7763. * @param scene defines the scene the texture is attached to
  7764. * @param forcedExtension defines the extension of the file if different from the url
  7765. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7766. * @return the prefiltered texture
  7767. */
  7768. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7769. /**
  7770. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7771. * as prefiltered data.
  7772. * @param rootUrl defines the url of the texture or the root name of the six images
  7773. * @param scene defines the scene the texture is attached to
  7774. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7775. * @param noMipmap defines if mipmaps should be created or not
  7776. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7777. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7778. * @param onError defines a callback triggered in case of error during load
  7779. * @param format defines the internal format to use for the texture once loaded
  7780. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7781. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7782. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7783. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7784. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7785. * @return the cube texture
  7786. */
  7787. 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);
  7788. /**
  7789. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7790. */
  7791. readonly isPrefiltered: boolean;
  7792. /**
  7793. * Get the current class name of the texture useful for serialization or dynamic coding.
  7794. * @returns "CubeTexture"
  7795. */
  7796. getClassName(): string;
  7797. /**
  7798. * Update the url (and optional buffer) of this texture if url was null during construction.
  7799. * @param url the url of the texture
  7800. * @param forcedExtension defines the extension to use
  7801. * @param onLoad callback called when the texture is loaded (defaults to null)
  7802. */
  7803. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7804. /**
  7805. * Delays loading of the cube texture
  7806. * @param forcedExtension defines the extension to use
  7807. */
  7808. delayLoad(forcedExtension?: string): void;
  7809. /**
  7810. * Returns the reflection texture matrix
  7811. * @returns the reflection texture matrix
  7812. */
  7813. getReflectionTextureMatrix(): Matrix;
  7814. /**
  7815. * Sets the reflection texture matrix
  7816. * @param value Reflection texture matrix
  7817. */
  7818. setReflectionTextureMatrix(value: Matrix): void;
  7819. /**
  7820. * Parses text to create a cube texture
  7821. * @param parsedTexture define the serialized text to read from
  7822. * @param scene defines the hosting scene
  7823. * @param rootUrl defines the root url of the cube texture
  7824. * @returns a cube texture
  7825. */
  7826. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7827. /**
  7828. * Makes a clone, or deep copy, of the cube texture
  7829. * @returns a new cube texture
  7830. */
  7831. clone(): CubeTexture;
  7832. }
  7833. }
  7834. declare module "babylonjs/Materials/materialDefines" {
  7835. /**
  7836. * Manages the defines for the Material
  7837. */
  7838. export class MaterialDefines {
  7839. /** @hidden */
  7840. protected _keys: string[];
  7841. private _isDirty;
  7842. /** @hidden */
  7843. _renderId: number;
  7844. /** @hidden */
  7845. _areLightsDirty: boolean;
  7846. /** @hidden */
  7847. _areLightsDisposed: boolean;
  7848. /** @hidden */
  7849. _areAttributesDirty: boolean;
  7850. /** @hidden */
  7851. _areTexturesDirty: boolean;
  7852. /** @hidden */
  7853. _areFresnelDirty: boolean;
  7854. /** @hidden */
  7855. _areMiscDirty: boolean;
  7856. /** @hidden */
  7857. _areImageProcessingDirty: boolean;
  7858. /** @hidden */
  7859. _normals: boolean;
  7860. /** @hidden */
  7861. _uvs: boolean;
  7862. /** @hidden */
  7863. _needNormals: boolean;
  7864. /** @hidden */
  7865. _needUVs: boolean;
  7866. [id: string]: any;
  7867. /**
  7868. * Specifies if the material needs to be re-calculated
  7869. */
  7870. readonly isDirty: boolean;
  7871. /**
  7872. * Marks the material to indicate that it has been re-calculated
  7873. */
  7874. markAsProcessed(): void;
  7875. /**
  7876. * Marks the material to indicate that it needs to be re-calculated
  7877. */
  7878. markAsUnprocessed(): void;
  7879. /**
  7880. * Marks the material to indicate all of its defines need to be re-calculated
  7881. */
  7882. markAllAsDirty(): void;
  7883. /**
  7884. * Marks the material to indicate that image processing needs to be re-calculated
  7885. */
  7886. markAsImageProcessingDirty(): void;
  7887. /**
  7888. * Marks the material to indicate the lights need to be re-calculated
  7889. * @param disposed Defines whether the light is dirty due to dispose or not
  7890. */
  7891. markAsLightDirty(disposed?: boolean): void;
  7892. /**
  7893. * Marks the attribute state as changed
  7894. */
  7895. markAsAttributesDirty(): void;
  7896. /**
  7897. * Marks the texture state as changed
  7898. */
  7899. markAsTexturesDirty(): void;
  7900. /**
  7901. * Marks the fresnel state as changed
  7902. */
  7903. markAsFresnelDirty(): void;
  7904. /**
  7905. * Marks the misc state as changed
  7906. */
  7907. markAsMiscDirty(): void;
  7908. /**
  7909. * Rebuilds the material defines
  7910. */
  7911. rebuild(): void;
  7912. /**
  7913. * Specifies if two material defines are equal
  7914. * @param other - A material define instance to compare to
  7915. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7916. */
  7917. isEqual(other: MaterialDefines): boolean;
  7918. /**
  7919. * Clones this instance's defines to another instance
  7920. * @param other - material defines to clone values to
  7921. */
  7922. cloneTo(other: MaterialDefines): void;
  7923. /**
  7924. * Resets the material define values
  7925. */
  7926. reset(): void;
  7927. /**
  7928. * Converts the material define values to a string
  7929. * @returns - String of material define information
  7930. */
  7931. toString(): string;
  7932. }
  7933. }
  7934. declare module "babylonjs/Materials/colorCurves" {
  7935. import { Effect } from "babylonjs/Materials/effect";
  7936. /**
  7937. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7938. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7939. * 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;
  7940. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7941. */
  7942. export class ColorCurves {
  7943. private _dirty;
  7944. private _tempColor;
  7945. private _globalCurve;
  7946. private _highlightsCurve;
  7947. private _midtonesCurve;
  7948. private _shadowsCurve;
  7949. private _positiveCurve;
  7950. private _negativeCurve;
  7951. private _globalHue;
  7952. private _globalDensity;
  7953. private _globalSaturation;
  7954. private _globalExposure;
  7955. /**
  7956. * Gets the global Hue value.
  7957. * 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).
  7958. */
  7959. /**
  7960. * Sets the global Hue value.
  7961. * 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).
  7962. */
  7963. globalHue: number;
  7964. /**
  7965. * Gets the global Density value.
  7966. * 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.
  7967. * Values less than zero provide a filter of opposite hue.
  7968. */
  7969. /**
  7970. * Sets the global Density value.
  7971. * 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.
  7972. * Values less than zero provide a filter of opposite hue.
  7973. */
  7974. globalDensity: number;
  7975. /**
  7976. * Gets the global Saturation value.
  7977. * 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.
  7978. */
  7979. /**
  7980. * Sets the global Saturation value.
  7981. * 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.
  7982. */
  7983. globalSaturation: number;
  7984. /**
  7985. * Gets the global Exposure value.
  7986. * 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.
  7987. */
  7988. /**
  7989. * Sets the global Exposure value.
  7990. * 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.
  7991. */
  7992. globalExposure: number;
  7993. private _highlightsHue;
  7994. private _highlightsDensity;
  7995. private _highlightsSaturation;
  7996. private _highlightsExposure;
  7997. /**
  7998. * Gets the highlights Hue value.
  7999. * 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).
  8000. */
  8001. /**
  8002. * Sets the highlights Hue value.
  8003. * 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).
  8004. */
  8005. highlightsHue: number;
  8006. /**
  8007. * Gets the highlights Density value.
  8008. * 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.
  8009. * Values less than zero provide a filter of opposite hue.
  8010. */
  8011. /**
  8012. * Sets the highlights Density value.
  8013. * 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.
  8014. * Values less than zero provide a filter of opposite hue.
  8015. */
  8016. highlightsDensity: number;
  8017. /**
  8018. * Gets the highlights Saturation value.
  8019. * 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.
  8020. */
  8021. /**
  8022. * Sets the highlights Saturation value.
  8023. * 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.
  8024. */
  8025. highlightsSaturation: number;
  8026. /**
  8027. * Gets the highlights Exposure value.
  8028. * 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.
  8029. */
  8030. /**
  8031. * Sets the highlights Exposure value.
  8032. * 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.
  8033. */
  8034. highlightsExposure: number;
  8035. private _midtonesHue;
  8036. private _midtonesDensity;
  8037. private _midtonesSaturation;
  8038. private _midtonesExposure;
  8039. /**
  8040. * Gets the midtones Hue value.
  8041. * 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).
  8042. */
  8043. /**
  8044. * Sets the midtones Hue value.
  8045. * 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).
  8046. */
  8047. midtonesHue: number;
  8048. /**
  8049. * Gets the midtones Density value.
  8050. * 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.
  8051. * Values less than zero provide a filter of opposite hue.
  8052. */
  8053. /**
  8054. * Sets the midtones Density value.
  8055. * 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.
  8056. * Values less than zero provide a filter of opposite hue.
  8057. */
  8058. midtonesDensity: number;
  8059. /**
  8060. * Gets the midtones Saturation value.
  8061. * 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.
  8062. */
  8063. /**
  8064. * Sets the midtones Saturation value.
  8065. * 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.
  8066. */
  8067. midtonesSaturation: number;
  8068. /**
  8069. * Gets the midtones Exposure value.
  8070. * 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.
  8071. */
  8072. /**
  8073. * Sets the midtones Exposure value.
  8074. * 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.
  8075. */
  8076. midtonesExposure: number;
  8077. private _shadowsHue;
  8078. private _shadowsDensity;
  8079. private _shadowsSaturation;
  8080. private _shadowsExposure;
  8081. /**
  8082. * Gets the shadows Hue value.
  8083. * 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).
  8084. */
  8085. /**
  8086. * Sets the shadows Hue value.
  8087. * 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).
  8088. */
  8089. shadowsHue: number;
  8090. /**
  8091. * Gets the shadows Density value.
  8092. * 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.
  8093. * Values less than zero provide a filter of opposite hue.
  8094. */
  8095. /**
  8096. * Sets the shadows Density value.
  8097. * 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.
  8098. * Values less than zero provide a filter of opposite hue.
  8099. */
  8100. shadowsDensity: number;
  8101. /**
  8102. * Gets the shadows Saturation value.
  8103. * 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.
  8104. */
  8105. /**
  8106. * Sets the shadows Saturation value.
  8107. * 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.
  8108. */
  8109. shadowsSaturation: number;
  8110. /**
  8111. * Gets the shadows Exposure value.
  8112. * 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.
  8113. */
  8114. /**
  8115. * Sets the shadows Exposure value.
  8116. * 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.
  8117. */
  8118. shadowsExposure: number;
  8119. /**
  8120. * Returns the class name
  8121. * @returns The class name
  8122. */
  8123. getClassName(): string;
  8124. /**
  8125. * Binds the color curves to the shader.
  8126. * @param colorCurves The color curve to bind
  8127. * @param effect The effect to bind to
  8128. * @param positiveUniform The positive uniform shader parameter
  8129. * @param neutralUniform The neutral uniform shader parameter
  8130. * @param negativeUniform The negative uniform shader parameter
  8131. */
  8132. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8133. /**
  8134. * Prepare the list of uniforms associated with the ColorCurves effects.
  8135. * @param uniformsList The list of uniforms used in the effect
  8136. */
  8137. static PrepareUniforms(uniformsList: string[]): void;
  8138. /**
  8139. * Returns color grading data based on a hue, density, saturation and exposure value.
  8140. * @param filterHue The hue of the color filter.
  8141. * @param filterDensity The density of the color filter.
  8142. * @param saturation The saturation.
  8143. * @param exposure The exposure.
  8144. * @param result The result data container.
  8145. */
  8146. private getColorGradingDataToRef;
  8147. /**
  8148. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8149. * @param value The input slider value in range [-100,100].
  8150. * @returns Adjusted value.
  8151. */
  8152. private static applyColorGradingSliderNonlinear;
  8153. /**
  8154. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8155. * @param hue The hue (H) input.
  8156. * @param saturation The saturation (S) input.
  8157. * @param brightness The brightness (B) input.
  8158. * @result An RGBA color represented as Vector4.
  8159. */
  8160. private static fromHSBToRef;
  8161. /**
  8162. * Returns a value clamped between min and max
  8163. * @param value The value to clamp
  8164. * @param min The minimum of value
  8165. * @param max The maximum of value
  8166. * @returns The clamped value.
  8167. */
  8168. private static clamp;
  8169. /**
  8170. * Clones the current color curve instance.
  8171. * @return The cloned curves
  8172. */
  8173. clone(): ColorCurves;
  8174. /**
  8175. * Serializes the current color curve instance to a json representation.
  8176. * @return a JSON representation
  8177. */
  8178. serialize(): any;
  8179. /**
  8180. * Parses the color curve from a json representation.
  8181. * @param source the JSON source to parse
  8182. * @return The parsed curves
  8183. */
  8184. static Parse(source: any): ColorCurves;
  8185. }
  8186. }
  8187. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8188. import { Observable } from "babylonjs/Misc/observable";
  8189. import { Nullable } from "babylonjs/types";
  8190. import { Color4 } from "babylonjs/Maths/math.color";
  8191. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8192. import { Effect } from "babylonjs/Materials/effect";
  8193. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8194. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8195. /**
  8196. * Interface to follow in your material defines to integrate easily the
  8197. * Image proccessing functions.
  8198. * @hidden
  8199. */
  8200. export interface IImageProcessingConfigurationDefines {
  8201. IMAGEPROCESSING: boolean;
  8202. VIGNETTE: boolean;
  8203. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8204. VIGNETTEBLENDMODEOPAQUE: boolean;
  8205. TONEMAPPING: boolean;
  8206. TONEMAPPING_ACES: boolean;
  8207. CONTRAST: boolean;
  8208. EXPOSURE: boolean;
  8209. COLORCURVES: boolean;
  8210. COLORGRADING: boolean;
  8211. COLORGRADING3D: boolean;
  8212. SAMPLER3DGREENDEPTH: boolean;
  8213. SAMPLER3DBGRMAP: boolean;
  8214. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8215. }
  8216. /**
  8217. * @hidden
  8218. */
  8219. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8220. IMAGEPROCESSING: boolean;
  8221. VIGNETTE: boolean;
  8222. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8223. VIGNETTEBLENDMODEOPAQUE: boolean;
  8224. TONEMAPPING: boolean;
  8225. TONEMAPPING_ACES: boolean;
  8226. CONTRAST: boolean;
  8227. COLORCURVES: boolean;
  8228. COLORGRADING: boolean;
  8229. COLORGRADING3D: boolean;
  8230. SAMPLER3DGREENDEPTH: boolean;
  8231. SAMPLER3DBGRMAP: boolean;
  8232. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8233. EXPOSURE: boolean;
  8234. constructor();
  8235. }
  8236. /**
  8237. * This groups together the common properties used for image processing either in direct forward pass
  8238. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8239. * or not.
  8240. */
  8241. export class ImageProcessingConfiguration {
  8242. /**
  8243. * Default tone mapping applied in BabylonJS.
  8244. */
  8245. static readonly TONEMAPPING_STANDARD: number;
  8246. /**
  8247. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8248. * to other engines rendering to increase portability.
  8249. */
  8250. static readonly TONEMAPPING_ACES: number;
  8251. /**
  8252. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8253. */
  8254. colorCurves: Nullable<ColorCurves>;
  8255. private _colorCurvesEnabled;
  8256. /**
  8257. * Gets wether the color curves effect is enabled.
  8258. */
  8259. /**
  8260. * Sets wether the color curves effect is enabled.
  8261. */
  8262. colorCurvesEnabled: boolean;
  8263. private _colorGradingTexture;
  8264. /**
  8265. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8266. */
  8267. /**
  8268. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8269. */
  8270. colorGradingTexture: Nullable<BaseTexture>;
  8271. private _colorGradingEnabled;
  8272. /**
  8273. * Gets wether the color grading effect is enabled.
  8274. */
  8275. /**
  8276. * Sets wether the color grading effect is enabled.
  8277. */
  8278. colorGradingEnabled: boolean;
  8279. private _colorGradingWithGreenDepth;
  8280. /**
  8281. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8282. */
  8283. /**
  8284. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8285. */
  8286. colorGradingWithGreenDepth: boolean;
  8287. private _colorGradingBGR;
  8288. /**
  8289. * Gets wether the color grading texture contains BGR values.
  8290. */
  8291. /**
  8292. * Sets wether the color grading texture contains BGR values.
  8293. */
  8294. colorGradingBGR: boolean;
  8295. /** @hidden */
  8296. _exposure: number;
  8297. /**
  8298. * Gets the Exposure used in the effect.
  8299. */
  8300. /**
  8301. * Sets the Exposure used in the effect.
  8302. */
  8303. exposure: number;
  8304. private _toneMappingEnabled;
  8305. /**
  8306. * Gets wether the tone mapping effect is enabled.
  8307. */
  8308. /**
  8309. * Sets wether the tone mapping effect is enabled.
  8310. */
  8311. toneMappingEnabled: boolean;
  8312. private _toneMappingType;
  8313. /**
  8314. * Gets the type of tone mapping effect.
  8315. */
  8316. /**
  8317. * Sets the type of tone mapping effect used in BabylonJS.
  8318. */
  8319. toneMappingType: number;
  8320. protected _contrast: number;
  8321. /**
  8322. * Gets the contrast used in the effect.
  8323. */
  8324. /**
  8325. * Sets the contrast used in the effect.
  8326. */
  8327. contrast: number;
  8328. /**
  8329. * Vignette stretch size.
  8330. */
  8331. vignetteStretch: number;
  8332. /**
  8333. * Vignette centre X Offset.
  8334. */
  8335. vignetteCentreX: number;
  8336. /**
  8337. * Vignette centre Y Offset.
  8338. */
  8339. vignetteCentreY: number;
  8340. /**
  8341. * Vignette weight or intensity of the vignette effect.
  8342. */
  8343. vignetteWeight: number;
  8344. /**
  8345. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8346. * if vignetteEnabled is set to true.
  8347. */
  8348. vignetteColor: Color4;
  8349. /**
  8350. * Camera field of view used by the Vignette effect.
  8351. */
  8352. vignetteCameraFov: number;
  8353. private _vignetteBlendMode;
  8354. /**
  8355. * Gets the vignette blend mode allowing different kind of effect.
  8356. */
  8357. /**
  8358. * Sets the vignette blend mode allowing different kind of effect.
  8359. */
  8360. vignetteBlendMode: number;
  8361. private _vignetteEnabled;
  8362. /**
  8363. * Gets wether the vignette effect is enabled.
  8364. */
  8365. /**
  8366. * Sets wether the vignette effect is enabled.
  8367. */
  8368. vignetteEnabled: boolean;
  8369. private _applyByPostProcess;
  8370. /**
  8371. * Gets wether the image processing is applied through a post process or not.
  8372. */
  8373. /**
  8374. * Sets wether the image processing is applied through a post process or not.
  8375. */
  8376. applyByPostProcess: boolean;
  8377. private _isEnabled;
  8378. /**
  8379. * Gets wether the image processing is enabled or not.
  8380. */
  8381. /**
  8382. * Sets wether the image processing is enabled or not.
  8383. */
  8384. isEnabled: boolean;
  8385. /**
  8386. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8387. */
  8388. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8389. /**
  8390. * Method called each time the image processing information changes requires to recompile the effect.
  8391. */
  8392. protected _updateParameters(): void;
  8393. /**
  8394. * Gets the current class name.
  8395. * @return "ImageProcessingConfiguration"
  8396. */
  8397. getClassName(): string;
  8398. /**
  8399. * Prepare the list of uniforms associated with the Image Processing effects.
  8400. * @param uniforms The list of uniforms used in the effect
  8401. * @param defines the list of defines currently in use
  8402. */
  8403. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8404. /**
  8405. * Prepare the list of samplers associated with the Image Processing effects.
  8406. * @param samplersList The list of uniforms used in the effect
  8407. * @param defines the list of defines currently in use
  8408. */
  8409. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8410. /**
  8411. * Prepare the list of defines associated to the shader.
  8412. * @param defines the list of defines to complete
  8413. * @param forPostProcess Define if we are currently in post process mode or not
  8414. */
  8415. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8416. /**
  8417. * Returns true if all the image processing information are ready.
  8418. * @returns True if ready, otherwise, false
  8419. */
  8420. isReady(): boolean;
  8421. /**
  8422. * Binds the image processing to the shader.
  8423. * @param effect The effect to bind to
  8424. * @param overrideAspectRatio Override the aspect ratio of the effect
  8425. */
  8426. bind(effect: Effect, overrideAspectRatio?: number): void;
  8427. /**
  8428. * Clones the current image processing instance.
  8429. * @return The cloned image processing
  8430. */
  8431. clone(): ImageProcessingConfiguration;
  8432. /**
  8433. * Serializes the current image processing instance to a json representation.
  8434. * @return a JSON representation
  8435. */
  8436. serialize(): any;
  8437. /**
  8438. * Parses the image processing from a json representation.
  8439. * @param source the JSON source to parse
  8440. * @return The parsed image processing
  8441. */
  8442. static Parse(source: any): ImageProcessingConfiguration;
  8443. private static _VIGNETTEMODE_MULTIPLY;
  8444. private static _VIGNETTEMODE_OPAQUE;
  8445. /**
  8446. * Used to apply the vignette as a mix with the pixel color.
  8447. */
  8448. static readonly VIGNETTEMODE_MULTIPLY: number;
  8449. /**
  8450. * Used to apply the vignette as a replacement of the pixel color.
  8451. */
  8452. static readonly VIGNETTEMODE_OPAQUE: number;
  8453. }
  8454. }
  8455. declare module "babylonjs/Shaders/postprocess.vertex" {
  8456. /** @hidden */
  8457. export var postprocessVertexShader: {
  8458. name: string;
  8459. shader: string;
  8460. };
  8461. }
  8462. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8463. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8464. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8465. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8466. module "babylonjs/Engines/thinEngine" {
  8467. interface ThinEngine {
  8468. /**
  8469. * Creates a new render target texture
  8470. * @param size defines the size of the texture
  8471. * @param options defines the options used to create the texture
  8472. * @returns a new render target texture stored in an InternalTexture
  8473. */
  8474. createRenderTargetTexture(size: number | {
  8475. width: number;
  8476. height: number;
  8477. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8478. /**
  8479. * Creates a depth stencil texture.
  8480. * This is only available in WebGL 2 or with the depth texture extension available.
  8481. * @param size The size of face edge in the texture.
  8482. * @param options The options defining the texture.
  8483. * @returns The texture
  8484. */
  8485. createDepthStencilTexture(size: number | {
  8486. width: number;
  8487. height: number;
  8488. }, options: DepthTextureCreationOptions): InternalTexture;
  8489. /** @hidden */
  8490. _createDepthStencilTexture(size: number | {
  8491. width: number;
  8492. height: number;
  8493. }, options: DepthTextureCreationOptions): InternalTexture;
  8494. }
  8495. }
  8496. }
  8497. declare module "babylonjs/Maths/math.axis" {
  8498. import { Vector3 } from "babylonjs/Maths/math.vector";
  8499. /** Defines supported spaces */
  8500. export enum Space {
  8501. /** Local (object) space */
  8502. LOCAL = 0,
  8503. /** World space */
  8504. WORLD = 1,
  8505. /** Bone space */
  8506. BONE = 2
  8507. }
  8508. /** Defines the 3 main axes */
  8509. export class Axis {
  8510. /** X axis */
  8511. static X: Vector3;
  8512. /** Y axis */
  8513. static Y: Vector3;
  8514. /** Z axis */
  8515. static Z: Vector3;
  8516. }
  8517. }
  8518. declare module "babylonjs/Cameras/targetCamera" {
  8519. import { Nullable } from "babylonjs/types";
  8520. import { Camera } from "babylonjs/Cameras/camera";
  8521. import { Scene } from "babylonjs/scene";
  8522. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8523. /**
  8524. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8525. * This is the base of the follow, arc rotate cameras and Free camera
  8526. * @see http://doc.babylonjs.com/features/cameras
  8527. */
  8528. export class TargetCamera extends Camera {
  8529. private static _RigCamTransformMatrix;
  8530. private static _TargetTransformMatrix;
  8531. private static _TargetFocalPoint;
  8532. /**
  8533. * Define the current direction the camera is moving to
  8534. */
  8535. cameraDirection: Vector3;
  8536. /**
  8537. * Define the current rotation the camera is rotating to
  8538. */
  8539. cameraRotation: Vector2;
  8540. /**
  8541. * When set, the up vector of the camera will be updated by the rotation of the camera
  8542. */
  8543. updateUpVectorFromRotation: boolean;
  8544. private _tmpQuaternion;
  8545. /**
  8546. * Define the current rotation of the camera
  8547. */
  8548. rotation: Vector3;
  8549. /**
  8550. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8551. */
  8552. rotationQuaternion: Quaternion;
  8553. /**
  8554. * Define the current speed of the camera
  8555. */
  8556. speed: number;
  8557. /**
  8558. * Add constraint to the camera to prevent it to move freely in all directions and
  8559. * around all axis.
  8560. */
  8561. noRotationConstraint: boolean;
  8562. /**
  8563. * Define the current target of the camera as an object or a position.
  8564. */
  8565. lockedTarget: any;
  8566. /** @hidden */
  8567. _currentTarget: Vector3;
  8568. /** @hidden */
  8569. _initialFocalDistance: number;
  8570. /** @hidden */
  8571. _viewMatrix: Matrix;
  8572. /** @hidden */
  8573. _camMatrix: Matrix;
  8574. /** @hidden */
  8575. _cameraTransformMatrix: Matrix;
  8576. /** @hidden */
  8577. _cameraRotationMatrix: Matrix;
  8578. /** @hidden */
  8579. _referencePoint: Vector3;
  8580. /** @hidden */
  8581. _transformedReferencePoint: Vector3;
  8582. protected _globalCurrentTarget: Vector3;
  8583. protected _globalCurrentUpVector: Vector3;
  8584. /** @hidden */
  8585. _reset: () => void;
  8586. private _defaultUp;
  8587. /**
  8588. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8589. * This is the base of the follow, arc rotate cameras and Free camera
  8590. * @see http://doc.babylonjs.com/features/cameras
  8591. * @param name Defines the name of the camera in the scene
  8592. * @param position Defines the start position of the camera in the scene
  8593. * @param scene Defines the scene the camera belongs to
  8594. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8595. */
  8596. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8597. /**
  8598. * Gets the position in front of the camera at a given distance.
  8599. * @param distance The distance from the camera we want the position to be
  8600. * @returns the position
  8601. */
  8602. getFrontPosition(distance: number): Vector3;
  8603. /** @hidden */
  8604. _getLockedTargetPosition(): Nullable<Vector3>;
  8605. private _storedPosition;
  8606. private _storedRotation;
  8607. private _storedRotationQuaternion;
  8608. /**
  8609. * Store current camera state of the camera (fov, position, rotation, etc..)
  8610. * @returns the camera
  8611. */
  8612. storeState(): Camera;
  8613. /**
  8614. * Restored camera state. You must call storeState() first
  8615. * @returns whether it was successful or not
  8616. * @hidden
  8617. */
  8618. _restoreStateValues(): boolean;
  8619. /** @hidden */
  8620. _initCache(): void;
  8621. /** @hidden */
  8622. _updateCache(ignoreParentClass?: boolean): void;
  8623. /** @hidden */
  8624. _isSynchronizedViewMatrix(): boolean;
  8625. /** @hidden */
  8626. _computeLocalCameraSpeed(): number;
  8627. /**
  8628. * Defines the target the camera should look at.
  8629. * @param target Defines the new target as a Vector or a mesh
  8630. */
  8631. setTarget(target: Vector3): void;
  8632. /**
  8633. * Return the current target position of the camera. This value is expressed in local space.
  8634. * @returns the target position
  8635. */
  8636. getTarget(): Vector3;
  8637. /** @hidden */
  8638. _decideIfNeedsToMove(): boolean;
  8639. /** @hidden */
  8640. _updatePosition(): void;
  8641. /** @hidden */
  8642. _checkInputs(): void;
  8643. protected _updateCameraRotationMatrix(): void;
  8644. /**
  8645. * 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)
  8646. * @returns the current camera
  8647. */
  8648. private _rotateUpVectorWithCameraRotationMatrix;
  8649. private _cachedRotationZ;
  8650. private _cachedQuaternionRotationZ;
  8651. /** @hidden */
  8652. _getViewMatrix(): Matrix;
  8653. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8654. /**
  8655. * @hidden
  8656. */
  8657. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8658. /**
  8659. * @hidden
  8660. */
  8661. _updateRigCameras(): void;
  8662. private _getRigCamPositionAndTarget;
  8663. /**
  8664. * Gets the current object class name.
  8665. * @return the class name
  8666. */
  8667. getClassName(): string;
  8668. }
  8669. }
  8670. declare module "babylonjs/Events/keyboardEvents" {
  8671. /**
  8672. * Gather the list of keyboard event types as constants.
  8673. */
  8674. export class KeyboardEventTypes {
  8675. /**
  8676. * The keydown event is fired when a key becomes active (pressed).
  8677. */
  8678. static readonly KEYDOWN: number;
  8679. /**
  8680. * The keyup event is fired when a key has been released.
  8681. */
  8682. static readonly KEYUP: number;
  8683. }
  8684. /**
  8685. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8686. */
  8687. export class KeyboardInfo {
  8688. /**
  8689. * Defines the type of event (KeyboardEventTypes)
  8690. */
  8691. type: number;
  8692. /**
  8693. * Defines the related dom event
  8694. */
  8695. event: KeyboardEvent;
  8696. /**
  8697. * Instantiates a new keyboard info.
  8698. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8699. * @param type Defines the type of event (KeyboardEventTypes)
  8700. * @param event Defines the related dom event
  8701. */
  8702. constructor(
  8703. /**
  8704. * Defines the type of event (KeyboardEventTypes)
  8705. */
  8706. type: number,
  8707. /**
  8708. * Defines the related dom event
  8709. */
  8710. event: KeyboardEvent);
  8711. }
  8712. /**
  8713. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8714. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8715. */
  8716. export class KeyboardInfoPre extends KeyboardInfo {
  8717. /**
  8718. * Defines the type of event (KeyboardEventTypes)
  8719. */
  8720. type: number;
  8721. /**
  8722. * Defines the related dom event
  8723. */
  8724. event: KeyboardEvent;
  8725. /**
  8726. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8727. */
  8728. skipOnPointerObservable: boolean;
  8729. /**
  8730. * Instantiates a new keyboard pre info.
  8731. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8732. * @param type Defines the type of event (KeyboardEventTypes)
  8733. * @param event Defines the related dom event
  8734. */
  8735. constructor(
  8736. /**
  8737. * Defines the type of event (KeyboardEventTypes)
  8738. */
  8739. type: number,
  8740. /**
  8741. * Defines the related dom event
  8742. */
  8743. event: KeyboardEvent);
  8744. }
  8745. }
  8746. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8747. import { Nullable } from "babylonjs/types";
  8748. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8749. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8750. /**
  8751. * Manage the keyboard inputs to control the movement of a free camera.
  8752. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8753. */
  8754. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8755. /**
  8756. * Defines the camera the input is attached to.
  8757. */
  8758. camera: FreeCamera;
  8759. /**
  8760. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8761. */
  8762. keysUp: number[];
  8763. /**
  8764. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8765. */
  8766. keysDown: number[];
  8767. /**
  8768. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8769. */
  8770. keysLeft: number[];
  8771. /**
  8772. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8773. */
  8774. keysRight: number[];
  8775. private _keys;
  8776. private _onCanvasBlurObserver;
  8777. private _onKeyboardObserver;
  8778. private _engine;
  8779. private _scene;
  8780. /**
  8781. * Attach the input controls to a specific dom element to get the input from.
  8782. * @param element Defines the element the controls should be listened from
  8783. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8784. */
  8785. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8786. /**
  8787. * Detach the current controls from the specified dom element.
  8788. * @param element Defines the element to stop listening the inputs from
  8789. */
  8790. detachControl(element: Nullable<HTMLElement>): void;
  8791. /**
  8792. * Update the current camera state depending on the inputs that have been used this frame.
  8793. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8794. */
  8795. checkInputs(): void;
  8796. /**
  8797. * Gets the class name of the current intput.
  8798. * @returns the class name
  8799. */
  8800. getClassName(): string;
  8801. /** @hidden */
  8802. _onLostFocus(): void;
  8803. /**
  8804. * Get the friendly name associated with the input class.
  8805. * @returns the input friendly name
  8806. */
  8807. getSimpleName(): string;
  8808. }
  8809. }
  8810. declare module "babylonjs/Lights/shadowLight" {
  8811. import { Camera } from "babylonjs/Cameras/camera";
  8812. import { Scene } from "babylonjs/scene";
  8813. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8814. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8815. import { Light } from "babylonjs/Lights/light";
  8816. /**
  8817. * Interface describing all the common properties and methods a shadow light needs to implement.
  8818. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8819. * as well as binding the different shadow properties to the effects.
  8820. */
  8821. export interface IShadowLight extends Light {
  8822. /**
  8823. * The light id in the scene (used in scene.findLighById for instance)
  8824. */
  8825. id: string;
  8826. /**
  8827. * The position the shdow will be casted from.
  8828. */
  8829. position: Vector3;
  8830. /**
  8831. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8832. */
  8833. direction: Vector3;
  8834. /**
  8835. * The transformed position. Position of the light in world space taking parenting in account.
  8836. */
  8837. transformedPosition: Vector3;
  8838. /**
  8839. * The transformed direction. Direction of the light in world space taking parenting in account.
  8840. */
  8841. transformedDirection: Vector3;
  8842. /**
  8843. * The friendly name of the light in the scene.
  8844. */
  8845. name: string;
  8846. /**
  8847. * Defines the shadow projection clipping minimum z value.
  8848. */
  8849. shadowMinZ: number;
  8850. /**
  8851. * Defines the shadow projection clipping maximum z value.
  8852. */
  8853. shadowMaxZ: number;
  8854. /**
  8855. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8856. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8857. */
  8858. computeTransformedInformation(): boolean;
  8859. /**
  8860. * Gets the scene the light belongs to.
  8861. * @returns The scene
  8862. */
  8863. getScene(): Scene;
  8864. /**
  8865. * Callback defining a custom Projection Matrix Builder.
  8866. * This can be used to override the default projection matrix computation.
  8867. */
  8868. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8869. /**
  8870. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8871. * @param matrix The materix to updated with the projection information
  8872. * @param viewMatrix The transform matrix of the light
  8873. * @param renderList The list of mesh to render in the map
  8874. * @returns The current light
  8875. */
  8876. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8877. /**
  8878. * Gets the current depth scale used in ESM.
  8879. * @returns The scale
  8880. */
  8881. getDepthScale(): number;
  8882. /**
  8883. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8884. * @returns true if a cube texture needs to be use
  8885. */
  8886. needCube(): boolean;
  8887. /**
  8888. * Detects if the projection matrix requires to be recomputed this frame.
  8889. * @returns true if it requires to be recomputed otherwise, false.
  8890. */
  8891. needProjectionMatrixCompute(): boolean;
  8892. /**
  8893. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8894. */
  8895. forceProjectionMatrixCompute(): void;
  8896. /**
  8897. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8898. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8899. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8900. */
  8901. getShadowDirection(faceIndex?: number): Vector3;
  8902. /**
  8903. * Gets the minZ used for shadow according to both the scene and the light.
  8904. * @param activeCamera The camera we are returning the min for
  8905. * @returns the depth min z
  8906. */
  8907. getDepthMinZ(activeCamera: Camera): number;
  8908. /**
  8909. * Gets the maxZ used for shadow according to both the scene and the light.
  8910. * @param activeCamera The camera we are returning the max for
  8911. * @returns the depth max z
  8912. */
  8913. getDepthMaxZ(activeCamera: Camera): number;
  8914. }
  8915. /**
  8916. * Base implementation IShadowLight
  8917. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8918. */
  8919. export abstract class ShadowLight extends Light implements IShadowLight {
  8920. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8921. protected _position: Vector3;
  8922. protected _setPosition(value: Vector3): void;
  8923. /**
  8924. * Sets the position the shadow will be casted from. Also use as the light position for both
  8925. * point and spot lights.
  8926. */
  8927. /**
  8928. * Sets the position the shadow will be casted from. Also use as the light position for both
  8929. * point and spot lights.
  8930. */
  8931. position: Vector3;
  8932. protected _direction: Vector3;
  8933. protected _setDirection(value: Vector3): void;
  8934. /**
  8935. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8936. * Also use as the light direction on spot and directional lights.
  8937. */
  8938. /**
  8939. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8940. * Also use as the light direction on spot and directional lights.
  8941. */
  8942. direction: Vector3;
  8943. private _shadowMinZ;
  8944. /**
  8945. * Gets the shadow projection clipping minimum z value.
  8946. */
  8947. /**
  8948. * Sets the shadow projection clipping minimum z value.
  8949. */
  8950. shadowMinZ: number;
  8951. private _shadowMaxZ;
  8952. /**
  8953. * Sets the shadow projection clipping maximum z value.
  8954. */
  8955. /**
  8956. * Gets the shadow projection clipping maximum z value.
  8957. */
  8958. shadowMaxZ: number;
  8959. /**
  8960. * Callback defining a custom Projection Matrix Builder.
  8961. * This can be used to override the default projection matrix computation.
  8962. */
  8963. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8964. /**
  8965. * The transformed position. Position of the light in world space taking parenting in account.
  8966. */
  8967. transformedPosition: Vector3;
  8968. /**
  8969. * The transformed direction. Direction of the light in world space taking parenting in account.
  8970. */
  8971. transformedDirection: Vector3;
  8972. private _needProjectionMatrixCompute;
  8973. /**
  8974. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8975. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8976. */
  8977. computeTransformedInformation(): boolean;
  8978. /**
  8979. * Return the depth scale used for the shadow map.
  8980. * @returns the depth scale.
  8981. */
  8982. getDepthScale(): number;
  8983. /**
  8984. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8985. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8986. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8987. */
  8988. getShadowDirection(faceIndex?: number): Vector3;
  8989. /**
  8990. * Returns the ShadowLight absolute position in the World.
  8991. * @returns the position vector in world space
  8992. */
  8993. getAbsolutePosition(): Vector3;
  8994. /**
  8995. * Sets the ShadowLight direction toward the passed target.
  8996. * @param target The point to target in local space
  8997. * @returns the updated ShadowLight direction
  8998. */
  8999. setDirectionToTarget(target: Vector3): Vector3;
  9000. /**
  9001. * Returns the light rotation in euler definition.
  9002. * @returns the x y z rotation in local space.
  9003. */
  9004. getRotation(): Vector3;
  9005. /**
  9006. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9007. * @returns true if a cube texture needs to be use
  9008. */
  9009. needCube(): boolean;
  9010. /**
  9011. * Detects if the projection matrix requires to be recomputed this frame.
  9012. * @returns true if it requires to be recomputed otherwise, false.
  9013. */
  9014. needProjectionMatrixCompute(): boolean;
  9015. /**
  9016. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9017. */
  9018. forceProjectionMatrixCompute(): void;
  9019. /** @hidden */
  9020. _initCache(): void;
  9021. /** @hidden */
  9022. _isSynchronized(): boolean;
  9023. /**
  9024. * Computes the world matrix of the node
  9025. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9026. * @returns the world matrix
  9027. */
  9028. computeWorldMatrix(force?: boolean): Matrix;
  9029. /**
  9030. * Gets the minZ used for shadow according to both the scene and the light.
  9031. * @param activeCamera The camera we are returning the min for
  9032. * @returns the depth min z
  9033. */
  9034. getDepthMinZ(activeCamera: Camera): number;
  9035. /**
  9036. * Gets the maxZ used for shadow according to both the scene and the light.
  9037. * @param activeCamera The camera we are returning the max for
  9038. * @returns the depth max z
  9039. */
  9040. getDepthMaxZ(activeCamera: Camera): number;
  9041. /**
  9042. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9043. * @param matrix The materix to updated with the projection information
  9044. * @param viewMatrix The transform matrix of the light
  9045. * @param renderList The list of mesh to render in the map
  9046. * @returns The current light
  9047. */
  9048. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9049. }
  9050. }
  9051. declare module "babylonjs/Materials/effectFallbacks" {
  9052. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9053. import { Effect } from "babylonjs/Materials/effect";
  9054. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9055. /**
  9056. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9057. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9058. */
  9059. export class EffectFallbacks implements IEffectFallbacks {
  9060. private _defines;
  9061. private _currentRank;
  9062. private _maxRank;
  9063. private _mesh;
  9064. /**
  9065. * Removes the fallback from the bound mesh.
  9066. */
  9067. unBindMesh(): void;
  9068. /**
  9069. * Adds a fallback on the specified property.
  9070. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9071. * @param define The name of the define in the shader
  9072. */
  9073. addFallback(rank: number, define: string): void;
  9074. /**
  9075. * Sets the mesh to use CPU skinning when needing to fallback.
  9076. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9077. * @param mesh The mesh to use the fallbacks.
  9078. */
  9079. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9080. /**
  9081. * Checks to see if more fallbacks are still availible.
  9082. */
  9083. readonly hasMoreFallbacks: boolean;
  9084. /**
  9085. * Removes the defines that should be removed when falling back.
  9086. * @param currentDefines defines the current define statements for the shader.
  9087. * @param effect defines the current effect we try to compile
  9088. * @returns The resulting defines with defines of the current rank removed.
  9089. */
  9090. reduce(currentDefines: string, effect: Effect): string;
  9091. }
  9092. }
  9093. declare module "babylonjs/Materials/materialHelper" {
  9094. import { Nullable } from "babylonjs/types";
  9095. import { Scene } from "babylonjs/scene";
  9096. import { Engine } from "babylonjs/Engines/engine";
  9097. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9098. import { Light } from "babylonjs/Lights/light";
  9099. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9100. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9101. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9102. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9103. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9104. /**
  9105. * "Static Class" containing the most commonly used helper while dealing with material for
  9106. * rendering purpose.
  9107. *
  9108. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9109. *
  9110. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9111. */
  9112. export class MaterialHelper {
  9113. /**
  9114. * Bind the current view position to an effect.
  9115. * @param effect The effect to be bound
  9116. * @param scene The scene the eyes position is used from
  9117. */
  9118. static BindEyePosition(effect: Effect, scene: Scene): void;
  9119. /**
  9120. * Helps preparing the defines values about the UVs in used in the effect.
  9121. * UVs are shared as much as we can accross channels in the shaders.
  9122. * @param texture The texture we are preparing the UVs for
  9123. * @param defines The defines to update
  9124. * @param key The channel key "diffuse", "specular"... used in the shader
  9125. */
  9126. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9127. /**
  9128. * Binds a texture matrix value to its corrsponding uniform
  9129. * @param texture The texture to bind the matrix for
  9130. * @param uniformBuffer The uniform buffer receivin the data
  9131. * @param key The channel key "diffuse", "specular"... used in the shader
  9132. */
  9133. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9134. /**
  9135. * Gets the current status of the fog (should it be enabled?)
  9136. * @param mesh defines the mesh to evaluate for fog support
  9137. * @param scene defines the hosting scene
  9138. * @returns true if fog must be enabled
  9139. */
  9140. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9141. /**
  9142. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9143. * @param mesh defines the current mesh
  9144. * @param scene defines the current scene
  9145. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9146. * @param pointsCloud defines if point cloud rendering has to be turned on
  9147. * @param fogEnabled defines if fog has to be turned on
  9148. * @param alphaTest defines if alpha testing has to be turned on
  9149. * @param defines defines the current list of defines
  9150. */
  9151. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9152. /**
  9153. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9154. * @param scene defines the current scene
  9155. * @param engine defines the current engine
  9156. * @param defines specifies the list of active defines
  9157. * @param useInstances defines if instances have to be turned on
  9158. * @param useClipPlane defines if clip plane have to be turned on
  9159. */
  9160. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9161. /**
  9162. * Prepares the defines for bones
  9163. * @param mesh The mesh containing the geometry data we will draw
  9164. * @param defines The defines to update
  9165. */
  9166. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9167. /**
  9168. * Prepares the defines for morph targets
  9169. * @param mesh The mesh containing the geometry data we will draw
  9170. * @param defines The defines to update
  9171. */
  9172. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9173. /**
  9174. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9175. * @param mesh The mesh containing the geometry data we will draw
  9176. * @param defines The defines to update
  9177. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9178. * @param useBones Precise whether bones should be used or not (override mesh info)
  9179. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9180. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9181. * @returns false if defines are considered not dirty and have not been checked
  9182. */
  9183. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9184. /**
  9185. * Prepares the defines related to multiview
  9186. * @param scene The scene we are intending to draw
  9187. * @param defines The defines to update
  9188. */
  9189. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9190. /**
  9191. * Prepares the defines related to the light information passed in parameter
  9192. * @param scene The scene we are intending to draw
  9193. * @param mesh The mesh the effect is compiling for
  9194. * @param light The light the effect is compiling for
  9195. * @param lightIndex The index of the light
  9196. * @param defines The defines to update
  9197. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9198. * @param state Defines the current state regarding what is needed (normals, etc...)
  9199. */
  9200. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9201. needNormals: boolean;
  9202. needRebuild: boolean;
  9203. shadowEnabled: boolean;
  9204. specularEnabled: boolean;
  9205. lightmapMode: boolean;
  9206. }): void;
  9207. /**
  9208. * Prepares the defines related to the light information passed in parameter
  9209. * @param scene The scene we are intending to draw
  9210. * @param mesh The mesh the effect is compiling for
  9211. * @param defines The defines to update
  9212. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9213. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9214. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9215. * @returns true if normals will be required for the rest of the effect
  9216. */
  9217. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9218. /**
  9219. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9220. * @param lightIndex defines the light index
  9221. * @param uniformsList The uniform list
  9222. * @param samplersList The sampler list
  9223. * @param projectedLightTexture defines if projected texture must be used
  9224. * @param uniformBuffersList defines an optional list of uniform buffers
  9225. */
  9226. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9227. /**
  9228. * Prepares the uniforms and samplers list to be used in the effect
  9229. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9230. * @param samplersList The sampler list
  9231. * @param defines The defines helping in the list generation
  9232. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9233. */
  9234. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9235. /**
  9236. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9237. * @param defines The defines to update while falling back
  9238. * @param fallbacks The authorized effect fallbacks
  9239. * @param maxSimultaneousLights The maximum number of lights allowed
  9240. * @param rank the current rank of the Effect
  9241. * @returns The newly affected rank
  9242. */
  9243. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9244. private static _TmpMorphInfluencers;
  9245. /**
  9246. * Prepares the list of attributes required for morph targets according to the effect defines.
  9247. * @param attribs The current list of supported attribs
  9248. * @param mesh The mesh to prepare the morph targets attributes for
  9249. * @param influencers The number of influencers
  9250. */
  9251. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9252. /**
  9253. * Prepares the list of attributes required for morph targets according to the effect defines.
  9254. * @param attribs The current list of supported attribs
  9255. * @param mesh The mesh to prepare the morph targets attributes for
  9256. * @param defines The current Defines of the effect
  9257. */
  9258. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9259. /**
  9260. * Prepares the list of attributes required for bones according to the effect defines.
  9261. * @param attribs The current list of supported attribs
  9262. * @param mesh The mesh to prepare the bones attributes for
  9263. * @param defines The current Defines of the effect
  9264. * @param fallbacks The current efffect fallback strategy
  9265. */
  9266. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9267. /**
  9268. * Check and prepare the list of attributes required for instances according to the effect defines.
  9269. * @param attribs The current list of supported attribs
  9270. * @param defines The current MaterialDefines of the effect
  9271. */
  9272. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9273. /**
  9274. * Add the list of attributes required for instances to the attribs array.
  9275. * @param attribs The current list of supported attribs
  9276. */
  9277. static PushAttributesForInstances(attribs: string[]): void;
  9278. /**
  9279. * Binds the light information to the effect.
  9280. * @param light The light containing the generator
  9281. * @param effect The effect we are binding the data to
  9282. * @param lightIndex The light index in the effect used to render
  9283. */
  9284. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9285. /**
  9286. * Binds the lights information from the scene to the effect for the given mesh.
  9287. * @param light Light to bind
  9288. * @param lightIndex Light index
  9289. * @param scene The scene where the light belongs to
  9290. * @param effect The effect we are binding the data to
  9291. * @param useSpecular Defines if specular is supported
  9292. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9293. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9294. */
  9295. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9296. /**
  9297. * Binds the lights information from the scene to the effect for the given mesh.
  9298. * @param scene The scene the lights belongs to
  9299. * @param mesh The mesh we are binding the information to render
  9300. * @param effect The effect we are binding the data to
  9301. * @param defines The generated defines for the effect
  9302. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9303. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9304. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9305. */
  9306. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9307. private static _tempFogColor;
  9308. /**
  9309. * Binds the fog information from the scene to the effect for the given mesh.
  9310. * @param scene The scene the lights belongs to
  9311. * @param mesh The mesh we are binding the information to render
  9312. * @param effect The effect we are binding the data to
  9313. * @param linearSpace Defines if the fog effect is applied in linear space
  9314. */
  9315. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9316. /**
  9317. * Binds the bones information from the mesh to the effect.
  9318. * @param mesh The mesh we are binding the information to render
  9319. * @param effect The effect we are binding the data to
  9320. */
  9321. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9322. /**
  9323. * Binds the morph targets information from the mesh to the effect.
  9324. * @param abstractMesh The mesh we are binding the information to render
  9325. * @param effect The effect we are binding the data to
  9326. */
  9327. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9328. /**
  9329. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9330. * @param defines The generated defines used in the effect
  9331. * @param effect The effect we are binding the data to
  9332. * @param scene The scene we are willing to render with logarithmic scale for
  9333. */
  9334. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9335. /**
  9336. * Binds the clip plane information from the scene to the effect.
  9337. * @param scene The scene the clip plane information are extracted from
  9338. * @param effect The effect we are binding the data to
  9339. */
  9340. static BindClipPlane(effect: Effect, scene: Scene): void;
  9341. }
  9342. }
  9343. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9344. /** @hidden */
  9345. export var packingFunctions: {
  9346. name: string;
  9347. shader: string;
  9348. };
  9349. }
  9350. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9351. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9352. /** @hidden */
  9353. export var shadowMapPixelShader: {
  9354. name: string;
  9355. shader: string;
  9356. };
  9357. }
  9358. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9359. /** @hidden */
  9360. export var bonesDeclaration: {
  9361. name: string;
  9362. shader: string;
  9363. };
  9364. }
  9365. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9366. /** @hidden */
  9367. export var morphTargetsVertexGlobalDeclaration: {
  9368. name: string;
  9369. shader: string;
  9370. };
  9371. }
  9372. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9373. /** @hidden */
  9374. export var morphTargetsVertexDeclaration: {
  9375. name: string;
  9376. shader: string;
  9377. };
  9378. }
  9379. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9380. /** @hidden */
  9381. export var instancesDeclaration: {
  9382. name: string;
  9383. shader: string;
  9384. };
  9385. }
  9386. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9387. /** @hidden */
  9388. export var helperFunctions: {
  9389. name: string;
  9390. shader: string;
  9391. };
  9392. }
  9393. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9394. /** @hidden */
  9395. export var morphTargetsVertex: {
  9396. name: string;
  9397. shader: string;
  9398. };
  9399. }
  9400. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9401. /** @hidden */
  9402. export var instancesVertex: {
  9403. name: string;
  9404. shader: string;
  9405. };
  9406. }
  9407. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9408. /** @hidden */
  9409. export var bonesVertex: {
  9410. name: string;
  9411. shader: string;
  9412. };
  9413. }
  9414. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9415. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9416. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9417. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9418. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9419. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9420. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9421. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9422. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9423. /** @hidden */
  9424. export var shadowMapVertexShader: {
  9425. name: string;
  9426. shader: string;
  9427. };
  9428. }
  9429. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9430. /** @hidden */
  9431. export var depthBoxBlurPixelShader: {
  9432. name: string;
  9433. shader: string;
  9434. };
  9435. }
  9436. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9437. import { Nullable } from "babylonjs/types";
  9438. import { Scene } from "babylonjs/scene";
  9439. import { Matrix } from "babylonjs/Maths/math.vector";
  9440. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9441. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9442. import { Mesh } from "babylonjs/Meshes/mesh";
  9443. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9444. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9445. import { Effect } from "babylonjs/Materials/effect";
  9446. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9447. import "babylonjs/Shaders/shadowMap.fragment";
  9448. import "babylonjs/Shaders/shadowMap.vertex";
  9449. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9450. import { Observable } from "babylonjs/Misc/observable";
  9451. /**
  9452. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9453. */
  9454. export interface ICustomShaderOptions {
  9455. /**
  9456. * Gets or sets the custom shader name to use
  9457. */
  9458. shaderName: string;
  9459. /**
  9460. * The list of attribute names used in the shader
  9461. */
  9462. attributes?: string[];
  9463. /**
  9464. * The list of unifrom names used in the shader
  9465. */
  9466. uniforms?: string[];
  9467. /**
  9468. * The list of sampler names used in the shader
  9469. */
  9470. samplers?: string[];
  9471. /**
  9472. * The list of defines used in the shader
  9473. */
  9474. defines?: string[];
  9475. }
  9476. /**
  9477. * Interface to implement to create a shadow generator compatible with BJS.
  9478. */
  9479. export interface IShadowGenerator {
  9480. /**
  9481. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9482. * @returns The render target texture if present otherwise, null
  9483. */
  9484. getShadowMap(): Nullable<RenderTargetTexture>;
  9485. /**
  9486. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9487. * @returns The render target texture if the shadow map is present otherwise, null
  9488. */
  9489. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9490. /**
  9491. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9492. * @param subMesh The submesh we want to render in the shadow map
  9493. * @param useInstances Defines wether will draw in the map using instances
  9494. * @returns true if ready otherwise, false
  9495. */
  9496. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9497. /**
  9498. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9499. * @param defines Defines of the material we want to update
  9500. * @param lightIndex Index of the light in the enabled light list of the material
  9501. */
  9502. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9503. /**
  9504. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9505. * defined in the generator but impacting the effect).
  9506. * It implies the unifroms available on the materials are the standard BJS ones.
  9507. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9508. * @param effect The effect we are binfing the information for
  9509. */
  9510. bindShadowLight(lightIndex: string, effect: Effect): void;
  9511. /**
  9512. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9513. * (eq to shadow prjection matrix * light transform matrix)
  9514. * @returns The transform matrix used to create the shadow map
  9515. */
  9516. getTransformMatrix(): Matrix;
  9517. /**
  9518. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9519. * Cube and 2D textures for instance.
  9520. */
  9521. recreateShadowMap(): void;
  9522. /**
  9523. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9524. * @param onCompiled Callback triggered at the and of the effects compilation
  9525. * @param options Sets of optional options forcing the compilation with different modes
  9526. */
  9527. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9528. useInstances: boolean;
  9529. }>): void;
  9530. /**
  9531. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9532. * @param options Sets of optional options forcing the compilation with different modes
  9533. * @returns A promise that resolves when the compilation completes
  9534. */
  9535. forceCompilationAsync(options?: Partial<{
  9536. useInstances: boolean;
  9537. }>): Promise<void>;
  9538. /**
  9539. * Serializes the shadow generator setup to a json object.
  9540. * @returns The serialized JSON object
  9541. */
  9542. serialize(): any;
  9543. /**
  9544. * Disposes the Shadow map and related Textures and effects.
  9545. */
  9546. dispose(): void;
  9547. }
  9548. /**
  9549. * Default implementation IShadowGenerator.
  9550. * This is the main object responsible of generating shadows in the framework.
  9551. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9552. */
  9553. export class ShadowGenerator implements IShadowGenerator {
  9554. /**
  9555. * Shadow generator mode None: no filtering applied.
  9556. */
  9557. static readonly FILTER_NONE: number;
  9558. /**
  9559. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9560. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9561. */
  9562. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9563. /**
  9564. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9565. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9566. */
  9567. static readonly FILTER_POISSONSAMPLING: number;
  9568. /**
  9569. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9570. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9571. */
  9572. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9573. /**
  9574. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9575. * edge artifacts on steep falloff.
  9576. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9577. */
  9578. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9579. /**
  9580. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9581. * edge artifacts on steep falloff.
  9582. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9583. */
  9584. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9585. /**
  9586. * Shadow generator mode PCF: Percentage Closer Filtering
  9587. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9588. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9589. */
  9590. static readonly FILTER_PCF: number;
  9591. /**
  9592. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9593. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9594. * Contact Hardening
  9595. */
  9596. static readonly FILTER_PCSS: number;
  9597. /**
  9598. * Reserved for PCF and PCSS
  9599. * Highest Quality.
  9600. *
  9601. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9602. *
  9603. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9604. */
  9605. static readonly QUALITY_HIGH: number;
  9606. /**
  9607. * Reserved for PCF and PCSS
  9608. * Good tradeoff for quality/perf cross devices
  9609. *
  9610. * Execute PCF on a 3*3 kernel.
  9611. *
  9612. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9613. */
  9614. static readonly QUALITY_MEDIUM: number;
  9615. /**
  9616. * Reserved for PCF and PCSS
  9617. * The lowest quality but the fastest.
  9618. *
  9619. * Execute PCF on a 1*1 kernel.
  9620. *
  9621. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9622. */
  9623. static readonly QUALITY_LOW: number;
  9624. /** Gets or sets the custom shader name to use */
  9625. customShaderOptions: ICustomShaderOptions;
  9626. /**
  9627. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9628. */
  9629. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9630. /**
  9631. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9632. */
  9633. onAfterShadowMapRenderObservable: Observable<Effect>;
  9634. /**
  9635. * Observable triggered before a mesh is rendered in the shadow map.
  9636. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9637. */
  9638. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9639. /**
  9640. * Observable triggered after a mesh is rendered in the shadow map.
  9641. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9642. */
  9643. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9644. private _bias;
  9645. /**
  9646. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9647. */
  9648. /**
  9649. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9650. */
  9651. bias: number;
  9652. private _normalBias;
  9653. /**
  9654. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9655. */
  9656. /**
  9657. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9658. */
  9659. normalBias: number;
  9660. private _blurBoxOffset;
  9661. /**
  9662. * Gets the blur box offset: offset applied during the blur pass.
  9663. * Only useful if useKernelBlur = false
  9664. */
  9665. /**
  9666. * Sets the blur box offset: offset applied during the blur pass.
  9667. * Only useful if useKernelBlur = false
  9668. */
  9669. blurBoxOffset: number;
  9670. private _blurScale;
  9671. /**
  9672. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9673. * 2 means half of the size.
  9674. */
  9675. /**
  9676. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9677. * 2 means half of the size.
  9678. */
  9679. blurScale: number;
  9680. private _blurKernel;
  9681. /**
  9682. * Gets the blur kernel: kernel size of the blur pass.
  9683. * Only useful if useKernelBlur = true
  9684. */
  9685. /**
  9686. * Sets the blur kernel: kernel size of the blur pass.
  9687. * Only useful if useKernelBlur = true
  9688. */
  9689. blurKernel: number;
  9690. private _useKernelBlur;
  9691. /**
  9692. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9693. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9694. */
  9695. /**
  9696. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9697. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9698. */
  9699. useKernelBlur: boolean;
  9700. private _depthScale;
  9701. /**
  9702. * Gets the depth scale used in ESM mode.
  9703. */
  9704. /**
  9705. * Sets the depth scale used in ESM mode.
  9706. * This can override the scale stored on the light.
  9707. */
  9708. depthScale: number;
  9709. private _filter;
  9710. /**
  9711. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9712. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9713. */
  9714. /**
  9715. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9716. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9717. */
  9718. filter: number;
  9719. /**
  9720. * Gets if the current filter is set to Poisson Sampling.
  9721. */
  9722. /**
  9723. * Sets the current filter to Poisson Sampling.
  9724. */
  9725. usePoissonSampling: boolean;
  9726. /**
  9727. * Gets if the current filter is set to ESM.
  9728. */
  9729. /**
  9730. * Sets the current filter is to ESM.
  9731. */
  9732. useExponentialShadowMap: boolean;
  9733. /**
  9734. * Gets if the current filter is set to filtered ESM.
  9735. */
  9736. /**
  9737. * Gets if the current filter is set to filtered ESM.
  9738. */
  9739. useBlurExponentialShadowMap: boolean;
  9740. /**
  9741. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9742. * exponential to prevent steep falloff artifacts).
  9743. */
  9744. /**
  9745. * Sets the current filter to "close ESM" (using the inverse of the
  9746. * exponential to prevent steep falloff artifacts).
  9747. */
  9748. useCloseExponentialShadowMap: boolean;
  9749. /**
  9750. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9751. * exponential to prevent steep falloff artifacts).
  9752. */
  9753. /**
  9754. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9755. * exponential to prevent steep falloff artifacts).
  9756. */
  9757. useBlurCloseExponentialShadowMap: boolean;
  9758. /**
  9759. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9760. */
  9761. /**
  9762. * Sets the current filter to "PCF" (percentage closer filtering).
  9763. */
  9764. usePercentageCloserFiltering: boolean;
  9765. private _filteringQuality;
  9766. /**
  9767. * Gets the PCF or PCSS Quality.
  9768. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9769. */
  9770. /**
  9771. * Sets the PCF or PCSS Quality.
  9772. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9773. */
  9774. filteringQuality: number;
  9775. /**
  9776. * Gets if the current filter is set to "PCSS" (contact hardening).
  9777. */
  9778. /**
  9779. * Sets the current filter to "PCSS" (contact hardening).
  9780. */
  9781. useContactHardeningShadow: boolean;
  9782. private _contactHardeningLightSizeUVRatio;
  9783. /**
  9784. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9785. * Using a ratio helps keeping shape stability independently of the map size.
  9786. *
  9787. * It does not account for the light projection as it was having too much
  9788. * instability during the light setup or during light position changes.
  9789. *
  9790. * Only valid if useContactHardeningShadow is true.
  9791. */
  9792. /**
  9793. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9794. * Using a ratio helps keeping shape stability independently of the map size.
  9795. *
  9796. * It does not account for the light projection as it was having too much
  9797. * instability during the light setup or during light position changes.
  9798. *
  9799. * Only valid if useContactHardeningShadow is true.
  9800. */
  9801. contactHardeningLightSizeUVRatio: number;
  9802. private _darkness;
  9803. /** Gets or sets the actual darkness of a shadow */
  9804. darkness: number;
  9805. /**
  9806. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9807. * 0 means strongest and 1 would means no shadow.
  9808. * @returns the darkness.
  9809. */
  9810. getDarkness(): number;
  9811. /**
  9812. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9813. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9814. * @returns the shadow generator allowing fluent coding.
  9815. */
  9816. setDarkness(darkness: number): ShadowGenerator;
  9817. private _transparencyShadow;
  9818. /** Gets or sets the ability to have transparent shadow */
  9819. transparencyShadow: boolean;
  9820. /**
  9821. * Sets the ability to have transparent shadow (boolean).
  9822. * @param transparent True if transparent else False
  9823. * @returns the shadow generator allowing fluent coding
  9824. */
  9825. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9826. private _shadowMap;
  9827. private _shadowMap2;
  9828. /**
  9829. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9830. * @returns The render target texture if present otherwise, null
  9831. */
  9832. getShadowMap(): Nullable<RenderTargetTexture>;
  9833. /**
  9834. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9835. * @returns The render target texture if the shadow map is present otherwise, null
  9836. */
  9837. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9838. /**
  9839. * Gets the class name of that object
  9840. * @returns "ShadowGenerator"
  9841. */
  9842. getClassName(): string;
  9843. /**
  9844. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9845. * @param mesh Mesh to add
  9846. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9847. * @returns the Shadow Generator itself
  9848. */
  9849. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9850. /**
  9851. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9852. * @param mesh Mesh to remove
  9853. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9854. * @returns the Shadow Generator itself
  9855. */
  9856. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9857. /**
  9858. * Controls the extent to which the shadows fade out at the edge of the frustum
  9859. * Used only by directionals and spots
  9860. */
  9861. frustumEdgeFalloff: number;
  9862. private _light;
  9863. /**
  9864. * Returns the associated light object.
  9865. * @returns the light generating the shadow
  9866. */
  9867. getLight(): IShadowLight;
  9868. /**
  9869. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9870. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9871. * It might on the other hand introduce peter panning.
  9872. */
  9873. forceBackFacesOnly: boolean;
  9874. private _scene;
  9875. private _lightDirection;
  9876. private _effect;
  9877. private _viewMatrix;
  9878. private _projectionMatrix;
  9879. private _transformMatrix;
  9880. private _cachedPosition;
  9881. private _cachedDirection;
  9882. private _cachedDefines;
  9883. private _currentRenderID;
  9884. private _boxBlurPostprocess;
  9885. private _kernelBlurXPostprocess;
  9886. private _kernelBlurYPostprocess;
  9887. private _blurPostProcesses;
  9888. private _mapSize;
  9889. private _currentFaceIndex;
  9890. private _currentFaceIndexCache;
  9891. private _textureType;
  9892. private _defaultTextureMatrix;
  9893. private _storedUniqueId;
  9894. /** @hidden */
  9895. static _SceneComponentInitialization: (scene: Scene) => void;
  9896. /**
  9897. * Creates a ShadowGenerator object.
  9898. * A ShadowGenerator is the required tool to use the shadows.
  9899. * Each light casting shadows needs to use its own ShadowGenerator.
  9900. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9901. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9902. * @param light The light object generating the shadows.
  9903. * @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.
  9904. */
  9905. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9906. private _initializeGenerator;
  9907. private _initializeShadowMap;
  9908. private _initializeBlurRTTAndPostProcesses;
  9909. private _renderForShadowMap;
  9910. private _renderSubMeshForShadowMap;
  9911. private _applyFilterValues;
  9912. /**
  9913. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9914. * @param onCompiled Callback triggered at the and of the effects compilation
  9915. * @param options Sets of optional options forcing the compilation with different modes
  9916. */
  9917. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9918. useInstances: boolean;
  9919. }>): void;
  9920. /**
  9921. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9922. * @param options Sets of optional options forcing the compilation with different modes
  9923. * @returns A promise that resolves when the compilation completes
  9924. */
  9925. forceCompilationAsync(options?: Partial<{
  9926. useInstances: boolean;
  9927. }>): Promise<void>;
  9928. /**
  9929. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9930. * @param subMesh The submesh we want to render in the shadow map
  9931. * @param useInstances Defines wether will draw in the map using instances
  9932. * @returns true if ready otherwise, false
  9933. */
  9934. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9935. /**
  9936. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9937. * @param defines Defines of the material we want to update
  9938. * @param lightIndex Index of the light in the enabled light list of the material
  9939. */
  9940. prepareDefines(defines: any, lightIndex: number): void;
  9941. /**
  9942. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9943. * defined in the generator but impacting the effect).
  9944. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9945. * @param effect The effect we are binfing the information for
  9946. */
  9947. bindShadowLight(lightIndex: string, effect: Effect): void;
  9948. /**
  9949. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9950. * (eq to shadow prjection matrix * light transform matrix)
  9951. * @returns The transform matrix used to create the shadow map
  9952. */
  9953. getTransformMatrix(): Matrix;
  9954. /**
  9955. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9956. * Cube and 2D textures for instance.
  9957. */
  9958. recreateShadowMap(): void;
  9959. private _disposeBlurPostProcesses;
  9960. private _disposeRTTandPostProcesses;
  9961. /**
  9962. * Disposes the ShadowGenerator.
  9963. * Returns nothing.
  9964. */
  9965. dispose(): void;
  9966. /**
  9967. * Serializes the shadow generator setup to a json object.
  9968. * @returns The serialized JSON object
  9969. */
  9970. serialize(): any;
  9971. /**
  9972. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9973. * @param parsedShadowGenerator The JSON object to parse
  9974. * @param scene The scene to create the shadow map for
  9975. * @returns The parsed shadow generator
  9976. */
  9977. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9978. }
  9979. }
  9980. declare module "babylonjs/Lights/light" {
  9981. import { Nullable } from "babylonjs/types";
  9982. import { Scene } from "babylonjs/scene";
  9983. import { Vector3 } from "babylonjs/Maths/math.vector";
  9984. import { Color3 } from "babylonjs/Maths/math.color";
  9985. import { Node } from "babylonjs/node";
  9986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9987. import { Effect } from "babylonjs/Materials/effect";
  9988. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9989. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9990. /**
  9991. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9992. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9993. * 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.
  9994. */
  9995. export abstract class Light extends Node {
  9996. /**
  9997. * Falloff Default: light is falling off following the material specification:
  9998. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9999. */
  10000. static readonly FALLOFF_DEFAULT: number;
  10001. /**
  10002. * Falloff Physical: light is falling off following the inverse squared distance law.
  10003. */
  10004. static readonly FALLOFF_PHYSICAL: number;
  10005. /**
  10006. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10007. * to enhance interoperability with other engines.
  10008. */
  10009. static readonly FALLOFF_GLTF: number;
  10010. /**
  10011. * Falloff Standard: light is falling off like in the standard material
  10012. * to enhance interoperability with other materials.
  10013. */
  10014. static readonly FALLOFF_STANDARD: number;
  10015. /**
  10016. * If every light affecting the material is in this lightmapMode,
  10017. * material.lightmapTexture adds or multiplies
  10018. * (depends on material.useLightmapAsShadowmap)
  10019. * after every other light calculations.
  10020. */
  10021. static readonly LIGHTMAP_DEFAULT: number;
  10022. /**
  10023. * material.lightmapTexture as only diffuse lighting from this light
  10024. * adds only specular lighting from this light
  10025. * adds dynamic shadows
  10026. */
  10027. static readonly LIGHTMAP_SPECULAR: number;
  10028. /**
  10029. * material.lightmapTexture as only lighting
  10030. * no light calculation from this light
  10031. * only adds dynamic shadows from this light
  10032. */
  10033. static readonly LIGHTMAP_SHADOWSONLY: number;
  10034. /**
  10035. * Each light type uses the default quantity according to its type:
  10036. * point/spot lights use luminous intensity
  10037. * directional lights use illuminance
  10038. */
  10039. static readonly INTENSITYMODE_AUTOMATIC: number;
  10040. /**
  10041. * lumen (lm)
  10042. */
  10043. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10044. /**
  10045. * candela (lm/sr)
  10046. */
  10047. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10048. /**
  10049. * lux (lm/m^2)
  10050. */
  10051. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10052. /**
  10053. * nit (cd/m^2)
  10054. */
  10055. static readonly INTENSITYMODE_LUMINANCE: number;
  10056. /**
  10057. * Light type const id of the point light.
  10058. */
  10059. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10060. /**
  10061. * Light type const id of the directional light.
  10062. */
  10063. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10064. /**
  10065. * Light type const id of the spot light.
  10066. */
  10067. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10068. /**
  10069. * Light type const id of the hemispheric light.
  10070. */
  10071. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10072. /**
  10073. * Diffuse gives the basic color to an object.
  10074. */
  10075. diffuse: Color3;
  10076. /**
  10077. * Specular produces a highlight color on an object.
  10078. * Note: This is note affecting PBR materials.
  10079. */
  10080. specular: Color3;
  10081. /**
  10082. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10083. * falling off base on range or angle.
  10084. * This can be set to any values in Light.FALLOFF_x.
  10085. *
  10086. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10087. * other types of materials.
  10088. */
  10089. falloffType: number;
  10090. /**
  10091. * Strength of the light.
  10092. * Note: By default it is define in the framework own unit.
  10093. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10094. */
  10095. intensity: number;
  10096. private _range;
  10097. protected _inverseSquaredRange: number;
  10098. /**
  10099. * Defines how far from the source the light is impacting in scene units.
  10100. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10101. */
  10102. /**
  10103. * Defines how far from the source the light is impacting in scene units.
  10104. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10105. */
  10106. range: number;
  10107. /**
  10108. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10109. * of light.
  10110. */
  10111. private _photometricScale;
  10112. private _intensityMode;
  10113. /**
  10114. * Gets the photometric scale used to interpret the intensity.
  10115. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10116. */
  10117. /**
  10118. * Sets the photometric scale used to interpret the intensity.
  10119. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10120. */
  10121. intensityMode: number;
  10122. private _radius;
  10123. /**
  10124. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10125. */
  10126. /**
  10127. * sets the light radius used by PBR Materials to simulate soft area lights.
  10128. */
  10129. radius: number;
  10130. private _renderPriority;
  10131. /**
  10132. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10133. * exceeding the number allowed of the materials.
  10134. */
  10135. renderPriority: number;
  10136. private _shadowEnabled;
  10137. /**
  10138. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10139. * the current shadow generator.
  10140. */
  10141. /**
  10142. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10143. * the current shadow generator.
  10144. */
  10145. shadowEnabled: boolean;
  10146. private _includedOnlyMeshes;
  10147. /**
  10148. * Gets the only meshes impacted by this light.
  10149. */
  10150. /**
  10151. * Sets the only meshes impacted by this light.
  10152. */
  10153. includedOnlyMeshes: AbstractMesh[];
  10154. private _excludedMeshes;
  10155. /**
  10156. * Gets the meshes not impacted by this light.
  10157. */
  10158. /**
  10159. * Sets the meshes not impacted by this light.
  10160. */
  10161. excludedMeshes: AbstractMesh[];
  10162. private _excludeWithLayerMask;
  10163. /**
  10164. * Gets the layer id use to find what meshes are not impacted by the light.
  10165. * Inactive if 0
  10166. */
  10167. /**
  10168. * Sets the layer id use to find what meshes are not impacted by the light.
  10169. * Inactive if 0
  10170. */
  10171. excludeWithLayerMask: number;
  10172. private _includeOnlyWithLayerMask;
  10173. /**
  10174. * Gets the layer id use to find what meshes are impacted by the light.
  10175. * Inactive if 0
  10176. */
  10177. /**
  10178. * Sets the layer id use to find what meshes are impacted by the light.
  10179. * Inactive if 0
  10180. */
  10181. includeOnlyWithLayerMask: number;
  10182. private _lightmapMode;
  10183. /**
  10184. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10185. */
  10186. /**
  10187. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10188. */
  10189. lightmapMode: number;
  10190. /**
  10191. * Shadow generator associted to the light.
  10192. * @hidden Internal use only.
  10193. */
  10194. _shadowGenerator: Nullable<IShadowGenerator>;
  10195. /**
  10196. * @hidden Internal use only.
  10197. */
  10198. _excludedMeshesIds: string[];
  10199. /**
  10200. * @hidden Internal use only.
  10201. */
  10202. _includedOnlyMeshesIds: string[];
  10203. /**
  10204. * The current light unifom buffer.
  10205. * @hidden Internal use only.
  10206. */
  10207. _uniformBuffer: UniformBuffer;
  10208. /** @hidden */
  10209. _renderId: number;
  10210. /**
  10211. * Creates a Light object in the scene.
  10212. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10213. * @param name The firendly name of the light
  10214. * @param scene The scene the light belongs too
  10215. */
  10216. constructor(name: string, scene: Scene);
  10217. protected abstract _buildUniformLayout(): void;
  10218. /**
  10219. * Sets the passed Effect "effect" with the Light information.
  10220. * @param effect The effect to update
  10221. * @param lightIndex The index of the light in the effect to update
  10222. * @returns The light
  10223. */
  10224. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10225. /**
  10226. * Sets the passed Effect "effect" with the Light textures.
  10227. * @param effect The effect to update
  10228. * @param lightIndex The index of the light in the effect to update
  10229. * @returns The light
  10230. */
  10231. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  10232. /**
  10233. * Binds the lights information from the scene to the effect for the given mesh.
  10234. * @param lightIndex Light index
  10235. * @param scene The scene where the light belongs to
  10236. * @param effect The effect we are binding the data to
  10237. * @param useSpecular Defines if specular is supported
  10238. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  10239. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  10240. */
  10241. bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  10242. /**
  10243. * Sets the passed Effect "effect" with the Light information.
  10244. * @param effect The effect to update
  10245. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10246. * @returns The light
  10247. */
  10248. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10249. /**
  10250. * Returns the string "Light".
  10251. * @returns the class name
  10252. */
  10253. getClassName(): string;
  10254. /** @hidden */
  10255. readonly _isLight: boolean;
  10256. /**
  10257. * Converts the light information to a readable string for debug purpose.
  10258. * @param fullDetails Supports for multiple levels of logging within scene loading
  10259. * @returns the human readable light info
  10260. */
  10261. toString(fullDetails?: boolean): string;
  10262. /** @hidden */
  10263. protected _syncParentEnabledState(): void;
  10264. /**
  10265. * Set the enabled state of this node.
  10266. * @param value - the new enabled state
  10267. */
  10268. setEnabled(value: boolean): void;
  10269. /**
  10270. * Returns the Light associated shadow generator if any.
  10271. * @return the associated shadow generator.
  10272. */
  10273. getShadowGenerator(): Nullable<IShadowGenerator>;
  10274. /**
  10275. * Returns a Vector3, the absolute light position in the World.
  10276. * @returns the world space position of the light
  10277. */
  10278. getAbsolutePosition(): Vector3;
  10279. /**
  10280. * Specifies if the light will affect the passed mesh.
  10281. * @param mesh The mesh to test against the light
  10282. * @return true the mesh is affected otherwise, false.
  10283. */
  10284. canAffectMesh(mesh: AbstractMesh): boolean;
  10285. /**
  10286. * Sort function to order lights for rendering.
  10287. * @param a First Light object to compare to second.
  10288. * @param b Second Light object to compare first.
  10289. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10290. */
  10291. static CompareLightsPriority(a: Light, b: Light): number;
  10292. /**
  10293. * Releases resources associated with this node.
  10294. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10295. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10296. */
  10297. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10298. /**
  10299. * Returns the light type ID (integer).
  10300. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10301. */
  10302. getTypeID(): number;
  10303. /**
  10304. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10305. * @returns the scaled intensity in intensity mode unit
  10306. */
  10307. getScaledIntensity(): number;
  10308. /**
  10309. * Returns a new Light object, named "name", from the current one.
  10310. * @param name The name of the cloned light
  10311. * @returns the new created light
  10312. */
  10313. clone(name: string): Nullable<Light>;
  10314. /**
  10315. * Serializes the current light into a Serialization object.
  10316. * @returns the serialized object.
  10317. */
  10318. serialize(): any;
  10319. /**
  10320. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10321. * This new light is named "name" and added to the passed scene.
  10322. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10323. * @param name The friendly name of the light
  10324. * @param scene The scene the new light will belong to
  10325. * @returns the constructor function
  10326. */
  10327. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10328. /**
  10329. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10330. * @param parsedLight The JSON representation of the light
  10331. * @param scene The scene to create the parsed light in
  10332. * @returns the created light after parsing
  10333. */
  10334. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10335. private _hookArrayForExcluded;
  10336. private _hookArrayForIncludedOnly;
  10337. private _resyncMeshes;
  10338. /**
  10339. * Forces the meshes to update their light related information in their rendering used effects
  10340. * @hidden Internal Use Only
  10341. */
  10342. _markMeshesAsLightDirty(): void;
  10343. /**
  10344. * Recomputes the cached photometric scale if needed.
  10345. */
  10346. private _computePhotometricScale;
  10347. /**
  10348. * Returns the Photometric Scale according to the light type and intensity mode.
  10349. */
  10350. private _getPhotometricScale;
  10351. /**
  10352. * Reorder the light in the scene according to their defined priority.
  10353. * @hidden Internal Use Only
  10354. */
  10355. _reorderLightsInScene(): void;
  10356. /**
  10357. * Prepares the list of defines specific to the light type.
  10358. * @param defines the list of defines
  10359. * @param lightIndex defines the index of the light for the effect
  10360. */
  10361. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10362. }
  10363. }
  10364. declare module "babylonjs/Actions/action" {
  10365. import { Observable } from "babylonjs/Misc/observable";
  10366. import { Condition } from "babylonjs/Actions/condition";
  10367. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10368. import { ActionManager } from "babylonjs/Actions/actionManager";
  10369. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10370. /**
  10371. * Interface used to define Action
  10372. */
  10373. export interface IAction {
  10374. /**
  10375. * Trigger for the action
  10376. */
  10377. trigger: number;
  10378. /** Options of the trigger */
  10379. triggerOptions: any;
  10380. /**
  10381. * Gets the trigger parameters
  10382. * @returns the trigger parameters
  10383. */
  10384. getTriggerParameter(): any;
  10385. /**
  10386. * Internal only - executes current action event
  10387. * @hidden
  10388. */
  10389. _executeCurrent(evt?: ActionEvent): void;
  10390. /**
  10391. * Serialize placeholder for child classes
  10392. * @param parent of child
  10393. * @returns the serialized object
  10394. */
  10395. serialize(parent: any): any;
  10396. /**
  10397. * Internal only
  10398. * @hidden
  10399. */
  10400. _prepare(): void;
  10401. /**
  10402. * Internal only - manager for action
  10403. * @hidden
  10404. */
  10405. _actionManager: AbstractActionManager;
  10406. /**
  10407. * Adds action to chain of actions, may be a DoNothingAction
  10408. * @param action defines the next action to execute
  10409. * @returns The action passed in
  10410. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10411. */
  10412. then(action: IAction): IAction;
  10413. }
  10414. /**
  10415. * The action to be carried out following a trigger
  10416. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10417. */
  10418. export class Action implements IAction {
  10419. /** the trigger, with or without parameters, for the action */
  10420. triggerOptions: any;
  10421. /**
  10422. * Trigger for the action
  10423. */
  10424. trigger: number;
  10425. /**
  10426. * Internal only - manager for action
  10427. * @hidden
  10428. */
  10429. _actionManager: ActionManager;
  10430. private _nextActiveAction;
  10431. private _child;
  10432. private _condition?;
  10433. private _triggerParameter;
  10434. /**
  10435. * An event triggered prior to action being executed.
  10436. */
  10437. onBeforeExecuteObservable: Observable<Action>;
  10438. /**
  10439. * Creates a new Action
  10440. * @param triggerOptions the trigger, with or without parameters, for the action
  10441. * @param condition an optional determinant of action
  10442. */
  10443. constructor(
  10444. /** the trigger, with or without parameters, for the action */
  10445. triggerOptions: any, condition?: Condition);
  10446. /**
  10447. * Internal only
  10448. * @hidden
  10449. */
  10450. _prepare(): void;
  10451. /**
  10452. * Gets the trigger parameters
  10453. * @returns the trigger parameters
  10454. */
  10455. getTriggerParameter(): any;
  10456. /**
  10457. * Internal only - executes current action event
  10458. * @hidden
  10459. */
  10460. _executeCurrent(evt?: ActionEvent): void;
  10461. /**
  10462. * Execute placeholder for child classes
  10463. * @param evt optional action event
  10464. */
  10465. execute(evt?: ActionEvent): void;
  10466. /**
  10467. * Skips to next active action
  10468. */
  10469. skipToNextActiveAction(): void;
  10470. /**
  10471. * Adds action to chain of actions, may be a DoNothingAction
  10472. * @param action defines the next action to execute
  10473. * @returns The action passed in
  10474. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10475. */
  10476. then(action: Action): Action;
  10477. /**
  10478. * Internal only
  10479. * @hidden
  10480. */
  10481. _getProperty(propertyPath: string): string;
  10482. /**
  10483. * Internal only
  10484. * @hidden
  10485. */
  10486. _getEffectiveTarget(target: any, propertyPath: string): any;
  10487. /**
  10488. * Serialize placeholder for child classes
  10489. * @param parent of child
  10490. * @returns the serialized object
  10491. */
  10492. serialize(parent: any): any;
  10493. /**
  10494. * Internal only called by serialize
  10495. * @hidden
  10496. */
  10497. protected _serialize(serializedAction: any, parent?: any): any;
  10498. /**
  10499. * Internal only
  10500. * @hidden
  10501. */
  10502. static _SerializeValueAsString: (value: any) => string;
  10503. /**
  10504. * Internal only
  10505. * @hidden
  10506. */
  10507. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10508. name: string;
  10509. targetType: string;
  10510. value: string;
  10511. };
  10512. }
  10513. }
  10514. declare module "babylonjs/Actions/condition" {
  10515. import { ActionManager } from "babylonjs/Actions/actionManager";
  10516. /**
  10517. * A Condition applied to an Action
  10518. */
  10519. export class Condition {
  10520. /**
  10521. * Internal only - manager for action
  10522. * @hidden
  10523. */
  10524. _actionManager: ActionManager;
  10525. /**
  10526. * Internal only
  10527. * @hidden
  10528. */
  10529. _evaluationId: number;
  10530. /**
  10531. * Internal only
  10532. * @hidden
  10533. */
  10534. _currentResult: boolean;
  10535. /**
  10536. * Creates a new Condition
  10537. * @param actionManager the manager of the action the condition is applied to
  10538. */
  10539. constructor(actionManager: ActionManager);
  10540. /**
  10541. * Check if the current condition is valid
  10542. * @returns a boolean
  10543. */
  10544. isValid(): boolean;
  10545. /**
  10546. * Internal only
  10547. * @hidden
  10548. */
  10549. _getProperty(propertyPath: string): string;
  10550. /**
  10551. * Internal only
  10552. * @hidden
  10553. */
  10554. _getEffectiveTarget(target: any, propertyPath: string): any;
  10555. /**
  10556. * Serialize placeholder for child classes
  10557. * @returns the serialized object
  10558. */
  10559. serialize(): any;
  10560. /**
  10561. * Internal only
  10562. * @hidden
  10563. */
  10564. protected _serialize(serializedCondition: any): any;
  10565. }
  10566. /**
  10567. * Defines specific conditional operators as extensions of Condition
  10568. */
  10569. export class ValueCondition extends Condition {
  10570. /** path to specify the property of the target the conditional operator uses */
  10571. propertyPath: string;
  10572. /** the value compared by the conditional operator against the current value of the property */
  10573. value: any;
  10574. /** the conditional operator, default ValueCondition.IsEqual */
  10575. operator: number;
  10576. /**
  10577. * Internal only
  10578. * @hidden
  10579. */
  10580. private static _IsEqual;
  10581. /**
  10582. * Internal only
  10583. * @hidden
  10584. */
  10585. private static _IsDifferent;
  10586. /**
  10587. * Internal only
  10588. * @hidden
  10589. */
  10590. private static _IsGreater;
  10591. /**
  10592. * Internal only
  10593. * @hidden
  10594. */
  10595. private static _IsLesser;
  10596. /**
  10597. * returns the number for IsEqual
  10598. */
  10599. static readonly IsEqual: number;
  10600. /**
  10601. * Returns the number for IsDifferent
  10602. */
  10603. static readonly IsDifferent: number;
  10604. /**
  10605. * Returns the number for IsGreater
  10606. */
  10607. static readonly IsGreater: number;
  10608. /**
  10609. * Returns the number for IsLesser
  10610. */
  10611. static readonly IsLesser: number;
  10612. /**
  10613. * Internal only The action manager for the condition
  10614. * @hidden
  10615. */
  10616. _actionManager: ActionManager;
  10617. /**
  10618. * Internal only
  10619. * @hidden
  10620. */
  10621. private _target;
  10622. /**
  10623. * Internal only
  10624. * @hidden
  10625. */
  10626. private _effectiveTarget;
  10627. /**
  10628. * Internal only
  10629. * @hidden
  10630. */
  10631. private _property;
  10632. /**
  10633. * Creates a new ValueCondition
  10634. * @param actionManager manager for the action the condition applies to
  10635. * @param target for the action
  10636. * @param propertyPath path to specify the property of the target the conditional operator uses
  10637. * @param value the value compared by the conditional operator against the current value of the property
  10638. * @param operator the conditional operator, default ValueCondition.IsEqual
  10639. */
  10640. constructor(actionManager: ActionManager, target: any,
  10641. /** path to specify the property of the target the conditional operator uses */
  10642. propertyPath: string,
  10643. /** the value compared by the conditional operator against the current value of the property */
  10644. value: any,
  10645. /** the conditional operator, default ValueCondition.IsEqual */
  10646. operator?: number);
  10647. /**
  10648. * Compares the given value with the property value for the specified conditional operator
  10649. * @returns the result of the comparison
  10650. */
  10651. isValid(): boolean;
  10652. /**
  10653. * Serialize the ValueCondition into a JSON compatible object
  10654. * @returns serialization object
  10655. */
  10656. serialize(): any;
  10657. /**
  10658. * Gets the name of the conditional operator for the ValueCondition
  10659. * @param operator the conditional operator
  10660. * @returns the name
  10661. */
  10662. static GetOperatorName(operator: number): string;
  10663. }
  10664. /**
  10665. * Defines a predicate condition as an extension of Condition
  10666. */
  10667. export class PredicateCondition extends Condition {
  10668. /** defines the predicate function used to validate the condition */
  10669. predicate: () => boolean;
  10670. /**
  10671. * Internal only - manager for action
  10672. * @hidden
  10673. */
  10674. _actionManager: ActionManager;
  10675. /**
  10676. * Creates a new PredicateCondition
  10677. * @param actionManager manager for the action the condition applies to
  10678. * @param predicate defines the predicate function used to validate the condition
  10679. */
  10680. constructor(actionManager: ActionManager,
  10681. /** defines the predicate function used to validate the condition */
  10682. predicate: () => boolean);
  10683. /**
  10684. * @returns the validity of the predicate condition
  10685. */
  10686. isValid(): boolean;
  10687. }
  10688. /**
  10689. * Defines a state condition as an extension of Condition
  10690. */
  10691. export class StateCondition extends Condition {
  10692. /** Value to compare with target state */
  10693. value: string;
  10694. /**
  10695. * Internal only - manager for action
  10696. * @hidden
  10697. */
  10698. _actionManager: ActionManager;
  10699. /**
  10700. * Internal only
  10701. * @hidden
  10702. */
  10703. private _target;
  10704. /**
  10705. * Creates a new StateCondition
  10706. * @param actionManager manager for the action the condition applies to
  10707. * @param target of the condition
  10708. * @param value to compare with target state
  10709. */
  10710. constructor(actionManager: ActionManager, target: any,
  10711. /** Value to compare with target state */
  10712. value: string);
  10713. /**
  10714. * Gets a boolean indicating if the current condition is met
  10715. * @returns the validity of the state
  10716. */
  10717. isValid(): boolean;
  10718. /**
  10719. * Serialize the StateCondition into a JSON compatible object
  10720. * @returns serialization object
  10721. */
  10722. serialize(): any;
  10723. }
  10724. }
  10725. declare module "babylonjs/Actions/directActions" {
  10726. import { Action } from "babylonjs/Actions/action";
  10727. import { Condition } from "babylonjs/Actions/condition";
  10728. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10729. /**
  10730. * This defines an action responsible to toggle a boolean once triggered.
  10731. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10732. */
  10733. export class SwitchBooleanAction extends Action {
  10734. /**
  10735. * The path to the boolean property in the target object
  10736. */
  10737. propertyPath: string;
  10738. private _target;
  10739. private _effectiveTarget;
  10740. private _property;
  10741. /**
  10742. * Instantiate the action
  10743. * @param triggerOptions defines the trigger options
  10744. * @param target defines the object containing the boolean
  10745. * @param propertyPath defines the path to the boolean property in the target object
  10746. * @param condition defines the trigger related conditions
  10747. */
  10748. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10749. /** @hidden */
  10750. _prepare(): void;
  10751. /**
  10752. * Execute the action toggle the boolean value.
  10753. */
  10754. execute(): void;
  10755. /**
  10756. * Serializes the actions and its related information.
  10757. * @param parent defines the object to serialize in
  10758. * @returns the serialized object
  10759. */
  10760. serialize(parent: any): any;
  10761. }
  10762. /**
  10763. * This defines an action responsible to set a the state field of the target
  10764. * to a desired value once triggered.
  10765. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10766. */
  10767. export class SetStateAction extends Action {
  10768. /**
  10769. * The value to store in the state field.
  10770. */
  10771. value: string;
  10772. private _target;
  10773. /**
  10774. * Instantiate the action
  10775. * @param triggerOptions defines the trigger options
  10776. * @param target defines the object containing the state property
  10777. * @param value defines the value to store in the state field
  10778. * @param condition defines the trigger related conditions
  10779. */
  10780. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10781. /**
  10782. * Execute the action and store the value on the target state property.
  10783. */
  10784. execute(): void;
  10785. /**
  10786. * Serializes the actions and its related information.
  10787. * @param parent defines the object to serialize in
  10788. * @returns the serialized object
  10789. */
  10790. serialize(parent: any): any;
  10791. }
  10792. /**
  10793. * This defines an action responsible to set a property of the target
  10794. * to a desired value once triggered.
  10795. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10796. */
  10797. export class SetValueAction extends Action {
  10798. /**
  10799. * The path of the property to set in the target.
  10800. */
  10801. propertyPath: string;
  10802. /**
  10803. * The value to set in the property
  10804. */
  10805. value: any;
  10806. private _target;
  10807. private _effectiveTarget;
  10808. private _property;
  10809. /**
  10810. * Instantiate the action
  10811. * @param triggerOptions defines the trigger options
  10812. * @param target defines the object containing the property
  10813. * @param propertyPath defines the path of the property to set in the target
  10814. * @param value defines the value to set in the property
  10815. * @param condition defines the trigger related conditions
  10816. */
  10817. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10818. /** @hidden */
  10819. _prepare(): void;
  10820. /**
  10821. * Execute the action and set the targetted property to the desired value.
  10822. */
  10823. execute(): void;
  10824. /**
  10825. * Serializes the actions and its related information.
  10826. * @param parent defines the object to serialize in
  10827. * @returns the serialized object
  10828. */
  10829. serialize(parent: any): any;
  10830. }
  10831. /**
  10832. * This defines an action responsible to increment the target value
  10833. * to a desired value once triggered.
  10834. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10835. */
  10836. export class IncrementValueAction extends Action {
  10837. /**
  10838. * The path of the property to increment in the target.
  10839. */
  10840. propertyPath: string;
  10841. /**
  10842. * The value we should increment the property by.
  10843. */
  10844. value: any;
  10845. private _target;
  10846. private _effectiveTarget;
  10847. private _property;
  10848. /**
  10849. * Instantiate the action
  10850. * @param triggerOptions defines the trigger options
  10851. * @param target defines the object containing the property
  10852. * @param propertyPath defines the path of the property to increment in the target
  10853. * @param value defines the value value we should increment the property by
  10854. * @param condition defines the trigger related conditions
  10855. */
  10856. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10857. /** @hidden */
  10858. _prepare(): void;
  10859. /**
  10860. * Execute the action and increment the target of the value amount.
  10861. */
  10862. execute(): void;
  10863. /**
  10864. * Serializes the actions and its related information.
  10865. * @param parent defines the object to serialize in
  10866. * @returns the serialized object
  10867. */
  10868. serialize(parent: any): any;
  10869. }
  10870. /**
  10871. * This defines an action responsible to start an animation once triggered.
  10872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10873. */
  10874. export class PlayAnimationAction extends Action {
  10875. /**
  10876. * Where the animation should start (animation frame)
  10877. */
  10878. from: number;
  10879. /**
  10880. * Where the animation should stop (animation frame)
  10881. */
  10882. to: number;
  10883. /**
  10884. * Define if the animation should loop or stop after the first play.
  10885. */
  10886. loop?: boolean;
  10887. private _target;
  10888. /**
  10889. * Instantiate the action
  10890. * @param triggerOptions defines the trigger options
  10891. * @param target defines the target animation or animation name
  10892. * @param from defines from where the animation should start (animation frame)
  10893. * @param end defines where the animation should stop (animation frame)
  10894. * @param loop defines if the animation should loop or stop after the first play
  10895. * @param condition defines the trigger related conditions
  10896. */
  10897. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10898. /** @hidden */
  10899. _prepare(): void;
  10900. /**
  10901. * Execute the action and play the animation.
  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. * This defines an action responsible to stop an animation once triggered.
  10913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10914. */
  10915. export class StopAnimationAction extends Action {
  10916. private _target;
  10917. /**
  10918. * Instantiate the action
  10919. * @param triggerOptions defines the trigger options
  10920. * @param target defines the target animation or animation name
  10921. * @param condition defines the trigger related conditions
  10922. */
  10923. constructor(triggerOptions: any, target: any, condition?: Condition);
  10924. /** @hidden */
  10925. _prepare(): void;
  10926. /**
  10927. * Execute the action and stop the animation.
  10928. */
  10929. execute(): void;
  10930. /**
  10931. * Serializes the actions and its related information.
  10932. * @param parent defines the object to serialize in
  10933. * @returns the serialized object
  10934. */
  10935. serialize(parent: any): any;
  10936. }
  10937. /**
  10938. * This defines an action responsible that does nothing once triggered.
  10939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10940. */
  10941. export class DoNothingAction extends Action {
  10942. /**
  10943. * Instantiate the action
  10944. * @param triggerOptions defines the trigger options
  10945. * @param condition defines the trigger related conditions
  10946. */
  10947. constructor(triggerOptions?: any, condition?: Condition);
  10948. /**
  10949. * Execute the action and do nothing.
  10950. */
  10951. execute(): void;
  10952. /**
  10953. * Serializes the actions and its related information.
  10954. * @param parent defines the object to serialize in
  10955. * @returns the serialized object
  10956. */
  10957. serialize(parent: any): any;
  10958. }
  10959. /**
  10960. * This defines an action responsible to trigger several actions once triggered.
  10961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10962. */
  10963. export class CombineAction extends Action {
  10964. /**
  10965. * The list of aggregated animations to run.
  10966. */
  10967. children: Action[];
  10968. /**
  10969. * Instantiate the action
  10970. * @param triggerOptions defines the trigger options
  10971. * @param children defines the list of aggregated animations to run
  10972. * @param condition defines the trigger related conditions
  10973. */
  10974. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10975. /** @hidden */
  10976. _prepare(): void;
  10977. /**
  10978. * Execute the action and executes all the aggregated actions.
  10979. */
  10980. execute(evt: ActionEvent): void;
  10981. /**
  10982. * Serializes the actions and its related information.
  10983. * @param parent defines the object to serialize in
  10984. * @returns the serialized object
  10985. */
  10986. serialize(parent: any): any;
  10987. }
  10988. /**
  10989. * This defines an action responsible to run code (external event) once triggered.
  10990. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10991. */
  10992. export class ExecuteCodeAction extends Action {
  10993. /**
  10994. * The callback function to run.
  10995. */
  10996. func: (evt: ActionEvent) => void;
  10997. /**
  10998. * Instantiate the action
  10999. * @param triggerOptions defines the trigger options
  11000. * @param func defines the callback function to run
  11001. * @param condition defines the trigger related conditions
  11002. */
  11003. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11004. /**
  11005. * Execute the action and run the attached code.
  11006. */
  11007. execute(evt: ActionEvent): void;
  11008. }
  11009. /**
  11010. * This defines an action responsible to set the parent property of the target once triggered.
  11011. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11012. */
  11013. export class SetParentAction extends Action {
  11014. private _parent;
  11015. private _target;
  11016. /**
  11017. * Instantiate the action
  11018. * @param triggerOptions defines the trigger options
  11019. * @param target defines the target containing the parent property
  11020. * @param parent defines from where the animation should start (animation frame)
  11021. * @param condition defines the trigger related conditions
  11022. */
  11023. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11024. /** @hidden */
  11025. _prepare(): void;
  11026. /**
  11027. * Execute the action and set the parent property.
  11028. */
  11029. execute(): void;
  11030. /**
  11031. * Serializes the actions and its related information.
  11032. * @param parent defines the object to serialize in
  11033. * @returns the serialized object
  11034. */
  11035. serialize(parent: any): any;
  11036. }
  11037. }
  11038. declare module "babylonjs/Actions/actionManager" {
  11039. import { Nullable } from "babylonjs/types";
  11040. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11041. import { Scene } from "babylonjs/scene";
  11042. import { IAction } from "babylonjs/Actions/action";
  11043. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11044. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11045. /**
  11046. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11047. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11048. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11049. */
  11050. export class ActionManager extends AbstractActionManager {
  11051. /**
  11052. * Nothing
  11053. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11054. */
  11055. static readonly NothingTrigger: number;
  11056. /**
  11057. * On pick
  11058. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11059. */
  11060. static readonly OnPickTrigger: number;
  11061. /**
  11062. * On left pick
  11063. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11064. */
  11065. static readonly OnLeftPickTrigger: number;
  11066. /**
  11067. * On right pick
  11068. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11069. */
  11070. static readonly OnRightPickTrigger: number;
  11071. /**
  11072. * On center pick
  11073. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11074. */
  11075. static readonly OnCenterPickTrigger: number;
  11076. /**
  11077. * On pick down
  11078. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11079. */
  11080. static readonly OnPickDownTrigger: number;
  11081. /**
  11082. * On double pick
  11083. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11084. */
  11085. static readonly OnDoublePickTrigger: number;
  11086. /**
  11087. * On pick up
  11088. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11089. */
  11090. static readonly OnPickUpTrigger: number;
  11091. /**
  11092. * On pick out.
  11093. * This trigger will only be raised if you also declared a OnPickDown
  11094. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11095. */
  11096. static readonly OnPickOutTrigger: number;
  11097. /**
  11098. * On long press
  11099. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11100. */
  11101. static readonly OnLongPressTrigger: number;
  11102. /**
  11103. * On pointer over
  11104. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11105. */
  11106. static readonly OnPointerOverTrigger: number;
  11107. /**
  11108. * On pointer out
  11109. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11110. */
  11111. static readonly OnPointerOutTrigger: number;
  11112. /**
  11113. * On every frame
  11114. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11115. */
  11116. static readonly OnEveryFrameTrigger: number;
  11117. /**
  11118. * On intersection enter
  11119. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11120. */
  11121. static readonly OnIntersectionEnterTrigger: number;
  11122. /**
  11123. * On intersection exit
  11124. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11125. */
  11126. static readonly OnIntersectionExitTrigger: number;
  11127. /**
  11128. * On key down
  11129. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11130. */
  11131. static readonly OnKeyDownTrigger: number;
  11132. /**
  11133. * On key up
  11134. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11135. */
  11136. static readonly OnKeyUpTrigger: number;
  11137. private _scene;
  11138. /**
  11139. * Creates a new action manager
  11140. * @param scene defines the hosting scene
  11141. */
  11142. constructor(scene: Scene);
  11143. /**
  11144. * Releases all associated resources
  11145. */
  11146. dispose(): void;
  11147. /**
  11148. * Gets hosting scene
  11149. * @returns the hosting scene
  11150. */
  11151. getScene(): Scene;
  11152. /**
  11153. * Does this action manager handles actions of any of the given triggers
  11154. * @param triggers defines the triggers to be tested
  11155. * @return a boolean indicating whether one (or more) of the triggers is handled
  11156. */
  11157. hasSpecificTriggers(triggers: number[]): boolean;
  11158. /**
  11159. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11160. * speed.
  11161. * @param triggerA defines the trigger to be tested
  11162. * @param triggerB defines the trigger to be tested
  11163. * @return a boolean indicating whether one (or more) of the triggers is handled
  11164. */
  11165. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11166. /**
  11167. * Does this action manager handles actions of a given trigger
  11168. * @param trigger defines the trigger to be tested
  11169. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11170. * @return whether the trigger is handled
  11171. */
  11172. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11173. /**
  11174. * Does this action manager has pointer triggers
  11175. */
  11176. readonly hasPointerTriggers: boolean;
  11177. /**
  11178. * Does this action manager has pick triggers
  11179. */
  11180. readonly hasPickTriggers: boolean;
  11181. /**
  11182. * Registers an action to this action manager
  11183. * @param action defines the action to be registered
  11184. * @return the action amended (prepared) after registration
  11185. */
  11186. registerAction(action: IAction): Nullable<IAction>;
  11187. /**
  11188. * Unregisters an action to this action manager
  11189. * @param action defines the action to be unregistered
  11190. * @return a boolean indicating whether the action has been unregistered
  11191. */
  11192. unregisterAction(action: IAction): Boolean;
  11193. /**
  11194. * Process a specific trigger
  11195. * @param trigger defines the trigger to process
  11196. * @param evt defines the event details to be processed
  11197. */
  11198. processTrigger(trigger: number, evt?: IActionEvent): void;
  11199. /** @hidden */
  11200. _getEffectiveTarget(target: any, propertyPath: string): any;
  11201. /** @hidden */
  11202. _getProperty(propertyPath: string): string;
  11203. /**
  11204. * Serialize this manager to a JSON object
  11205. * @param name defines the property name to store this manager
  11206. * @returns a JSON representation of this manager
  11207. */
  11208. serialize(name: string): any;
  11209. /**
  11210. * Creates a new ActionManager from a JSON data
  11211. * @param parsedActions defines the JSON data to read from
  11212. * @param object defines the hosting mesh
  11213. * @param scene defines the hosting scene
  11214. */
  11215. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11216. /**
  11217. * Get a trigger name by index
  11218. * @param trigger defines the trigger index
  11219. * @returns a trigger name
  11220. */
  11221. static GetTriggerName(trigger: number): string;
  11222. }
  11223. }
  11224. declare module "babylonjs/Culling/ray" {
  11225. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11226. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11227. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11228. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11229. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11230. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11231. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11232. import { Plane } from "babylonjs/Maths/math.plane";
  11233. /**
  11234. * Class representing a ray with position and direction
  11235. */
  11236. export class Ray {
  11237. /** origin point */
  11238. origin: Vector3;
  11239. /** direction */
  11240. direction: Vector3;
  11241. /** length of the ray */
  11242. length: number;
  11243. private static readonly TmpVector3;
  11244. private _tmpRay;
  11245. /**
  11246. * Creates a new ray
  11247. * @param origin origin point
  11248. * @param direction direction
  11249. * @param length length of the ray
  11250. */
  11251. constructor(
  11252. /** origin point */
  11253. origin: Vector3,
  11254. /** direction */
  11255. direction: Vector3,
  11256. /** length of the ray */
  11257. length?: number);
  11258. /**
  11259. * Checks if the ray intersects a box
  11260. * @param minimum bound of the box
  11261. * @param maximum bound of the box
  11262. * @param intersectionTreshold extra extend to be added to the box in all direction
  11263. * @returns if the box was hit
  11264. */
  11265. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11266. /**
  11267. * Checks if the ray intersects a box
  11268. * @param box the bounding box to check
  11269. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11270. * @returns if the box was hit
  11271. */
  11272. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11273. /**
  11274. * If the ray hits a sphere
  11275. * @param sphere the bounding sphere to check
  11276. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11277. * @returns true if it hits the sphere
  11278. */
  11279. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11280. /**
  11281. * If the ray hits a triange
  11282. * @param vertex0 triangle vertex
  11283. * @param vertex1 triangle vertex
  11284. * @param vertex2 triangle vertex
  11285. * @returns intersection information if hit
  11286. */
  11287. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11288. /**
  11289. * Checks if ray intersects a plane
  11290. * @param plane the plane to check
  11291. * @returns the distance away it was hit
  11292. */
  11293. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11294. /**
  11295. * Calculate the intercept of a ray on a given axis
  11296. * @param axis to check 'x' | 'y' | 'z'
  11297. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11298. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11299. */
  11300. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11301. /**
  11302. * Checks if ray intersects a mesh
  11303. * @param mesh the mesh to check
  11304. * @param fastCheck if only the bounding box should checked
  11305. * @returns picking info of the intersecton
  11306. */
  11307. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11308. /**
  11309. * Checks if ray intersects a mesh
  11310. * @param meshes the meshes to check
  11311. * @param fastCheck if only the bounding box should checked
  11312. * @param results array to store result in
  11313. * @returns Array of picking infos
  11314. */
  11315. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11316. private _comparePickingInfo;
  11317. private static smallnum;
  11318. private static rayl;
  11319. /**
  11320. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11321. * @param sega the first point of the segment to test the intersection against
  11322. * @param segb the second point of the segment to test the intersection against
  11323. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11324. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11325. */
  11326. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11327. /**
  11328. * Update the ray from viewport position
  11329. * @param x position
  11330. * @param y y position
  11331. * @param viewportWidth viewport width
  11332. * @param viewportHeight viewport height
  11333. * @param world world matrix
  11334. * @param view view matrix
  11335. * @param projection projection matrix
  11336. * @returns this ray updated
  11337. */
  11338. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11339. /**
  11340. * Creates a ray with origin and direction of 0,0,0
  11341. * @returns the new ray
  11342. */
  11343. static Zero(): Ray;
  11344. /**
  11345. * Creates a new ray from screen space and viewport
  11346. * @param x position
  11347. * @param y y position
  11348. * @param viewportWidth viewport width
  11349. * @param viewportHeight viewport height
  11350. * @param world world matrix
  11351. * @param view view matrix
  11352. * @param projection projection matrix
  11353. * @returns new ray
  11354. */
  11355. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11356. /**
  11357. * 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
  11358. * transformed to the given world matrix.
  11359. * @param origin The origin point
  11360. * @param end The end point
  11361. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11362. * @returns the new ray
  11363. */
  11364. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11365. /**
  11366. * Transforms a ray by a matrix
  11367. * @param ray ray to transform
  11368. * @param matrix matrix to apply
  11369. * @returns the resulting new ray
  11370. */
  11371. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11372. /**
  11373. * Transforms a ray by a matrix
  11374. * @param ray ray to transform
  11375. * @param matrix matrix to apply
  11376. * @param result ray to store result in
  11377. */
  11378. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11379. /**
  11380. * Unproject a ray from screen space to object space
  11381. * @param sourceX defines the screen space x coordinate to use
  11382. * @param sourceY defines the screen space y coordinate to use
  11383. * @param viewportWidth defines the current width of the viewport
  11384. * @param viewportHeight defines the current height of the viewport
  11385. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11386. * @param view defines the view matrix to use
  11387. * @param projection defines the projection matrix to use
  11388. */
  11389. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11390. }
  11391. /**
  11392. * Type used to define predicate used to select faces when a mesh intersection is detected
  11393. */
  11394. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11395. module "babylonjs/scene" {
  11396. interface Scene {
  11397. /** @hidden */
  11398. _tempPickingRay: Nullable<Ray>;
  11399. /** @hidden */
  11400. _cachedRayForTransform: Ray;
  11401. /** @hidden */
  11402. _pickWithRayInverseMatrix: Matrix;
  11403. /** @hidden */
  11404. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11405. /** @hidden */
  11406. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11407. }
  11408. }
  11409. }
  11410. declare module "babylonjs/sceneComponent" {
  11411. import { Scene } from "babylonjs/scene";
  11412. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11413. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11414. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11415. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11416. import { Nullable } from "babylonjs/types";
  11417. import { Camera } from "babylonjs/Cameras/camera";
  11418. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11419. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11420. import { AbstractScene } from "babylonjs/abstractScene";
  11421. import { Mesh } from "babylonjs/Meshes/mesh";
  11422. /**
  11423. * Groups all the scene component constants in one place to ease maintenance.
  11424. * @hidden
  11425. */
  11426. export class SceneComponentConstants {
  11427. static readonly NAME_EFFECTLAYER: string;
  11428. static readonly NAME_LAYER: string;
  11429. static readonly NAME_LENSFLARESYSTEM: string;
  11430. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11431. static readonly NAME_PARTICLESYSTEM: string;
  11432. static readonly NAME_GAMEPAD: string;
  11433. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11434. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11435. static readonly NAME_DEPTHRENDERER: string;
  11436. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11437. static readonly NAME_SPRITE: string;
  11438. static readonly NAME_OUTLINERENDERER: string;
  11439. static readonly NAME_PROCEDURALTEXTURE: string;
  11440. static readonly NAME_SHADOWGENERATOR: string;
  11441. static readonly NAME_OCTREE: string;
  11442. static readonly NAME_PHYSICSENGINE: string;
  11443. static readonly NAME_AUDIO: string;
  11444. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11445. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11446. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11447. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11448. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11449. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11450. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11451. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11452. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11453. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11454. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11455. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11456. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11457. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11458. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11459. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11460. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11461. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11462. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11463. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11464. static readonly STEP_AFTERRENDER_AUDIO: number;
  11465. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11466. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11467. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11468. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11469. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11470. static readonly STEP_POINTERMOVE_SPRITE: number;
  11471. static readonly STEP_POINTERDOWN_SPRITE: number;
  11472. static readonly STEP_POINTERUP_SPRITE: number;
  11473. }
  11474. /**
  11475. * This represents a scene component.
  11476. *
  11477. * This is used to decouple the dependency the scene is having on the different workloads like
  11478. * layers, post processes...
  11479. */
  11480. export interface ISceneComponent {
  11481. /**
  11482. * The name of the component. Each component must have a unique name.
  11483. */
  11484. name: string;
  11485. /**
  11486. * The scene the component belongs to.
  11487. */
  11488. scene: Scene;
  11489. /**
  11490. * Register the component to one instance of a scene.
  11491. */
  11492. register(): void;
  11493. /**
  11494. * Rebuilds the elements related to this component in case of
  11495. * context lost for instance.
  11496. */
  11497. rebuild(): void;
  11498. /**
  11499. * Disposes the component and the associated ressources.
  11500. */
  11501. dispose(): void;
  11502. }
  11503. /**
  11504. * This represents a SERIALIZABLE scene component.
  11505. *
  11506. * This extends Scene Component to add Serialization methods on top.
  11507. */
  11508. export interface ISceneSerializableComponent extends ISceneComponent {
  11509. /**
  11510. * Adds all the elements from the container to the scene
  11511. * @param container the container holding the elements
  11512. */
  11513. addFromContainer(container: AbstractScene): void;
  11514. /**
  11515. * Removes all the elements in the container from the scene
  11516. * @param container contains the elements to remove
  11517. * @param dispose if the removed element should be disposed (default: false)
  11518. */
  11519. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11520. /**
  11521. * Serializes the component data to the specified json object
  11522. * @param serializationObject The object to serialize to
  11523. */
  11524. serialize(serializationObject: any): void;
  11525. }
  11526. /**
  11527. * Strong typing of a Mesh related stage step action
  11528. */
  11529. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11530. /**
  11531. * Strong typing of a Evaluate Sub Mesh related stage step action
  11532. */
  11533. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11534. /**
  11535. * Strong typing of a Active Mesh related stage step action
  11536. */
  11537. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11538. /**
  11539. * Strong typing of a Camera related stage step action
  11540. */
  11541. export type CameraStageAction = (camera: Camera) => void;
  11542. /**
  11543. * Strong typing of a Camera Frame buffer related stage step action
  11544. */
  11545. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11546. /**
  11547. * Strong typing of a Render Target related stage step action
  11548. */
  11549. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11550. /**
  11551. * Strong typing of a RenderingGroup related stage step action
  11552. */
  11553. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11554. /**
  11555. * Strong typing of a Mesh Render related stage step action
  11556. */
  11557. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11558. /**
  11559. * Strong typing of a simple stage step action
  11560. */
  11561. export type SimpleStageAction = () => void;
  11562. /**
  11563. * Strong typing of a render target action.
  11564. */
  11565. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11566. /**
  11567. * Strong typing of a pointer move action.
  11568. */
  11569. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11570. /**
  11571. * Strong typing of a pointer up/down action.
  11572. */
  11573. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11574. /**
  11575. * Representation of a stage in the scene (Basically a list of ordered steps)
  11576. * @hidden
  11577. */
  11578. export class Stage<T extends Function> extends Array<{
  11579. index: number;
  11580. component: ISceneComponent;
  11581. action: T;
  11582. }> {
  11583. /**
  11584. * Hide ctor from the rest of the world.
  11585. * @param items The items to add.
  11586. */
  11587. private constructor();
  11588. /**
  11589. * Creates a new Stage.
  11590. * @returns A new instance of a Stage
  11591. */
  11592. static Create<T extends Function>(): Stage<T>;
  11593. /**
  11594. * Registers a step in an ordered way in the targeted stage.
  11595. * @param index Defines the position to register the step in
  11596. * @param component Defines the component attached to the step
  11597. * @param action Defines the action to launch during the step
  11598. */
  11599. registerStep(index: number, component: ISceneComponent, action: T): void;
  11600. /**
  11601. * Clears all the steps from the stage.
  11602. */
  11603. clear(): void;
  11604. }
  11605. }
  11606. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11607. import { Nullable } from "babylonjs/types";
  11608. import { Observable } from "babylonjs/Misc/observable";
  11609. import { Scene } from "babylonjs/scene";
  11610. import { Sprite } from "babylonjs/Sprites/sprite";
  11611. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11612. import { Ray } from "babylonjs/Culling/ray";
  11613. import { Camera } from "babylonjs/Cameras/camera";
  11614. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11615. import { ISceneComponent } from "babylonjs/sceneComponent";
  11616. module "babylonjs/scene" {
  11617. interface Scene {
  11618. /** @hidden */
  11619. _pointerOverSprite: Nullable<Sprite>;
  11620. /** @hidden */
  11621. _pickedDownSprite: Nullable<Sprite>;
  11622. /** @hidden */
  11623. _tempSpritePickingRay: Nullable<Ray>;
  11624. /**
  11625. * All of the sprite managers added to this scene
  11626. * @see http://doc.babylonjs.com/babylon101/sprites
  11627. */
  11628. spriteManagers: Array<ISpriteManager>;
  11629. /**
  11630. * An event triggered when sprites rendering is about to start
  11631. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11632. */
  11633. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11634. /**
  11635. * An event triggered when sprites rendering is done
  11636. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11637. */
  11638. onAfterSpritesRenderingObservable: Observable<Scene>;
  11639. /** @hidden */
  11640. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11641. /** Launch a ray to try to pick a sprite in the scene
  11642. * @param x position on screen
  11643. * @param y position on screen
  11644. * @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
  11645. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11646. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11647. * @returns a PickingInfo
  11648. */
  11649. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11650. /** Use the given ray to pick a sprite in the scene
  11651. * @param ray The ray (in world space) to use to pick meshes
  11652. * @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
  11653. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11654. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11655. * @returns a PickingInfo
  11656. */
  11657. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11658. /** @hidden */
  11659. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11660. /** Launch a ray to try to pick sprites in the scene
  11661. * @param x position on screen
  11662. * @param y position on screen
  11663. * @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
  11664. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11665. * @returns a PickingInfo array
  11666. */
  11667. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11668. /** Use the given ray to pick sprites in the scene
  11669. * @param ray The ray (in world space) to use to pick meshes
  11670. * @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
  11671. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11672. * @returns a PickingInfo array
  11673. */
  11674. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11675. /**
  11676. * Force the sprite under the pointer
  11677. * @param sprite defines the sprite to use
  11678. */
  11679. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11680. /**
  11681. * Gets the sprite under the pointer
  11682. * @returns a Sprite or null if no sprite is under the pointer
  11683. */
  11684. getPointerOverSprite(): Nullable<Sprite>;
  11685. }
  11686. }
  11687. /**
  11688. * Defines the sprite scene component responsible to manage sprites
  11689. * in a given scene.
  11690. */
  11691. export class SpriteSceneComponent implements ISceneComponent {
  11692. /**
  11693. * The component name helpfull to identify the component in the list of scene components.
  11694. */
  11695. readonly name: string;
  11696. /**
  11697. * The scene the component belongs to.
  11698. */
  11699. scene: Scene;
  11700. /** @hidden */
  11701. private _spritePredicate;
  11702. /**
  11703. * Creates a new instance of the component for the given scene
  11704. * @param scene Defines the scene to register the component in
  11705. */
  11706. constructor(scene: Scene);
  11707. /**
  11708. * Registers the component in a given scene
  11709. */
  11710. register(): void;
  11711. /**
  11712. * Rebuilds the elements related to this component in case of
  11713. * context lost for instance.
  11714. */
  11715. rebuild(): void;
  11716. /**
  11717. * Disposes the component and the associated ressources.
  11718. */
  11719. dispose(): void;
  11720. private _pickSpriteButKeepRay;
  11721. private _pointerMove;
  11722. private _pointerDown;
  11723. private _pointerUp;
  11724. }
  11725. }
  11726. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11727. /** @hidden */
  11728. export var fogFragmentDeclaration: {
  11729. name: string;
  11730. shader: string;
  11731. };
  11732. }
  11733. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11734. /** @hidden */
  11735. export var fogFragment: {
  11736. name: string;
  11737. shader: string;
  11738. };
  11739. }
  11740. declare module "babylonjs/Shaders/sprites.fragment" {
  11741. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11742. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11743. /** @hidden */
  11744. export var spritesPixelShader: {
  11745. name: string;
  11746. shader: string;
  11747. };
  11748. }
  11749. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11750. /** @hidden */
  11751. export var fogVertexDeclaration: {
  11752. name: string;
  11753. shader: string;
  11754. };
  11755. }
  11756. declare module "babylonjs/Shaders/sprites.vertex" {
  11757. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11758. /** @hidden */
  11759. export var spritesVertexShader: {
  11760. name: string;
  11761. shader: string;
  11762. };
  11763. }
  11764. declare module "babylonjs/Sprites/spriteManager" {
  11765. import { IDisposable, Scene } from "babylonjs/scene";
  11766. import { Nullable } from "babylonjs/types";
  11767. import { Observable } from "babylonjs/Misc/observable";
  11768. import { Sprite } from "babylonjs/Sprites/sprite";
  11769. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11770. import { Camera } from "babylonjs/Cameras/camera";
  11771. import { Texture } from "babylonjs/Materials/Textures/texture";
  11772. import "babylonjs/Shaders/sprites.fragment";
  11773. import "babylonjs/Shaders/sprites.vertex";
  11774. import { Ray } from "babylonjs/Culling/ray";
  11775. /**
  11776. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11777. */
  11778. export interface ISpriteManager extends IDisposable {
  11779. /**
  11780. * Restricts the camera to viewing objects with the same layerMask.
  11781. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11782. */
  11783. layerMask: number;
  11784. /**
  11785. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11786. */
  11787. isPickable: boolean;
  11788. /**
  11789. * Specifies the rendering group id for this mesh (0 by default)
  11790. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11791. */
  11792. renderingGroupId: number;
  11793. /**
  11794. * Defines the list of sprites managed by the manager.
  11795. */
  11796. sprites: Array<Sprite>;
  11797. /**
  11798. * Tests the intersection of a sprite with a specific ray.
  11799. * @param ray The ray we are sending to test the collision
  11800. * @param camera The camera space we are sending rays in
  11801. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11802. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11803. * @returns picking info or null.
  11804. */
  11805. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11806. /**
  11807. * Intersects the sprites with a ray
  11808. * @param ray defines the ray to intersect with
  11809. * @param camera defines the current active camera
  11810. * @param predicate defines a predicate used to select candidate sprites
  11811. * @returns null if no hit or a PickingInfo array
  11812. */
  11813. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11814. /**
  11815. * Renders the list of sprites on screen.
  11816. */
  11817. render(): void;
  11818. }
  11819. /**
  11820. * Class used to manage multiple sprites on the same spritesheet
  11821. * @see http://doc.babylonjs.com/babylon101/sprites
  11822. */
  11823. export class SpriteManager implements ISpriteManager {
  11824. /** defines the manager's name */
  11825. name: string;
  11826. /** Gets the list of sprites */
  11827. sprites: Sprite[];
  11828. /** Gets or sets the rendering group id (0 by default) */
  11829. renderingGroupId: number;
  11830. /** Gets or sets camera layer mask */
  11831. layerMask: number;
  11832. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11833. fogEnabled: boolean;
  11834. /** Gets or sets a boolean indicating if the sprites are pickable */
  11835. isPickable: boolean;
  11836. /** Defines the default width of a cell in the spritesheet */
  11837. cellWidth: number;
  11838. /** Defines the default height of a cell in the spritesheet */
  11839. cellHeight: number;
  11840. /** Associative array from JSON sprite data file */
  11841. private _cellData;
  11842. /** Array of sprite names from JSON sprite data file */
  11843. private _spriteMap;
  11844. /** True when packed cell data from JSON file is ready*/
  11845. private _packedAndReady;
  11846. /**
  11847. * An event triggered when the manager is disposed.
  11848. */
  11849. onDisposeObservable: Observable<SpriteManager>;
  11850. private _onDisposeObserver;
  11851. /**
  11852. * Callback called when the manager is disposed
  11853. */
  11854. onDispose: () => void;
  11855. private _capacity;
  11856. private _fromPacked;
  11857. private _spriteTexture;
  11858. private _epsilon;
  11859. private _scene;
  11860. private _vertexData;
  11861. private _buffer;
  11862. private _vertexBuffers;
  11863. private _indexBuffer;
  11864. private _effectBase;
  11865. private _effectFog;
  11866. /**
  11867. * Gets or sets the spritesheet texture
  11868. */
  11869. texture: Texture;
  11870. /**
  11871. * Creates a new sprite manager
  11872. * @param name defines the manager's name
  11873. * @param imgUrl defines the sprite sheet url
  11874. * @param capacity defines the maximum allowed number of sprites
  11875. * @param cellSize defines the size of a sprite cell
  11876. * @param scene defines the hosting scene
  11877. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11878. * @param samplingMode defines the smapling mode to use with spritesheet
  11879. * @param fromPacked set to false; do not alter
  11880. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11881. */
  11882. constructor(
  11883. /** defines the manager's name */
  11884. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11885. private _makePacked;
  11886. private _appendSpriteVertex;
  11887. /**
  11888. * Intersects the sprites with a ray
  11889. * @param ray defines the ray to intersect with
  11890. * @param camera defines the current active camera
  11891. * @param predicate defines a predicate used to select candidate sprites
  11892. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11893. * @returns null if no hit or a PickingInfo
  11894. */
  11895. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11896. /**
  11897. * Intersects the sprites with a ray
  11898. * @param ray defines the ray to intersect with
  11899. * @param camera defines the current active camera
  11900. * @param predicate defines a predicate used to select candidate sprites
  11901. * @returns null if no hit or a PickingInfo array
  11902. */
  11903. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11904. /**
  11905. * Render all child sprites
  11906. */
  11907. render(): void;
  11908. /**
  11909. * Release associated resources
  11910. */
  11911. dispose(): void;
  11912. }
  11913. }
  11914. declare module "babylonjs/Sprites/sprite" {
  11915. import { Vector3 } from "babylonjs/Maths/math.vector";
  11916. import { Nullable } from "babylonjs/types";
  11917. import { ActionManager } from "babylonjs/Actions/actionManager";
  11918. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11919. import { Color4 } from "babylonjs/Maths/math.color";
  11920. /**
  11921. * Class used to represent a sprite
  11922. * @see http://doc.babylonjs.com/babylon101/sprites
  11923. */
  11924. export class Sprite {
  11925. /** defines the name */
  11926. name: string;
  11927. /** Gets or sets the current world position */
  11928. position: Vector3;
  11929. /** Gets or sets the main color */
  11930. color: Color4;
  11931. /** Gets or sets the width */
  11932. width: number;
  11933. /** Gets or sets the height */
  11934. height: number;
  11935. /** Gets or sets rotation angle */
  11936. angle: number;
  11937. /** Gets or sets the cell index in the sprite sheet */
  11938. cellIndex: number;
  11939. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11940. cellRef: string;
  11941. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11942. invertU: number;
  11943. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11944. invertV: number;
  11945. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11946. disposeWhenFinishedAnimating: boolean;
  11947. /** Gets the list of attached animations */
  11948. animations: Animation[];
  11949. /** Gets or sets a boolean indicating if the sprite can be picked */
  11950. isPickable: boolean;
  11951. /**
  11952. * Gets or sets the associated action manager
  11953. */
  11954. actionManager: Nullable<ActionManager>;
  11955. private _animationStarted;
  11956. private _loopAnimation;
  11957. private _fromIndex;
  11958. private _toIndex;
  11959. private _delay;
  11960. private _direction;
  11961. private _manager;
  11962. private _time;
  11963. private _onAnimationEnd;
  11964. /**
  11965. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11966. */
  11967. isVisible: boolean;
  11968. /**
  11969. * Gets or sets the sprite size
  11970. */
  11971. size: number;
  11972. /**
  11973. * Creates a new Sprite
  11974. * @param name defines the name
  11975. * @param manager defines the manager
  11976. */
  11977. constructor(
  11978. /** defines the name */
  11979. name: string, manager: ISpriteManager);
  11980. /**
  11981. * Starts an animation
  11982. * @param from defines the initial key
  11983. * @param to defines the end key
  11984. * @param loop defines if the animation must loop
  11985. * @param delay defines the start delay (in ms)
  11986. * @param onAnimationEnd defines a callback to call when animation ends
  11987. */
  11988. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11989. /** Stops current animation (if any) */
  11990. stopAnimation(): void;
  11991. /** @hidden */
  11992. _animate(deltaTime: number): void;
  11993. /** Release associated resources */
  11994. dispose(): void;
  11995. }
  11996. }
  11997. declare module "babylonjs/Collisions/pickingInfo" {
  11998. import { Nullable } from "babylonjs/types";
  11999. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  12000. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12001. import { Sprite } from "babylonjs/Sprites/sprite";
  12002. import { Ray } from "babylonjs/Culling/ray";
  12003. /**
  12004. * Information about the result of picking within a scene
  12005. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12006. */
  12007. export class PickingInfo {
  12008. /** @hidden */
  12009. _pickingUnavailable: boolean;
  12010. /**
  12011. * If the pick collided with an object
  12012. */
  12013. hit: boolean;
  12014. /**
  12015. * Distance away where the pick collided
  12016. */
  12017. distance: number;
  12018. /**
  12019. * The location of pick collision
  12020. */
  12021. pickedPoint: Nullable<Vector3>;
  12022. /**
  12023. * The mesh corresponding the the pick collision
  12024. */
  12025. pickedMesh: Nullable<AbstractMesh>;
  12026. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  12027. bu: number;
  12028. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  12029. bv: number;
  12030. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12031. faceId: number;
  12032. /** Id of the the submesh that was picked */
  12033. subMeshId: number;
  12034. /** If a sprite was picked, this will be the sprite the pick collided with */
  12035. pickedSprite: Nullable<Sprite>;
  12036. /**
  12037. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12038. */
  12039. originMesh: Nullable<AbstractMesh>;
  12040. /**
  12041. * The ray that was used to perform the picking.
  12042. */
  12043. ray: Nullable<Ray>;
  12044. /**
  12045. * Gets the normal correspodning to the face the pick collided with
  12046. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12047. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12048. * @returns The normal correspodning to the face the pick collided with
  12049. */
  12050. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12051. /**
  12052. * Gets the texture coordinates of where the pick occured
  12053. * @returns the vector containing the coordnates of the texture
  12054. */
  12055. getTextureCoordinates(): Nullable<Vector2>;
  12056. }
  12057. }
  12058. declare module "babylonjs/Events/pointerEvents" {
  12059. import { Nullable } from "babylonjs/types";
  12060. import { Vector2 } from "babylonjs/Maths/math.vector";
  12061. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12062. import { Ray } from "babylonjs/Culling/ray";
  12063. /**
  12064. * Gather the list of pointer event types as constants.
  12065. */
  12066. export class PointerEventTypes {
  12067. /**
  12068. * 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.
  12069. */
  12070. static readonly POINTERDOWN: number;
  12071. /**
  12072. * The pointerup event is fired when a pointer is no longer active.
  12073. */
  12074. static readonly POINTERUP: number;
  12075. /**
  12076. * The pointermove event is fired when a pointer changes coordinates.
  12077. */
  12078. static readonly POINTERMOVE: number;
  12079. /**
  12080. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12081. */
  12082. static readonly POINTERWHEEL: number;
  12083. /**
  12084. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12085. */
  12086. static readonly POINTERPICK: number;
  12087. /**
  12088. * The pointertap event is fired when a the object has been touched and released without drag.
  12089. */
  12090. static readonly POINTERTAP: number;
  12091. /**
  12092. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12093. */
  12094. static readonly POINTERDOUBLETAP: number;
  12095. }
  12096. /**
  12097. * Base class of pointer info types.
  12098. */
  12099. export class PointerInfoBase {
  12100. /**
  12101. * Defines the type of event (PointerEventTypes)
  12102. */
  12103. type: number;
  12104. /**
  12105. * Defines the related dom event
  12106. */
  12107. event: PointerEvent | MouseWheelEvent;
  12108. /**
  12109. * Instantiates the base class of pointers info.
  12110. * @param type Defines the type of event (PointerEventTypes)
  12111. * @param event Defines the related dom event
  12112. */
  12113. constructor(
  12114. /**
  12115. * Defines the type of event (PointerEventTypes)
  12116. */
  12117. type: number,
  12118. /**
  12119. * Defines the related dom event
  12120. */
  12121. event: PointerEvent | MouseWheelEvent);
  12122. }
  12123. /**
  12124. * This class is used to store pointer related info for the onPrePointerObservable event.
  12125. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12126. */
  12127. export class PointerInfoPre extends PointerInfoBase {
  12128. /**
  12129. * Ray from a pointer if availible (eg. 6dof controller)
  12130. */
  12131. ray: Nullable<Ray>;
  12132. /**
  12133. * Defines the local position of the pointer on the canvas.
  12134. */
  12135. localPosition: Vector2;
  12136. /**
  12137. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12138. */
  12139. skipOnPointerObservable: boolean;
  12140. /**
  12141. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12142. * @param type Defines the type of event (PointerEventTypes)
  12143. * @param event Defines the related dom event
  12144. * @param localX Defines the local x coordinates of the pointer when the event occured
  12145. * @param localY Defines the local y coordinates of the pointer when the event occured
  12146. */
  12147. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12148. }
  12149. /**
  12150. * This type contains all the data related to a pointer event in Babylon.js.
  12151. * 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.
  12152. */
  12153. export class PointerInfo extends PointerInfoBase {
  12154. /**
  12155. * Defines the picking info associated to the info (if any)\
  12156. */
  12157. pickInfo: Nullable<PickingInfo>;
  12158. /**
  12159. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12160. * @param type Defines the type of event (PointerEventTypes)
  12161. * @param event Defines the related dom event
  12162. * @param pickInfo Defines the picking info associated to the info (if any)\
  12163. */
  12164. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12165. /**
  12166. * Defines the picking info associated to the info (if any)\
  12167. */
  12168. pickInfo: Nullable<PickingInfo>);
  12169. }
  12170. /**
  12171. * Data relating to a touch event on the screen.
  12172. */
  12173. export interface PointerTouch {
  12174. /**
  12175. * X coordinate of touch.
  12176. */
  12177. x: number;
  12178. /**
  12179. * Y coordinate of touch.
  12180. */
  12181. y: number;
  12182. /**
  12183. * Id of touch. Unique for each finger.
  12184. */
  12185. pointerId: number;
  12186. /**
  12187. * Event type passed from DOM.
  12188. */
  12189. type: any;
  12190. }
  12191. }
  12192. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12193. import { Observable } from "babylonjs/Misc/observable";
  12194. import { Nullable } from "babylonjs/types";
  12195. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12196. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12197. /**
  12198. * Manage the mouse inputs to control the movement of a free camera.
  12199. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12200. */
  12201. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12202. /**
  12203. * Define if touch is enabled in the mouse input
  12204. */
  12205. touchEnabled: boolean;
  12206. /**
  12207. * Defines the camera the input is attached to.
  12208. */
  12209. camera: FreeCamera;
  12210. /**
  12211. * Defines the buttons associated with the input to handle camera move.
  12212. */
  12213. buttons: number[];
  12214. /**
  12215. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12216. */
  12217. angularSensibility: number;
  12218. private _pointerInput;
  12219. private _onMouseMove;
  12220. private _observer;
  12221. private previousPosition;
  12222. /**
  12223. * Observable for when a pointer move event occurs containing the move offset
  12224. */
  12225. onPointerMovedObservable: Observable<{
  12226. offsetX: number;
  12227. offsetY: number;
  12228. }>;
  12229. /**
  12230. * @hidden
  12231. * If the camera should be rotated automatically based on pointer movement
  12232. */
  12233. _allowCameraRotation: boolean;
  12234. /**
  12235. * Manage the mouse inputs to control the movement of a free camera.
  12236. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12237. * @param touchEnabled Defines if touch is enabled or not
  12238. */
  12239. constructor(
  12240. /**
  12241. * Define if touch is enabled in the mouse input
  12242. */
  12243. touchEnabled?: boolean);
  12244. /**
  12245. * Attach the input controls to a specific dom element to get the input from.
  12246. * @param element Defines the element the controls should be listened from
  12247. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12248. */
  12249. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12250. /**
  12251. * Called on JS contextmenu event.
  12252. * Override this method to provide functionality.
  12253. */
  12254. protected onContextMenu(evt: PointerEvent): void;
  12255. /**
  12256. * Detach the current controls from the specified dom element.
  12257. * @param element Defines the element to stop listening the inputs from
  12258. */
  12259. detachControl(element: Nullable<HTMLElement>): void;
  12260. /**
  12261. * Gets the class name of the current intput.
  12262. * @returns the class name
  12263. */
  12264. getClassName(): string;
  12265. /**
  12266. * Get the friendly name associated with the input class.
  12267. * @returns the input friendly name
  12268. */
  12269. getSimpleName(): string;
  12270. }
  12271. }
  12272. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12273. import { Nullable } from "babylonjs/types";
  12274. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12275. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12276. /**
  12277. * Manage the touch inputs to control the movement of a free camera.
  12278. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12279. */
  12280. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12281. /**
  12282. * Defines the camera the input is attached to.
  12283. */
  12284. camera: FreeCamera;
  12285. /**
  12286. * Defines the touch sensibility for rotation.
  12287. * The higher the faster.
  12288. */
  12289. touchAngularSensibility: number;
  12290. /**
  12291. * Defines the touch sensibility for move.
  12292. * The higher the faster.
  12293. */
  12294. touchMoveSensibility: number;
  12295. private _offsetX;
  12296. private _offsetY;
  12297. private _pointerPressed;
  12298. private _pointerInput;
  12299. private _observer;
  12300. private _onLostFocus;
  12301. /**
  12302. * Attach the input controls to a specific dom element to get the input from.
  12303. * @param element Defines the element the controls should be listened from
  12304. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12305. */
  12306. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12307. /**
  12308. * Detach the current controls from the specified dom element.
  12309. * @param element Defines the element to stop listening the inputs from
  12310. */
  12311. detachControl(element: Nullable<HTMLElement>): void;
  12312. /**
  12313. * Update the current camera state depending on the inputs that have been used this frame.
  12314. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12315. */
  12316. checkInputs(): void;
  12317. /**
  12318. * Gets the class name of the current intput.
  12319. * @returns the class name
  12320. */
  12321. getClassName(): string;
  12322. /**
  12323. * Get the friendly name associated with the input class.
  12324. * @returns the input friendly name
  12325. */
  12326. getSimpleName(): string;
  12327. }
  12328. }
  12329. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12330. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12331. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12332. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12333. import { Nullable } from "babylonjs/types";
  12334. /**
  12335. * Default Inputs manager for the FreeCamera.
  12336. * It groups all the default supported inputs for ease of use.
  12337. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12338. */
  12339. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12340. /**
  12341. * @hidden
  12342. */
  12343. _mouseInput: Nullable<FreeCameraMouseInput>;
  12344. /**
  12345. * Instantiates a new FreeCameraInputsManager.
  12346. * @param camera Defines the camera the inputs belong to
  12347. */
  12348. constructor(camera: FreeCamera);
  12349. /**
  12350. * Add keyboard input support to the input manager.
  12351. * @returns the current input manager
  12352. */
  12353. addKeyboard(): FreeCameraInputsManager;
  12354. /**
  12355. * Add mouse input support to the input manager.
  12356. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12357. * @returns the current input manager
  12358. */
  12359. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12360. /**
  12361. * Removes the mouse input support from the manager
  12362. * @returns the current input manager
  12363. */
  12364. removeMouse(): FreeCameraInputsManager;
  12365. /**
  12366. * Add touch input support to the input manager.
  12367. * @returns the current input manager
  12368. */
  12369. addTouch(): FreeCameraInputsManager;
  12370. /**
  12371. * Remove all attached input methods from a camera
  12372. */
  12373. clear(): void;
  12374. }
  12375. }
  12376. declare module "babylonjs/Cameras/freeCamera" {
  12377. import { Vector3 } from "babylonjs/Maths/math.vector";
  12378. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12379. import { Scene } from "babylonjs/scene";
  12380. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12381. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12382. /**
  12383. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12384. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12385. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12386. */
  12387. export class FreeCamera extends TargetCamera {
  12388. /**
  12389. * Define the collision ellipsoid of the camera.
  12390. * This is helpful to simulate a camera body like the player body around the camera
  12391. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12392. */
  12393. ellipsoid: Vector3;
  12394. /**
  12395. * Define an offset for the position of the ellipsoid around the camera.
  12396. * This can be helpful to determine the center of the body near the gravity center of the body
  12397. * instead of its head.
  12398. */
  12399. ellipsoidOffset: Vector3;
  12400. /**
  12401. * Enable or disable collisions of the camera with the rest of the scene objects.
  12402. */
  12403. checkCollisions: boolean;
  12404. /**
  12405. * Enable or disable gravity on the camera.
  12406. */
  12407. applyGravity: boolean;
  12408. /**
  12409. * Define the input manager associated to the camera.
  12410. */
  12411. inputs: FreeCameraInputsManager;
  12412. /**
  12413. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12414. * Higher values reduce sensitivity.
  12415. */
  12416. /**
  12417. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12418. * Higher values reduce sensitivity.
  12419. */
  12420. angularSensibility: number;
  12421. /**
  12422. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12423. */
  12424. keysUp: number[];
  12425. /**
  12426. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12427. */
  12428. keysDown: number[];
  12429. /**
  12430. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12431. */
  12432. keysLeft: number[];
  12433. /**
  12434. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12435. */
  12436. keysRight: number[];
  12437. /**
  12438. * Event raised when the camera collide with a mesh in the scene.
  12439. */
  12440. onCollide: (collidedMesh: AbstractMesh) => void;
  12441. private _collider;
  12442. private _needMoveForGravity;
  12443. private _oldPosition;
  12444. private _diffPosition;
  12445. private _newPosition;
  12446. /** @hidden */
  12447. _localDirection: Vector3;
  12448. /** @hidden */
  12449. _transformedDirection: Vector3;
  12450. /**
  12451. * Instantiates a Free Camera.
  12452. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12453. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12454. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12455. * @param name Define the name of the camera in the scene
  12456. * @param position Define the start position of the camera in the scene
  12457. * @param scene Define the scene the camera belongs to
  12458. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12459. */
  12460. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12461. /**
  12462. * Attached controls to the current camera.
  12463. * @param element Defines the element the controls should be listened from
  12464. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12465. */
  12466. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12467. /**
  12468. * Detach the current controls from the camera.
  12469. * The camera will stop reacting to inputs.
  12470. * @param element Defines the element to stop listening the inputs from
  12471. */
  12472. detachControl(element: HTMLElement): void;
  12473. private _collisionMask;
  12474. /**
  12475. * Define a collision mask to limit the list of object the camera can collide with
  12476. */
  12477. collisionMask: number;
  12478. /** @hidden */
  12479. _collideWithWorld(displacement: Vector3): void;
  12480. private _onCollisionPositionChange;
  12481. /** @hidden */
  12482. _checkInputs(): void;
  12483. /** @hidden */
  12484. _decideIfNeedsToMove(): boolean;
  12485. /** @hidden */
  12486. _updatePosition(): void;
  12487. /**
  12488. * Destroy the camera and release the current resources hold by it.
  12489. */
  12490. dispose(): void;
  12491. /**
  12492. * Gets the current object class name.
  12493. * @return the class name
  12494. */
  12495. getClassName(): string;
  12496. }
  12497. }
  12498. declare module "babylonjs/Gamepads/gamepad" {
  12499. import { Observable } from "babylonjs/Misc/observable";
  12500. /**
  12501. * Represents a gamepad control stick position
  12502. */
  12503. export class StickValues {
  12504. /**
  12505. * The x component of the control stick
  12506. */
  12507. x: number;
  12508. /**
  12509. * The y component of the control stick
  12510. */
  12511. y: number;
  12512. /**
  12513. * Initializes the gamepad x and y control stick values
  12514. * @param x The x component of the gamepad control stick value
  12515. * @param y The y component of the gamepad control stick value
  12516. */
  12517. constructor(
  12518. /**
  12519. * The x component of the control stick
  12520. */
  12521. x: number,
  12522. /**
  12523. * The y component of the control stick
  12524. */
  12525. y: number);
  12526. }
  12527. /**
  12528. * An interface which manages callbacks for gamepad button changes
  12529. */
  12530. export interface GamepadButtonChanges {
  12531. /**
  12532. * Called when a gamepad has been changed
  12533. */
  12534. changed: boolean;
  12535. /**
  12536. * Called when a gamepad press event has been triggered
  12537. */
  12538. pressChanged: boolean;
  12539. /**
  12540. * Called when a touch event has been triggered
  12541. */
  12542. touchChanged: boolean;
  12543. /**
  12544. * Called when a value has changed
  12545. */
  12546. valueChanged: boolean;
  12547. }
  12548. /**
  12549. * Represents a gamepad
  12550. */
  12551. export class Gamepad {
  12552. /**
  12553. * The id of the gamepad
  12554. */
  12555. id: string;
  12556. /**
  12557. * The index of the gamepad
  12558. */
  12559. index: number;
  12560. /**
  12561. * The browser gamepad
  12562. */
  12563. browserGamepad: any;
  12564. /**
  12565. * Specifies what type of gamepad this represents
  12566. */
  12567. type: number;
  12568. private _leftStick;
  12569. private _rightStick;
  12570. /** @hidden */
  12571. _isConnected: boolean;
  12572. private _leftStickAxisX;
  12573. private _leftStickAxisY;
  12574. private _rightStickAxisX;
  12575. private _rightStickAxisY;
  12576. /**
  12577. * Triggered when the left control stick has been changed
  12578. */
  12579. private _onleftstickchanged;
  12580. /**
  12581. * Triggered when the right control stick has been changed
  12582. */
  12583. private _onrightstickchanged;
  12584. /**
  12585. * Represents a gamepad controller
  12586. */
  12587. static GAMEPAD: number;
  12588. /**
  12589. * Represents a generic controller
  12590. */
  12591. static GENERIC: number;
  12592. /**
  12593. * Represents an XBox controller
  12594. */
  12595. static XBOX: number;
  12596. /**
  12597. * Represents a pose-enabled controller
  12598. */
  12599. static POSE_ENABLED: number;
  12600. /**
  12601. * Represents an Dual Shock controller
  12602. */
  12603. static DUALSHOCK: number;
  12604. /**
  12605. * Specifies whether the left control stick should be Y-inverted
  12606. */
  12607. protected _invertLeftStickY: boolean;
  12608. /**
  12609. * Specifies if the gamepad has been connected
  12610. */
  12611. readonly isConnected: boolean;
  12612. /**
  12613. * Initializes the gamepad
  12614. * @param id The id of the gamepad
  12615. * @param index The index of the gamepad
  12616. * @param browserGamepad The browser gamepad
  12617. * @param leftStickX The x component of the left joystick
  12618. * @param leftStickY The y component of the left joystick
  12619. * @param rightStickX The x component of the right joystick
  12620. * @param rightStickY The y component of the right joystick
  12621. */
  12622. constructor(
  12623. /**
  12624. * The id of the gamepad
  12625. */
  12626. id: string,
  12627. /**
  12628. * The index of the gamepad
  12629. */
  12630. index: number,
  12631. /**
  12632. * The browser gamepad
  12633. */
  12634. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12635. /**
  12636. * Callback triggered when the left joystick has changed
  12637. * @param callback
  12638. */
  12639. onleftstickchanged(callback: (values: StickValues) => void): void;
  12640. /**
  12641. * Callback triggered when the right joystick has changed
  12642. * @param callback
  12643. */
  12644. onrightstickchanged(callback: (values: StickValues) => void): void;
  12645. /**
  12646. * Gets the left joystick
  12647. */
  12648. /**
  12649. * Sets the left joystick values
  12650. */
  12651. leftStick: StickValues;
  12652. /**
  12653. * Gets the right joystick
  12654. */
  12655. /**
  12656. * Sets the right joystick value
  12657. */
  12658. rightStick: StickValues;
  12659. /**
  12660. * Updates the gamepad joystick positions
  12661. */
  12662. update(): void;
  12663. /**
  12664. * Disposes the gamepad
  12665. */
  12666. dispose(): void;
  12667. }
  12668. /**
  12669. * Represents a generic gamepad
  12670. */
  12671. export class GenericPad extends Gamepad {
  12672. private _buttons;
  12673. private _onbuttondown;
  12674. private _onbuttonup;
  12675. /**
  12676. * Observable triggered when a button has been pressed
  12677. */
  12678. onButtonDownObservable: Observable<number>;
  12679. /**
  12680. * Observable triggered when a button has been released
  12681. */
  12682. onButtonUpObservable: Observable<number>;
  12683. /**
  12684. * Callback triggered when a button has been pressed
  12685. * @param callback Called when a button has been pressed
  12686. */
  12687. onbuttondown(callback: (buttonPressed: number) => void): void;
  12688. /**
  12689. * Callback triggered when a button has been released
  12690. * @param callback Called when a button has been released
  12691. */
  12692. onbuttonup(callback: (buttonReleased: number) => void): void;
  12693. /**
  12694. * Initializes the generic gamepad
  12695. * @param id The id of the generic gamepad
  12696. * @param index The index of the generic gamepad
  12697. * @param browserGamepad The browser gamepad
  12698. */
  12699. constructor(id: string, index: number, browserGamepad: any);
  12700. private _setButtonValue;
  12701. /**
  12702. * Updates the generic gamepad
  12703. */
  12704. update(): void;
  12705. /**
  12706. * Disposes the generic gamepad
  12707. */
  12708. dispose(): void;
  12709. }
  12710. }
  12711. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12712. import { Nullable } from "babylonjs/types";
  12713. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12714. import { Scene } from "babylonjs/scene";
  12715. module "babylonjs/Engines/engine" {
  12716. interface Engine {
  12717. /**
  12718. * Creates a raw texture
  12719. * @param data defines the data to store in the texture
  12720. * @param width defines the width of the texture
  12721. * @param height defines the height of the texture
  12722. * @param format defines the format of the data
  12723. * @param generateMipMaps defines if the engine should generate the mip levels
  12724. * @param invertY defines if data must be stored with Y axis inverted
  12725. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12726. * @param compression defines the compression used (null by default)
  12727. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12728. * @returns the raw texture inside an InternalTexture
  12729. */
  12730. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12731. /**
  12732. * Update a raw texture
  12733. * @param texture defines the texture to update
  12734. * @param data defines the data to store in the texture
  12735. * @param format defines the format of the data
  12736. * @param invertY defines if data must be stored with Y axis inverted
  12737. */
  12738. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12739. /**
  12740. * Update a raw texture
  12741. * @param texture defines the texture to update
  12742. * @param data defines the data to store in the texture
  12743. * @param format defines the format of the data
  12744. * @param invertY defines if data must be stored with Y axis inverted
  12745. * @param compression defines the compression used (null by default)
  12746. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12747. */
  12748. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12749. /**
  12750. * Creates a new raw cube texture
  12751. * @param data defines the array of data to use to create each face
  12752. * @param size defines the size of the textures
  12753. * @param format defines the format of the data
  12754. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12755. * @param generateMipMaps defines if the engine should generate the mip levels
  12756. * @param invertY defines if data must be stored with Y axis inverted
  12757. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12758. * @param compression defines the compression used (null by default)
  12759. * @returns the cube texture as an InternalTexture
  12760. */
  12761. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12762. /**
  12763. * Update a raw cube texture
  12764. * @param texture defines the texture to udpdate
  12765. * @param data defines the data to store
  12766. * @param format defines the data format
  12767. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12768. * @param invertY defines if data must be stored with Y axis inverted
  12769. */
  12770. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12771. /**
  12772. * Update a raw cube texture
  12773. * @param texture defines the texture to udpdate
  12774. * @param data defines the data to store
  12775. * @param format defines the data format
  12776. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12777. * @param invertY defines if data must be stored with Y axis inverted
  12778. * @param compression defines the compression used (null by default)
  12779. */
  12780. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12781. /**
  12782. * Update a raw cube texture
  12783. * @param texture defines the texture to udpdate
  12784. * @param data defines the data to store
  12785. * @param format defines the data format
  12786. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12787. * @param invertY defines if data must be stored with Y axis inverted
  12788. * @param compression defines the compression used (null by default)
  12789. * @param level defines which level of the texture to update
  12790. */
  12791. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12792. /**
  12793. * Creates a new raw cube texture from a specified url
  12794. * @param url defines the url where the data is located
  12795. * @param scene defines the current scene
  12796. * @param size defines the size of the textures
  12797. * @param format defines the format of the data
  12798. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12799. * @param noMipmap defines if the engine should avoid generating the mip levels
  12800. * @param callback defines a callback used to extract texture data from loaded data
  12801. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12802. * @param onLoad defines a callback called when texture is loaded
  12803. * @param onError defines a callback called if there is an error
  12804. * @returns the cube texture as an InternalTexture
  12805. */
  12806. 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;
  12807. /**
  12808. * Creates a new raw cube texture from a specified url
  12809. * @param url defines the url where the data is located
  12810. * @param scene defines the current scene
  12811. * @param size defines the size of the textures
  12812. * @param format defines the format of the data
  12813. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12814. * @param noMipmap defines if the engine should avoid generating the mip levels
  12815. * @param callback defines a callback used to extract texture data from loaded data
  12816. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12817. * @param onLoad defines a callback called when texture is loaded
  12818. * @param onError defines a callback called if there is an error
  12819. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12820. * @param invertY defines if data must be stored with Y axis inverted
  12821. * @returns the cube texture as an InternalTexture
  12822. */
  12823. 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;
  12824. /**
  12825. * Creates a new raw 3D texture
  12826. * @param data defines the data used to create the texture
  12827. * @param width defines the width of the texture
  12828. * @param height defines the height of the texture
  12829. * @param depth defines the depth of the texture
  12830. * @param format defines the format of the texture
  12831. * @param generateMipMaps defines if the engine must generate mip levels
  12832. * @param invertY defines if data must be stored with Y axis inverted
  12833. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12834. * @param compression defines the compressed used (can be null)
  12835. * @param textureType defines the compressed used (can be null)
  12836. * @returns a new raw 3D texture (stored in an InternalTexture)
  12837. */
  12838. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12839. /**
  12840. * Update a raw 3D texture
  12841. * @param texture defines the texture to update
  12842. * @param data defines the data to store
  12843. * @param format defines the data format
  12844. * @param invertY defines if data must be stored with Y axis inverted
  12845. */
  12846. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12847. /**
  12848. * Update a raw 3D texture
  12849. * @param texture defines the texture to update
  12850. * @param data defines the data to store
  12851. * @param format defines the data format
  12852. * @param invertY defines if data must be stored with Y axis inverted
  12853. * @param compression defines the used compression (can be null)
  12854. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12855. */
  12856. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12857. /**
  12858. * Creates a new raw 2D array texture
  12859. * @param data defines the data used to create the texture
  12860. * @param width defines the width of the texture
  12861. * @param height defines the height of the texture
  12862. * @param depth defines the number of layers of the texture
  12863. * @param format defines the format of the texture
  12864. * @param generateMipMaps defines if the engine must generate mip levels
  12865. * @param invertY defines if data must be stored with Y axis inverted
  12866. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12867. * @param compression defines the compressed used (can be null)
  12868. * @param textureType defines the compressed used (can be null)
  12869. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12870. */
  12871. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12872. /**
  12873. * Update a raw 2D array texture
  12874. * @param texture defines the texture to update
  12875. * @param data defines the data to store
  12876. * @param format defines the data format
  12877. * @param invertY defines if data must be stored with Y axis inverted
  12878. */
  12879. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12880. /**
  12881. * Update a raw 2D array texture
  12882. * @param texture defines the texture to update
  12883. * @param data defines the data to store
  12884. * @param format defines the data format
  12885. * @param invertY defines if data must be stored with Y axis inverted
  12886. * @param compression defines the used compression (can be null)
  12887. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12888. */
  12889. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12890. }
  12891. }
  12892. }
  12893. declare module "babylonjs/Materials/Textures/rawTexture" {
  12894. import { Scene } from "babylonjs/scene";
  12895. import { Texture } from "babylonjs/Materials/Textures/texture";
  12896. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12897. /**
  12898. * Raw texture can help creating a texture directly from an array of data.
  12899. * This can be super useful if you either get the data from an uncompressed source or
  12900. * if you wish to create your texture pixel by pixel.
  12901. */
  12902. export class RawTexture extends Texture {
  12903. /**
  12904. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12905. */
  12906. format: number;
  12907. private _engine;
  12908. /**
  12909. * Instantiates a new RawTexture.
  12910. * Raw texture can help creating a texture directly from an array of data.
  12911. * This can be super useful if you either get the data from an uncompressed source or
  12912. * if you wish to create your texture pixel by pixel.
  12913. * @param data define the array of data to use to create the texture
  12914. * @param width define the width of the texture
  12915. * @param height define the height of the texture
  12916. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12917. * @param scene define the scene the texture belongs to
  12918. * @param generateMipMaps define whether mip maps should be generated or not
  12919. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12920. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12921. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12922. */
  12923. constructor(data: ArrayBufferView, width: number, height: number,
  12924. /**
  12925. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12926. */
  12927. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12928. /**
  12929. * Updates the texture underlying data.
  12930. * @param data Define the new data of the texture
  12931. */
  12932. update(data: ArrayBufferView): void;
  12933. /**
  12934. * Creates a luminance texture from some data.
  12935. * @param data Define the texture data
  12936. * @param width Define the width of the texture
  12937. * @param height Define the height of the texture
  12938. * @param scene Define the scene the texture belongs to
  12939. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12940. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12941. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12942. * @returns the luminance texture
  12943. */
  12944. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12945. /**
  12946. * Creates a luminance alpha texture from some data.
  12947. * @param data Define the texture data
  12948. * @param width Define the width of the texture
  12949. * @param height Define the height of the texture
  12950. * @param scene Define the scene the texture belongs to
  12951. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12952. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12953. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12954. * @returns the luminance alpha texture
  12955. */
  12956. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12957. /**
  12958. * Creates an alpha texture from some data.
  12959. * @param data Define the texture data
  12960. * @param width Define the width of the texture
  12961. * @param height Define the height of the texture
  12962. * @param scene Define the scene the texture belongs to
  12963. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12964. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12965. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12966. * @returns the alpha texture
  12967. */
  12968. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12969. /**
  12970. * Creates a RGB texture from some data.
  12971. * @param data Define the texture data
  12972. * @param width Define the width of the texture
  12973. * @param height Define the height of the texture
  12974. * @param scene Define the scene the texture belongs to
  12975. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12976. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12977. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12978. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12979. * @returns the RGB alpha texture
  12980. */
  12981. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12982. /**
  12983. * Creates a RGBA texture from some data.
  12984. * @param data Define the texture data
  12985. * @param width Define the width of the texture
  12986. * @param height Define the height of the texture
  12987. * @param scene Define the scene the texture belongs to
  12988. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12989. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12990. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12991. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12992. * @returns the RGBA texture
  12993. */
  12994. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12995. /**
  12996. * Creates a R texture from some data.
  12997. * @param data Define the texture data
  12998. * @param width Define the width of the texture
  12999. * @param height Define the height of the texture
  13000. * @param scene Define the scene the texture belongs to
  13001. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13002. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13003. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13004. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13005. * @returns the R texture
  13006. */
  13007. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13008. }
  13009. }
  13010. declare module "babylonjs/Maths/math.size" {
  13011. /**
  13012. * Interface for the size containing width and height
  13013. */
  13014. export interface ISize {
  13015. /**
  13016. * Width
  13017. */
  13018. width: number;
  13019. /**
  13020. * Heighht
  13021. */
  13022. height: number;
  13023. }
  13024. /**
  13025. * Size containing widht and height
  13026. */
  13027. export class Size implements ISize {
  13028. /**
  13029. * Width
  13030. */
  13031. width: number;
  13032. /**
  13033. * Height
  13034. */
  13035. height: number;
  13036. /**
  13037. * Creates a Size object from the given width and height (floats).
  13038. * @param width width of the new size
  13039. * @param height height of the new size
  13040. */
  13041. constructor(width: number, height: number);
  13042. /**
  13043. * Returns a string with the Size width and height
  13044. * @returns a string with the Size width and height
  13045. */
  13046. toString(): string;
  13047. /**
  13048. * "Size"
  13049. * @returns the string "Size"
  13050. */
  13051. getClassName(): string;
  13052. /**
  13053. * Returns the Size hash code.
  13054. * @returns a hash code for a unique width and height
  13055. */
  13056. getHashCode(): number;
  13057. /**
  13058. * Updates the current size from the given one.
  13059. * @param src the given size
  13060. */
  13061. copyFrom(src: Size): void;
  13062. /**
  13063. * Updates in place the current Size from the given floats.
  13064. * @param width width of the new size
  13065. * @param height height of the new size
  13066. * @returns the updated Size.
  13067. */
  13068. copyFromFloats(width: number, height: number): Size;
  13069. /**
  13070. * Updates in place the current Size from the given floats.
  13071. * @param width width to set
  13072. * @param height height to set
  13073. * @returns the updated Size.
  13074. */
  13075. set(width: number, height: number): Size;
  13076. /**
  13077. * Multiplies the width and height by numbers
  13078. * @param w factor to multiple the width by
  13079. * @param h factor to multiple the height by
  13080. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  13081. */
  13082. multiplyByFloats(w: number, h: number): Size;
  13083. /**
  13084. * Clones the size
  13085. * @returns a new Size copied from the given one.
  13086. */
  13087. clone(): Size;
  13088. /**
  13089. * True if the current Size and the given one width and height are strictly equal.
  13090. * @param other the other size to compare against
  13091. * @returns True if the current Size and the given one width and height are strictly equal.
  13092. */
  13093. equals(other: Size): boolean;
  13094. /**
  13095. * The surface of the Size : width * height (float).
  13096. */
  13097. readonly surface: number;
  13098. /**
  13099. * Create a new size of zero
  13100. * @returns a new Size set to (0.0, 0.0)
  13101. */
  13102. static Zero(): Size;
  13103. /**
  13104. * Sums the width and height of two sizes
  13105. * @param otherSize size to add to this size
  13106. * @returns a new Size set as the addition result of the current Size and the given one.
  13107. */
  13108. add(otherSize: Size): Size;
  13109. /**
  13110. * Subtracts the width and height of two
  13111. * @param otherSize size to subtract to this size
  13112. * @returns a new Size set as the subtraction result of the given one from the current Size.
  13113. */
  13114. subtract(otherSize: Size): Size;
  13115. /**
  13116. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  13117. * @param start starting size to lerp between
  13118. * @param end end size to lerp between
  13119. * @param amount amount to lerp between the start and end values
  13120. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  13121. */
  13122. static Lerp(start: Size, end: Size, amount: number): Size;
  13123. }
  13124. }
  13125. declare module "babylonjs/Animations/runtimeAnimation" {
  13126. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  13127. import { Animatable } from "babylonjs/Animations/animatable";
  13128. import { Scene } from "babylonjs/scene";
  13129. /**
  13130. * Defines a runtime animation
  13131. */
  13132. export class RuntimeAnimation {
  13133. private _events;
  13134. /**
  13135. * The current frame of the runtime animation
  13136. */
  13137. private _currentFrame;
  13138. /**
  13139. * The animation used by the runtime animation
  13140. */
  13141. private _animation;
  13142. /**
  13143. * The target of the runtime animation
  13144. */
  13145. private _target;
  13146. /**
  13147. * The initiating animatable
  13148. */
  13149. private _host;
  13150. /**
  13151. * The original value of the runtime animation
  13152. */
  13153. private _originalValue;
  13154. /**
  13155. * The original blend value of the runtime animation
  13156. */
  13157. private _originalBlendValue;
  13158. /**
  13159. * The offsets cache of the runtime animation
  13160. */
  13161. private _offsetsCache;
  13162. /**
  13163. * The high limits cache of the runtime animation
  13164. */
  13165. private _highLimitsCache;
  13166. /**
  13167. * Specifies if the runtime animation has been stopped
  13168. */
  13169. private _stopped;
  13170. /**
  13171. * The blending factor of the runtime animation
  13172. */
  13173. private _blendingFactor;
  13174. /**
  13175. * The BabylonJS scene
  13176. */
  13177. private _scene;
  13178. /**
  13179. * The current value of the runtime animation
  13180. */
  13181. private _currentValue;
  13182. /** @hidden */
  13183. _animationState: _IAnimationState;
  13184. /**
  13185. * The active target of the runtime animation
  13186. */
  13187. private _activeTargets;
  13188. private _currentActiveTarget;
  13189. private _directTarget;
  13190. /**
  13191. * The target path of the runtime animation
  13192. */
  13193. private _targetPath;
  13194. /**
  13195. * The weight of the runtime animation
  13196. */
  13197. private _weight;
  13198. /**
  13199. * The ratio offset of the runtime animation
  13200. */
  13201. private _ratioOffset;
  13202. /**
  13203. * The previous delay of the runtime animation
  13204. */
  13205. private _previousDelay;
  13206. /**
  13207. * The previous ratio of the runtime animation
  13208. */
  13209. private _previousRatio;
  13210. private _enableBlending;
  13211. private _keys;
  13212. private _minFrame;
  13213. private _maxFrame;
  13214. private _minValue;
  13215. private _maxValue;
  13216. private _targetIsArray;
  13217. /**
  13218. * Gets the current frame of the runtime animation
  13219. */
  13220. readonly currentFrame: number;
  13221. /**
  13222. * Gets the weight of the runtime animation
  13223. */
  13224. readonly weight: number;
  13225. /**
  13226. * Gets the current value of the runtime animation
  13227. */
  13228. readonly currentValue: any;
  13229. /**
  13230. * Gets the target path of the runtime animation
  13231. */
  13232. readonly targetPath: string;
  13233. /**
  13234. * Gets the actual target of the runtime animation
  13235. */
  13236. readonly target: any;
  13237. /** @hidden */
  13238. _onLoop: () => void;
  13239. /**
  13240. * Create a new RuntimeAnimation object
  13241. * @param target defines the target of the animation
  13242. * @param animation defines the source animation object
  13243. * @param scene defines the hosting scene
  13244. * @param host defines the initiating Animatable
  13245. */
  13246. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13247. private _preparePath;
  13248. /**
  13249. * Gets the animation from the runtime animation
  13250. */
  13251. readonly animation: Animation;
  13252. /**
  13253. * Resets the runtime animation to the beginning
  13254. * @param restoreOriginal defines whether to restore the target property to the original value
  13255. */
  13256. reset(restoreOriginal?: boolean): void;
  13257. /**
  13258. * Specifies if the runtime animation is stopped
  13259. * @returns Boolean specifying if the runtime animation is stopped
  13260. */
  13261. isStopped(): boolean;
  13262. /**
  13263. * Disposes of the runtime animation
  13264. */
  13265. dispose(): void;
  13266. /**
  13267. * Apply the interpolated value to the target
  13268. * @param currentValue defines the value computed by the animation
  13269. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13270. */
  13271. setValue(currentValue: any, weight: number): void;
  13272. private _getOriginalValues;
  13273. private _setValue;
  13274. /**
  13275. * Gets the loop pmode of the runtime animation
  13276. * @returns Loop Mode
  13277. */
  13278. private _getCorrectLoopMode;
  13279. /**
  13280. * Move the current animation to a given frame
  13281. * @param frame defines the frame to move to
  13282. */
  13283. goToFrame(frame: number): void;
  13284. /**
  13285. * @hidden Internal use only
  13286. */
  13287. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13288. /**
  13289. * Execute the current animation
  13290. * @param delay defines the delay to add to the current frame
  13291. * @param from defines the lower bound of the animation range
  13292. * @param to defines the upper bound of the animation range
  13293. * @param loop defines if the current animation must loop
  13294. * @param speedRatio defines the current speed ratio
  13295. * @param weight defines the weight of the animation (default is -1 so no weight)
  13296. * @param onLoop optional callback called when animation loops
  13297. * @returns a boolean indicating if the animation is running
  13298. */
  13299. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13300. }
  13301. }
  13302. declare module "babylonjs/Animations/animatable" {
  13303. import { Animation } from "babylonjs/Animations/animation";
  13304. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13305. import { Nullable } from "babylonjs/types";
  13306. import { Observable } from "babylonjs/Misc/observable";
  13307. import { Scene } from "babylonjs/scene";
  13308. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13309. import { Node } from "babylonjs/node";
  13310. /**
  13311. * Class used to store an actual running animation
  13312. */
  13313. export class Animatable {
  13314. /** defines the target object */
  13315. target: any;
  13316. /** defines the starting frame number (default is 0) */
  13317. fromFrame: number;
  13318. /** defines the ending frame number (default is 100) */
  13319. toFrame: number;
  13320. /** defines if the animation must loop (default is false) */
  13321. loopAnimation: boolean;
  13322. /** defines a callback to call when animation ends if it is not looping */
  13323. onAnimationEnd?: (() => void) | null | undefined;
  13324. /** defines a callback to call when animation loops */
  13325. onAnimationLoop?: (() => void) | null | undefined;
  13326. private _localDelayOffset;
  13327. private _pausedDelay;
  13328. private _runtimeAnimations;
  13329. private _paused;
  13330. private _scene;
  13331. private _speedRatio;
  13332. private _weight;
  13333. private _syncRoot;
  13334. /**
  13335. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13336. * This will only apply for non looping animation (default is true)
  13337. */
  13338. disposeOnEnd: boolean;
  13339. /**
  13340. * Gets a boolean indicating if the animation has started
  13341. */
  13342. animationStarted: boolean;
  13343. /**
  13344. * Observer raised when the animation ends
  13345. */
  13346. onAnimationEndObservable: Observable<Animatable>;
  13347. /**
  13348. * Observer raised when the animation loops
  13349. */
  13350. onAnimationLoopObservable: Observable<Animatable>;
  13351. /**
  13352. * Gets the root Animatable used to synchronize and normalize animations
  13353. */
  13354. readonly syncRoot: Nullable<Animatable>;
  13355. /**
  13356. * Gets the current frame of the first RuntimeAnimation
  13357. * Used to synchronize Animatables
  13358. */
  13359. readonly masterFrame: number;
  13360. /**
  13361. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13362. */
  13363. weight: number;
  13364. /**
  13365. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13366. */
  13367. speedRatio: number;
  13368. /**
  13369. * Creates a new Animatable
  13370. * @param scene defines the hosting scene
  13371. * @param target defines the target object
  13372. * @param fromFrame defines the starting frame number (default is 0)
  13373. * @param toFrame defines the ending frame number (default is 100)
  13374. * @param loopAnimation defines if the animation must loop (default is false)
  13375. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13376. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13377. * @param animations defines a group of animation to add to the new Animatable
  13378. * @param onAnimationLoop defines a callback to call when animation loops
  13379. */
  13380. constructor(scene: Scene,
  13381. /** defines the target object */
  13382. target: any,
  13383. /** defines the starting frame number (default is 0) */
  13384. fromFrame?: number,
  13385. /** defines the ending frame number (default is 100) */
  13386. toFrame?: number,
  13387. /** defines if the animation must loop (default is false) */
  13388. loopAnimation?: boolean, speedRatio?: number,
  13389. /** defines a callback to call when animation ends if it is not looping */
  13390. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13391. /** defines a callback to call when animation loops */
  13392. onAnimationLoop?: (() => void) | null | undefined);
  13393. /**
  13394. * Synchronize and normalize current Animatable with a source Animatable
  13395. * This is useful when using animation weights and when animations are not of the same length
  13396. * @param root defines the root Animatable to synchronize with
  13397. * @returns the current Animatable
  13398. */
  13399. syncWith(root: Animatable): Animatable;
  13400. /**
  13401. * Gets the list of runtime animations
  13402. * @returns an array of RuntimeAnimation
  13403. */
  13404. getAnimations(): RuntimeAnimation[];
  13405. /**
  13406. * Adds more animations to the current animatable
  13407. * @param target defines the target of the animations
  13408. * @param animations defines the new animations to add
  13409. */
  13410. appendAnimations(target: any, animations: Animation[]): void;
  13411. /**
  13412. * Gets the source animation for a specific property
  13413. * @param property defines the propertyu to look for
  13414. * @returns null or the source animation for the given property
  13415. */
  13416. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13417. /**
  13418. * Gets the runtime animation for a specific property
  13419. * @param property defines the propertyu to look for
  13420. * @returns null or the runtime animation for the given property
  13421. */
  13422. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13423. /**
  13424. * Resets the animatable to its original state
  13425. */
  13426. reset(): void;
  13427. /**
  13428. * Allows the animatable to blend with current running animations
  13429. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13430. * @param blendingSpeed defines the blending speed to use
  13431. */
  13432. enableBlending(blendingSpeed: number): void;
  13433. /**
  13434. * Disable animation blending
  13435. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13436. */
  13437. disableBlending(): void;
  13438. /**
  13439. * Jump directly to a given frame
  13440. * @param frame defines the frame to jump to
  13441. */
  13442. goToFrame(frame: number): void;
  13443. /**
  13444. * Pause the animation
  13445. */
  13446. pause(): void;
  13447. /**
  13448. * Restart the animation
  13449. */
  13450. restart(): void;
  13451. private _raiseOnAnimationEnd;
  13452. /**
  13453. * Stop and delete the current animation
  13454. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13455. * @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)
  13456. */
  13457. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13458. /**
  13459. * Wait asynchronously for the animation to end
  13460. * @returns a promise which will be fullfilled when the animation ends
  13461. */
  13462. waitAsync(): Promise<Animatable>;
  13463. /** @hidden */
  13464. _animate(delay: number): boolean;
  13465. }
  13466. module "babylonjs/scene" {
  13467. interface Scene {
  13468. /** @hidden */
  13469. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13470. /** @hidden */
  13471. _processLateAnimationBindingsForMatrices(holder: {
  13472. totalWeight: number;
  13473. animations: RuntimeAnimation[];
  13474. originalValue: Matrix;
  13475. }): any;
  13476. /** @hidden */
  13477. _processLateAnimationBindingsForQuaternions(holder: {
  13478. totalWeight: number;
  13479. animations: RuntimeAnimation[];
  13480. originalValue: Quaternion;
  13481. }, refQuaternion: Quaternion): Quaternion;
  13482. /** @hidden */
  13483. _processLateAnimationBindings(): void;
  13484. /**
  13485. * Will start the animation sequence of a given target
  13486. * @param target defines the target
  13487. * @param from defines from which frame should animation start
  13488. * @param to defines until which frame should animation run.
  13489. * @param weight defines the weight to apply to the animation (1.0 by default)
  13490. * @param loop defines if the animation loops
  13491. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13492. * @param onAnimationEnd defines the function to be executed when the animation ends
  13493. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13494. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13495. * @param onAnimationLoop defines the callback to call when an animation loops
  13496. * @returns the animatable object created for this animation
  13497. */
  13498. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13499. /**
  13500. * Will start the animation sequence of a given target
  13501. * @param target defines the target
  13502. * @param from defines from which frame should animation start
  13503. * @param to defines until which frame should animation run.
  13504. * @param loop defines if the animation loops
  13505. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13506. * @param onAnimationEnd defines the function to be executed when the animation ends
  13507. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13508. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13509. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13510. * @param onAnimationLoop defines the callback to call when an animation loops
  13511. * @returns the animatable object created for this animation
  13512. */
  13513. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13514. /**
  13515. * Will start the animation sequence of a given target and its hierarchy
  13516. * @param target defines the target
  13517. * @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.
  13518. * @param from defines from which frame should animation start
  13519. * @param to defines until which frame should animation run.
  13520. * @param loop defines if the animation loops
  13521. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13522. * @param onAnimationEnd defines the function to be executed when the animation ends
  13523. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13524. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13525. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13526. * @param onAnimationLoop defines the callback to call when an animation loops
  13527. * @returns the list of created animatables
  13528. */
  13529. 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[];
  13530. /**
  13531. * Begin a new animation on a given node
  13532. * @param target defines the target where the animation will take place
  13533. * @param animations defines the list of animations to start
  13534. * @param from defines the initial value
  13535. * @param to defines the final value
  13536. * @param loop defines if you want animation to loop (off by default)
  13537. * @param speedRatio defines the speed ratio to apply to all animations
  13538. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13539. * @param onAnimationLoop defines the callback to call when an animation loops
  13540. * @returns the list of created animatables
  13541. */
  13542. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13543. /**
  13544. * Begin a new animation on a given node and its hierarchy
  13545. * @param target defines the root node where the animation will take place
  13546. * @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.
  13547. * @param animations defines the list of animations to start
  13548. * @param from defines the initial value
  13549. * @param to defines the final value
  13550. * @param loop defines if you want animation to loop (off by default)
  13551. * @param speedRatio defines the speed ratio to apply to all animations
  13552. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13553. * @param onAnimationLoop defines the callback to call when an animation loops
  13554. * @returns the list of animatables created for all nodes
  13555. */
  13556. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13557. /**
  13558. * Gets the animatable associated with a specific target
  13559. * @param target defines the target of the animatable
  13560. * @returns the required animatable if found
  13561. */
  13562. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13563. /**
  13564. * Gets all animatables associated with a given target
  13565. * @param target defines the target to look animatables for
  13566. * @returns an array of Animatables
  13567. */
  13568. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13569. /**
  13570. * Stops and removes all animations that have been applied to the scene
  13571. */
  13572. stopAllAnimations(): void;
  13573. /**
  13574. * Gets the current delta time used by animation engine
  13575. */
  13576. deltaTime: number;
  13577. }
  13578. }
  13579. module "babylonjs/Bones/bone" {
  13580. interface Bone {
  13581. /**
  13582. * Copy an animation range from another bone
  13583. * @param source defines the source bone
  13584. * @param rangeName defines the range name to copy
  13585. * @param frameOffset defines the frame offset
  13586. * @param rescaleAsRequired defines if rescaling must be applied if required
  13587. * @param skelDimensionsRatio defines the scaling ratio
  13588. * @returns true if operation was successful
  13589. */
  13590. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13591. }
  13592. }
  13593. }
  13594. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13595. /**
  13596. * Class used to override all child animations of a given target
  13597. */
  13598. export class AnimationPropertiesOverride {
  13599. /**
  13600. * Gets or sets a value indicating if animation blending must be used
  13601. */
  13602. enableBlending: boolean;
  13603. /**
  13604. * Gets or sets the blending speed to use when enableBlending is true
  13605. */
  13606. blendingSpeed: number;
  13607. /**
  13608. * Gets or sets the default loop mode to use
  13609. */
  13610. loopMode: number;
  13611. }
  13612. }
  13613. declare module "babylonjs/Bones/skeleton" {
  13614. import { Bone } from "babylonjs/Bones/bone";
  13615. import { Observable } from "babylonjs/Misc/observable";
  13616. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13617. import { Scene } from "babylonjs/scene";
  13618. import { Nullable } from "babylonjs/types";
  13619. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13620. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13621. import { Animatable } from "babylonjs/Animations/animatable";
  13622. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13623. import { Animation } from "babylonjs/Animations/animation";
  13624. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13625. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13626. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13627. /**
  13628. * Class used to handle skinning animations
  13629. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13630. */
  13631. export class Skeleton implements IAnimatable {
  13632. /** defines the skeleton name */
  13633. name: string;
  13634. /** defines the skeleton Id */
  13635. id: string;
  13636. /**
  13637. * Defines the list of child bones
  13638. */
  13639. bones: Bone[];
  13640. /**
  13641. * Defines an estimate of the dimension of the skeleton at rest
  13642. */
  13643. dimensionsAtRest: Vector3;
  13644. /**
  13645. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13646. */
  13647. needInitialSkinMatrix: boolean;
  13648. /**
  13649. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13650. */
  13651. overrideMesh: Nullable<AbstractMesh>;
  13652. /**
  13653. * Gets the list of animations attached to this skeleton
  13654. */
  13655. animations: Array<Animation>;
  13656. private _scene;
  13657. private _isDirty;
  13658. private _transformMatrices;
  13659. private _transformMatrixTexture;
  13660. private _meshesWithPoseMatrix;
  13661. private _animatables;
  13662. private _identity;
  13663. private _synchronizedWithMesh;
  13664. private _ranges;
  13665. private _lastAbsoluteTransformsUpdateId;
  13666. private _canUseTextureForBones;
  13667. private _uniqueId;
  13668. /** @hidden */
  13669. _numBonesWithLinkedTransformNode: number;
  13670. /** @hidden */
  13671. _hasWaitingData: Nullable<boolean>;
  13672. /**
  13673. * Specifies if the skeleton should be serialized
  13674. */
  13675. doNotSerialize: boolean;
  13676. private _useTextureToStoreBoneMatrices;
  13677. /**
  13678. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13679. * Please note that this option is not available if the hardware does not support it
  13680. */
  13681. useTextureToStoreBoneMatrices: boolean;
  13682. private _animationPropertiesOverride;
  13683. /**
  13684. * Gets or sets the animation properties override
  13685. */
  13686. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13687. /**
  13688. * List of inspectable custom properties (used by the Inspector)
  13689. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13690. */
  13691. inspectableCustomProperties: IInspectable[];
  13692. /**
  13693. * An observable triggered before computing the skeleton's matrices
  13694. */
  13695. onBeforeComputeObservable: Observable<Skeleton>;
  13696. /**
  13697. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13698. */
  13699. readonly isUsingTextureForMatrices: boolean;
  13700. /**
  13701. * Gets the unique ID of this skeleton
  13702. */
  13703. readonly uniqueId: number;
  13704. /**
  13705. * Creates a new skeleton
  13706. * @param name defines the skeleton name
  13707. * @param id defines the skeleton Id
  13708. * @param scene defines the hosting scene
  13709. */
  13710. constructor(
  13711. /** defines the skeleton name */
  13712. name: string,
  13713. /** defines the skeleton Id */
  13714. id: string, scene: Scene);
  13715. /**
  13716. * Gets the current object class name.
  13717. * @return the class name
  13718. */
  13719. getClassName(): string;
  13720. /**
  13721. * Returns an array containing the root bones
  13722. * @returns an array containing the root bones
  13723. */
  13724. getChildren(): Array<Bone>;
  13725. /**
  13726. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13727. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13728. * @returns a Float32Array containing matrices data
  13729. */
  13730. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13731. /**
  13732. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13733. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13734. * @returns a raw texture containing the data
  13735. */
  13736. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13737. /**
  13738. * Gets the current hosting scene
  13739. * @returns a scene object
  13740. */
  13741. getScene(): Scene;
  13742. /**
  13743. * Gets a string representing the current skeleton data
  13744. * @param fullDetails defines a boolean indicating if we want a verbose version
  13745. * @returns a string representing the current skeleton data
  13746. */
  13747. toString(fullDetails?: boolean): string;
  13748. /**
  13749. * Get bone's index searching by name
  13750. * @param name defines bone's name to search for
  13751. * @return the indice of the bone. Returns -1 if not found
  13752. */
  13753. getBoneIndexByName(name: string): number;
  13754. /**
  13755. * Creater a new animation range
  13756. * @param name defines the name of the range
  13757. * @param from defines the start key
  13758. * @param to defines the end key
  13759. */
  13760. createAnimationRange(name: string, from: number, to: number): void;
  13761. /**
  13762. * Delete a specific animation range
  13763. * @param name defines the name of the range
  13764. * @param deleteFrames defines if frames must be removed as well
  13765. */
  13766. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13767. /**
  13768. * Gets a specific animation range
  13769. * @param name defines the name of the range to look for
  13770. * @returns the requested animation range or null if not found
  13771. */
  13772. getAnimationRange(name: string): Nullable<AnimationRange>;
  13773. /**
  13774. * Gets the list of all animation ranges defined on this skeleton
  13775. * @returns an array
  13776. */
  13777. getAnimationRanges(): Nullable<AnimationRange>[];
  13778. /**
  13779. * Copy animation range from a source skeleton.
  13780. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13781. * @param source defines the source skeleton
  13782. * @param name defines the name of the range to copy
  13783. * @param rescaleAsRequired defines if rescaling must be applied if required
  13784. * @returns true if operation was successful
  13785. */
  13786. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13787. /**
  13788. * Forces the skeleton to go to rest pose
  13789. */
  13790. returnToRest(): void;
  13791. private _getHighestAnimationFrame;
  13792. /**
  13793. * Begin a specific animation range
  13794. * @param name defines the name of the range to start
  13795. * @param loop defines if looping must be turned on (false by default)
  13796. * @param speedRatio defines the speed ratio to apply (1 by default)
  13797. * @param onAnimationEnd defines a callback which will be called when animation will end
  13798. * @returns a new animatable
  13799. */
  13800. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13801. /** @hidden */
  13802. _markAsDirty(): void;
  13803. /** @hidden */
  13804. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13805. /** @hidden */
  13806. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13807. private _computeTransformMatrices;
  13808. /**
  13809. * Build all resources required to render a skeleton
  13810. */
  13811. prepare(): void;
  13812. /**
  13813. * Gets the list of animatables currently running for this skeleton
  13814. * @returns an array of animatables
  13815. */
  13816. getAnimatables(): IAnimatable[];
  13817. /**
  13818. * Clone the current skeleton
  13819. * @param name defines the name of the new skeleton
  13820. * @param id defines the id of the new skeleton
  13821. * @returns the new skeleton
  13822. */
  13823. clone(name: string, id?: string): Skeleton;
  13824. /**
  13825. * Enable animation blending for this skeleton
  13826. * @param blendingSpeed defines the blending speed to apply
  13827. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13828. */
  13829. enableBlending(blendingSpeed?: number): void;
  13830. /**
  13831. * Releases all resources associated with the current skeleton
  13832. */
  13833. dispose(): void;
  13834. /**
  13835. * Serialize the skeleton in a JSON object
  13836. * @returns a JSON object
  13837. */
  13838. serialize(): any;
  13839. /**
  13840. * Creates a new skeleton from serialized data
  13841. * @param parsedSkeleton defines the serialized data
  13842. * @param scene defines the hosting scene
  13843. * @returns a new skeleton
  13844. */
  13845. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13846. /**
  13847. * Compute all node absolute transforms
  13848. * @param forceUpdate defines if computation must be done even if cache is up to date
  13849. */
  13850. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13851. /**
  13852. * Gets the root pose matrix
  13853. * @returns a matrix
  13854. */
  13855. getPoseMatrix(): Nullable<Matrix>;
  13856. /**
  13857. * Sorts bones per internal index
  13858. */
  13859. sortBones(): void;
  13860. private _sortBones;
  13861. }
  13862. }
  13863. declare module "babylonjs/Bones/bone" {
  13864. import { Skeleton } from "babylonjs/Bones/skeleton";
  13865. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13866. import { Nullable } from "babylonjs/types";
  13867. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13868. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13869. import { Node } from "babylonjs/node";
  13870. import { Space } from "babylonjs/Maths/math.axis";
  13871. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13872. /**
  13873. * Class used to store bone information
  13874. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13875. */
  13876. export class Bone extends Node {
  13877. /**
  13878. * defines the bone name
  13879. */
  13880. name: string;
  13881. private static _tmpVecs;
  13882. private static _tmpQuat;
  13883. private static _tmpMats;
  13884. /**
  13885. * Gets the list of child bones
  13886. */
  13887. children: Bone[];
  13888. /** Gets the animations associated with this bone */
  13889. animations: import("babylonjs/Animations/animation").Animation[];
  13890. /**
  13891. * Gets or sets bone length
  13892. */
  13893. length: number;
  13894. /**
  13895. * @hidden Internal only
  13896. * Set this value to map this bone to a different index in the transform matrices
  13897. * Set this value to -1 to exclude the bone from the transform matrices
  13898. */
  13899. _index: Nullable<number>;
  13900. private _skeleton;
  13901. private _localMatrix;
  13902. private _restPose;
  13903. private _baseMatrix;
  13904. private _absoluteTransform;
  13905. private _invertedAbsoluteTransform;
  13906. private _parent;
  13907. private _scalingDeterminant;
  13908. private _worldTransform;
  13909. private _localScaling;
  13910. private _localRotation;
  13911. private _localPosition;
  13912. private _needToDecompose;
  13913. private _needToCompose;
  13914. /** @hidden */
  13915. _linkedTransformNode: Nullable<TransformNode>;
  13916. /** @hidden */
  13917. _waitingTransformNodeId: Nullable<string>;
  13918. /** @hidden */
  13919. /** @hidden */
  13920. _matrix: Matrix;
  13921. /**
  13922. * Create a new bone
  13923. * @param name defines the bone name
  13924. * @param skeleton defines the parent skeleton
  13925. * @param parentBone defines the parent (can be null if the bone is the root)
  13926. * @param localMatrix defines the local matrix
  13927. * @param restPose defines the rest pose matrix
  13928. * @param baseMatrix defines the base matrix
  13929. * @param index defines index of the bone in the hiearchy
  13930. */
  13931. constructor(
  13932. /**
  13933. * defines the bone name
  13934. */
  13935. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13936. /**
  13937. * Gets the current object class name.
  13938. * @return the class name
  13939. */
  13940. getClassName(): string;
  13941. /**
  13942. * Gets the parent skeleton
  13943. * @returns a skeleton
  13944. */
  13945. getSkeleton(): Skeleton;
  13946. /**
  13947. * Gets parent bone
  13948. * @returns a bone or null if the bone is the root of the bone hierarchy
  13949. */
  13950. getParent(): Nullable<Bone>;
  13951. /**
  13952. * Returns an array containing the root bones
  13953. * @returns an array containing the root bones
  13954. */
  13955. getChildren(): Array<Bone>;
  13956. /**
  13957. * Gets the node index in matrix array generated for rendering
  13958. * @returns the node index
  13959. */
  13960. getIndex(): number;
  13961. /**
  13962. * Sets the parent bone
  13963. * @param parent defines the parent (can be null if the bone is the root)
  13964. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13965. */
  13966. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13967. /**
  13968. * Gets the local matrix
  13969. * @returns a matrix
  13970. */
  13971. getLocalMatrix(): Matrix;
  13972. /**
  13973. * Gets the base matrix (initial matrix which remains unchanged)
  13974. * @returns a matrix
  13975. */
  13976. getBaseMatrix(): Matrix;
  13977. /**
  13978. * Gets the rest pose matrix
  13979. * @returns a matrix
  13980. */
  13981. getRestPose(): Matrix;
  13982. /**
  13983. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13984. */
  13985. getWorldMatrix(): Matrix;
  13986. /**
  13987. * Sets the local matrix to rest pose matrix
  13988. */
  13989. returnToRest(): void;
  13990. /**
  13991. * Gets the inverse of the absolute transform matrix.
  13992. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13993. * @returns a matrix
  13994. */
  13995. getInvertedAbsoluteTransform(): Matrix;
  13996. /**
  13997. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13998. * @returns a matrix
  13999. */
  14000. getAbsoluteTransform(): Matrix;
  14001. /**
  14002. * Links with the given transform node.
  14003. * The local matrix of this bone is copied from the transform node every frame.
  14004. * @param transformNode defines the transform node to link to
  14005. */
  14006. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14007. /**
  14008. * Gets the node used to drive the bone's transformation
  14009. * @returns a transform node or null
  14010. */
  14011. getTransformNode(): Nullable<TransformNode>;
  14012. /** Gets or sets current position (in local space) */
  14013. position: Vector3;
  14014. /** Gets or sets current rotation (in local space) */
  14015. rotation: Vector3;
  14016. /** Gets or sets current rotation quaternion (in local space) */
  14017. rotationQuaternion: Quaternion;
  14018. /** Gets or sets current scaling (in local space) */
  14019. scaling: Vector3;
  14020. /**
  14021. * Gets the animation properties override
  14022. */
  14023. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  14024. private _decompose;
  14025. private _compose;
  14026. /**
  14027. * Update the base and local matrices
  14028. * @param matrix defines the new base or local matrix
  14029. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14030. * @param updateLocalMatrix defines if the local matrix should be updated
  14031. */
  14032. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14033. /** @hidden */
  14034. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14035. /**
  14036. * Flag the bone as dirty (Forcing it to update everything)
  14037. */
  14038. markAsDirty(): void;
  14039. /** @hidden */
  14040. _markAsDirtyAndCompose(): void;
  14041. private _markAsDirtyAndDecompose;
  14042. /**
  14043. * Translate the bone in local or world space
  14044. * @param vec The amount to translate the bone
  14045. * @param space The space that the translation is in
  14046. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14047. */
  14048. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14049. /**
  14050. * Set the postion of the bone in local or world space
  14051. * @param position The position to set the bone
  14052. * @param space The space that the position is in
  14053. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14054. */
  14055. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14056. /**
  14057. * Set the absolute position of the bone (world space)
  14058. * @param position The position to set the bone
  14059. * @param mesh The mesh that this bone is attached to
  14060. */
  14061. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14062. /**
  14063. * Scale the bone on the x, y and z axes (in local space)
  14064. * @param x The amount to scale the bone on the x axis
  14065. * @param y The amount to scale the bone on the y axis
  14066. * @param z The amount to scale the bone on the z axis
  14067. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14068. */
  14069. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14070. /**
  14071. * Set the bone scaling in local space
  14072. * @param scale defines the scaling vector
  14073. */
  14074. setScale(scale: Vector3): void;
  14075. /**
  14076. * Gets the current scaling in local space
  14077. * @returns the current scaling vector
  14078. */
  14079. getScale(): Vector3;
  14080. /**
  14081. * Gets the current scaling in local space and stores it in a target vector
  14082. * @param result defines the target vector
  14083. */
  14084. getScaleToRef(result: Vector3): void;
  14085. /**
  14086. * Set the yaw, pitch, and roll of the bone in local or world space
  14087. * @param yaw The rotation of the bone on the y axis
  14088. * @param pitch The rotation of the bone on the x axis
  14089. * @param roll The rotation of the bone on the z axis
  14090. * @param space The space that the axes of rotation are in
  14091. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14092. */
  14093. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14094. /**
  14095. * Add a rotation to the bone on an axis in local or world space
  14096. * @param axis The axis to rotate the bone on
  14097. * @param amount The amount to rotate the bone
  14098. * @param space The space that the axis is in
  14099. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14100. */
  14101. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14102. /**
  14103. * Set the rotation of the bone to a particular axis angle in local or world space
  14104. * @param axis The axis to rotate the bone on
  14105. * @param angle The angle that the bone should be rotated to
  14106. * @param space The space that the axis is in
  14107. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14108. */
  14109. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14110. /**
  14111. * Set the euler rotation of the bone in local of world space
  14112. * @param rotation The euler rotation that the bone should be set to
  14113. * @param space The space that the rotation is in
  14114. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14115. */
  14116. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14117. /**
  14118. * Set the quaternion rotation of the bone in local of world space
  14119. * @param quat The quaternion rotation that the bone should be set to
  14120. * @param space The space that the rotation is in
  14121. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14122. */
  14123. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14124. /**
  14125. * Set the rotation matrix of the bone in local of world space
  14126. * @param rotMat The rotation matrix that the bone should be set to
  14127. * @param space The space that the rotation is in
  14128. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14129. */
  14130. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14131. private _rotateWithMatrix;
  14132. private _getNegativeRotationToRef;
  14133. /**
  14134. * Get the position of the bone in local or world space
  14135. * @param space The space that the returned position is in
  14136. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14137. * @returns The position of the bone
  14138. */
  14139. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14140. /**
  14141. * Copy the position of the bone to a vector3 in local or world space
  14142. * @param space The space that the returned position is in
  14143. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14144. * @param result The vector3 to copy the position to
  14145. */
  14146. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14147. /**
  14148. * Get the absolute position of the bone (world space)
  14149. * @param mesh The mesh that this bone is attached to
  14150. * @returns The absolute position of the bone
  14151. */
  14152. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14153. /**
  14154. * Copy the absolute position of the bone (world space) to the result param
  14155. * @param mesh The mesh that this bone is attached to
  14156. * @param result The vector3 to copy the absolute position to
  14157. */
  14158. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14159. /**
  14160. * Compute the absolute transforms of this bone and its children
  14161. */
  14162. computeAbsoluteTransforms(): void;
  14163. /**
  14164. * Get the world direction from an axis that is in the local space of the bone
  14165. * @param localAxis The local direction that is used to compute the world direction
  14166. * @param mesh The mesh that this bone is attached to
  14167. * @returns The world direction
  14168. */
  14169. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14170. /**
  14171. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14172. * @param localAxis The local direction that is used to compute the world direction
  14173. * @param mesh The mesh that this bone is attached to
  14174. * @param result The vector3 that the world direction will be copied to
  14175. */
  14176. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14177. /**
  14178. * Get the euler rotation of the bone in local or world space
  14179. * @param space The space that the rotation should be in
  14180. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14181. * @returns The euler rotation
  14182. */
  14183. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14184. /**
  14185. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14186. * @param space The space that the rotation should be in
  14187. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14188. * @param result The vector3 that the rotation should be copied to
  14189. */
  14190. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14191. /**
  14192. * Get the quaternion rotation of the bone in either local or world space
  14193. * @param space The space that the rotation should be in
  14194. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14195. * @returns The quaternion rotation
  14196. */
  14197. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14198. /**
  14199. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14200. * @param space The space that the rotation should be in
  14201. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14202. * @param result The quaternion that the rotation should be copied to
  14203. */
  14204. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14205. /**
  14206. * Get the rotation matrix of the bone in local or world space
  14207. * @param space The space that the rotation should be in
  14208. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14209. * @returns The rotation matrix
  14210. */
  14211. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14212. /**
  14213. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14214. * @param space The space that the rotation should be in
  14215. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14216. * @param result The quaternion that the rotation should be copied to
  14217. */
  14218. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14219. /**
  14220. * Get the world position of a point that is in the local space of the bone
  14221. * @param position The local position
  14222. * @param mesh The mesh that this bone is attached to
  14223. * @returns The world position
  14224. */
  14225. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14226. /**
  14227. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14228. * @param position The local position
  14229. * @param mesh The mesh that this bone is attached to
  14230. * @param result The vector3 that the world position should be copied to
  14231. */
  14232. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14233. /**
  14234. * Get the local position of a point that is in world space
  14235. * @param position The world position
  14236. * @param mesh The mesh that this bone is attached to
  14237. * @returns The local position
  14238. */
  14239. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14240. /**
  14241. * Get the local position of a point that is in world space and copy it to the result param
  14242. * @param position The world position
  14243. * @param mesh The mesh that this bone is attached to
  14244. * @param result The vector3 that the local position should be copied to
  14245. */
  14246. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14247. }
  14248. }
  14249. declare module "babylonjs/Meshes/transformNode" {
  14250. import { DeepImmutable } from "babylonjs/types";
  14251. import { Observable } from "babylonjs/Misc/observable";
  14252. import { Nullable } from "babylonjs/types";
  14253. import { Camera } from "babylonjs/Cameras/camera";
  14254. import { Scene } from "babylonjs/scene";
  14255. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14256. import { Node } from "babylonjs/node";
  14257. import { Bone } from "babylonjs/Bones/bone";
  14258. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14259. import { Space } from "babylonjs/Maths/math.axis";
  14260. /**
  14261. * 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.
  14262. * @see https://doc.babylonjs.com/how_to/transformnode
  14263. */
  14264. export class TransformNode extends Node {
  14265. /**
  14266. * Object will not rotate to face the camera
  14267. */
  14268. static BILLBOARDMODE_NONE: number;
  14269. /**
  14270. * Object will rotate to face the camera but only on the x axis
  14271. */
  14272. static BILLBOARDMODE_X: number;
  14273. /**
  14274. * Object will rotate to face the camera but only on the y axis
  14275. */
  14276. static BILLBOARDMODE_Y: number;
  14277. /**
  14278. * Object will rotate to face the camera but only on the z axis
  14279. */
  14280. static BILLBOARDMODE_Z: number;
  14281. /**
  14282. * Object will rotate to face the camera
  14283. */
  14284. static BILLBOARDMODE_ALL: number;
  14285. /**
  14286. * Object will rotate to face the camera's position instead of orientation
  14287. */
  14288. static BILLBOARDMODE_USE_POSITION: number;
  14289. private _forward;
  14290. private _forwardInverted;
  14291. private _up;
  14292. private _right;
  14293. private _rightInverted;
  14294. private _position;
  14295. private _rotation;
  14296. private _rotationQuaternion;
  14297. protected _scaling: Vector3;
  14298. protected _isDirty: boolean;
  14299. private _transformToBoneReferal;
  14300. private _isAbsoluteSynced;
  14301. private _billboardMode;
  14302. /**
  14303. * Gets or sets the billboard mode. Default is 0.
  14304. *
  14305. * | Value | Type | Description |
  14306. * | --- | --- | --- |
  14307. * | 0 | BILLBOARDMODE_NONE | |
  14308. * | 1 | BILLBOARDMODE_X | |
  14309. * | 2 | BILLBOARDMODE_Y | |
  14310. * | 4 | BILLBOARDMODE_Z | |
  14311. * | 7 | BILLBOARDMODE_ALL | |
  14312. *
  14313. */
  14314. billboardMode: number;
  14315. private _preserveParentRotationForBillboard;
  14316. /**
  14317. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14318. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14319. */
  14320. preserveParentRotationForBillboard: boolean;
  14321. /**
  14322. * 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
  14323. */
  14324. scalingDeterminant: number;
  14325. private _infiniteDistance;
  14326. /**
  14327. * Gets or sets the distance of the object to max, often used by skybox
  14328. */
  14329. infiniteDistance: boolean;
  14330. /**
  14331. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14332. * By default the system will update normals to compensate
  14333. */
  14334. ignoreNonUniformScaling: boolean;
  14335. /**
  14336. * 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
  14337. */
  14338. reIntegrateRotationIntoRotationQuaternion: boolean;
  14339. /** @hidden */
  14340. _poseMatrix: Nullable<Matrix>;
  14341. /** @hidden */
  14342. _localMatrix: Matrix;
  14343. private _usePivotMatrix;
  14344. private _absolutePosition;
  14345. private _absoluteScaling;
  14346. private _absoluteRotationQuaternion;
  14347. private _pivotMatrix;
  14348. private _pivotMatrixInverse;
  14349. protected _postMultiplyPivotMatrix: boolean;
  14350. protected _isWorldMatrixFrozen: boolean;
  14351. /** @hidden */
  14352. _indexInSceneTransformNodesArray: number;
  14353. /**
  14354. * An event triggered after the world matrix is updated
  14355. */
  14356. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14357. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14358. /**
  14359. * Gets a string identifying the name of the class
  14360. * @returns "TransformNode" string
  14361. */
  14362. getClassName(): string;
  14363. /**
  14364. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14365. */
  14366. position: Vector3;
  14367. /**
  14368. * 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)).
  14369. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14370. */
  14371. rotation: Vector3;
  14372. /**
  14373. * 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)).
  14374. */
  14375. scaling: Vector3;
  14376. /**
  14377. * 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).
  14378. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14379. */
  14380. rotationQuaternion: Nullable<Quaternion>;
  14381. /**
  14382. * The forward direction of that transform in world space.
  14383. */
  14384. readonly forward: Vector3;
  14385. /**
  14386. * The up direction of that transform in world space.
  14387. */
  14388. readonly up: Vector3;
  14389. /**
  14390. * The right direction of that transform in world space.
  14391. */
  14392. readonly right: Vector3;
  14393. /**
  14394. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14395. * @param matrix the matrix to copy the pose from
  14396. * @returns this TransformNode.
  14397. */
  14398. updatePoseMatrix(matrix: Matrix): TransformNode;
  14399. /**
  14400. * Returns the mesh Pose matrix.
  14401. * @returns the pose matrix
  14402. */
  14403. getPoseMatrix(): Matrix;
  14404. /** @hidden */
  14405. _isSynchronized(): boolean;
  14406. /** @hidden */
  14407. _initCache(): void;
  14408. /**
  14409. * Flag the transform node as dirty (Forcing it to update everything)
  14410. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14411. * @returns this transform node
  14412. */
  14413. markAsDirty(property: string): TransformNode;
  14414. /**
  14415. * Returns the current mesh absolute position.
  14416. * Returns a Vector3.
  14417. */
  14418. readonly absolutePosition: Vector3;
  14419. /**
  14420. * Returns the current mesh absolute scaling.
  14421. * Returns a Vector3.
  14422. */
  14423. readonly absoluteScaling: Vector3;
  14424. /**
  14425. * Returns the current mesh absolute rotation.
  14426. * Returns a Quaternion.
  14427. */
  14428. readonly absoluteRotationQuaternion: Quaternion;
  14429. /**
  14430. * Sets a new matrix to apply before all other transformation
  14431. * @param matrix defines the transform matrix
  14432. * @returns the current TransformNode
  14433. */
  14434. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14435. /**
  14436. * Sets a new pivot matrix to the current node
  14437. * @param matrix defines the new pivot matrix to use
  14438. * @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
  14439. * @returns the current TransformNode
  14440. */
  14441. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14442. /**
  14443. * Returns the mesh pivot matrix.
  14444. * Default : Identity.
  14445. * @returns the matrix
  14446. */
  14447. getPivotMatrix(): Matrix;
  14448. /**
  14449. * Instantiate (when possible) or clone that node with its hierarchy
  14450. * @param newParent defines the new parent to use for the instance (or clone)
  14451. * @param options defines options to configure how copy is done
  14452. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14453. * @returns an instance (or a clone) of the current node with its hiearchy
  14454. */
  14455. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14456. doNotInstantiate: boolean;
  14457. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14458. /**
  14459. * Prevents the World matrix to be computed any longer
  14460. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14461. * @returns the TransformNode.
  14462. */
  14463. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14464. /**
  14465. * Allows back the World matrix computation.
  14466. * @returns the TransformNode.
  14467. */
  14468. unfreezeWorldMatrix(): this;
  14469. /**
  14470. * True if the World matrix has been frozen.
  14471. */
  14472. readonly isWorldMatrixFrozen: boolean;
  14473. /**
  14474. * Retuns the mesh absolute position in the World.
  14475. * @returns a Vector3.
  14476. */
  14477. getAbsolutePosition(): Vector3;
  14478. /**
  14479. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14480. * @param absolutePosition the absolute position to set
  14481. * @returns the TransformNode.
  14482. */
  14483. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14484. /**
  14485. * Sets the mesh position in its local space.
  14486. * @param vector3 the position to set in localspace
  14487. * @returns the TransformNode.
  14488. */
  14489. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14490. /**
  14491. * Returns the mesh position in the local space from the current World matrix values.
  14492. * @returns a new Vector3.
  14493. */
  14494. getPositionExpressedInLocalSpace(): Vector3;
  14495. /**
  14496. * Translates the mesh along the passed Vector3 in its local space.
  14497. * @param vector3 the distance to translate in localspace
  14498. * @returns the TransformNode.
  14499. */
  14500. locallyTranslate(vector3: Vector3): TransformNode;
  14501. private static _lookAtVectorCache;
  14502. /**
  14503. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14504. * @param targetPoint the position (must be in same space as current mesh) to look at
  14505. * @param yawCor optional yaw (y-axis) correction in radians
  14506. * @param pitchCor optional pitch (x-axis) correction in radians
  14507. * @param rollCor optional roll (z-axis) correction in radians
  14508. * @param space the choosen space of the target
  14509. * @returns the TransformNode.
  14510. */
  14511. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14512. /**
  14513. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14514. * This Vector3 is expressed in the World space.
  14515. * @param localAxis axis to rotate
  14516. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14517. */
  14518. getDirection(localAxis: Vector3): Vector3;
  14519. /**
  14520. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14521. * localAxis is expressed in the mesh local space.
  14522. * result is computed in the Wordl space from the mesh World matrix.
  14523. * @param localAxis axis to rotate
  14524. * @param result the resulting transformnode
  14525. * @returns this TransformNode.
  14526. */
  14527. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14528. /**
  14529. * Sets this transform node rotation to the given local axis.
  14530. * @param localAxis the axis in local space
  14531. * @param yawCor optional yaw (y-axis) correction in radians
  14532. * @param pitchCor optional pitch (x-axis) correction in radians
  14533. * @param rollCor optional roll (z-axis) correction in radians
  14534. * @returns this TransformNode
  14535. */
  14536. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14537. /**
  14538. * Sets a new pivot point to the current node
  14539. * @param point defines the new pivot point to use
  14540. * @param space defines if the point is in world or local space (local by default)
  14541. * @returns the current TransformNode
  14542. */
  14543. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14544. /**
  14545. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14546. * @returns the pivot point
  14547. */
  14548. getPivotPoint(): Vector3;
  14549. /**
  14550. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14551. * @param result the vector3 to store the result
  14552. * @returns this TransformNode.
  14553. */
  14554. getPivotPointToRef(result: Vector3): TransformNode;
  14555. /**
  14556. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14557. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14558. */
  14559. getAbsolutePivotPoint(): Vector3;
  14560. /**
  14561. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14562. * @param result vector3 to store the result
  14563. * @returns this TransformNode.
  14564. */
  14565. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14566. /**
  14567. * Defines the passed node as the parent of the current node.
  14568. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14569. * @see https://doc.babylonjs.com/how_to/parenting
  14570. * @param node the node ot set as the parent
  14571. * @returns this TransformNode.
  14572. */
  14573. setParent(node: Nullable<Node>): TransformNode;
  14574. private _nonUniformScaling;
  14575. /**
  14576. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14577. */
  14578. readonly nonUniformScaling: boolean;
  14579. /** @hidden */
  14580. _updateNonUniformScalingState(value: boolean): boolean;
  14581. /**
  14582. * Attach the current TransformNode to another TransformNode associated with a bone
  14583. * @param bone Bone affecting the TransformNode
  14584. * @param affectedTransformNode TransformNode associated with the bone
  14585. * @returns this object
  14586. */
  14587. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14588. /**
  14589. * Detach the transform node if its associated with a bone
  14590. * @returns this object
  14591. */
  14592. detachFromBone(): TransformNode;
  14593. private static _rotationAxisCache;
  14594. /**
  14595. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14596. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14597. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14598. * The passed axis is also normalized.
  14599. * @param axis the axis to rotate around
  14600. * @param amount the amount to rotate in radians
  14601. * @param space Space to rotate in (Default: local)
  14602. * @returns the TransformNode.
  14603. */
  14604. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14605. /**
  14606. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14607. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14608. * The passed axis is also normalized. .
  14609. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14610. * @param point the point to rotate around
  14611. * @param axis the axis to rotate around
  14612. * @param amount the amount to rotate in radians
  14613. * @returns the TransformNode
  14614. */
  14615. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14616. /**
  14617. * Translates the mesh along the axis vector for the passed distance in the given space.
  14618. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14619. * @param axis the axis to translate in
  14620. * @param distance the distance to translate
  14621. * @param space Space to rotate in (Default: local)
  14622. * @returns the TransformNode.
  14623. */
  14624. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14625. /**
  14626. * Adds a rotation step to the mesh current rotation.
  14627. * x, y, z are Euler angles expressed in radians.
  14628. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14629. * This means this rotation is made in the mesh local space only.
  14630. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14631. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14632. * ```javascript
  14633. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14634. * ```
  14635. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14636. * 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.
  14637. * @param x Rotation to add
  14638. * @param y Rotation to add
  14639. * @param z Rotation to add
  14640. * @returns the TransformNode.
  14641. */
  14642. addRotation(x: number, y: number, z: number): TransformNode;
  14643. /**
  14644. * @hidden
  14645. */
  14646. protected _getEffectiveParent(): Nullable<Node>;
  14647. /**
  14648. * Computes the world matrix of the node
  14649. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14650. * @returns the world matrix
  14651. */
  14652. computeWorldMatrix(force?: boolean): Matrix;
  14653. protected _afterComputeWorldMatrix(): void;
  14654. /**
  14655. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14656. * @param func callback function to add
  14657. *
  14658. * @returns the TransformNode.
  14659. */
  14660. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14661. /**
  14662. * Removes a registered callback function.
  14663. * @param func callback function to remove
  14664. * @returns the TransformNode.
  14665. */
  14666. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14667. /**
  14668. * Gets the position of the current mesh in camera space
  14669. * @param camera defines the camera to use
  14670. * @returns a position
  14671. */
  14672. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14673. /**
  14674. * Returns the distance from the mesh to the active camera
  14675. * @param camera defines the camera to use
  14676. * @returns the distance
  14677. */
  14678. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14679. /**
  14680. * Clone the current transform node
  14681. * @param name Name of the new clone
  14682. * @param newParent New parent for the clone
  14683. * @param doNotCloneChildren Do not clone children hierarchy
  14684. * @returns the new transform node
  14685. */
  14686. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14687. /**
  14688. * Serializes the objects information.
  14689. * @param currentSerializationObject defines the object to serialize in
  14690. * @returns the serialized object
  14691. */
  14692. serialize(currentSerializationObject?: any): any;
  14693. /**
  14694. * Returns a new TransformNode object parsed from the source provided.
  14695. * @param parsedTransformNode is the source.
  14696. * @param scene the scne the object belongs to
  14697. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14698. * @returns a new TransformNode object parsed from the source provided.
  14699. */
  14700. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14701. /**
  14702. * Get all child-transformNodes of this node
  14703. * @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
  14704. * @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
  14705. * @returns an array of TransformNode
  14706. */
  14707. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14708. /**
  14709. * Releases resources associated with this transform node.
  14710. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14711. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14712. */
  14713. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14714. /**
  14715. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14716. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14717. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14718. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14719. * @returns the current mesh
  14720. */
  14721. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14722. private _syncAbsoluteScalingAndRotation;
  14723. }
  14724. }
  14725. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14726. import { Observable } from "babylonjs/Misc/observable";
  14727. import { Nullable } from "babylonjs/types";
  14728. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14729. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14730. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14731. import { Ray } from "babylonjs/Culling/ray";
  14732. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14733. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14734. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14735. /**
  14736. * Defines the types of pose enabled controllers that are supported
  14737. */
  14738. export enum PoseEnabledControllerType {
  14739. /**
  14740. * HTC Vive
  14741. */
  14742. VIVE = 0,
  14743. /**
  14744. * Oculus Rift
  14745. */
  14746. OCULUS = 1,
  14747. /**
  14748. * Windows mixed reality
  14749. */
  14750. WINDOWS = 2,
  14751. /**
  14752. * Samsung gear VR
  14753. */
  14754. GEAR_VR = 3,
  14755. /**
  14756. * Google Daydream
  14757. */
  14758. DAYDREAM = 4,
  14759. /**
  14760. * Generic
  14761. */
  14762. GENERIC = 5
  14763. }
  14764. /**
  14765. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14766. */
  14767. export interface MutableGamepadButton {
  14768. /**
  14769. * Value of the button/trigger
  14770. */
  14771. value: number;
  14772. /**
  14773. * If the button/trigger is currently touched
  14774. */
  14775. touched: boolean;
  14776. /**
  14777. * If the button/trigger is currently pressed
  14778. */
  14779. pressed: boolean;
  14780. }
  14781. /**
  14782. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14783. * @hidden
  14784. */
  14785. export interface ExtendedGamepadButton extends GamepadButton {
  14786. /**
  14787. * If the button/trigger is currently pressed
  14788. */
  14789. readonly pressed: boolean;
  14790. /**
  14791. * If the button/trigger is currently touched
  14792. */
  14793. readonly touched: boolean;
  14794. /**
  14795. * Value of the button/trigger
  14796. */
  14797. readonly value: number;
  14798. }
  14799. /** @hidden */
  14800. export interface _GamePadFactory {
  14801. /**
  14802. * Returns wether or not the current gamepad can be created for this type of controller.
  14803. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14804. * @returns true if it can be created, otherwise false
  14805. */
  14806. canCreate(gamepadInfo: any): boolean;
  14807. /**
  14808. * Creates a new instance of the Gamepad.
  14809. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14810. * @returns the new gamepad instance
  14811. */
  14812. create(gamepadInfo: any): Gamepad;
  14813. }
  14814. /**
  14815. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14816. */
  14817. export class PoseEnabledControllerHelper {
  14818. /** @hidden */
  14819. static _ControllerFactories: _GamePadFactory[];
  14820. /** @hidden */
  14821. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14822. /**
  14823. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14824. * @param vrGamepad the gamepad to initialized
  14825. * @returns a vr controller of the type the gamepad identified as
  14826. */
  14827. static InitiateController(vrGamepad: any): Gamepad;
  14828. }
  14829. /**
  14830. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14831. */
  14832. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14833. /**
  14834. * If the controller is used in a webXR session
  14835. */
  14836. isXR: boolean;
  14837. private _deviceRoomPosition;
  14838. private _deviceRoomRotationQuaternion;
  14839. /**
  14840. * The device position in babylon space
  14841. */
  14842. devicePosition: Vector3;
  14843. /**
  14844. * The device rotation in babylon space
  14845. */
  14846. deviceRotationQuaternion: Quaternion;
  14847. /**
  14848. * The scale factor of the device in babylon space
  14849. */
  14850. deviceScaleFactor: number;
  14851. /**
  14852. * (Likely devicePosition should be used instead) The device position in its room space
  14853. */
  14854. position: Vector3;
  14855. /**
  14856. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14857. */
  14858. rotationQuaternion: Quaternion;
  14859. /**
  14860. * The type of controller (Eg. Windows mixed reality)
  14861. */
  14862. controllerType: PoseEnabledControllerType;
  14863. protected _calculatedPosition: Vector3;
  14864. private _calculatedRotation;
  14865. /**
  14866. * The raw pose from the device
  14867. */
  14868. rawPose: DevicePose;
  14869. private _trackPosition;
  14870. private _maxRotationDistFromHeadset;
  14871. private _draggedRoomRotation;
  14872. /**
  14873. * @hidden
  14874. */
  14875. _disableTrackPosition(fixedPosition: Vector3): void;
  14876. /**
  14877. * Internal, the mesh attached to the controller
  14878. * @hidden
  14879. */
  14880. _mesh: Nullable<AbstractMesh>;
  14881. private _poseControlledCamera;
  14882. private _leftHandSystemQuaternion;
  14883. /**
  14884. * Internal, matrix used to convert room space to babylon space
  14885. * @hidden
  14886. */
  14887. _deviceToWorld: Matrix;
  14888. /**
  14889. * Node to be used when casting a ray from the controller
  14890. * @hidden
  14891. */
  14892. _pointingPoseNode: Nullable<TransformNode>;
  14893. /**
  14894. * Name of the child mesh that can be used to cast a ray from the controller
  14895. */
  14896. static readonly POINTING_POSE: string;
  14897. /**
  14898. * Creates a new PoseEnabledController from a gamepad
  14899. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14900. */
  14901. constructor(browserGamepad: any);
  14902. private _workingMatrix;
  14903. /**
  14904. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14905. */
  14906. update(): void;
  14907. /**
  14908. * Updates only the pose device and mesh without doing any button event checking
  14909. */
  14910. protected _updatePoseAndMesh(): void;
  14911. /**
  14912. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14913. * @param poseData raw pose fromthe device
  14914. */
  14915. updateFromDevice(poseData: DevicePose): void;
  14916. /**
  14917. * @hidden
  14918. */
  14919. _meshAttachedObservable: Observable<AbstractMesh>;
  14920. /**
  14921. * Attaches a mesh to the controller
  14922. * @param mesh the mesh to be attached
  14923. */
  14924. attachToMesh(mesh: AbstractMesh): void;
  14925. /**
  14926. * Attaches the controllers mesh to a camera
  14927. * @param camera the camera the mesh should be attached to
  14928. */
  14929. attachToPoseControlledCamera(camera: TargetCamera): void;
  14930. /**
  14931. * Disposes of the controller
  14932. */
  14933. dispose(): void;
  14934. /**
  14935. * The mesh that is attached to the controller
  14936. */
  14937. readonly mesh: Nullable<AbstractMesh>;
  14938. /**
  14939. * Gets the ray of the controller in the direction the controller is pointing
  14940. * @param length the length the resulting ray should be
  14941. * @returns a ray in the direction the controller is pointing
  14942. */
  14943. getForwardRay(length?: number): Ray;
  14944. }
  14945. }
  14946. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14947. import { Observable } from "babylonjs/Misc/observable";
  14948. import { Scene } from "babylonjs/scene";
  14949. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14950. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14951. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14952. import { Nullable } from "babylonjs/types";
  14953. /**
  14954. * Defines the WebVRController object that represents controllers tracked in 3D space
  14955. */
  14956. export abstract class WebVRController extends PoseEnabledController {
  14957. /**
  14958. * Internal, the default controller model for the controller
  14959. */
  14960. protected _defaultModel: Nullable<AbstractMesh>;
  14961. /**
  14962. * Fired when the trigger state has changed
  14963. */
  14964. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14965. /**
  14966. * Fired when the main button state has changed
  14967. */
  14968. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14969. /**
  14970. * Fired when the secondary button state has changed
  14971. */
  14972. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14973. /**
  14974. * Fired when the pad state has changed
  14975. */
  14976. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14977. /**
  14978. * Fired when controllers stick values have changed
  14979. */
  14980. onPadValuesChangedObservable: Observable<StickValues>;
  14981. /**
  14982. * Array of button availible on the controller
  14983. */
  14984. protected _buttons: Array<MutableGamepadButton>;
  14985. private _onButtonStateChange;
  14986. /**
  14987. * Fired when a controller button's state has changed
  14988. * @param callback the callback containing the button that was modified
  14989. */
  14990. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14991. /**
  14992. * X and Y axis corresponding to the controllers joystick
  14993. */
  14994. pad: StickValues;
  14995. /**
  14996. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14997. */
  14998. hand: string;
  14999. /**
  15000. * The default controller model for the controller
  15001. */
  15002. readonly defaultModel: Nullable<AbstractMesh>;
  15003. /**
  15004. * Creates a new WebVRController from a gamepad
  15005. * @param vrGamepad the gamepad that the WebVRController should be created from
  15006. */
  15007. constructor(vrGamepad: any);
  15008. /**
  15009. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  15010. */
  15011. update(): void;
  15012. /**
  15013. * Function to be called when a button is modified
  15014. */
  15015. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  15016. /**
  15017. * Loads a mesh and attaches it to the controller
  15018. * @param scene the scene the mesh should be added to
  15019. * @param meshLoaded callback for when the mesh has been loaded
  15020. */
  15021. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  15022. private _setButtonValue;
  15023. private _changes;
  15024. private _checkChanges;
  15025. /**
  15026. * Disposes of th webVRCOntroller
  15027. */
  15028. dispose(): void;
  15029. }
  15030. }
  15031. declare module "babylonjs/Lights/hemisphericLight" {
  15032. import { Nullable } from "babylonjs/types";
  15033. import { Scene } from "babylonjs/scene";
  15034. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15035. import { Color3 } from "babylonjs/Maths/math.color";
  15036. import { Effect } from "babylonjs/Materials/effect";
  15037. import { Light } from "babylonjs/Lights/light";
  15038. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  15039. /**
  15040. * The HemisphericLight simulates the ambient environment light,
  15041. * so the passed direction is the light reflection direction, not the incoming direction.
  15042. */
  15043. export class HemisphericLight extends Light {
  15044. /**
  15045. * The groundColor is the light in the opposite direction to the one specified during creation.
  15046. * 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.
  15047. */
  15048. groundColor: Color3;
  15049. /**
  15050. * The light reflection direction, not the incoming direction.
  15051. */
  15052. direction: Vector3;
  15053. /**
  15054. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15055. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15056. * The HemisphericLight can't cast shadows.
  15057. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15058. * @param name The friendly name of the light
  15059. * @param direction The direction of the light reflection
  15060. * @param scene The scene the light belongs to
  15061. */
  15062. constructor(name: string, direction: Vector3, scene: Scene);
  15063. protected _buildUniformLayout(): void;
  15064. /**
  15065. * Returns the string "HemisphericLight".
  15066. * @return The class name
  15067. */
  15068. getClassName(): string;
  15069. /**
  15070. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15071. * Returns the updated direction.
  15072. * @param target The target the direction should point to
  15073. * @return The computed direction
  15074. */
  15075. setDirectionToTarget(target: Vector3): Vector3;
  15076. /**
  15077. * Returns the shadow generator associated to the light.
  15078. * @returns Always null for hemispheric lights because it does not support shadows.
  15079. */
  15080. getShadowGenerator(): Nullable<IShadowGenerator>;
  15081. /**
  15082. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15083. * @param effect The effect to update
  15084. * @param lightIndex The index of the light in the effect to update
  15085. * @returns The hemispheric light
  15086. */
  15087. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15088. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  15089. /**
  15090. * Computes the world matrix of the node
  15091. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15092. * @param useWasUpdatedFlag defines a reserved property
  15093. * @returns the world matrix
  15094. */
  15095. computeWorldMatrix(): Matrix;
  15096. /**
  15097. * Returns the integer 3.
  15098. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15099. */
  15100. getTypeID(): number;
  15101. /**
  15102. * Prepares the list of defines specific to the light type.
  15103. * @param defines the list of defines
  15104. * @param lightIndex defines the index of the light for the effect
  15105. */
  15106. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15107. }
  15108. }
  15109. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  15110. /** @hidden */
  15111. export var vrMultiviewToSingleviewPixelShader: {
  15112. name: string;
  15113. shader: string;
  15114. };
  15115. }
  15116. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  15117. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15118. import { Scene } from "babylonjs/scene";
  15119. /**
  15120. * Renders to multiple views with a single draw call
  15121. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  15122. */
  15123. export class MultiviewRenderTarget extends RenderTargetTexture {
  15124. /**
  15125. * Creates a multiview render target
  15126. * @param scene scene used with the render target
  15127. * @param size the size of the render target (used for each view)
  15128. */
  15129. constructor(scene: Scene, size?: number | {
  15130. width: number;
  15131. height: number;
  15132. } | {
  15133. ratio: number;
  15134. });
  15135. /**
  15136. * @hidden
  15137. * @param faceIndex the face index, if its a cube texture
  15138. */
  15139. _bindFrameBuffer(faceIndex?: number): void;
  15140. /**
  15141. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  15142. * @returns the view count
  15143. */
  15144. getViewCount(): number;
  15145. }
  15146. }
  15147. declare module "babylonjs/Maths/math.frustum" {
  15148. import { Matrix } from "babylonjs/Maths/math.vector";
  15149. import { DeepImmutable } from "babylonjs/types";
  15150. import { Plane } from "babylonjs/Maths/math.plane";
  15151. /**
  15152. * Represents a camera frustum
  15153. */
  15154. export class Frustum {
  15155. /**
  15156. * Gets the planes representing the frustum
  15157. * @param transform matrix to be applied to the returned planes
  15158. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15159. */
  15160. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  15161. /**
  15162. * Gets the near frustum plane transformed by the transform matrix
  15163. * @param transform transformation matrix to be applied to the resulting frustum plane
  15164. * @param frustumPlane the resuling frustum plane
  15165. */
  15166. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15167. /**
  15168. * Gets the far frustum plane transformed by the transform matrix
  15169. * @param transform transformation matrix to be applied to the resulting frustum plane
  15170. * @param frustumPlane the resuling frustum plane
  15171. */
  15172. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15173. /**
  15174. * Gets the left frustum plane transformed by the transform matrix
  15175. * @param transform transformation matrix to be applied to the resulting frustum plane
  15176. * @param frustumPlane the resuling frustum plane
  15177. */
  15178. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15179. /**
  15180. * Gets the right frustum plane transformed by the transform matrix
  15181. * @param transform transformation matrix to be applied to the resulting frustum plane
  15182. * @param frustumPlane the resuling frustum plane
  15183. */
  15184. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15185. /**
  15186. * Gets the top frustum plane transformed by the transform matrix
  15187. * @param transform transformation matrix to be applied to the resulting frustum plane
  15188. * @param frustumPlane the resuling frustum plane
  15189. */
  15190. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15191. /**
  15192. * Gets the bottom frustum plane transformed by the transform matrix
  15193. * @param transform transformation matrix to be applied to the resulting frustum plane
  15194. * @param frustumPlane the resuling frustum plane
  15195. */
  15196. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15197. /**
  15198. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15199. * @param transform transformation matrix to be applied to the resulting frustum planes
  15200. * @param frustumPlanes the resuling frustum planes
  15201. */
  15202. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15203. }
  15204. }
  15205. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  15206. import { Camera } from "babylonjs/Cameras/camera";
  15207. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15208. import { Nullable } from "babylonjs/types";
  15209. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15210. import { Matrix } from "babylonjs/Maths/math.vector";
  15211. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  15212. module "babylonjs/Engines/engine" {
  15213. interface Engine {
  15214. /**
  15215. * Creates a new multiview render target
  15216. * @param width defines the width of the texture
  15217. * @param height defines the height of the texture
  15218. * @returns the created multiview texture
  15219. */
  15220. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15221. /**
  15222. * Binds a multiview framebuffer to be drawn to
  15223. * @param multiviewTexture texture to bind
  15224. */
  15225. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15226. }
  15227. }
  15228. module "babylonjs/Cameras/camera" {
  15229. interface Camera {
  15230. /**
  15231. * @hidden
  15232. * 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)
  15233. */
  15234. _useMultiviewToSingleView: boolean;
  15235. /**
  15236. * @hidden
  15237. * 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)
  15238. */
  15239. _multiviewTexture: Nullable<RenderTargetTexture>;
  15240. /**
  15241. * @hidden
  15242. * ensures the multiview texture of the camera exists and has the specified width/height
  15243. * @param width height to set on the multiview texture
  15244. * @param height width to set on the multiview texture
  15245. */
  15246. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15247. }
  15248. }
  15249. module "babylonjs/scene" {
  15250. interface Scene {
  15251. /** @hidden */
  15252. _transformMatrixR: Matrix;
  15253. /** @hidden */
  15254. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15255. /** @hidden */
  15256. _createMultiviewUbo(): void;
  15257. /** @hidden */
  15258. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15259. /** @hidden */
  15260. _renderMultiviewToSingleView(camera: Camera): void;
  15261. }
  15262. }
  15263. }
  15264. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15265. import { Camera } from "babylonjs/Cameras/camera";
  15266. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15267. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15268. import "babylonjs/Engines/Extensions/engine.multiview";
  15269. /**
  15270. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15271. * This will not be used for webXR as it supports displaying texture arrays directly
  15272. */
  15273. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15274. /**
  15275. * Initializes a VRMultiviewToSingleview
  15276. * @param name name of the post process
  15277. * @param camera camera to be applied to
  15278. * @param scaleFactor scaling factor to the size of the output texture
  15279. */
  15280. constructor(name: string, camera: Camera, scaleFactor: number);
  15281. }
  15282. }
  15283. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15284. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15285. import { Nullable } from "babylonjs/types";
  15286. import { Size } from "babylonjs/Maths/math.size";
  15287. import { Observable } from "babylonjs/Misc/observable";
  15288. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  15289. /**
  15290. * Interface used to define additional presentation attributes
  15291. */
  15292. export interface IVRPresentationAttributes {
  15293. /**
  15294. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  15295. */
  15296. highRefreshRate: boolean;
  15297. /**
  15298. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  15299. */
  15300. foveationLevel: number;
  15301. }
  15302. module "babylonjs/Engines/engine" {
  15303. interface Engine {
  15304. /** @hidden */
  15305. _vrDisplay: any;
  15306. /** @hidden */
  15307. _vrSupported: boolean;
  15308. /** @hidden */
  15309. _oldSize: Size;
  15310. /** @hidden */
  15311. _oldHardwareScaleFactor: number;
  15312. /** @hidden */
  15313. _vrExclusivePointerMode: boolean;
  15314. /** @hidden */
  15315. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15316. /** @hidden */
  15317. _onVRDisplayPointerRestricted: () => void;
  15318. /** @hidden */
  15319. _onVRDisplayPointerUnrestricted: () => void;
  15320. /** @hidden */
  15321. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15322. /** @hidden */
  15323. _onVrDisplayDisconnect: Nullable<() => void>;
  15324. /** @hidden */
  15325. _onVrDisplayPresentChange: Nullable<() => void>;
  15326. /**
  15327. * Observable signaled when VR display mode changes
  15328. */
  15329. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15330. /**
  15331. * Observable signaled when VR request present is complete
  15332. */
  15333. onVRRequestPresentComplete: Observable<boolean>;
  15334. /**
  15335. * Observable signaled when VR request present starts
  15336. */
  15337. onVRRequestPresentStart: Observable<Engine>;
  15338. /**
  15339. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15340. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15341. */
  15342. isInVRExclusivePointerMode: boolean;
  15343. /**
  15344. * Gets a boolean indicating if a webVR device was detected
  15345. * @returns true if a webVR device was detected
  15346. */
  15347. isVRDevicePresent(): boolean;
  15348. /**
  15349. * Gets the current webVR device
  15350. * @returns the current webVR device (or null)
  15351. */
  15352. getVRDevice(): any;
  15353. /**
  15354. * Initializes a webVR display and starts listening to display change events
  15355. * The onVRDisplayChangedObservable will be notified upon these changes
  15356. * @returns A promise containing a VRDisplay and if vr is supported
  15357. */
  15358. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15359. /** @hidden */
  15360. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15361. /**
  15362. * Gets or sets the presentation attributes used to configure VR rendering
  15363. */
  15364. vrPresentationAttributes?: IVRPresentationAttributes;
  15365. /**
  15366. * Call this function to switch to webVR mode
  15367. * Will do nothing if webVR is not supported or if there is no webVR device
  15368. * @param options the webvr options provided to the camera. mainly used for multiview
  15369. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15370. */
  15371. enableVR(options: WebVROptions): void;
  15372. /** @hidden */
  15373. _onVRFullScreenTriggered(): void;
  15374. }
  15375. }
  15376. }
  15377. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15378. import { Nullable } from "babylonjs/types";
  15379. import { Observable } from "babylonjs/Misc/observable";
  15380. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15381. import { Scene } from "babylonjs/scene";
  15382. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15383. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15384. import { Node } from "babylonjs/node";
  15385. import { Ray } from "babylonjs/Culling/ray";
  15386. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15387. import "babylonjs/Engines/Extensions/engine.webVR";
  15388. /**
  15389. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15390. * IMPORTANT!! The data is right-hand data.
  15391. * @export
  15392. * @interface DevicePose
  15393. */
  15394. export interface DevicePose {
  15395. /**
  15396. * The position of the device, values in array are [x,y,z].
  15397. */
  15398. readonly position: Nullable<Float32Array>;
  15399. /**
  15400. * The linearVelocity of the device, values in array are [x,y,z].
  15401. */
  15402. readonly linearVelocity: Nullable<Float32Array>;
  15403. /**
  15404. * The linearAcceleration of the device, values in array are [x,y,z].
  15405. */
  15406. readonly linearAcceleration: Nullable<Float32Array>;
  15407. /**
  15408. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15409. */
  15410. readonly orientation: Nullable<Float32Array>;
  15411. /**
  15412. * The angularVelocity of the device, values in array are [x,y,z].
  15413. */
  15414. readonly angularVelocity: Nullable<Float32Array>;
  15415. /**
  15416. * The angularAcceleration of the device, values in array are [x,y,z].
  15417. */
  15418. readonly angularAcceleration: Nullable<Float32Array>;
  15419. }
  15420. /**
  15421. * Interface representing a pose controlled object in Babylon.
  15422. * A pose controlled object has both regular pose values as well as pose values
  15423. * from an external device such as a VR head mounted display
  15424. */
  15425. export interface PoseControlled {
  15426. /**
  15427. * The position of the object in babylon space.
  15428. */
  15429. position: Vector3;
  15430. /**
  15431. * The rotation quaternion of the object in babylon space.
  15432. */
  15433. rotationQuaternion: Quaternion;
  15434. /**
  15435. * The position of the device in babylon space.
  15436. */
  15437. devicePosition?: Vector3;
  15438. /**
  15439. * The rotation quaternion of the device in babylon space.
  15440. */
  15441. deviceRotationQuaternion: Quaternion;
  15442. /**
  15443. * The raw pose coming from the device.
  15444. */
  15445. rawPose: Nullable<DevicePose>;
  15446. /**
  15447. * The scale of the device to be used when translating from device space to babylon space.
  15448. */
  15449. deviceScaleFactor: number;
  15450. /**
  15451. * Updates the poseControlled values based on the input device pose.
  15452. * @param poseData the pose data to update the object with
  15453. */
  15454. updateFromDevice(poseData: DevicePose): void;
  15455. }
  15456. /**
  15457. * Set of options to customize the webVRCamera
  15458. */
  15459. export interface WebVROptions {
  15460. /**
  15461. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15462. */
  15463. trackPosition?: boolean;
  15464. /**
  15465. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15466. */
  15467. positionScale?: number;
  15468. /**
  15469. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15470. */
  15471. displayName?: string;
  15472. /**
  15473. * Should the native controller meshes be initialized. (default: true)
  15474. */
  15475. controllerMeshes?: boolean;
  15476. /**
  15477. * Creating a default HemiLight only on controllers. (default: true)
  15478. */
  15479. defaultLightingOnControllers?: boolean;
  15480. /**
  15481. * If you don't want to use the default VR button of the helper. (default: false)
  15482. */
  15483. useCustomVRButton?: boolean;
  15484. /**
  15485. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15486. */
  15487. customVRButton?: HTMLButtonElement;
  15488. /**
  15489. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15490. */
  15491. rayLength?: number;
  15492. /**
  15493. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15494. */
  15495. defaultHeight?: number;
  15496. /**
  15497. * If multiview should be used if availible (default: false)
  15498. */
  15499. useMultiview?: boolean;
  15500. }
  15501. /**
  15502. * This represents a WebVR camera.
  15503. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15504. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15505. */
  15506. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15507. private webVROptions;
  15508. /**
  15509. * @hidden
  15510. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15511. */
  15512. _vrDevice: any;
  15513. /**
  15514. * The rawPose of the vrDevice.
  15515. */
  15516. rawPose: Nullable<DevicePose>;
  15517. private _onVREnabled;
  15518. private _specsVersion;
  15519. private _attached;
  15520. private _frameData;
  15521. protected _descendants: Array<Node>;
  15522. private _deviceRoomPosition;
  15523. /** @hidden */
  15524. _deviceRoomRotationQuaternion: Quaternion;
  15525. private _standingMatrix;
  15526. /**
  15527. * Represents device position in babylon space.
  15528. */
  15529. devicePosition: Vector3;
  15530. /**
  15531. * Represents device rotation in babylon space.
  15532. */
  15533. deviceRotationQuaternion: Quaternion;
  15534. /**
  15535. * The scale of the device to be used when translating from device space to babylon space.
  15536. */
  15537. deviceScaleFactor: number;
  15538. private _deviceToWorld;
  15539. private _worldToDevice;
  15540. /**
  15541. * References to the webVR controllers for the vrDevice.
  15542. */
  15543. controllers: Array<WebVRController>;
  15544. /**
  15545. * Emits an event when a controller is attached.
  15546. */
  15547. onControllersAttachedObservable: Observable<WebVRController[]>;
  15548. /**
  15549. * Emits an event when a controller's mesh has been loaded;
  15550. */
  15551. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15552. /**
  15553. * Emits an event when the HMD's pose has been updated.
  15554. */
  15555. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15556. private _poseSet;
  15557. /**
  15558. * If the rig cameras be used as parent instead of this camera.
  15559. */
  15560. rigParenting: boolean;
  15561. private _lightOnControllers;
  15562. private _defaultHeight?;
  15563. /**
  15564. * Instantiates a WebVRFreeCamera.
  15565. * @param name The name of the WebVRFreeCamera
  15566. * @param position The starting anchor position for the camera
  15567. * @param scene The scene the camera belongs to
  15568. * @param webVROptions a set of customizable options for the webVRCamera
  15569. */
  15570. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15571. /**
  15572. * Gets the device distance from the ground in meters.
  15573. * @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.
  15574. */
  15575. deviceDistanceToRoomGround(): number;
  15576. /**
  15577. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15578. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15579. */
  15580. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15581. /**
  15582. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15583. * @returns A promise with a boolean set to if the standing matrix is supported.
  15584. */
  15585. useStandingMatrixAsync(): Promise<boolean>;
  15586. /**
  15587. * Disposes the camera
  15588. */
  15589. dispose(): void;
  15590. /**
  15591. * Gets a vrController by name.
  15592. * @param name The name of the controller to retreive
  15593. * @returns the controller matching the name specified or null if not found
  15594. */
  15595. getControllerByName(name: string): Nullable<WebVRController>;
  15596. private _leftController;
  15597. /**
  15598. * The controller corresponding to the users left hand.
  15599. */
  15600. readonly leftController: Nullable<WebVRController>;
  15601. private _rightController;
  15602. /**
  15603. * The controller corresponding to the users right hand.
  15604. */
  15605. readonly rightController: Nullable<WebVRController>;
  15606. /**
  15607. * Casts a ray forward from the vrCamera's gaze.
  15608. * @param length Length of the ray (default: 100)
  15609. * @returns the ray corresponding to the gaze
  15610. */
  15611. getForwardRay(length?: number): Ray;
  15612. /**
  15613. * @hidden
  15614. * Updates the camera based on device's frame data
  15615. */
  15616. _checkInputs(): void;
  15617. /**
  15618. * Updates the poseControlled values based on the input device pose.
  15619. * @param poseData Pose coming from the device
  15620. */
  15621. updateFromDevice(poseData: DevicePose): void;
  15622. private _htmlElementAttached;
  15623. private _detachIfAttached;
  15624. /**
  15625. * WebVR's attach control will start broadcasting frames to the device.
  15626. * Note that in certain browsers (chrome for example) this function must be called
  15627. * within a user-interaction callback. Example:
  15628. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15629. *
  15630. * @param element html element to attach the vrDevice to
  15631. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15632. */
  15633. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15634. /**
  15635. * Detaches the camera from the html element and disables VR
  15636. *
  15637. * @param element html element to detach from
  15638. */
  15639. detachControl(element: HTMLElement): void;
  15640. /**
  15641. * @returns the name of this class
  15642. */
  15643. getClassName(): string;
  15644. /**
  15645. * Calls resetPose on the vrDisplay
  15646. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15647. */
  15648. resetToCurrentRotation(): void;
  15649. /**
  15650. * @hidden
  15651. * Updates the rig cameras (left and right eye)
  15652. */
  15653. _updateRigCameras(): void;
  15654. private _workingVector;
  15655. private _oneVector;
  15656. private _workingMatrix;
  15657. private updateCacheCalled;
  15658. private _correctPositionIfNotTrackPosition;
  15659. /**
  15660. * @hidden
  15661. * Updates the cached values of the camera
  15662. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15663. */
  15664. _updateCache(ignoreParentClass?: boolean): void;
  15665. /**
  15666. * @hidden
  15667. * Get current device position in babylon world
  15668. */
  15669. _computeDevicePosition(): void;
  15670. /**
  15671. * Updates the current device position and rotation in the babylon world
  15672. */
  15673. update(): void;
  15674. /**
  15675. * @hidden
  15676. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15677. * @returns an identity matrix
  15678. */
  15679. _getViewMatrix(): Matrix;
  15680. private _tmpMatrix;
  15681. /**
  15682. * This function is called by the two RIG cameras.
  15683. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15684. * @hidden
  15685. */
  15686. _getWebVRViewMatrix(): Matrix;
  15687. /** @hidden */
  15688. _getWebVRProjectionMatrix(): Matrix;
  15689. private _onGamepadConnectedObserver;
  15690. private _onGamepadDisconnectedObserver;
  15691. private _updateCacheWhenTrackingDisabledObserver;
  15692. /**
  15693. * Initializes the controllers and their meshes
  15694. */
  15695. initControllers(): void;
  15696. }
  15697. }
  15698. declare module "babylonjs/PostProcesses/postProcess" {
  15699. import { Nullable } from "babylonjs/types";
  15700. import { SmartArray } from "babylonjs/Misc/smartArray";
  15701. import { Observable } from "babylonjs/Misc/observable";
  15702. import { Vector2 } from "babylonjs/Maths/math.vector";
  15703. import { Camera } from "babylonjs/Cameras/camera";
  15704. import { Effect } from "babylonjs/Materials/effect";
  15705. import "babylonjs/Shaders/postprocess.vertex";
  15706. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15707. import { Engine } from "babylonjs/Engines/engine";
  15708. import { Color4 } from "babylonjs/Maths/math.color";
  15709. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15710. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15711. /**
  15712. * Size options for a post process
  15713. */
  15714. export type PostProcessOptions = {
  15715. width: number;
  15716. height: number;
  15717. };
  15718. /**
  15719. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15720. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15721. */
  15722. export class PostProcess {
  15723. /** Name of the PostProcess. */
  15724. name: string;
  15725. /**
  15726. * Gets or sets the unique id of the post process
  15727. */
  15728. uniqueId: number;
  15729. /**
  15730. * Width of the texture to apply the post process on
  15731. */
  15732. width: number;
  15733. /**
  15734. * Height of the texture to apply the post process on
  15735. */
  15736. height: number;
  15737. /**
  15738. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15739. * @hidden
  15740. */
  15741. _outputTexture: Nullable<InternalTexture>;
  15742. /**
  15743. * Sampling mode used by the shader
  15744. * See https://doc.babylonjs.com/classes/3.1/texture
  15745. */
  15746. renderTargetSamplingMode: number;
  15747. /**
  15748. * Clear color to use when screen clearing
  15749. */
  15750. clearColor: Color4;
  15751. /**
  15752. * If the buffer needs to be cleared before applying the post process. (default: true)
  15753. * Should be set to false if shader will overwrite all previous pixels.
  15754. */
  15755. autoClear: boolean;
  15756. /**
  15757. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15758. */
  15759. alphaMode: number;
  15760. /**
  15761. * Sets the setAlphaBlendConstants of the babylon engine
  15762. */
  15763. alphaConstants: Color4;
  15764. /**
  15765. * Animations to be used for the post processing
  15766. */
  15767. animations: import("babylonjs/Animations/animation").Animation[];
  15768. /**
  15769. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15770. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15771. */
  15772. enablePixelPerfectMode: boolean;
  15773. /**
  15774. * Force the postprocess to be applied without taking in account viewport
  15775. */
  15776. forceFullscreenViewport: boolean;
  15777. /**
  15778. * List of inspectable custom properties (used by the Inspector)
  15779. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15780. */
  15781. inspectableCustomProperties: IInspectable[];
  15782. /**
  15783. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15784. *
  15785. * | Value | Type | Description |
  15786. * | ----- | ----------------------------------- | ----------- |
  15787. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15788. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15789. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15790. *
  15791. */
  15792. scaleMode: number;
  15793. /**
  15794. * Force textures to be a power of two (default: false)
  15795. */
  15796. alwaysForcePOT: boolean;
  15797. private _samples;
  15798. /**
  15799. * Number of sample textures (default: 1)
  15800. */
  15801. samples: number;
  15802. /**
  15803. * Modify the scale of the post process to be the same as the viewport (default: false)
  15804. */
  15805. adaptScaleToCurrentViewport: boolean;
  15806. private _camera;
  15807. private _scene;
  15808. private _engine;
  15809. private _options;
  15810. private _reusable;
  15811. private _textureType;
  15812. /**
  15813. * Smart array of input and output textures for the post process.
  15814. * @hidden
  15815. */
  15816. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15817. /**
  15818. * The index in _textures that corresponds to the output texture.
  15819. * @hidden
  15820. */
  15821. _currentRenderTextureInd: number;
  15822. private _effect;
  15823. private _samplers;
  15824. private _fragmentUrl;
  15825. private _vertexUrl;
  15826. private _parameters;
  15827. private _scaleRatio;
  15828. protected _indexParameters: any;
  15829. private _shareOutputWithPostProcess;
  15830. private _texelSize;
  15831. private _forcedOutputTexture;
  15832. /**
  15833. * Returns the fragment url or shader name used in the post process.
  15834. * @returns the fragment url or name in the shader store.
  15835. */
  15836. getEffectName(): string;
  15837. /**
  15838. * An event triggered when the postprocess is activated.
  15839. */
  15840. onActivateObservable: Observable<Camera>;
  15841. private _onActivateObserver;
  15842. /**
  15843. * A function that is added to the onActivateObservable
  15844. */
  15845. onActivate: Nullable<(camera: Camera) => void>;
  15846. /**
  15847. * An event triggered when the postprocess changes its size.
  15848. */
  15849. onSizeChangedObservable: Observable<PostProcess>;
  15850. private _onSizeChangedObserver;
  15851. /**
  15852. * A function that is added to the onSizeChangedObservable
  15853. */
  15854. onSizeChanged: (postProcess: PostProcess) => void;
  15855. /**
  15856. * An event triggered when the postprocess applies its effect.
  15857. */
  15858. onApplyObservable: Observable<Effect>;
  15859. private _onApplyObserver;
  15860. /**
  15861. * A function that is added to the onApplyObservable
  15862. */
  15863. onApply: (effect: Effect) => void;
  15864. /**
  15865. * An event triggered before rendering the postprocess
  15866. */
  15867. onBeforeRenderObservable: Observable<Effect>;
  15868. private _onBeforeRenderObserver;
  15869. /**
  15870. * A function that is added to the onBeforeRenderObservable
  15871. */
  15872. onBeforeRender: (effect: Effect) => void;
  15873. /**
  15874. * An event triggered after rendering the postprocess
  15875. */
  15876. onAfterRenderObservable: Observable<Effect>;
  15877. private _onAfterRenderObserver;
  15878. /**
  15879. * A function that is added to the onAfterRenderObservable
  15880. */
  15881. onAfterRender: (efect: Effect) => void;
  15882. /**
  15883. * 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
  15884. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15885. */
  15886. inputTexture: InternalTexture;
  15887. /**
  15888. * Gets the camera which post process is applied to.
  15889. * @returns The camera the post process is applied to.
  15890. */
  15891. getCamera(): Camera;
  15892. /**
  15893. * Gets the texel size of the postprocess.
  15894. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15895. */
  15896. readonly texelSize: Vector2;
  15897. /**
  15898. * Creates a new instance PostProcess
  15899. * @param name The name of the PostProcess.
  15900. * @param fragmentUrl The url of the fragment shader to be used.
  15901. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15902. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15903. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15904. * @param camera The camera to apply the render pass to.
  15905. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15906. * @param engine The engine which the post process will be applied. (default: current engine)
  15907. * @param reusable If the post process can be reused on the same frame. (default: false)
  15908. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15909. * @param textureType Type of textures used when performing the post process. (default: 0)
  15910. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15911. * @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
  15912. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15913. */
  15914. constructor(
  15915. /** Name of the PostProcess. */
  15916. 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);
  15917. /**
  15918. * Gets a string idenfifying the name of the class
  15919. * @returns "PostProcess" string
  15920. */
  15921. getClassName(): string;
  15922. /**
  15923. * Gets the engine which this post process belongs to.
  15924. * @returns The engine the post process was enabled with.
  15925. */
  15926. getEngine(): Engine;
  15927. /**
  15928. * The effect that is created when initializing the post process.
  15929. * @returns The created effect corresponding the the postprocess.
  15930. */
  15931. getEffect(): Effect;
  15932. /**
  15933. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15934. * @param postProcess The post process to share the output with.
  15935. * @returns This post process.
  15936. */
  15937. shareOutputWith(postProcess: PostProcess): PostProcess;
  15938. /**
  15939. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15940. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15941. */
  15942. useOwnOutput(): void;
  15943. /**
  15944. * Updates the effect with the current post process compile time values and recompiles the shader.
  15945. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15946. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15947. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15948. * @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
  15949. * @param onCompiled Called when the shader has been compiled.
  15950. * @param onError Called if there is an error when compiling a shader.
  15951. */
  15952. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15953. /**
  15954. * The post process is reusable if it can be used multiple times within one frame.
  15955. * @returns If the post process is reusable
  15956. */
  15957. isReusable(): boolean;
  15958. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15959. markTextureDirty(): void;
  15960. /**
  15961. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15962. * 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.
  15963. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15964. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15965. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15966. * @returns The target texture that was bound to be written to.
  15967. */
  15968. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15969. /**
  15970. * If the post process is supported.
  15971. */
  15972. readonly isSupported: boolean;
  15973. /**
  15974. * The aspect ratio of the output texture.
  15975. */
  15976. readonly aspectRatio: number;
  15977. /**
  15978. * Get a value indicating if the post-process is ready to be used
  15979. * @returns true if the post-process is ready (shader is compiled)
  15980. */
  15981. isReady(): boolean;
  15982. /**
  15983. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15984. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15985. */
  15986. apply(): Nullable<Effect>;
  15987. private _disposeTextures;
  15988. /**
  15989. * Disposes the post process.
  15990. * @param camera The camera to dispose the post process on.
  15991. */
  15992. dispose(camera?: Camera): void;
  15993. }
  15994. }
  15995. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15996. /** @hidden */
  15997. export var kernelBlurVaryingDeclaration: {
  15998. name: string;
  15999. shader: string;
  16000. };
  16001. }
  16002. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  16003. /** @hidden */
  16004. export var kernelBlurFragment: {
  16005. name: string;
  16006. shader: string;
  16007. };
  16008. }
  16009. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  16010. /** @hidden */
  16011. export var kernelBlurFragment2: {
  16012. name: string;
  16013. shader: string;
  16014. };
  16015. }
  16016. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  16017. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16018. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  16019. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  16020. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  16021. /** @hidden */
  16022. export var kernelBlurPixelShader: {
  16023. name: string;
  16024. shader: string;
  16025. };
  16026. }
  16027. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  16028. /** @hidden */
  16029. export var kernelBlurVertex: {
  16030. name: string;
  16031. shader: string;
  16032. };
  16033. }
  16034. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  16035. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16036. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  16037. /** @hidden */
  16038. export var kernelBlurVertexShader: {
  16039. name: string;
  16040. shader: string;
  16041. };
  16042. }
  16043. declare module "babylonjs/PostProcesses/blurPostProcess" {
  16044. import { Vector2 } from "babylonjs/Maths/math.vector";
  16045. import { Nullable } from "babylonjs/types";
  16046. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  16047. import { Camera } from "babylonjs/Cameras/camera";
  16048. import { Effect } from "babylonjs/Materials/effect";
  16049. import { Engine } from "babylonjs/Engines/engine";
  16050. import "babylonjs/Shaders/kernelBlur.fragment";
  16051. import "babylonjs/Shaders/kernelBlur.vertex";
  16052. /**
  16053. * The Blur Post Process which blurs an image based on a kernel and direction.
  16054. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  16055. */
  16056. export class BlurPostProcess extends PostProcess {
  16057. /** The direction in which to blur the image. */
  16058. direction: Vector2;
  16059. private blockCompilation;
  16060. protected _kernel: number;
  16061. protected _idealKernel: number;
  16062. protected _packedFloat: boolean;
  16063. private _staticDefines;
  16064. /**
  16065. * Sets the length in pixels of the blur sample region
  16066. */
  16067. /**
  16068. * Gets the length in pixels of the blur sample region
  16069. */
  16070. kernel: number;
  16071. /**
  16072. * Sets wether or not the blur needs to unpack/repack floats
  16073. */
  16074. /**
  16075. * Gets wether or not the blur is unpacking/repacking floats
  16076. */
  16077. packedFloat: boolean;
  16078. /**
  16079. * Creates a new instance BlurPostProcess
  16080. * @param name The name of the effect.
  16081. * @param direction The direction in which to blur the image.
  16082. * @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.
  16083. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  16084. * @param camera The camera to apply the render pass to.
  16085. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  16086. * @param engine The engine which the post process will be applied. (default: current engine)
  16087. * @param reusable If the post process can be reused on the same frame. (default: false)
  16088. * @param textureType Type of textures used when performing the post process. (default: 0)
  16089. * @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)
  16090. */
  16091. constructor(name: string,
  16092. /** The direction in which to blur the image. */
  16093. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  16094. /**
  16095. * Updates the effect with the current post process compile time values and recompiles the shader.
  16096. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  16097. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  16098. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  16099. * @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
  16100. * @param onCompiled Called when the shader has been compiled.
  16101. * @param onError Called if there is an error when compiling a shader.
  16102. */
  16103. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16104. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16105. /**
  16106. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  16107. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  16108. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  16109. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  16110. * The gaps between physical kernels are compensated for in the weighting of the samples
  16111. * @param idealKernel Ideal blur kernel.
  16112. * @return Nearest best kernel.
  16113. */
  16114. protected _nearestBestKernel(idealKernel: number): number;
  16115. /**
  16116. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  16117. * @param x The point on the Gaussian distribution to sample.
  16118. * @return the value of the Gaussian function at x.
  16119. */
  16120. protected _gaussianWeight(x: number): number;
  16121. /**
  16122. * Generates a string that can be used as a floating point number in GLSL.
  16123. * @param x Value to print.
  16124. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  16125. * @return GLSL float string.
  16126. */
  16127. protected _glslFloat(x: number, decimalFigures?: number): string;
  16128. }
  16129. }
  16130. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  16131. import { Scene } from "babylonjs/scene";
  16132. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16133. import { Plane } from "babylonjs/Maths/math.plane";
  16134. /**
  16135. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16136. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16137. * You can then easily use it as a reflectionTexture on a flat surface.
  16138. * In case the surface is not a plane, please consider relying on reflection probes.
  16139. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16140. */
  16141. export class MirrorTexture extends RenderTargetTexture {
  16142. private scene;
  16143. /**
  16144. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  16145. * 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.
  16146. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16147. */
  16148. mirrorPlane: Plane;
  16149. /**
  16150. * Define the blur ratio used to blur the reflection if needed.
  16151. */
  16152. blurRatio: number;
  16153. /**
  16154. * Define the adaptive blur kernel used to blur the reflection if needed.
  16155. * This will autocompute the closest best match for the `blurKernel`
  16156. */
  16157. adaptiveBlurKernel: number;
  16158. /**
  16159. * Define the blur kernel used to blur the reflection if needed.
  16160. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16161. */
  16162. blurKernel: number;
  16163. /**
  16164. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  16165. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16166. */
  16167. blurKernelX: number;
  16168. /**
  16169. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  16170. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16171. */
  16172. blurKernelY: number;
  16173. private _autoComputeBlurKernel;
  16174. protected _onRatioRescale(): void;
  16175. private _updateGammaSpace;
  16176. private _imageProcessingConfigChangeObserver;
  16177. private _transformMatrix;
  16178. private _mirrorMatrix;
  16179. private _savedViewMatrix;
  16180. private _blurX;
  16181. private _blurY;
  16182. private _adaptiveBlurKernel;
  16183. private _blurKernelX;
  16184. private _blurKernelY;
  16185. private _blurRatio;
  16186. /**
  16187. * Instantiates a Mirror Texture.
  16188. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16189. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16190. * You can then easily use it as a reflectionTexture on a flat surface.
  16191. * In case the surface is not a plane, please consider relying on reflection probes.
  16192. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16193. * @param name
  16194. * @param size
  16195. * @param scene
  16196. * @param generateMipMaps
  16197. * @param type
  16198. * @param samplingMode
  16199. * @param generateDepthBuffer
  16200. */
  16201. constructor(name: string, size: number | {
  16202. width: number;
  16203. height: number;
  16204. } | {
  16205. ratio: number;
  16206. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16207. private _preparePostProcesses;
  16208. /**
  16209. * Clone the mirror texture.
  16210. * @returns the cloned texture
  16211. */
  16212. clone(): MirrorTexture;
  16213. /**
  16214. * Serialize the texture to a JSON representation you could use in Parse later on
  16215. * @returns the serialized JSON representation
  16216. */
  16217. serialize(): any;
  16218. /**
  16219. * Dispose the texture and release its associated resources.
  16220. */
  16221. dispose(): void;
  16222. }
  16223. }
  16224. declare module "babylonjs/Materials/Textures/texture" {
  16225. import { Observable } from "babylonjs/Misc/observable";
  16226. import { Nullable } from "babylonjs/types";
  16227. import { Matrix } from "babylonjs/Maths/math.vector";
  16228. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16229. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16230. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  16231. import { Scene } from "babylonjs/scene";
  16232. /**
  16233. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16234. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16235. */
  16236. export class Texture extends BaseTexture {
  16237. /**
  16238. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16239. */
  16240. static SerializeBuffers: boolean;
  16241. /** @hidden */
  16242. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  16243. /** @hidden */
  16244. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  16245. /** @hidden */
  16246. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  16247. /** nearest is mag = nearest and min = nearest and mip = linear */
  16248. static readonly NEAREST_SAMPLINGMODE: number;
  16249. /** nearest is mag = nearest and min = nearest and mip = linear */
  16250. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16251. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16252. static readonly BILINEAR_SAMPLINGMODE: number;
  16253. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16254. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16255. /** Trilinear is mag = linear and min = linear and mip = linear */
  16256. static readonly TRILINEAR_SAMPLINGMODE: number;
  16257. /** Trilinear is mag = linear and min = linear and mip = linear */
  16258. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16259. /** mag = nearest and min = nearest and mip = nearest */
  16260. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16261. /** mag = nearest and min = linear and mip = nearest */
  16262. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16263. /** mag = nearest and min = linear and mip = linear */
  16264. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16265. /** mag = nearest and min = linear and mip = none */
  16266. static readonly NEAREST_LINEAR: number;
  16267. /** mag = nearest and min = nearest and mip = none */
  16268. static readonly NEAREST_NEAREST: number;
  16269. /** mag = linear and min = nearest and mip = nearest */
  16270. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16271. /** mag = linear and min = nearest and mip = linear */
  16272. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16273. /** mag = linear and min = linear and mip = none */
  16274. static readonly LINEAR_LINEAR: number;
  16275. /** mag = linear and min = nearest and mip = none */
  16276. static readonly LINEAR_NEAREST: number;
  16277. /** Explicit coordinates mode */
  16278. static readonly EXPLICIT_MODE: number;
  16279. /** Spherical coordinates mode */
  16280. static readonly SPHERICAL_MODE: number;
  16281. /** Planar coordinates mode */
  16282. static readonly PLANAR_MODE: number;
  16283. /** Cubic coordinates mode */
  16284. static readonly CUBIC_MODE: number;
  16285. /** Projection coordinates mode */
  16286. static readonly PROJECTION_MODE: number;
  16287. /** Inverse Cubic coordinates mode */
  16288. static readonly SKYBOX_MODE: number;
  16289. /** Inverse Cubic coordinates mode */
  16290. static readonly INVCUBIC_MODE: number;
  16291. /** Equirectangular coordinates mode */
  16292. static readonly EQUIRECTANGULAR_MODE: number;
  16293. /** Equirectangular Fixed coordinates mode */
  16294. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16295. /** Equirectangular Fixed Mirrored coordinates mode */
  16296. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16297. /** Texture is not repeating outside of 0..1 UVs */
  16298. static readonly CLAMP_ADDRESSMODE: number;
  16299. /** Texture is repeating outside of 0..1 UVs */
  16300. static readonly WRAP_ADDRESSMODE: number;
  16301. /** Texture is repeating and mirrored */
  16302. static readonly MIRROR_ADDRESSMODE: number;
  16303. /**
  16304. * 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
  16305. */
  16306. static UseSerializedUrlIfAny: boolean;
  16307. /**
  16308. * Define the url of the texture.
  16309. */
  16310. url: Nullable<string>;
  16311. /**
  16312. * Define an offset on the texture to offset the u coordinates of the UVs
  16313. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16314. */
  16315. uOffset: number;
  16316. /**
  16317. * Define an offset on the texture to offset the v coordinates of the UVs
  16318. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16319. */
  16320. vOffset: number;
  16321. /**
  16322. * Define an offset on the texture to scale the u coordinates of the UVs
  16323. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16324. */
  16325. uScale: number;
  16326. /**
  16327. * Define an offset on the texture to scale the v coordinates of the UVs
  16328. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16329. */
  16330. vScale: number;
  16331. /**
  16332. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16333. * @see http://doc.babylonjs.com/how_to/more_materials
  16334. */
  16335. uAng: number;
  16336. /**
  16337. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16338. * @see http://doc.babylonjs.com/how_to/more_materials
  16339. */
  16340. vAng: number;
  16341. /**
  16342. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16343. * @see http://doc.babylonjs.com/how_to/more_materials
  16344. */
  16345. wAng: number;
  16346. /**
  16347. * Defines the center of rotation (U)
  16348. */
  16349. uRotationCenter: number;
  16350. /**
  16351. * Defines the center of rotation (V)
  16352. */
  16353. vRotationCenter: number;
  16354. /**
  16355. * Defines the center of rotation (W)
  16356. */
  16357. wRotationCenter: number;
  16358. /**
  16359. * Are mip maps generated for this texture or not.
  16360. */
  16361. readonly noMipmap: boolean;
  16362. /**
  16363. * List of inspectable custom properties (used by the Inspector)
  16364. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16365. */
  16366. inspectableCustomProperties: Nullable<IInspectable[]>;
  16367. private _noMipmap;
  16368. /** @hidden */
  16369. _invertY: boolean;
  16370. private _rowGenerationMatrix;
  16371. private _cachedTextureMatrix;
  16372. private _projectionModeMatrix;
  16373. private _t0;
  16374. private _t1;
  16375. private _t2;
  16376. private _cachedUOffset;
  16377. private _cachedVOffset;
  16378. private _cachedUScale;
  16379. private _cachedVScale;
  16380. private _cachedUAng;
  16381. private _cachedVAng;
  16382. private _cachedWAng;
  16383. private _cachedProjectionMatrixId;
  16384. private _cachedCoordinatesMode;
  16385. /** @hidden */
  16386. protected _initialSamplingMode: number;
  16387. /** @hidden */
  16388. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16389. private _deleteBuffer;
  16390. protected _format: Nullable<number>;
  16391. private _delayedOnLoad;
  16392. private _delayedOnError;
  16393. private _mimeType?;
  16394. /**
  16395. * Observable triggered once the texture has been loaded.
  16396. */
  16397. onLoadObservable: Observable<Texture>;
  16398. protected _isBlocking: boolean;
  16399. /**
  16400. * Is the texture preventing material to render while loading.
  16401. * If false, a default texture will be used instead of the loading one during the preparation step.
  16402. */
  16403. isBlocking: boolean;
  16404. /**
  16405. * Get the current sampling mode associated with the texture.
  16406. */
  16407. readonly samplingMode: number;
  16408. /**
  16409. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16410. */
  16411. readonly invertY: boolean;
  16412. /**
  16413. * Instantiates a new texture.
  16414. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16415. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16416. * @param url defines the url of the picture to load as a texture
  16417. * @param scene defines the scene or engine the texture will belong to
  16418. * @param noMipmap defines if the texture will require mip maps or not
  16419. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16420. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16421. * @param onLoad defines a callback triggered when the texture has been loaded
  16422. * @param onError defines a callback triggered when an error occurred during the loading session
  16423. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16424. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16425. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16426. * @param mimeType defines an optional mime type information
  16427. */
  16428. 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);
  16429. /**
  16430. * Update the url (and optional buffer) of this texture if url was null during construction.
  16431. * @param url the url of the texture
  16432. * @param buffer the buffer of the texture (defaults to null)
  16433. * @param onLoad callback called when the texture is loaded (defaults to null)
  16434. */
  16435. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16436. /**
  16437. * Finish the loading sequence of a texture flagged as delayed load.
  16438. * @hidden
  16439. */
  16440. delayLoad(): void;
  16441. private _prepareRowForTextureGeneration;
  16442. /**
  16443. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16444. * @returns the transform matrix of the texture.
  16445. */
  16446. getTextureMatrix(uBase?: number): Matrix;
  16447. /**
  16448. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16449. * @returns The reflection texture transform
  16450. */
  16451. getReflectionTextureMatrix(): Matrix;
  16452. /**
  16453. * Clones the texture.
  16454. * @returns the cloned texture
  16455. */
  16456. clone(): Texture;
  16457. /**
  16458. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16459. * @returns The JSON representation of the texture
  16460. */
  16461. serialize(): any;
  16462. /**
  16463. * Get the current class name of the texture useful for serialization or dynamic coding.
  16464. * @returns "Texture"
  16465. */
  16466. getClassName(): string;
  16467. /**
  16468. * Dispose the texture and release its associated resources.
  16469. */
  16470. dispose(): void;
  16471. /**
  16472. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16473. * @param parsedTexture Define the JSON representation of the texture
  16474. * @param scene Define the scene the parsed texture should be instantiated in
  16475. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16476. * @returns The parsed texture if successful
  16477. */
  16478. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16479. /**
  16480. * Creates a texture from its base 64 representation.
  16481. * @param data Define the base64 payload without the data: prefix
  16482. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16483. * @param scene Define the scene the texture should belong to
  16484. * @param noMipmap Forces the texture to not create mip map information if true
  16485. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16486. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16487. * @param onLoad define a callback triggered when the texture has been loaded
  16488. * @param onError define a callback triggered when an error occurred during the loading session
  16489. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16490. * @returns the created texture
  16491. */
  16492. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16493. /**
  16494. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16495. * @param data Define the base64 payload without the data: prefix
  16496. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16497. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16498. * @param scene Define the scene the texture should belong to
  16499. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16500. * @param noMipmap Forces the texture to not create mip map information if true
  16501. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16502. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16503. * @param onLoad define a callback triggered when the texture has been loaded
  16504. * @param onError define a callback triggered when an error occurred during the loading session
  16505. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16506. * @returns the created texture
  16507. */
  16508. 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;
  16509. }
  16510. }
  16511. declare module "babylonjs/PostProcesses/postProcessManager" {
  16512. import { Nullable } from "babylonjs/types";
  16513. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16514. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16515. import { Scene } from "babylonjs/scene";
  16516. /**
  16517. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16518. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16519. */
  16520. export class PostProcessManager {
  16521. private _scene;
  16522. private _indexBuffer;
  16523. private _vertexBuffers;
  16524. /**
  16525. * Creates a new instance PostProcess
  16526. * @param scene The scene that the post process is associated with.
  16527. */
  16528. constructor(scene: Scene);
  16529. private _prepareBuffers;
  16530. private _buildIndexBuffer;
  16531. /**
  16532. * Rebuilds the vertex buffers of the manager.
  16533. * @hidden
  16534. */
  16535. _rebuild(): void;
  16536. /**
  16537. * Prepares a frame to be run through a post process.
  16538. * @param sourceTexture The input texture to the post procesess. (default: null)
  16539. * @param postProcesses An array of post processes to be run. (default: null)
  16540. * @returns True if the post processes were able to be run.
  16541. * @hidden
  16542. */
  16543. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16544. /**
  16545. * Manually render a set of post processes to a texture.
  16546. * @param postProcesses An array of post processes to be run.
  16547. * @param targetTexture The target texture to render to.
  16548. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16549. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16550. * @param lodLevel defines which lod of the texture to render to
  16551. */
  16552. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16553. /**
  16554. * Finalize the result of the output of the postprocesses.
  16555. * @param doNotPresent If true the result will not be displayed to the screen.
  16556. * @param targetTexture The target texture to render to.
  16557. * @param faceIndex The index of the face to bind the target texture to.
  16558. * @param postProcesses The array of post processes to render.
  16559. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16560. * @hidden
  16561. */
  16562. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16563. /**
  16564. * Disposes of the post process manager.
  16565. */
  16566. dispose(): void;
  16567. }
  16568. }
  16569. declare module "babylonjs/Misc/gradients" {
  16570. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16571. /** Interface used by value gradients (color, factor, ...) */
  16572. export interface IValueGradient {
  16573. /**
  16574. * Gets or sets the gradient value (between 0 and 1)
  16575. */
  16576. gradient: number;
  16577. }
  16578. /** Class used to store color4 gradient */
  16579. export class ColorGradient implements IValueGradient {
  16580. /**
  16581. * Gets or sets the gradient value (between 0 and 1)
  16582. */
  16583. gradient: number;
  16584. /**
  16585. * Gets or sets first associated color
  16586. */
  16587. color1: Color4;
  16588. /**
  16589. * Gets or sets second associated color
  16590. */
  16591. color2?: Color4;
  16592. /**
  16593. * Will get a color picked randomly between color1 and color2.
  16594. * If color2 is undefined then color1 will be used
  16595. * @param result defines the target Color4 to store the result in
  16596. */
  16597. getColorToRef(result: Color4): void;
  16598. }
  16599. /** Class used to store color 3 gradient */
  16600. export class Color3Gradient implements IValueGradient {
  16601. /**
  16602. * Gets or sets the gradient value (between 0 and 1)
  16603. */
  16604. gradient: number;
  16605. /**
  16606. * Gets or sets the associated color
  16607. */
  16608. color: Color3;
  16609. }
  16610. /** Class used to store factor gradient */
  16611. export class FactorGradient implements IValueGradient {
  16612. /**
  16613. * Gets or sets the gradient value (between 0 and 1)
  16614. */
  16615. gradient: number;
  16616. /**
  16617. * Gets or sets first associated factor
  16618. */
  16619. factor1: number;
  16620. /**
  16621. * Gets or sets second associated factor
  16622. */
  16623. factor2?: number;
  16624. /**
  16625. * Will get a number picked randomly between factor1 and factor2.
  16626. * If factor2 is undefined then factor1 will be used
  16627. * @returns the picked number
  16628. */
  16629. getFactor(): number;
  16630. }
  16631. /**
  16632. * Helper used to simplify some generic gradient tasks
  16633. */
  16634. export class GradientHelper {
  16635. /**
  16636. * Gets the current gradient from an array of IValueGradient
  16637. * @param ratio defines the current ratio to get
  16638. * @param gradients defines the array of IValueGradient
  16639. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16640. */
  16641. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16642. }
  16643. }
  16644. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16645. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16646. import { Nullable } from "babylonjs/types";
  16647. module "babylonjs/Engines/thinEngine" {
  16648. interface ThinEngine {
  16649. /**
  16650. * Creates a dynamic texture
  16651. * @param width defines the width of the texture
  16652. * @param height defines the height of the texture
  16653. * @param generateMipMaps defines if the engine should generate the mip levels
  16654. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16655. * @returns the dynamic texture inside an InternalTexture
  16656. */
  16657. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16658. /**
  16659. * Update the content of a dynamic texture
  16660. * @param texture defines the texture to update
  16661. * @param canvas defines the canvas containing the source
  16662. * @param invertY defines if data must be stored with Y axis inverted
  16663. * @param premulAlpha defines if alpha is stored as premultiplied
  16664. * @param format defines the format of the data
  16665. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16666. */
  16667. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16668. }
  16669. }
  16670. }
  16671. declare module "babylonjs/Misc/canvasGenerator" {
  16672. /**
  16673. * Helper class used to generate a canvas to manipulate images
  16674. */
  16675. export class CanvasGenerator {
  16676. /**
  16677. * Create a new canvas (or offscreen canvas depending on the context)
  16678. * @param width defines the expected width
  16679. * @param height defines the expected height
  16680. * @return a new canvas or offscreen canvas
  16681. */
  16682. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16683. }
  16684. }
  16685. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16686. import { Scene } from "babylonjs/scene";
  16687. import { Texture } from "babylonjs/Materials/Textures/texture";
  16688. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16689. /**
  16690. * A class extending Texture allowing drawing on a texture
  16691. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16692. */
  16693. export class DynamicTexture extends Texture {
  16694. private _generateMipMaps;
  16695. private _canvas;
  16696. private _context;
  16697. private _engine;
  16698. /**
  16699. * Creates a DynamicTexture
  16700. * @param name defines the name of the texture
  16701. * @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
  16702. * @param scene defines the scene where you want the texture
  16703. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16704. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16705. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16706. */
  16707. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16708. /**
  16709. * Get the current class name of the texture useful for serialization or dynamic coding.
  16710. * @returns "DynamicTexture"
  16711. */
  16712. getClassName(): string;
  16713. /**
  16714. * Gets the current state of canRescale
  16715. */
  16716. readonly canRescale: boolean;
  16717. private _recreate;
  16718. /**
  16719. * Scales the texture
  16720. * @param ratio the scale factor to apply to both width and height
  16721. */
  16722. scale(ratio: number): void;
  16723. /**
  16724. * Resizes the texture
  16725. * @param width the new width
  16726. * @param height the new height
  16727. */
  16728. scaleTo(width: number, height: number): void;
  16729. /**
  16730. * Gets the context of the canvas used by the texture
  16731. * @returns the canvas context of the dynamic texture
  16732. */
  16733. getContext(): CanvasRenderingContext2D;
  16734. /**
  16735. * Clears the texture
  16736. */
  16737. clear(): void;
  16738. /**
  16739. * Updates the texture
  16740. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16741. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16742. */
  16743. update(invertY?: boolean, premulAlpha?: boolean): void;
  16744. /**
  16745. * Draws text onto the texture
  16746. * @param text defines the text to be drawn
  16747. * @param x defines the placement of the text from the left
  16748. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16749. * @param font defines the font to be used with font-style, font-size, font-name
  16750. * @param color defines the color used for the text
  16751. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16752. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16753. * @param update defines whether texture is immediately update (default is true)
  16754. */
  16755. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16756. /**
  16757. * Clones the texture
  16758. * @returns the clone of the texture.
  16759. */
  16760. clone(): DynamicTexture;
  16761. /**
  16762. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16763. * @returns a serialized dynamic texture object
  16764. */
  16765. serialize(): any;
  16766. /** @hidden */
  16767. _rebuild(): void;
  16768. }
  16769. }
  16770. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16771. import { Scene } from "babylonjs/scene";
  16772. import { ISceneComponent } from "babylonjs/sceneComponent";
  16773. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16774. module "babylonjs/abstractScene" {
  16775. interface AbstractScene {
  16776. /**
  16777. * The list of procedural textures added to the scene
  16778. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16779. */
  16780. proceduralTextures: Array<ProceduralTexture>;
  16781. }
  16782. }
  16783. /**
  16784. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16785. * in a given scene.
  16786. */
  16787. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16788. /**
  16789. * The component name helpfull to identify the component in the list of scene components.
  16790. */
  16791. readonly name: string;
  16792. /**
  16793. * The scene the component belongs to.
  16794. */
  16795. scene: Scene;
  16796. /**
  16797. * Creates a new instance of the component for the given scene
  16798. * @param scene Defines the scene to register the component in
  16799. */
  16800. constructor(scene: Scene);
  16801. /**
  16802. * Registers the component in a given scene
  16803. */
  16804. register(): void;
  16805. /**
  16806. * Rebuilds the elements related to this component in case of
  16807. * context lost for instance.
  16808. */
  16809. rebuild(): void;
  16810. /**
  16811. * Disposes the component and the associated ressources.
  16812. */
  16813. dispose(): void;
  16814. private _beforeClear;
  16815. }
  16816. }
  16817. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  16818. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16819. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16820. module "babylonjs/Engines/thinEngine" {
  16821. interface ThinEngine {
  16822. /**
  16823. * Creates a new render target cube texture
  16824. * @param size defines the size of the texture
  16825. * @param options defines the options used to create the texture
  16826. * @returns a new render target cube texture stored in an InternalTexture
  16827. */
  16828. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16829. }
  16830. }
  16831. }
  16832. declare module "babylonjs/Shaders/procedural.vertex" {
  16833. /** @hidden */
  16834. export var proceduralVertexShader: {
  16835. name: string;
  16836. shader: string;
  16837. };
  16838. }
  16839. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16840. import { Observable } from "babylonjs/Misc/observable";
  16841. import { Nullable } from "babylonjs/types";
  16842. import { Scene } from "babylonjs/scene";
  16843. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16844. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16845. import { Effect } from "babylonjs/Materials/effect";
  16846. import { Texture } from "babylonjs/Materials/Textures/texture";
  16847. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16848. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  16849. import "babylonjs/Shaders/procedural.vertex";
  16850. /**
  16851. * 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.
  16852. * This is the base class of any Procedural texture and contains most of the shareable code.
  16853. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16854. */
  16855. export class ProceduralTexture extends Texture {
  16856. isCube: boolean;
  16857. /**
  16858. * Define if the texture is enabled or not (disabled texture will not render)
  16859. */
  16860. isEnabled: boolean;
  16861. /**
  16862. * Define if the texture must be cleared before rendering (default is true)
  16863. */
  16864. autoClear: boolean;
  16865. /**
  16866. * Callback called when the texture is generated
  16867. */
  16868. onGenerated: () => void;
  16869. /**
  16870. * Event raised when the texture is generated
  16871. */
  16872. onGeneratedObservable: Observable<ProceduralTexture>;
  16873. /** @hidden */
  16874. _generateMipMaps: boolean;
  16875. /** @hidden **/
  16876. _effect: Effect;
  16877. /** @hidden */
  16878. _textures: {
  16879. [key: string]: Texture;
  16880. };
  16881. private _size;
  16882. private _currentRefreshId;
  16883. private _refreshRate;
  16884. private _vertexBuffers;
  16885. private _indexBuffer;
  16886. private _uniforms;
  16887. private _samplers;
  16888. private _fragment;
  16889. private _floats;
  16890. private _ints;
  16891. private _floatsArrays;
  16892. private _colors3;
  16893. private _colors4;
  16894. private _vectors2;
  16895. private _vectors3;
  16896. private _matrices;
  16897. private _fallbackTexture;
  16898. private _fallbackTextureUsed;
  16899. private _engine;
  16900. private _cachedDefines;
  16901. private _contentUpdateId;
  16902. private _contentData;
  16903. /**
  16904. * Instantiates a new procedural texture.
  16905. * 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.
  16906. * This is the base class of any Procedural texture and contains most of the shareable code.
  16907. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16908. * @param name Define the name of the texture
  16909. * @param size Define the size of the texture to create
  16910. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16911. * @param scene Define the scene the texture belongs to
  16912. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16913. * @param generateMipMaps Define if the texture should creates mip maps or not
  16914. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16915. */
  16916. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16917. /**
  16918. * The effect that is created when initializing the post process.
  16919. * @returns The created effect corresponding the the postprocess.
  16920. */
  16921. getEffect(): Effect;
  16922. /**
  16923. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16924. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16925. */
  16926. getContent(): Nullable<ArrayBufferView>;
  16927. private _createIndexBuffer;
  16928. /** @hidden */
  16929. _rebuild(): void;
  16930. /**
  16931. * Resets the texture in order to recreate its associated resources.
  16932. * This can be called in case of context loss
  16933. */
  16934. reset(): void;
  16935. protected _getDefines(): string;
  16936. /**
  16937. * Is the texture ready to be used ? (rendered at least once)
  16938. * @returns true if ready, otherwise, false.
  16939. */
  16940. isReady(): boolean;
  16941. /**
  16942. * Resets the refresh counter of the texture and start bak from scratch.
  16943. * Could be useful to regenerate the texture if it is setup to render only once.
  16944. */
  16945. resetRefreshCounter(): void;
  16946. /**
  16947. * Set the fragment shader to use in order to render the texture.
  16948. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16949. */
  16950. setFragment(fragment: any): void;
  16951. /**
  16952. * Define the refresh rate of the texture or the rendering frequency.
  16953. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16954. */
  16955. refreshRate: number;
  16956. /** @hidden */
  16957. _shouldRender(): boolean;
  16958. /**
  16959. * Get the size the texture is rendering at.
  16960. * @returns the size (texture is always squared)
  16961. */
  16962. getRenderSize(): number;
  16963. /**
  16964. * Resize the texture to new value.
  16965. * @param size Define the new size the texture should have
  16966. * @param generateMipMaps Define whether the new texture should create mip maps
  16967. */
  16968. resize(size: number, generateMipMaps: boolean): void;
  16969. private _checkUniform;
  16970. /**
  16971. * Set a texture in the shader program used to render.
  16972. * @param name Define the name of the uniform samplers as defined in the shader
  16973. * @param texture Define the texture to bind to this sampler
  16974. * @return the texture itself allowing "fluent" like uniform updates
  16975. */
  16976. setTexture(name: string, texture: Texture): ProceduralTexture;
  16977. /**
  16978. * Set a float in the shader.
  16979. * @param name Define the name of the uniform as defined in the shader
  16980. * @param value Define the value to give to the uniform
  16981. * @return the texture itself allowing "fluent" like uniform updates
  16982. */
  16983. setFloat(name: string, value: number): ProceduralTexture;
  16984. /**
  16985. * Set a int in the shader.
  16986. * @param name Define the name of the uniform as defined in the shader
  16987. * @param value Define the value to give to the uniform
  16988. * @return the texture itself allowing "fluent" like uniform updates
  16989. */
  16990. setInt(name: string, value: number): ProceduralTexture;
  16991. /**
  16992. * Set an array of floats in the shader.
  16993. * @param name Define the name of the uniform as defined in the shader
  16994. * @param value Define the value to give to the uniform
  16995. * @return the texture itself allowing "fluent" like uniform updates
  16996. */
  16997. setFloats(name: string, value: number[]): ProceduralTexture;
  16998. /**
  16999. * Set a vec3 in the shader from a Color3.
  17000. * @param name Define the name of the uniform as defined in the shader
  17001. * @param value Define the value to give to the uniform
  17002. * @return the texture itself allowing "fluent" like uniform updates
  17003. */
  17004. setColor3(name: string, value: Color3): ProceduralTexture;
  17005. /**
  17006. * Set a vec4 in the shader from a Color4.
  17007. * @param name Define the name of the uniform as defined in the shader
  17008. * @param value Define the value to give to the uniform
  17009. * @return the texture itself allowing "fluent" like uniform updates
  17010. */
  17011. setColor4(name: string, value: Color4): ProceduralTexture;
  17012. /**
  17013. * Set a vec2 in the shader from a Vector2.
  17014. * @param name Define the name of the uniform as defined in the shader
  17015. * @param value Define the value to give to the uniform
  17016. * @return the texture itself allowing "fluent" like uniform updates
  17017. */
  17018. setVector2(name: string, value: Vector2): ProceduralTexture;
  17019. /**
  17020. * Set a vec3 in the shader from a Vector3.
  17021. * @param name Define the name of the uniform as defined in the shader
  17022. * @param value Define the value to give to the uniform
  17023. * @return the texture itself allowing "fluent" like uniform updates
  17024. */
  17025. setVector3(name: string, value: Vector3): ProceduralTexture;
  17026. /**
  17027. * Set a mat4 in the shader from a MAtrix.
  17028. * @param name Define the name of the uniform as defined in the shader
  17029. * @param value Define the value to give to the uniform
  17030. * @return the texture itself allowing "fluent" like uniform updates
  17031. */
  17032. setMatrix(name: string, value: Matrix): ProceduralTexture;
  17033. /**
  17034. * Render the texture to its associated render target.
  17035. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  17036. */
  17037. render(useCameraPostProcess?: boolean): void;
  17038. /**
  17039. * Clone the texture.
  17040. * @returns the cloned texture
  17041. */
  17042. clone(): ProceduralTexture;
  17043. /**
  17044. * Dispose the texture and release its asoociated resources.
  17045. */
  17046. dispose(): void;
  17047. }
  17048. }
  17049. declare module "babylonjs/Particles/baseParticleSystem" {
  17050. import { Nullable } from "babylonjs/types";
  17051. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  17052. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17053. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  17054. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  17055. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  17056. import { Scene } from "babylonjs/scene";
  17057. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  17058. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  17059. import { Texture } from "babylonjs/Materials/Textures/texture";
  17060. import { Color4 } from "babylonjs/Maths/math.color";
  17061. import { Animation } from "babylonjs/Animations/animation";
  17062. /**
  17063. * This represents the base class for particle system in Babylon.
  17064. * 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.
  17065. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17066. * @example https://doc.babylonjs.com/babylon101/particles
  17067. */
  17068. export class BaseParticleSystem {
  17069. /**
  17070. * Source color is added to the destination color without alpha affecting the result
  17071. */
  17072. static BLENDMODE_ONEONE: number;
  17073. /**
  17074. * Blend current color and particle color using particle’s alpha
  17075. */
  17076. static BLENDMODE_STANDARD: number;
  17077. /**
  17078. * Add current color and particle color multiplied by particle’s alpha
  17079. */
  17080. static BLENDMODE_ADD: number;
  17081. /**
  17082. * Multiply current color with particle color
  17083. */
  17084. static BLENDMODE_MULTIPLY: number;
  17085. /**
  17086. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  17087. */
  17088. static BLENDMODE_MULTIPLYADD: number;
  17089. /**
  17090. * List of animations used by the particle system.
  17091. */
  17092. animations: Animation[];
  17093. /**
  17094. * The id of the Particle system.
  17095. */
  17096. id: string;
  17097. /**
  17098. * The friendly name of the Particle system.
  17099. */
  17100. name: string;
  17101. /**
  17102. * The rendering group used by the Particle system to chose when to render.
  17103. */
  17104. renderingGroupId: number;
  17105. /**
  17106. * The emitter represents the Mesh or position we are attaching the particle system to.
  17107. */
  17108. emitter: Nullable<AbstractMesh | Vector3>;
  17109. /**
  17110. * The maximum number of particles to emit per frame
  17111. */
  17112. emitRate: number;
  17113. /**
  17114. * If you want to launch only a few particles at once, that can be done, as well.
  17115. */
  17116. manualEmitCount: number;
  17117. /**
  17118. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17119. */
  17120. updateSpeed: number;
  17121. /**
  17122. * The amount of time the particle system is running (depends of the overall update speed).
  17123. */
  17124. targetStopDuration: number;
  17125. /**
  17126. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17127. */
  17128. disposeOnStop: boolean;
  17129. /**
  17130. * Minimum power of emitting particles.
  17131. */
  17132. minEmitPower: number;
  17133. /**
  17134. * Maximum power of emitting particles.
  17135. */
  17136. maxEmitPower: number;
  17137. /**
  17138. * Minimum life time of emitting particles.
  17139. */
  17140. minLifeTime: number;
  17141. /**
  17142. * Maximum life time of emitting particles.
  17143. */
  17144. maxLifeTime: number;
  17145. /**
  17146. * Minimum Size of emitting particles.
  17147. */
  17148. minSize: number;
  17149. /**
  17150. * Maximum Size of emitting particles.
  17151. */
  17152. maxSize: number;
  17153. /**
  17154. * Minimum scale of emitting particles on X axis.
  17155. */
  17156. minScaleX: number;
  17157. /**
  17158. * Maximum scale of emitting particles on X axis.
  17159. */
  17160. maxScaleX: number;
  17161. /**
  17162. * Minimum scale of emitting particles on Y axis.
  17163. */
  17164. minScaleY: number;
  17165. /**
  17166. * Maximum scale of emitting particles on Y axis.
  17167. */
  17168. maxScaleY: number;
  17169. /**
  17170. * Gets or sets the minimal initial rotation in radians.
  17171. */
  17172. minInitialRotation: number;
  17173. /**
  17174. * Gets or sets the maximal initial rotation in radians.
  17175. */
  17176. maxInitialRotation: number;
  17177. /**
  17178. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17179. */
  17180. minAngularSpeed: number;
  17181. /**
  17182. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17183. */
  17184. maxAngularSpeed: number;
  17185. /**
  17186. * The texture used to render each particle. (this can be a spritesheet)
  17187. */
  17188. particleTexture: Nullable<Texture>;
  17189. /**
  17190. * The layer mask we are rendering the particles through.
  17191. */
  17192. layerMask: number;
  17193. /**
  17194. * This can help using your own shader to render the particle system.
  17195. * The according effect will be created
  17196. */
  17197. customShader: any;
  17198. /**
  17199. * By default particle system starts as soon as they are created. This prevents the
  17200. * automatic start to happen and let you decide when to start emitting particles.
  17201. */
  17202. preventAutoStart: boolean;
  17203. private _noiseTexture;
  17204. /**
  17205. * Gets or sets a texture used to add random noise to particle positions
  17206. */
  17207. noiseTexture: Nullable<ProceduralTexture>;
  17208. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17209. noiseStrength: Vector3;
  17210. /**
  17211. * Callback triggered when the particle animation is ending.
  17212. */
  17213. onAnimationEnd: Nullable<() => void>;
  17214. /**
  17215. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17216. */
  17217. blendMode: number;
  17218. /**
  17219. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17220. * to override the particles.
  17221. */
  17222. forceDepthWrite: boolean;
  17223. /** 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 */
  17224. preWarmCycles: number;
  17225. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17226. preWarmStepOffset: number;
  17227. /**
  17228. * 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)
  17229. */
  17230. spriteCellChangeSpeed: number;
  17231. /**
  17232. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17233. */
  17234. startSpriteCellID: number;
  17235. /**
  17236. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17237. */
  17238. endSpriteCellID: number;
  17239. /**
  17240. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17241. */
  17242. spriteCellWidth: number;
  17243. /**
  17244. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17245. */
  17246. spriteCellHeight: number;
  17247. /**
  17248. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17249. */
  17250. spriteRandomStartCell: boolean;
  17251. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17252. translationPivot: Vector2;
  17253. /** @hidden */
  17254. protected _isAnimationSheetEnabled: boolean;
  17255. /**
  17256. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17257. */
  17258. beginAnimationOnStart: boolean;
  17259. /**
  17260. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17261. */
  17262. beginAnimationFrom: number;
  17263. /**
  17264. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17265. */
  17266. beginAnimationTo: number;
  17267. /**
  17268. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17269. */
  17270. beginAnimationLoop: boolean;
  17271. /**
  17272. * Gets or sets a world offset applied to all particles
  17273. */
  17274. worldOffset: Vector3;
  17275. /**
  17276. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17277. */
  17278. isAnimationSheetEnabled: boolean;
  17279. /**
  17280. * Get hosting scene
  17281. * @returns the scene
  17282. */
  17283. getScene(): Scene;
  17284. /**
  17285. * You can use gravity if you want to give an orientation to your particles.
  17286. */
  17287. gravity: Vector3;
  17288. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17289. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17290. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17291. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17292. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17293. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17294. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17295. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17296. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17297. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17298. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17299. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17300. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17301. /**
  17302. * Defines the delay in milliseconds before starting the system (0 by default)
  17303. */
  17304. startDelay: number;
  17305. /**
  17306. * Gets the current list of drag gradients.
  17307. * You must use addDragGradient and removeDragGradient to udpate this list
  17308. * @returns the list of drag gradients
  17309. */
  17310. getDragGradients(): Nullable<Array<FactorGradient>>;
  17311. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17312. limitVelocityDamping: number;
  17313. /**
  17314. * Gets the current list of limit velocity gradients.
  17315. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17316. * @returns the list of limit velocity gradients
  17317. */
  17318. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17319. /**
  17320. * Gets the current list of color gradients.
  17321. * You must use addColorGradient and removeColorGradient to udpate this list
  17322. * @returns the list of color gradients
  17323. */
  17324. getColorGradients(): Nullable<Array<ColorGradient>>;
  17325. /**
  17326. * Gets the current list of size gradients.
  17327. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17328. * @returns the list of size gradients
  17329. */
  17330. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17331. /**
  17332. * Gets the current list of color remap gradients.
  17333. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17334. * @returns the list of color remap gradients
  17335. */
  17336. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17337. /**
  17338. * Gets the current list of alpha remap gradients.
  17339. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17340. * @returns the list of alpha remap gradients
  17341. */
  17342. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17343. /**
  17344. * Gets the current list of life time gradients.
  17345. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17346. * @returns the list of life time gradients
  17347. */
  17348. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17349. /**
  17350. * Gets the current list of angular speed gradients.
  17351. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17352. * @returns the list of angular speed gradients
  17353. */
  17354. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17355. /**
  17356. * Gets the current list of velocity gradients.
  17357. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17358. * @returns the list of velocity gradients
  17359. */
  17360. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17361. /**
  17362. * Gets the current list of start size gradients.
  17363. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17364. * @returns the list of start size gradients
  17365. */
  17366. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17367. /**
  17368. * Gets the current list of emit rate gradients.
  17369. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17370. * @returns the list of emit rate gradients
  17371. */
  17372. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17373. /**
  17374. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17375. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17376. */
  17377. direction1: Vector3;
  17378. /**
  17379. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17380. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17381. */
  17382. direction2: Vector3;
  17383. /**
  17384. * 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.
  17385. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17386. */
  17387. minEmitBox: Vector3;
  17388. /**
  17389. * 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.
  17390. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17391. */
  17392. maxEmitBox: Vector3;
  17393. /**
  17394. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17395. */
  17396. color1: Color4;
  17397. /**
  17398. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17399. */
  17400. color2: Color4;
  17401. /**
  17402. * Color the particle will have at the end of its lifetime
  17403. */
  17404. colorDead: Color4;
  17405. /**
  17406. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17407. */
  17408. textureMask: Color4;
  17409. /**
  17410. * The particle emitter type defines the emitter used by the particle system.
  17411. * It can be for example box, sphere, or cone...
  17412. */
  17413. particleEmitterType: IParticleEmitterType;
  17414. /** @hidden */
  17415. _isSubEmitter: boolean;
  17416. /**
  17417. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17418. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17419. */
  17420. billboardMode: number;
  17421. protected _isBillboardBased: boolean;
  17422. /**
  17423. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17424. */
  17425. isBillboardBased: boolean;
  17426. /**
  17427. * The scene the particle system belongs to.
  17428. */
  17429. protected _scene: Scene;
  17430. /**
  17431. * Local cache of defines for image processing.
  17432. */
  17433. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17434. /**
  17435. * Default configuration related to image processing available in the standard Material.
  17436. */
  17437. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17438. /**
  17439. * Gets the image processing configuration used either in this material.
  17440. */
  17441. /**
  17442. * Sets the Default image processing configuration used either in the this material.
  17443. *
  17444. * If sets to null, the scene one is in use.
  17445. */
  17446. imageProcessingConfiguration: ImageProcessingConfiguration;
  17447. /**
  17448. * Attaches a new image processing configuration to the Standard Material.
  17449. * @param configuration
  17450. */
  17451. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17452. /** @hidden */
  17453. protected _reset(): void;
  17454. /** @hidden */
  17455. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17456. /**
  17457. * Instantiates a particle system.
  17458. * 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.
  17459. * @param name The name of the particle system
  17460. */
  17461. constructor(name: string);
  17462. /**
  17463. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17464. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17465. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17466. * @returns the emitter
  17467. */
  17468. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17469. /**
  17470. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17471. * @param radius The radius of the hemisphere to emit from
  17472. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17473. * @returns the emitter
  17474. */
  17475. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17476. /**
  17477. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17478. * @param radius The radius of the sphere to emit from
  17479. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17480. * @returns the emitter
  17481. */
  17482. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17483. /**
  17484. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17485. * @param radius The radius of the sphere to emit from
  17486. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17487. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17488. * @returns the emitter
  17489. */
  17490. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17491. /**
  17492. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17493. * @param radius The radius of the emission cylinder
  17494. * @param height The height of the emission cylinder
  17495. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17496. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17497. * @returns the emitter
  17498. */
  17499. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17500. /**
  17501. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17502. * @param radius The radius of the cylinder to emit from
  17503. * @param height The height of the emission cylinder
  17504. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17505. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17506. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17507. * @returns the emitter
  17508. */
  17509. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17510. /**
  17511. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17512. * @param radius The radius of the cone to emit from
  17513. * @param angle The base angle of the cone
  17514. * @returns the emitter
  17515. */
  17516. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17517. /**
  17518. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17519. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17520. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17521. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17522. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17523. * @returns the emitter
  17524. */
  17525. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17526. }
  17527. }
  17528. declare module "babylonjs/Particles/subEmitter" {
  17529. import { Scene } from "babylonjs/scene";
  17530. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17531. /**
  17532. * Type of sub emitter
  17533. */
  17534. export enum SubEmitterType {
  17535. /**
  17536. * Attached to the particle over it's lifetime
  17537. */
  17538. ATTACHED = 0,
  17539. /**
  17540. * Created when the particle dies
  17541. */
  17542. END = 1
  17543. }
  17544. /**
  17545. * Sub emitter class used to emit particles from an existing particle
  17546. */
  17547. export class SubEmitter {
  17548. /**
  17549. * the particle system to be used by the sub emitter
  17550. */
  17551. particleSystem: ParticleSystem;
  17552. /**
  17553. * Type of the submitter (Default: END)
  17554. */
  17555. type: SubEmitterType;
  17556. /**
  17557. * 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)
  17558. * Note: This only is supported when using an emitter of type Mesh
  17559. */
  17560. inheritDirection: boolean;
  17561. /**
  17562. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17563. */
  17564. inheritedVelocityAmount: number;
  17565. /**
  17566. * Creates a sub emitter
  17567. * @param particleSystem the particle system to be used by the sub emitter
  17568. */
  17569. constructor(
  17570. /**
  17571. * the particle system to be used by the sub emitter
  17572. */
  17573. particleSystem: ParticleSystem);
  17574. /**
  17575. * Clones the sub emitter
  17576. * @returns the cloned sub emitter
  17577. */
  17578. clone(): SubEmitter;
  17579. /**
  17580. * Serialize current object to a JSON object
  17581. * @returns the serialized object
  17582. */
  17583. serialize(): any;
  17584. /** @hidden */
  17585. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17586. /**
  17587. * Creates a new SubEmitter from a serialized JSON version
  17588. * @param serializationObject defines the JSON object to read from
  17589. * @param scene defines the hosting scene
  17590. * @param rootUrl defines the rootUrl for data loading
  17591. * @returns a new SubEmitter
  17592. */
  17593. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17594. /** Release associated resources */
  17595. dispose(): void;
  17596. }
  17597. }
  17598. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17599. /** @hidden */
  17600. export var clipPlaneFragmentDeclaration: {
  17601. name: string;
  17602. shader: string;
  17603. };
  17604. }
  17605. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17606. /** @hidden */
  17607. export var imageProcessingDeclaration: {
  17608. name: string;
  17609. shader: string;
  17610. };
  17611. }
  17612. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17613. /** @hidden */
  17614. export var imageProcessingFunctions: {
  17615. name: string;
  17616. shader: string;
  17617. };
  17618. }
  17619. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17620. /** @hidden */
  17621. export var clipPlaneFragment: {
  17622. name: string;
  17623. shader: string;
  17624. };
  17625. }
  17626. declare module "babylonjs/Shaders/particles.fragment" {
  17627. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17628. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17629. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17630. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17631. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17632. /** @hidden */
  17633. export var particlesPixelShader: {
  17634. name: string;
  17635. shader: string;
  17636. };
  17637. }
  17638. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17639. /** @hidden */
  17640. export var clipPlaneVertexDeclaration: {
  17641. name: string;
  17642. shader: string;
  17643. };
  17644. }
  17645. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17646. /** @hidden */
  17647. export var clipPlaneVertex: {
  17648. name: string;
  17649. shader: string;
  17650. };
  17651. }
  17652. declare module "babylonjs/Shaders/particles.vertex" {
  17653. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17654. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17655. /** @hidden */
  17656. export var particlesVertexShader: {
  17657. name: string;
  17658. shader: string;
  17659. };
  17660. }
  17661. declare module "babylonjs/Particles/particleSystem" {
  17662. import { Nullable } from "babylonjs/types";
  17663. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17664. import { Observable } from "babylonjs/Misc/observable";
  17665. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17666. import { Effect } from "babylonjs/Materials/effect";
  17667. import { Scene, IDisposable } from "babylonjs/scene";
  17668. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17669. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17670. import { Particle } from "babylonjs/Particles/particle";
  17671. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17672. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17673. import "babylonjs/Shaders/particles.fragment";
  17674. import "babylonjs/Shaders/particles.vertex";
  17675. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17676. /**
  17677. * This represents a particle system in Babylon.
  17678. * 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.
  17679. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17680. * @example https://doc.babylonjs.com/babylon101/particles
  17681. */
  17682. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17683. /**
  17684. * Billboard mode will only apply to Y axis
  17685. */
  17686. static readonly BILLBOARDMODE_Y: number;
  17687. /**
  17688. * Billboard mode will apply to all axes
  17689. */
  17690. static readonly BILLBOARDMODE_ALL: number;
  17691. /**
  17692. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17693. */
  17694. static readonly BILLBOARDMODE_STRETCHED: number;
  17695. /**
  17696. * This function can be defined to provide custom update for active particles.
  17697. * This function will be called instead of regular update (age, position, color, etc.).
  17698. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17699. */
  17700. updateFunction: (particles: Particle[]) => void;
  17701. private _emitterWorldMatrix;
  17702. /**
  17703. * This function can be defined to specify initial direction for every new particle.
  17704. * It by default use the emitterType defined function
  17705. */
  17706. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17707. /**
  17708. * This function can be defined to specify initial position for every new particle.
  17709. * It by default use the emitterType defined function
  17710. */
  17711. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17712. /**
  17713. * @hidden
  17714. */
  17715. _inheritedVelocityOffset: Vector3;
  17716. /**
  17717. * An event triggered when the system is disposed
  17718. */
  17719. onDisposeObservable: Observable<ParticleSystem>;
  17720. private _onDisposeObserver;
  17721. /**
  17722. * Sets a callback that will be triggered when the system is disposed
  17723. */
  17724. onDispose: () => void;
  17725. private _particles;
  17726. private _epsilon;
  17727. private _capacity;
  17728. private _stockParticles;
  17729. private _newPartsExcess;
  17730. private _vertexData;
  17731. private _vertexBuffer;
  17732. private _vertexBuffers;
  17733. private _spriteBuffer;
  17734. private _indexBuffer;
  17735. private _effect;
  17736. private _customEffect;
  17737. private _cachedDefines;
  17738. private _scaledColorStep;
  17739. private _colorDiff;
  17740. private _scaledDirection;
  17741. private _scaledGravity;
  17742. private _currentRenderId;
  17743. private _alive;
  17744. private _useInstancing;
  17745. private _started;
  17746. private _stopped;
  17747. private _actualFrame;
  17748. private _scaledUpdateSpeed;
  17749. private _vertexBufferSize;
  17750. /** @hidden */
  17751. _currentEmitRateGradient: Nullable<FactorGradient>;
  17752. /** @hidden */
  17753. _currentEmitRate1: number;
  17754. /** @hidden */
  17755. _currentEmitRate2: number;
  17756. /** @hidden */
  17757. _currentStartSizeGradient: Nullable<FactorGradient>;
  17758. /** @hidden */
  17759. _currentStartSize1: number;
  17760. /** @hidden */
  17761. _currentStartSize2: number;
  17762. private readonly _rawTextureWidth;
  17763. private _rampGradientsTexture;
  17764. private _useRampGradients;
  17765. /** Gets or sets a boolean indicating that ramp gradients must be used
  17766. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17767. */
  17768. useRampGradients: boolean;
  17769. /**
  17770. * 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.
  17771. * 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: [])
  17772. */
  17773. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17774. private _subEmitters;
  17775. /**
  17776. * @hidden
  17777. * If the particle systems emitter should be disposed when the particle system is disposed
  17778. */
  17779. _disposeEmitterOnDispose: boolean;
  17780. /**
  17781. * The current active Sub-systems, this property is used by the root particle system only.
  17782. */
  17783. activeSubSystems: Array<ParticleSystem>;
  17784. private _rootParticleSystem;
  17785. /**
  17786. * Gets the current list of active particles
  17787. */
  17788. readonly particles: Particle[];
  17789. /**
  17790. * Returns the string "ParticleSystem"
  17791. * @returns a string containing the class name
  17792. */
  17793. getClassName(): string;
  17794. /**
  17795. * Instantiates a particle system.
  17796. * 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.
  17797. * @param name The name of the particle system
  17798. * @param capacity The max number of particles alive at the same time
  17799. * @param scene The scene the particle system belongs to
  17800. * @param customEffect a custom effect used to change the way particles are rendered by default
  17801. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17802. * @param epsilon Offset used to render the particles
  17803. */
  17804. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17805. private _addFactorGradient;
  17806. private _removeFactorGradient;
  17807. /**
  17808. * Adds a new life time gradient
  17809. * @param gradient defines the gradient to use (between 0 and 1)
  17810. * @param factor defines the life time factor to affect to the specified gradient
  17811. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17812. * @returns the current particle system
  17813. */
  17814. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17815. /**
  17816. * Remove a specific life time gradient
  17817. * @param gradient defines the gradient to remove
  17818. * @returns the current particle system
  17819. */
  17820. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17821. /**
  17822. * Adds a new size gradient
  17823. * @param gradient defines the gradient to use (between 0 and 1)
  17824. * @param factor defines the size factor to affect to the specified gradient
  17825. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17826. * @returns the current particle system
  17827. */
  17828. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17829. /**
  17830. * Remove a specific size gradient
  17831. * @param gradient defines the gradient to remove
  17832. * @returns the current particle system
  17833. */
  17834. removeSizeGradient(gradient: number): IParticleSystem;
  17835. /**
  17836. * Adds a new color remap gradient
  17837. * @param gradient defines the gradient to use (between 0 and 1)
  17838. * @param min defines the color remap minimal range
  17839. * @param max defines the color remap maximal range
  17840. * @returns the current particle system
  17841. */
  17842. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17843. /**
  17844. * Remove a specific color remap gradient
  17845. * @param gradient defines the gradient to remove
  17846. * @returns the current particle system
  17847. */
  17848. removeColorRemapGradient(gradient: number): IParticleSystem;
  17849. /**
  17850. * Adds a new alpha remap gradient
  17851. * @param gradient defines the gradient to use (between 0 and 1)
  17852. * @param min defines the alpha remap minimal range
  17853. * @param max defines the alpha remap maximal range
  17854. * @returns the current particle system
  17855. */
  17856. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17857. /**
  17858. * Remove a specific alpha remap gradient
  17859. * @param gradient defines the gradient to remove
  17860. * @returns the current particle system
  17861. */
  17862. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17863. /**
  17864. * Adds a new angular speed gradient
  17865. * @param gradient defines the gradient to use (between 0 and 1)
  17866. * @param factor defines the angular speed to affect to the specified gradient
  17867. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17868. * @returns the current particle system
  17869. */
  17870. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17871. /**
  17872. * Remove a specific angular speed gradient
  17873. * @param gradient defines the gradient to remove
  17874. * @returns the current particle system
  17875. */
  17876. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17877. /**
  17878. * Adds a new velocity gradient
  17879. * @param gradient defines the gradient to use (between 0 and 1)
  17880. * @param factor defines the velocity to affect to the specified gradient
  17881. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17882. * @returns the current particle system
  17883. */
  17884. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17885. /**
  17886. * Remove a specific velocity gradient
  17887. * @param gradient defines the gradient to remove
  17888. * @returns the current particle system
  17889. */
  17890. removeVelocityGradient(gradient: number): IParticleSystem;
  17891. /**
  17892. * Adds a new limit velocity gradient
  17893. * @param gradient defines the gradient to use (between 0 and 1)
  17894. * @param factor defines the limit velocity value to affect to the specified gradient
  17895. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17896. * @returns the current particle system
  17897. */
  17898. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17899. /**
  17900. * Remove a specific limit velocity gradient
  17901. * @param gradient defines the gradient to remove
  17902. * @returns the current particle system
  17903. */
  17904. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17905. /**
  17906. * Adds a new drag gradient
  17907. * @param gradient defines the gradient to use (between 0 and 1)
  17908. * @param factor defines the drag value to affect to the specified gradient
  17909. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17910. * @returns the current particle system
  17911. */
  17912. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17913. /**
  17914. * Remove a specific drag gradient
  17915. * @param gradient defines the gradient to remove
  17916. * @returns the current particle system
  17917. */
  17918. removeDragGradient(gradient: number): IParticleSystem;
  17919. /**
  17920. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17921. * @param gradient defines the gradient to use (between 0 and 1)
  17922. * @param factor defines the emit rate value to affect to the specified gradient
  17923. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17924. * @returns the current particle system
  17925. */
  17926. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17927. /**
  17928. * Remove a specific emit rate gradient
  17929. * @param gradient defines the gradient to remove
  17930. * @returns the current particle system
  17931. */
  17932. removeEmitRateGradient(gradient: number): IParticleSystem;
  17933. /**
  17934. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17935. * @param gradient defines the gradient to use (between 0 and 1)
  17936. * @param factor defines the start size value to affect to the specified gradient
  17937. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17938. * @returns the current particle system
  17939. */
  17940. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17941. /**
  17942. * Remove a specific start size gradient
  17943. * @param gradient defines the gradient to remove
  17944. * @returns the current particle system
  17945. */
  17946. removeStartSizeGradient(gradient: number): IParticleSystem;
  17947. private _createRampGradientTexture;
  17948. /**
  17949. * Gets the current list of ramp gradients.
  17950. * You must use addRampGradient and removeRampGradient to udpate this list
  17951. * @returns the list of ramp gradients
  17952. */
  17953. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17954. /**
  17955. * Adds a new ramp gradient used to remap particle colors
  17956. * @param gradient defines the gradient to use (between 0 and 1)
  17957. * @param color defines the color to affect to the specified gradient
  17958. * @returns the current particle system
  17959. */
  17960. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17961. /**
  17962. * Remove a specific ramp gradient
  17963. * @param gradient defines the gradient to remove
  17964. * @returns the current particle system
  17965. */
  17966. removeRampGradient(gradient: number): ParticleSystem;
  17967. /**
  17968. * Adds a new color gradient
  17969. * @param gradient defines the gradient to use (between 0 and 1)
  17970. * @param color1 defines the color to affect to the specified gradient
  17971. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17972. * @returns this particle system
  17973. */
  17974. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17975. /**
  17976. * Remove a specific color gradient
  17977. * @param gradient defines the gradient to remove
  17978. * @returns this particle system
  17979. */
  17980. removeColorGradient(gradient: number): IParticleSystem;
  17981. private _fetchR;
  17982. protected _reset(): void;
  17983. private _resetEffect;
  17984. private _createVertexBuffers;
  17985. private _createIndexBuffer;
  17986. /**
  17987. * Gets the maximum number of particles active at the same time.
  17988. * @returns The max number of active particles.
  17989. */
  17990. getCapacity(): number;
  17991. /**
  17992. * Gets whether there are still active particles in the system.
  17993. * @returns True if it is alive, otherwise false.
  17994. */
  17995. isAlive(): boolean;
  17996. /**
  17997. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17998. * @returns True if it has been started, otherwise false.
  17999. */
  18000. isStarted(): boolean;
  18001. private _prepareSubEmitterInternalArray;
  18002. /**
  18003. * Starts the particle system and begins to emit
  18004. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  18005. */
  18006. start(delay?: number): void;
  18007. /**
  18008. * Stops the particle system.
  18009. * @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.
  18010. */
  18011. stop(stopSubEmitters?: boolean): void;
  18012. /**
  18013. * Remove all active particles
  18014. */
  18015. reset(): void;
  18016. /**
  18017. * @hidden (for internal use only)
  18018. */
  18019. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  18020. /**
  18021. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  18022. * Its lifetime will start back at 0.
  18023. */
  18024. recycleParticle: (particle: Particle) => void;
  18025. private _stopSubEmitters;
  18026. private _createParticle;
  18027. private _removeFromRoot;
  18028. private _emitFromParticle;
  18029. private _update;
  18030. /** @hidden */
  18031. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  18032. /** @hidden */
  18033. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  18034. /** @hidden */
  18035. private _getEffect;
  18036. /**
  18037. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  18038. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  18039. */
  18040. animate(preWarmOnly?: boolean): void;
  18041. private _appendParticleVertices;
  18042. /**
  18043. * Rebuilds the particle system.
  18044. */
  18045. rebuild(): void;
  18046. /**
  18047. * Is this system ready to be used/rendered
  18048. * @return true if the system is ready
  18049. */
  18050. isReady(): boolean;
  18051. private _render;
  18052. /**
  18053. * Renders the particle system in its current state.
  18054. * @returns the current number of particles
  18055. */
  18056. render(): number;
  18057. /**
  18058. * Disposes the particle system and free the associated resources
  18059. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18060. */
  18061. dispose(disposeTexture?: boolean): void;
  18062. /**
  18063. * Clones the particle system.
  18064. * @param name The name of the cloned object
  18065. * @param newEmitter The new emitter to use
  18066. * @returns the cloned particle system
  18067. */
  18068. clone(name: string, newEmitter: any): ParticleSystem;
  18069. /**
  18070. * Serializes the particle system to a JSON object.
  18071. * @returns the JSON object
  18072. */
  18073. serialize(): any;
  18074. /** @hidden */
  18075. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  18076. /** @hidden */
  18077. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  18078. /**
  18079. * Parses a JSON object to create a particle system.
  18080. * @param parsedParticleSystem The JSON object to parse
  18081. * @param scene The scene to create the particle system in
  18082. * @param rootUrl The root url to use to load external dependencies like texture
  18083. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  18084. * @returns the Parsed particle system
  18085. */
  18086. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  18087. }
  18088. }
  18089. declare module "babylonjs/Particles/particle" {
  18090. import { Nullable } from "babylonjs/types";
  18091. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  18092. import { Color4 } from "babylonjs/Maths/math.color";
  18093. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  18094. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  18095. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  18096. /**
  18097. * A particle represents one of the element emitted by a particle system.
  18098. * This is mainly define by its coordinates, direction, velocity and age.
  18099. */
  18100. export class Particle {
  18101. /**
  18102. * The particle system the particle belongs to.
  18103. */
  18104. particleSystem: ParticleSystem;
  18105. private static _Count;
  18106. /**
  18107. * Unique ID of the particle
  18108. */
  18109. id: number;
  18110. /**
  18111. * The world position of the particle in the scene.
  18112. */
  18113. position: Vector3;
  18114. /**
  18115. * The world direction of the particle in the scene.
  18116. */
  18117. direction: Vector3;
  18118. /**
  18119. * The color of the particle.
  18120. */
  18121. color: Color4;
  18122. /**
  18123. * The color change of the particle per step.
  18124. */
  18125. colorStep: Color4;
  18126. /**
  18127. * Defines how long will the life of the particle be.
  18128. */
  18129. lifeTime: number;
  18130. /**
  18131. * The current age of the particle.
  18132. */
  18133. age: number;
  18134. /**
  18135. * The current size of the particle.
  18136. */
  18137. size: number;
  18138. /**
  18139. * The current scale of the particle.
  18140. */
  18141. scale: Vector2;
  18142. /**
  18143. * The current angle of the particle.
  18144. */
  18145. angle: number;
  18146. /**
  18147. * Defines how fast is the angle changing.
  18148. */
  18149. angularSpeed: number;
  18150. /**
  18151. * Defines the cell index used by the particle to be rendered from a sprite.
  18152. */
  18153. cellIndex: number;
  18154. /**
  18155. * The information required to support color remapping
  18156. */
  18157. remapData: Vector4;
  18158. /** @hidden */
  18159. _randomCellOffset?: number;
  18160. /** @hidden */
  18161. _initialDirection: Nullable<Vector3>;
  18162. /** @hidden */
  18163. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  18164. /** @hidden */
  18165. _initialStartSpriteCellID: number;
  18166. /** @hidden */
  18167. _initialEndSpriteCellID: number;
  18168. /** @hidden */
  18169. _currentColorGradient: Nullable<ColorGradient>;
  18170. /** @hidden */
  18171. _currentColor1: Color4;
  18172. /** @hidden */
  18173. _currentColor2: Color4;
  18174. /** @hidden */
  18175. _currentSizeGradient: Nullable<FactorGradient>;
  18176. /** @hidden */
  18177. _currentSize1: number;
  18178. /** @hidden */
  18179. _currentSize2: number;
  18180. /** @hidden */
  18181. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  18182. /** @hidden */
  18183. _currentAngularSpeed1: number;
  18184. /** @hidden */
  18185. _currentAngularSpeed2: number;
  18186. /** @hidden */
  18187. _currentVelocityGradient: Nullable<FactorGradient>;
  18188. /** @hidden */
  18189. _currentVelocity1: number;
  18190. /** @hidden */
  18191. _currentVelocity2: number;
  18192. /** @hidden */
  18193. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  18194. /** @hidden */
  18195. _currentLimitVelocity1: number;
  18196. /** @hidden */
  18197. _currentLimitVelocity2: number;
  18198. /** @hidden */
  18199. _currentDragGradient: Nullable<FactorGradient>;
  18200. /** @hidden */
  18201. _currentDrag1: number;
  18202. /** @hidden */
  18203. _currentDrag2: number;
  18204. /** @hidden */
  18205. _randomNoiseCoordinates1: Vector3;
  18206. /** @hidden */
  18207. _randomNoiseCoordinates2: Vector3;
  18208. /**
  18209. * Creates a new instance Particle
  18210. * @param particleSystem the particle system the particle belongs to
  18211. */
  18212. constructor(
  18213. /**
  18214. * The particle system the particle belongs to.
  18215. */
  18216. particleSystem: ParticleSystem);
  18217. private updateCellInfoFromSystem;
  18218. /**
  18219. * Defines how the sprite cell index is updated for the particle
  18220. */
  18221. updateCellIndex(): void;
  18222. /** @hidden */
  18223. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  18224. /** @hidden */
  18225. _inheritParticleInfoToSubEmitters(): void;
  18226. /** @hidden */
  18227. _reset(): void;
  18228. /**
  18229. * Copy the properties of particle to another one.
  18230. * @param other the particle to copy the information to.
  18231. */
  18232. copyTo(other: Particle): void;
  18233. }
  18234. }
  18235. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  18236. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18237. import { Effect } from "babylonjs/Materials/effect";
  18238. import { Particle } from "babylonjs/Particles/particle";
  18239. /**
  18240. * Particle emitter represents a volume emitting particles.
  18241. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  18242. */
  18243. export interface IParticleEmitterType {
  18244. /**
  18245. * Called by the particle System when the direction is computed for the created particle.
  18246. * @param worldMatrix is the world matrix of the particle system
  18247. * @param directionToUpdate is the direction vector to update with the result
  18248. * @param particle is the particle we are computed the direction for
  18249. */
  18250. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18251. /**
  18252. * Called by the particle System when the position is computed for the created particle.
  18253. * @param worldMatrix is the world matrix of the particle system
  18254. * @param positionToUpdate is the position vector to update with the result
  18255. * @param particle is the particle we are computed the position for
  18256. */
  18257. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18258. /**
  18259. * Clones the current emitter and returns a copy of it
  18260. * @returns the new emitter
  18261. */
  18262. clone(): IParticleEmitterType;
  18263. /**
  18264. * Called by the GPUParticleSystem to setup the update shader
  18265. * @param effect defines the update shader
  18266. */
  18267. applyToShader(effect: Effect): void;
  18268. /**
  18269. * Returns a string to use to update the GPU particles update shader
  18270. * @returns the effect defines string
  18271. */
  18272. getEffectDefines(): string;
  18273. /**
  18274. * Returns a string representing the class name
  18275. * @returns a string containing the class name
  18276. */
  18277. getClassName(): string;
  18278. /**
  18279. * Serializes the particle system to a JSON object.
  18280. * @returns the JSON object
  18281. */
  18282. serialize(): any;
  18283. /**
  18284. * Parse properties from a JSON object
  18285. * @param serializationObject defines the JSON object
  18286. */
  18287. parse(serializationObject: any): void;
  18288. }
  18289. }
  18290. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18291. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18292. import { Effect } from "babylonjs/Materials/effect";
  18293. import { Particle } from "babylonjs/Particles/particle";
  18294. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18295. /**
  18296. * Particle emitter emitting particles from the inside of a box.
  18297. * It emits the particles randomly between 2 given directions.
  18298. */
  18299. export class BoxParticleEmitter implements IParticleEmitterType {
  18300. /**
  18301. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18302. */
  18303. direction1: Vector3;
  18304. /**
  18305. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18306. */
  18307. direction2: Vector3;
  18308. /**
  18309. * 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.
  18310. */
  18311. minEmitBox: Vector3;
  18312. /**
  18313. * 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.
  18314. */
  18315. maxEmitBox: Vector3;
  18316. /**
  18317. * Creates a new instance BoxParticleEmitter
  18318. */
  18319. constructor();
  18320. /**
  18321. * Called by the particle System when the direction is computed for the created particle.
  18322. * @param worldMatrix is the world matrix of the particle system
  18323. * @param directionToUpdate is the direction vector to update with the result
  18324. * @param particle is the particle we are computed the direction for
  18325. */
  18326. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18327. /**
  18328. * Called by the particle System when the position is computed for the created particle.
  18329. * @param worldMatrix is the world matrix of the particle system
  18330. * @param positionToUpdate is the position vector to update with the result
  18331. * @param particle is the particle we are computed the position for
  18332. */
  18333. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18334. /**
  18335. * Clones the current emitter and returns a copy of it
  18336. * @returns the new emitter
  18337. */
  18338. clone(): BoxParticleEmitter;
  18339. /**
  18340. * Called by the GPUParticleSystem to setup the update shader
  18341. * @param effect defines the update shader
  18342. */
  18343. applyToShader(effect: Effect): void;
  18344. /**
  18345. * Returns a string to use to update the GPU particles update shader
  18346. * @returns a string containng the defines string
  18347. */
  18348. getEffectDefines(): string;
  18349. /**
  18350. * Returns the string "BoxParticleEmitter"
  18351. * @returns a string containing the class name
  18352. */
  18353. getClassName(): string;
  18354. /**
  18355. * Serializes the particle system to a JSON object.
  18356. * @returns the JSON object
  18357. */
  18358. serialize(): any;
  18359. /**
  18360. * Parse properties from a JSON object
  18361. * @param serializationObject defines the JSON object
  18362. */
  18363. parse(serializationObject: any): void;
  18364. }
  18365. }
  18366. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18367. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18368. import { Effect } from "babylonjs/Materials/effect";
  18369. import { Particle } from "babylonjs/Particles/particle";
  18370. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18371. /**
  18372. * Particle emitter emitting particles from the inside of a cone.
  18373. * It emits the particles alongside the cone volume from the base to the particle.
  18374. * The emission direction might be randomized.
  18375. */
  18376. export class ConeParticleEmitter implements IParticleEmitterType {
  18377. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18378. directionRandomizer: number;
  18379. private _radius;
  18380. private _angle;
  18381. private _height;
  18382. /**
  18383. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18384. */
  18385. radiusRange: number;
  18386. /**
  18387. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18388. */
  18389. heightRange: number;
  18390. /**
  18391. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18392. */
  18393. emitFromSpawnPointOnly: boolean;
  18394. /**
  18395. * Gets or sets the radius of the emission cone
  18396. */
  18397. radius: number;
  18398. /**
  18399. * Gets or sets the angle of the emission cone
  18400. */
  18401. angle: number;
  18402. private _buildHeight;
  18403. /**
  18404. * Creates a new instance ConeParticleEmitter
  18405. * @param radius the radius of the emission cone (1 by default)
  18406. * @param angle the cone base angle (PI by default)
  18407. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18408. */
  18409. constructor(radius?: number, angle?: number,
  18410. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18411. directionRandomizer?: number);
  18412. /**
  18413. * Called by the particle System when the direction is computed for the created particle.
  18414. * @param worldMatrix is the world matrix of the particle system
  18415. * @param directionToUpdate is the direction vector to update with the result
  18416. * @param particle is the particle we are computed the direction for
  18417. */
  18418. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18419. /**
  18420. * Called by the particle System when the position is computed for the created particle.
  18421. * @param worldMatrix is the world matrix of the particle system
  18422. * @param positionToUpdate is the position vector to update with the result
  18423. * @param particle is the particle we are computed the position for
  18424. */
  18425. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18426. /**
  18427. * Clones the current emitter and returns a copy of it
  18428. * @returns the new emitter
  18429. */
  18430. clone(): ConeParticleEmitter;
  18431. /**
  18432. * Called by the GPUParticleSystem to setup the update shader
  18433. * @param effect defines the update shader
  18434. */
  18435. applyToShader(effect: Effect): void;
  18436. /**
  18437. * Returns a string to use to update the GPU particles update shader
  18438. * @returns a string containng the defines string
  18439. */
  18440. getEffectDefines(): string;
  18441. /**
  18442. * Returns the string "ConeParticleEmitter"
  18443. * @returns a string containing the class name
  18444. */
  18445. getClassName(): string;
  18446. /**
  18447. * Serializes the particle system to a JSON object.
  18448. * @returns the JSON object
  18449. */
  18450. serialize(): any;
  18451. /**
  18452. * Parse properties from a JSON object
  18453. * @param serializationObject defines the JSON object
  18454. */
  18455. parse(serializationObject: any): void;
  18456. }
  18457. }
  18458. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18459. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18460. import { Effect } from "babylonjs/Materials/effect";
  18461. import { Particle } from "babylonjs/Particles/particle";
  18462. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18463. /**
  18464. * Particle emitter emitting particles from the inside of a cylinder.
  18465. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18466. */
  18467. export class CylinderParticleEmitter implements IParticleEmitterType {
  18468. /**
  18469. * The radius of the emission cylinder.
  18470. */
  18471. radius: number;
  18472. /**
  18473. * The height of the emission cylinder.
  18474. */
  18475. height: number;
  18476. /**
  18477. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18478. */
  18479. radiusRange: number;
  18480. /**
  18481. * How much to randomize the particle direction [0-1].
  18482. */
  18483. directionRandomizer: number;
  18484. /**
  18485. * Creates a new instance CylinderParticleEmitter
  18486. * @param radius the radius of the emission cylinder (1 by default)
  18487. * @param height the height of the emission cylinder (1 by default)
  18488. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18489. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18490. */
  18491. constructor(
  18492. /**
  18493. * The radius of the emission cylinder.
  18494. */
  18495. radius?: number,
  18496. /**
  18497. * The height of the emission cylinder.
  18498. */
  18499. height?: number,
  18500. /**
  18501. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18502. */
  18503. radiusRange?: number,
  18504. /**
  18505. * How much to randomize the particle direction [0-1].
  18506. */
  18507. directionRandomizer?: number);
  18508. /**
  18509. * Called by the particle System when the direction is computed for the created particle.
  18510. * @param worldMatrix is the world matrix of the particle system
  18511. * @param directionToUpdate is the direction vector to update with the result
  18512. * @param particle is the particle we are computed the direction for
  18513. */
  18514. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18515. /**
  18516. * Called by the particle System when the position is computed for the created particle.
  18517. * @param worldMatrix is the world matrix of the particle system
  18518. * @param positionToUpdate is the position vector to update with the result
  18519. * @param particle is the particle we are computed the position for
  18520. */
  18521. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18522. /**
  18523. * Clones the current emitter and returns a copy of it
  18524. * @returns the new emitter
  18525. */
  18526. clone(): CylinderParticleEmitter;
  18527. /**
  18528. * Called by the GPUParticleSystem to setup the update shader
  18529. * @param effect defines the update shader
  18530. */
  18531. applyToShader(effect: Effect): void;
  18532. /**
  18533. * Returns a string to use to update the GPU particles update shader
  18534. * @returns a string containng the defines string
  18535. */
  18536. getEffectDefines(): string;
  18537. /**
  18538. * Returns the string "CylinderParticleEmitter"
  18539. * @returns a string containing the class name
  18540. */
  18541. getClassName(): string;
  18542. /**
  18543. * Serializes the particle system to a JSON object.
  18544. * @returns the JSON object
  18545. */
  18546. serialize(): any;
  18547. /**
  18548. * Parse properties from a JSON object
  18549. * @param serializationObject defines the JSON object
  18550. */
  18551. parse(serializationObject: any): void;
  18552. }
  18553. /**
  18554. * Particle emitter emitting particles from the inside of a cylinder.
  18555. * It emits the particles randomly between two vectors.
  18556. */
  18557. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18558. /**
  18559. * The min limit of the emission direction.
  18560. */
  18561. direction1: Vector3;
  18562. /**
  18563. * The max limit of the emission direction.
  18564. */
  18565. direction2: Vector3;
  18566. /**
  18567. * Creates a new instance CylinderDirectedParticleEmitter
  18568. * @param radius the radius of the emission cylinder (1 by default)
  18569. * @param height the height of the emission cylinder (1 by default)
  18570. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18571. * @param direction1 the min limit of the emission direction (up vector by default)
  18572. * @param direction2 the max limit of the emission direction (up vector by default)
  18573. */
  18574. constructor(radius?: number, height?: number, radiusRange?: number,
  18575. /**
  18576. * The min limit of the emission direction.
  18577. */
  18578. direction1?: Vector3,
  18579. /**
  18580. * The max limit of the emission direction.
  18581. */
  18582. direction2?: Vector3);
  18583. /**
  18584. * Called by the particle System when the direction is computed for the created particle.
  18585. * @param worldMatrix is the world matrix of the particle system
  18586. * @param directionToUpdate is the direction vector to update with the result
  18587. * @param particle is the particle we are computed the direction for
  18588. */
  18589. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18590. /**
  18591. * Clones the current emitter and returns a copy of it
  18592. * @returns the new emitter
  18593. */
  18594. clone(): CylinderDirectedParticleEmitter;
  18595. /**
  18596. * Called by the GPUParticleSystem to setup the update shader
  18597. * @param effect defines the update shader
  18598. */
  18599. applyToShader(effect: Effect): void;
  18600. /**
  18601. * Returns a string to use to update the GPU particles update shader
  18602. * @returns a string containng the defines string
  18603. */
  18604. getEffectDefines(): string;
  18605. /**
  18606. * Returns the string "CylinderDirectedParticleEmitter"
  18607. * @returns a string containing the class name
  18608. */
  18609. getClassName(): string;
  18610. /**
  18611. * Serializes the particle system to a JSON object.
  18612. * @returns the JSON object
  18613. */
  18614. serialize(): any;
  18615. /**
  18616. * Parse properties from a JSON object
  18617. * @param serializationObject defines the JSON object
  18618. */
  18619. parse(serializationObject: any): void;
  18620. }
  18621. }
  18622. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18623. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18624. import { Effect } from "babylonjs/Materials/effect";
  18625. import { Particle } from "babylonjs/Particles/particle";
  18626. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18627. /**
  18628. * Particle emitter emitting particles from the inside of a hemisphere.
  18629. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18630. */
  18631. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18632. /**
  18633. * The radius of the emission hemisphere.
  18634. */
  18635. radius: number;
  18636. /**
  18637. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18638. */
  18639. radiusRange: number;
  18640. /**
  18641. * How much to randomize the particle direction [0-1].
  18642. */
  18643. directionRandomizer: number;
  18644. /**
  18645. * Creates a new instance HemisphericParticleEmitter
  18646. * @param radius the radius of the emission hemisphere (1 by default)
  18647. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18648. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18649. */
  18650. constructor(
  18651. /**
  18652. * The radius of the emission hemisphere.
  18653. */
  18654. radius?: number,
  18655. /**
  18656. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18657. */
  18658. radiusRange?: number,
  18659. /**
  18660. * How much to randomize the particle direction [0-1].
  18661. */
  18662. directionRandomizer?: number);
  18663. /**
  18664. * Called by the particle System when the direction is computed for the created particle.
  18665. * @param worldMatrix is the world matrix of the particle system
  18666. * @param directionToUpdate is the direction vector to update with the result
  18667. * @param particle is the particle we are computed the direction for
  18668. */
  18669. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18670. /**
  18671. * Called by the particle System when the position is computed for the created particle.
  18672. * @param worldMatrix is the world matrix of the particle system
  18673. * @param positionToUpdate is the position vector to update with the result
  18674. * @param particle is the particle we are computed the position for
  18675. */
  18676. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18677. /**
  18678. * Clones the current emitter and returns a copy of it
  18679. * @returns the new emitter
  18680. */
  18681. clone(): HemisphericParticleEmitter;
  18682. /**
  18683. * Called by the GPUParticleSystem to setup the update shader
  18684. * @param effect defines the update shader
  18685. */
  18686. applyToShader(effect: Effect): void;
  18687. /**
  18688. * Returns a string to use to update the GPU particles update shader
  18689. * @returns a string containng the defines string
  18690. */
  18691. getEffectDefines(): string;
  18692. /**
  18693. * Returns the string "HemisphericParticleEmitter"
  18694. * @returns a string containing the class name
  18695. */
  18696. getClassName(): string;
  18697. /**
  18698. * Serializes the particle system to a JSON object.
  18699. * @returns the JSON object
  18700. */
  18701. serialize(): any;
  18702. /**
  18703. * Parse properties from a JSON object
  18704. * @param serializationObject defines the JSON object
  18705. */
  18706. parse(serializationObject: any): void;
  18707. }
  18708. }
  18709. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18710. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18711. import { Effect } from "babylonjs/Materials/effect";
  18712. import { Particle } from "babylonjs/Particles/particle";
  18713. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18714. /**
  18715. * Particle emitter emitting particles from a point.
  18716. * It emits the particles randomly between 2 given directions.
  18717. */
  18718. export class PointParticleEmitter implements IParticleEmitterType {
  18719. /**
  18720. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18721. */
  18722. direction1: Vector3;
  18723. /**
  18724. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18725. */
  18726. direction2: Vector3;
  18727. /**
  18728. * Creates a new instance PointParticleEmitter
  18729. */
  18730. constructor();
  18731. /**
  18732. * Called by the particle System when the direction is computed for the created particle.
  18733. * @param worldMatrix is the world matrix of the particle system
  18734. * @param directionToUpdate is the direction vector to update with the result
  18735. * @param particle is the particle we are computed the direction for
  18736. */
  18737. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18738. /**
  18739. * Called by the particle System when the position is computed for the created particle.
  18740. * @param worldMatrix is the world matrix of the particle system
  18741. * @param positionToUpdate is the position vector to update with the result
  18742. * @param particle is the particle we are computed the position for
  18743. */
  18744. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18745. /**
  18746. * Clones the current emitter and returns a copy of it
  18747. * @returns the new emitter
  18748. */
  18749. clone(): PointParticleEmitter;
  18750. /**
  18751. * Called by the GPUParticleSystem to setup the update shader
  18752. * @param effect defines the update shader
  18753. */
  18754. applyToShader(effect: Effect): void;
  18755. /**
  18756. * Returns a string to use to update the GPU particles update shader
  18757. * @returns a string containng the defines string
  18758. */
  18759. getEffectDefines(): string;
  18760. /**
  18761. * Returns the string "PointParticleEmitter"
  18762. * @returns a string containing the class name
  18763. */
  18764. getClassName(): string;
  18765. /**
  18766. * Serializes the particle system to a JSON object.
  18767. * @returns the JSON object
  18768. */
  18769. serialize(): any;
  18770. /**
  18771. * Parse properties from a JSON object
  18772. * @param serializationObject defines the JSON object
  18773. */
  18774. parse(serializationObject: any): void;
  18775. }
  18776. }
  18777. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18778. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18779. import { Effect } from "babylonjs/Materials/effect";
  18780. import { Particle } from "babylonjs/Particles/particle";
  18781. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18782. /**
  18783. * Particle emitter emitting particles from the inside of a sphere.
  18784. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18785. */
  18786. export class SphereParticleEmitter implements IParticleEmitterType {
  18787. /**
  18788. * The radius of the emission sphere.
  18789. */
  18790. radius: number;
  18791. /**
  18792. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18793. */
  18794. radiusRange: number;
  18795. /**
  18796. * How much to randomize the particle direction [0-1].
  18797. */
  18798. directionRandomizer: number;
  18799. /**
  18800. * Creates a new instance SphereParticleEmitter
  18801. * @param radius the radius of the emission sphere (1 by default)
  18802. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18803. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18804. */
  18805. constructor(
  18806. /**
  18807. * The radius of the emission sphere.
  18808. */
  18809. radius?: number,
  18810. /**
  18811. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18812. */
  18813. radiusRange?: number,
  18814. /**
  18815. * How much to randomize the particle direction [0-1].
  18816. */
  18817. directionRandomizer?: number);
  18818. /**
  18819. * Called by the particle System when the direction is computed for the created particle.
  18820. * @param worldMatrix is the world matrix of the particle system
  18821. * @param directionToUpdate is the direction vector to update with the result
  18822. * @param particle is the particle we are computed the direction for
  18823. */
  18824. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18825. /**
  18826. * Called by the particle System when the position is computed for the created particle.
  18827. * @param worldMatrix is the world matrix of the particle system
  18828. * @param positionToUpdate is the position vector to update with the result
  18829. * @param particle is the particle we are computed the position for
  18830. */
  18831. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18832. /**
  18833. * Clones the current emitter and returns a copy of it
  18834. * @returns the new emitter
  18835. */
  18836. clone(): SphereParticleEmitter;
  18837. /**
  18838. * Called by the GPUParticleSystem to setup the update shader
  18839. * @param effect defines the update shader
  18840. */
  18841. applyToShader(effect: Effect): void;
  18842. /**
  18843. * Returns a string to use to update the GPU particles update shader
  18844. * @returns a string containng the defines string
  18845. */
  18846. getEffectDefines(): string;
  18847. /**
  18848. * Returns the string "SphereParticleEmitter"
  18849. * @returns a string containing the class name
  18850. */
  18851. getClassName(): string;
  18852. /**
  18853. * Serializes the particle system to a JSON object.
  18854. * @returns the JSON object
  18855. */
  18856. serialize(): any;
  18857. /**
  18858. * Parse properties from a JSON object
  18859. * @param serializationObject defines the JSON object
  18860. */
  18861. parse(serializationObject: any): void;
  18862. }
  18863. /**
  18864. * Particle emitter emitting particles from the inside of a sphere.
  18865. * It emits the particles randomly between two vectors.
  18866. */
  18867. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18868. /**
  18869. * The min limit of the emission direction.
  18870. */
  18871. direction1: Vector3;
  18872. /**
  18873. * The max limit of the emission direction.
  18874. */
  18875. direction2: Vector3;
  18876. /**
  18877. * Creates a new instance SphereDirectedParticleEmitter
  18878. * @param radius the radius of the emission sphere (1 by default)
  18879. * @param direction1 the min limit of the emission direction (up vector by default)
  18880. * @param direction2 the max limit of the emission direction (up vector by default)
  18881. */
  18882. constructor(radius?: number,
  18883. /**
  18884. * The min limit of the emission direction.
  18885. */
  18886. direction1?: Vector3,
  18887. /**
  18888. * The max limit of the emission direction.
  18889. */
  18890. direction2?: Vector3);
  18891. /**
  18892. * Called by the particle System when the direction is computed for the created particle.
  18893. * @param worldMatrix is the world matrix of the particle system
  18894. * @param directionToUpdate is the direction vector to update with the result
  18895. * @param particle is the particle we are computed the direction for
  18896. */
  18897. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18898. /**
  18899. * Clones the current emitter and returns a copy of it
  18900. * @returns the new emitter
  18901. */
  18902. clone(): SphereDirectedParticleEmitter;
  18903. /**
  18904. * Called by the GPUParticleSystem to setup the update shader
  18905. * @param effect defines the update shader
  18906. */
  18907. applyToShader(effect: Effect): void;
  18908. /**
  18909. * Returns a string to use to update the GPU particles update shader
  18910. * @returns a string containng the defines string
  18911. */
  18912. getEffectDefines(): string;
  18913. /**
  18914. * Returns the string "SphereDirectedParticleEmitter"
  18915. * @returns a string containing the class name
  18916. */
  18917. getClassName(): string;
  18918. /**
  18919. * Serializes the particle system to a JSON object.
  18920. * @returns the JSON object
  18921. */
  18922. serialize(): any;
  18923. /**
  18924. * Parse properties from a JSON object
  18925. * @param serializationObject defines the JSON object
  18926. */
  18927. parse(serializationObject: any): void;
  18928. }
  18929. }
  18930. declare module "babylonjs/Particles/EmitterTypes/index" {
  18931. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18932. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18933. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18934. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18935. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18936. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18937. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18938. }
  18939. declare module "babylonjs/Particles/IParticleSystem" {
  18940. import { Nullable } from "babylonjs/types";
  18941. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18942. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18943. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18944. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18945. import { Texture } from "babylonjs/Materials/Textures/texture";
  18946. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18947. import { Scene } from "babylonjs/scene";
  18948. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18949. import { Animation } from "babylonjs/Animations/animation";
  18950. /**
  18951. * Interface representing a particle system in Babylon.js.
  18952. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18953. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18954. */
  18955. export interface IParticleSystem {
  18956. /**
  18957. * List of animations used by the particle system.
  18958. */
  18959. animations: Animation[];
  18960. /**
  18961. * The id of the Particle system.
  18962. */
  18963. id: string;
  18964. /**
  18965. * The name of the Particle system.
  18966. */
  18967. name: string;
  18968. /**
  18969. * The emitter represents the Mesh or position we are attaching the particle system to.
  18970. */
  18971. emitter: Nullable<AbstractMesh | Vector3>;
  18972. /**
  18973. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18974. */
  18975. isBillboardBased: boolean;
  18976. /**
  18977. * The rendering group used by the Particle system to chose when to render.
  18978. */
  18979. renderingGroupId: number;
  18980. /**
  18981. * The layer mask we are rendering the particles through.
  18982. */
  18983. layerMask: number;
  18984. /**
  18985. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18986. */
  18987. updateSpeed: number;
  18988. /**
  18989. * The amount of time the particle system is running (depends of the overall update speed).
  18990. */
  18991. targetStopDuration: number;
  18992. /**
  18993. * The texture used to render each particle. (this can be a spritesheet)
  18994. */
  18995. particleTexture: Nullable<Texture>;
  18996. /**
  18997. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18998. */
  18999. blendMode: number;
  19000. /**
  19001. * Minimum life time of emitting particles.
  19002. */
  19003. minLifeTime: number;
  19004. /**
  19005. * Maximum life time of emitting particles.
  19006. */
  19007. maxLifeTime: number;
  19008. /**
  19009. * Minimum Size of emitting particles.
  19010. */
  19011. minSize: number;
  19012. /**
  19013. * Maximum Size of emitting particles.
  19014. */
  19015. maxSize: number;
  19016. /**
  19017. * Minimum scale of emitting particles on X axis.
  19018. */
  19019. minScaleX: number;
  19020. /**
  19021. * Maximum scale of emitting particles on X axis.
  19022. */
  19023. maxScaleX: number;
  19024. /**
  19025. * Minimum scale of emitting particles on Y axis.
  19026. */
  19027. minScaleY: number;
  19028. /**
  19029. * Maximum scale of emitting particles on Y axis.
  19030. */
  19031. maxScaleY: number;
  19032. /**
  19033. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19034. */
  19035. color1: Color4;
  19036. /**
  19037. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19038. */
  19039. color2: Color4;
  19040. /**
  19041. * Color the particle will have at the end of its lifetime.
  19042. */
  19043. colorDead: Color4;
  19044. /**
  19045. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  19046. */
  19047. emitRate: number;
  19048. /**
  19049. * You can use gravity if you want to give an orientation to your particles.
  19050. */
  19051. gravity: Vector3;
  19052. /**
  19053. * Minimum power of emitting particles.
  19054. */
  19055. minEmitPower: number;
  19056. /**
  19057. * Maximum power of emitting particles.
  19058. */
  19059. maxEmitPower: number;
  19060. /**
  19061. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19062. */
  19063. minAngularSpeed: number;
  19064. /**
  19065. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19066. */
  19067. maxAngularSpeed: number;
  19068. /**
  19069. * Gets or sets the minimal initial rotation in radians.
  19070. */
  19071. minInitialRotation: number;
  19072. /**
  19073. * Gets or sets the maximal initial rotation in radians.
  19074. */
  19075. maxInitialRotation: number;
  19076. /**
  19077. * The particle emitter type defines the emitter used by the particle system.
  19078. * It can be for example box, sphere, or cone...
  19079. */
  19080. particleEmitterType: Nullable<IParticleEmitterType>;
  19081. /**
  19082. * Defines the delay in milliseconds before starting the system (0 by default)
  19083. */
  19084. startDelay: number;
  19085. /**
  19086. * 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
  19087. */
  19088. preWarmCycles: number;
  19089. /**
  19090. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  19091. */
  19092. preWarmStepOffset: number;
  19093. /**
  19094. * 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)
  19095. */
  19096. spriteCellChangeSpeed: number;
  19097. /**
  19098. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19099. */
  19100. startSpriteCellID: number;
  19101. /**
  19102. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19103. */
  19104. endSpriteCellID: number;
  19105. /**
  19106. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19107. */
  19108. spriteCellWidth: number;
  19109. /**
  19110. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19111. */
  19112. spriteCellHeight: number;
  19113. /**
  19114. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19115. */
  19116. spriteRandomStartCell: boolean;
  19117. /**
  19118. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  19119. */
  19120. isAnimationSheetEnabled: boolean;
  19121. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19122. translationPivot: Vector2;
  19123. /**
  19124. * Gets or sets a texture used to add random noise to particle positions
  19125. */
  19126. noiseTexture: Nullable<BaseTexture>;
  19127. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19128. noiseStrength: Vector3;
  19129. /**
  19130. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19131. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19132. */
  19133. billboardMode: number;
  19134. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19135. limitVelocityDamping: number;
  19136. /**
  19137. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19138. */
  19139. beginAnimationOnStart: boolean;
  19140. /**
  19141. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19142. */
  19143. beginAnimationFrom: number;
  19144. /**
  19145. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19146. */
  19147. beginAnimationTo: number;
  19148. /**
  19149. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19150. */
  19151. beginAnimationLoop: boolean;
  19152. /**
  19153. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19154. */
  19155. disposeOnStop: boolean;
  19156. /**
  19157. * Gets the maximum number of particles active at the same time.
  19158. * @returns The max number of active particles.
  19159. */
  19160. getCapacity(): number;
  19161. /**
  19162. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19163. * @returns True if it has been started, otherwise false.
  19164. */
  19165. isStarted(): boolean;
  19166. /**
  19167. * Animates the particle system for this frame.
  19168. */
  19169. animate(): void;
  19170. /**
  19171. * Renders the particle system in its current state.
  19172. * @returns the current number of particles
  19173. */
  19174. render(): number;
  19175. /**
  19176. * Dispose the particle system and frees its associated resources.
  19177. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19178. */
  19179. dispose(disposeTexture?: boolean): void;
  19180. /**
  19181. * Clones the particle system.
  19182. * @param name The name of the cloned object
  19183. * @param newEmitter The new emitter to use
  19184. * @returns the cloned particle system
  19185. */
  19186. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  19187. /**
  19188. * Serializes the particle system to a JSON object.
  19189. * @returns the JSON object
  19190. */
  19191. serialize(): any;
  19192. /**
  19193. * Rebuild the particle system
  19194. */
  19195. rebuild(): void;
  19196. /**
  19197. * Starts the particle system and begins to emit
  19198. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  19199. */
  19200. start(delay?: number): void;
  19201. /**
  19202. * Stops the particle system.
  19203. */
  19204. stop(): void;
  19205. /**
  19206. * Remove all active particles
  19207. */
  19208. reset(): void;
  19209. /**
  19210. * Is this system ready to be used/rendered
  19211. * @return true if the system is ready
  19212. */
  19213. isReady(): boolean;
  19214. /**
  19215. * Adds a new color gradient
  19216. * @param gradient defines the gradient to use (between 0 and 1)
  19217. * @param color1 defines the color to affect to the specified gradient
  19218. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19219. * @returns the current particle system
  19220. */
  19221. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19222. /**
  19223. * Remove a specific color gradient
  19224. * @param gradient defines the gradient to remove
  19225. * @returns the current particle system
  19226. */
  19227. removeColorGradient(gradient: number): IParticleSystem;
  19228. /**
  19229. * Adds a new size gradient
  19230. * @param gradient defines the gradient to use (between 0 and 1)
  19231. * @param factor defines the size factor to affect to the specified gradient
  19232. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19233. * @returns the current particle system
  19234. */
  19235. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19236. /**
  19237. * Remove a specific size gradient
  19238. * @param gradient defines the gradient to remove
  19239. * @returns the current particle system
  19240. */
  19241. removeSizeGradient(gradient: number): IParticleSystem;
  19242. /**
  19243. * Gets the current list of color gradients.
  19244. * You must use addColorGradient and removeColorGradient to udpate this list
  19245. * @returns the list of color gradients
  19246. */
  19247. getColorGradients(): Nullable<Array<ColorGradient>>;
  19248. /**
  19249. * Gets the current list of size gradients.
  19250. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19251. * @returns the list of size gradients
  19252. */
  19253. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19254. /**
  19255. * Gets the current list of angular speed gradients.
  19256. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19257. * @returns the list of angular speed gradients
  19258. */
  19259. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19260. /**
  19261. * Adds a new angular speed gradient
  19262. * @param gradient defines the gradient to use (between 0 and 1)
  19263. * @param factor defines the angular speed to affect to the specified gradient
  19264. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19265. * @returns the current particle system
  19266. */
  19267. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19268. /**
  19269. * Remove a specific angular speed gradient
  19270. * @param gradient defines the gradient to remove
  19271. * @returns the current particle system
  19272. */
  19273. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19274. /**
  19275. * Gets the current list of velocity gradients.
  19276. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19277. * @returns the list of velocity gradients
  19278. */
  19279. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19280. /**
  19281. * Adds a new velocity gradient
  19282. * @param gradient defines the gradient to use (between 0 and 1)
  19283. * @param factor defines the velocity to affect to the specified gradient
  19284. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19285. * @returns the current particle system
  19286. */
  19287. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19288. /**
  19289. * Remove a specific velocity gradient
  19290. * @param gradient defines the gradient to remove
  19291. * @returns the current particle system
  19292. */
  19293. removeVelocityGradient(gradient: number): IParticleSystem;
  19294. /**
  19295. * Gets the current list of limit velocity gradients.
  19296. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19297. * @returns the list of limit velocity gradients
  19298. */
  19299. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19300. /**
  19301. * Adds a new limit velocity gradient
  19302. * @param gradient defines the gradient to use (between 0 and 1)
  19303. * @param factor defines the limit velocity to affect to the specified gradient
  19304. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19305. * @returns the current particle system
  19306. */
  19307. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19308. /**
  19309. * Remove a specific limit velocity gradient
  19310. * @param gradient defines the gradient to remove
  19311. * @returns the current particle system
  19312. */
  19313. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19314. /**
  19315. * Adds a new drag gradient
  19316. * @param gradient defines the gradient to use (between 0 and 1)
  19317. * @param factor defines the drag to affect to the specified gradient
  19318. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19319. * @returns the current particle system
  19320. */
  19321. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19322. /**
  19323. * Remove a specific drag gradient
  19324. * @param gradient defines the gradient to remove
  19325. * @returns the current particle system
  19326. */
  19327. removeDragGradient(gradient: number): IParticleSystem;
  19328. /**
  19329. * Gets the current list of drag gradients.
  19330. * You must use addDragGradient and removeDragGradient to udpate this list
  19331. * @returns the list of drag gradients
  19332. */
  19333. getDragGradients(): Nullable<Array<FactorGradient>>;
  19334. /**
  19335. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19336. * @param gradient defines the gradient to use (between 0 and 1)
  19337. * @param factor defines the emit rate to affect to the specified gradient
  19338. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19339. * @returns the current particle system
  19340. */
  19341. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19342. /**
  19343. * Remove a specific emit rate gradient
  19344. * @param gradient defines the gradient to remove
  19345. * @returns the current particle system
  19346. */
  19347. removeEmitRateGradient(gradient: number): IParticleSystem;
  19348. /**
  19349. * Gets the current list of emit rate gradients.
  19350. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19351. * @returns the list of emit rate gradients
  19352. */
  19353. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19354. /**
  19355. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19356. * @param gradient defines the gradient to use (between 0 and 1)
  19357. * @param factor defines the start size to affect to the specified gradient
  19358. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19359. * @returns the current particle system
  19360. */
  19361. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19362. /**
  19363. * Remove a specific start size gradient
  19364. * @param gradient defines the gradient to remove
  19365. * @returns the current particle system
  19366. */
  19367. removeStartSizeGradient(gradient: number): IParticleSystem;
  19368. /**
  19369. * Gets the current list of start size gradients.
  19370. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19371. * @returns the list of start size gradients
  19372. */
  19373. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19374. /**
  19375. * Adds a new life time gradient
  19376. * @param gradient defines the gradient to use (between 0 and 1)
  19377. * @param factor defines the life time factor to affect to the specified gradient
  19378. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19379. * @returns the current particle system
  19380. */
  19381. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19382. /**
  19383. * Remove a specific life time gradient
  19384. * @param gradient defines the gradient to remove
  19385. * @returns the current particle system
  19386. */
  19387. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19388. /**
  19389. * Gets the current list of life time gradients.
  19390. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19391. * @returns the list of life time gradients
  19392. */
  19393. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19394. /**
  19395. * Gets the current list of color gradients.
  19396. * You must use addColorGradient and removeColorGradient to udpate this list
  19397. * @returns the list of color gradients
  19398. */
  19399. getColorGradients(): Nullable<Array<ColorGradient>>;
  19400. /**
  19401. * Adds a new ramp gradient used to remap particle colors
  19402. * @param gradient defines the gradient to use (between 0 and 1)
  19403. * @param color defines the color to affect to the specified gradient
  19404. * @returns the current particle system
  19405. */
  19406. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19407. /**
  19408. * Gets the current list of ramp gradients.
  19409. * You must use addRampGradient and removeRampGradient to udpate this list
  19410. * @returns the list of ramp gradients
  19411. */
  19412. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19413. /** Gets or sets a boolean indicating that ramp gradients must be used
  19414. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19415. */
  19416. useRampGradients: boolean;
  19417. /**
  19418. * Adds a new color remap gradient
  19419. * @param gradient defines the gradient to use (between 0 and 1)
  19420. * @param min defines the color remap minimal range
  19421. * @param max defines the color remap maximal range
  19422. * @returns the current particle system
  19423. */
  19424. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19425. /**
  19426. * Gets the current list of color remap gradients.
  19427. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19428. * @returns the list of color remap gradients
  19429. */
  19430. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19431. /**
  19432. * Adds a new alpha remap gradient
  19433. * @param gradient defines the gradient to use (between 0 and 1)
  19434. * @param min defines the alpha remap minimal range
  19435. * @param max defines the alpha remap maximal range
  19436. * @returns the current particle system
  19437. */
  19438. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19439. /**
  19440. * Gets the current list of alpha remap gradients.
  19441. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19442. * @returns the list of alpha remap gradients
  19443. */
  19444. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19445. /**
  19446. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19447. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19448. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19449. * @returns the emitter
  19450. */
  19451. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19452. /**
  19453. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19454. * @param radius The radius of the hemisphere to emit from
  19455. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19456. * @returns the emitter
  19457. */
  19458. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19459. /**
  19460. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19461. * @param radius The radius of the sphere to emit from
  19462. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19463. * @returns the emitter
  19464. */
  19465. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19466. /**
  19467. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19468. * @param radius The radius of the sphere to emit from
  19469. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19470. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19471. * @returns the emitter
  19472. */
  19473. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19474. /**
  19475. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19476. * @param radius The radius of the emission cylinder
  19477. * @param height The height of the emission cylinder
  19478. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19479. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19480. * @returns the emitter
  19481. */
  19482. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19483. /**
  19484. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19485. * @param radius The radius of the cylinder to emit from
  19486. * @param height The height of the emission cylinder
  19487. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19488. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19489. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19490. * @returns the emitter
  19491. */
  19492. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19493. /**
  19494. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19495. * @param radius The radius of the cone to emit from
  19496. * @param angle The base angle of the cone
  19497. * @returns the emitter
  19498. */
  19499. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19500. /**
  19501. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19502. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19503. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19504. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19505. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19506. * @returns the emitter
  19507. */
  19508. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19509. /**
  19510. * Get hosting scene
  19511. * @returns the scene
  19512. */
  19513. getScene(): Scene;
  19514. }
  19515. }
  19516. declare module "babylonjs/Meshes/instancedMesh" {
  19517. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19518. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19519. import { Camera } from "babylonjs/Cameras/camera";
  19520. import { Node } from "babylonjs/node";
  19521. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19522. import { Mesh } from "babylonjs/Meshes/mesh";
  19523. import { Material } from "babylonjs/Materials/material";
  19524. import { Skeleton } from "babylonjs/Bones/skeleton";
  19525. import { Light } from "babylonjs/Lights/light";
  19526. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19527. /**
  19528. * Creates an instance based on a source mesh.
  19529. */
  19530. export class InstancedMesh extends AbstractMesh {
  19531. private _sourceMesh;
  19532. private _currentLOD;
  19533. /** @hidden */
  19534. _indexInSourceMeshInstanceArray: number;
  19535. constructor(name: string, source: Mesh);
  19536. /**
  19537. * Returns the string "InstancedMesh".
  19538. */
  19539. getClassName(): string;
  19540. /** Gets the list of lights affecting that mesh */
  19541. readonly lightSources: Light[];
  19542. _resyncLightSources(): void;
  19543. _resyncLightSource(light: Light): void;
  19544. _removeLightSource(light: Light, dispose: boolean): void;
  19545. /**
  19546. * If the source mesh receives shadows
  19547. */
  19548. readonly receiveShadows: boolean;
  19549. /**
  19550. * The material of the source mesh
  19551. */
  19552. readonly material: Nullable<Material>;
  19553. /**
  19554. * Visibility of the source mesh
  19555. */
  19556. readonly visibility: number;
  19557. /**
  19558. * Skeleton of the source mesh
  19559. */
  19560. readonly skeleton: Nullable<Skeleton>;
  19561. /**
  19562. * Rendering ground id of the source mesh
  19563. */
  19564. renderingGroupId: number;
  19565. /**
  19566. * Returns the total number of vertices (integer).
  19567. */
  19568. getTotalVertices(): number;
  19569. /**
  19570. * Returns a positive integer : the total number of indices in this mesh geometry.
  19571. * @returns the numner of indices or zero if the mesh has no geometry.
  19572. */
  19573. getTotalIndices(): number;
  19574. /**
  19575. * The source mesh of the instance
  19576. */
  19577. readonly sourceMesh: Mesh;
  19578. /**
  19579. * Is this node ready to be used/rendered
  19580. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19581. * @return {boolean} is it ready
  19582. */
  19583. isReady(completeCheck?: boolean): boolean;
  19584. /**
  19585. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19586. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19587. * @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.
  19588. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19589. */
  19590. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19591. /**
  19592. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19593. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19594. * The `data` are either a numeric array either a Float32Array.
  19595. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19596. * 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).
  19597. * Note that a new underlying VertexBuffer object is created each call.
  19598. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19599. *
  19600. * Possible `kind` values :
  19601. * - VertexBuffer.PositionKind
  19602. * - VertexBuffer.UVKind
  19603. * - VertexBuffer.UV2Kind
  19604. * - VertexBuffer.UV3Kind
  19605. * - VertexBuffer.UV4Kind
  19606. * - VertexBuffer.UV5Kind
  19607. * - VertexBuffer.UV6Kind
  19608. * - VertexBuffer.ColorKind
  19609. * - VertexBuffer.MatricesIndicesKind
  19610. * - VertexBuffer.MatricesIndicesExtraKind
  19611. * - VertexBuffer.MatricesWeightsKind
  19612. * - VertexBuffer.MatricesWeightsExtraKind
  19613. *
  19614. * Returns the Mesh.
  19615. */
  19616. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19617. /**
  19618. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19619. * If the mesh has no geometry, it is simply returned as it is.
  19620. * The `data` are either a numeric array either a Float32Array.
  19621. * No new underlying VertexBuffer object is created.
  19622. * 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.
  19623. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19624. *
  19625. * Possible `kind` values :
  19626. * - VertexBuffer.PositionKind
  19627. * - VertexBuffer.UVKind
  19628. * - VertexBuffer.UV2Kind
  19629. * - VertexBuffer.UV3Kind
  19630. * - VertexBuffer.UV4Kind
  19631. * - VertexBuffer.UV5Kind
  19632. * - VertexBuffer.UV6Kind
  19633. * - VertexBuffer.ColorKind
  19634. * - VertexBuffer.MatricesIndicesKind
  19635. * - VertexBuffer.MatricesIndicesExtraKind
  19636. * - VertexBuffer.MatricesWeightsKind
  19637. * - VertexBuffer.MatricesWeightsExtraKind
  19638. *
  19639. * Returns the Mesh.
  19640. */
  19641. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19642. /**
  19643. * Sets the mesh indices.
  19644. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19645. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19646. * This method creates a new index buffer each call.
  19647. * Returns the Mesh.
  19648. */
  19649. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19650. /**
  19651. * Boolean : True if the mesh owns the requested kind of data.
  19652. */
  19653. isVerticesDataPresent(kind: string): boolean;
  19654. /**
  19655. * Returns an array of indices (IndicesArray).
  19656. */
  19657. getIndices(): Nullable<IndicesArray>;
  19658. readonly _positions: Nullable<Vector3[]>;
  19659. /**
  19660. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19661. * This means the mesh underlying bounding box and sphere are recomputed.
  19662. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19663. * @returns the current mesh
  19664. */
  19665. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19666. /** @hidden */
  19667. _preActivate(): InstancedMesh;
  19668. /** @hidden */
  19669. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19670. /** @hidden */
  19671. _postActivate(): void;
  19672. getWorldMatrix(): Matrix;
  19673. readonly isAnInstance: boolean;
  19674. /**
  19675. * Returns the current associated LOD AbstractMesh.
  19676. */
  19677. getLOD(camera: Camera): AbstractMesh;
  19678. /** @hidden */
  19679. _syncSubMeshes(): InstancedMesh;
  19680. /** @hidden */
  19681. _generatePointsArray(): boolean;
  19682. /**
  19683. * Creates a new InstancedMesh from the current mesh.
  19684. * - name (string) : the cloned mesh name
  19685. * - newParent (optional Node) : the optional Node to parent the clone to.
  19686. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19687. *
  19688. * Returns the clone.
  19689. */
  19690. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19691. /**
  19692. * Disposes the InstancedMesh.
  19693. * Returns nothing.
  19694. */
  19695. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19696. }
  19697. module "babylonjs/Meshes/mesh" {
  19698. interface Mesh {
  19699. /**
  19700. * Register a custom buffer that will be instanced
  19701. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19702. * @param kind defines the buffer kind
  19703. * @param stride defines the stride in floats
  19704. */
  19705. registerInstancedBuffer(kind: string, stride: number): void;
  19706. /** @hidden */
  19707. _userInstancedBuffersStorage: {
  19708. data: {
  19709. [key: string]: Float32Array;
  19710. };
  19711. sizes: {
  19712. [key: string]: number;
  19713. };
  19714. vertexBuffers: {
  19715. [key: string]: Nullable<VertexBuffer>;
  19716. };
  19717. strides: {
  19718. [key: string]: number;
  19719. };
  19720. };
  19721. }
  19722. }
  19723. module "babylonjs/Meshes/abstractMesh" {
  19724. interface AbstractMesh {
  19725. /**
  19726. * Object used to store instanced buffers defined by user
  19727. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19728. */
  19729. instancedBuffers: {
  19730. [key: string]: any;
  19731. };
  19732. }
  19733. }
  19734. }
  19735. declare module "babylonjs/Materials/shaderMaterial" {
  19736. import { Scene } from "babylonjs/scene";
  19737. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19738. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19739. import { Mesh } from "babylonjs/Meshes/mesh";
  19740. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19741. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19742. import { Texture } from "babylonjs/Materials/Textures/texture";
  19743. import { Material } from "babylonjs/Materials/material";
  19744. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19745. /**
  19746. * Defines the options associated with the creation of a shader material.
  19747. */
  19748. export interface IShaderMaterialOptions {
  19749. /**
  19750. * Does the material work in alpha blend mode
  19751. */
  19752. needAlphaBlending: boolean;
  19753. /**
  19754. * Does the material work in alpha test mode
  19755. */
  19756. needAlphaTesting: boolean;
  19757. /**
  19758. * The list of attribute names used in the shader
  19759. */
  19760. attributes: string[];
  19761. /**
  19762. * The list of unifrom names used in the shader
  19763. */
  19764. uniforms: string[];
  19765. /**
  19766. * The list of UBO names used in the shader
  19767. */
  19768. uniformBuffers: string[];
  19769. /**
  19770. * The list of sampler names used in the shader
  19771. */
  19772. samplers: string[];
  19773. /**
  19774. * The list of defines used in the shader
  19775. */
  19776. defines: string[];
  19777. }
  19778. /**
  19779. * 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.
  19780. *
  19781. * This returned material effects how the mesh will look based on the code in the shaders.
  19782. *
  19783. * @see http://doc.babylonjs.com/how_to/shader_material
  19784. */
  19785. export class ShaderMaterial extends Material {
  19786. private _shaderPath;
  19787. private _options;
  19788. private _textures;
  19789. private _textureArrays;
  19790. private _floats;
  19791. private _ints;
  19792. private _floatsArrays;
  19793. private _colors3;
  19794. private _colors3Arrays;
  19795. private _colors4;
  19796. private _colors4Arrays;
  19797. private _vectors2;
  19798. private _vectors3;
  19799. private _vectors4;
  19800. private _matrices;
  19801. private _matrixArrays;
  19802. private _matrices3x3;
  19803. private _matrices2x2;
  19804. private _vectors2Arrays;
  19805. private _vectors3Arrays;
  19806. private _vectors4Arrays;
  19807. private _cachedWorldViewMatrix;
  19808. private _cachedWorldViewProjectionMatrix;
  19809. private _renderId;
  19810. private _multiview;
  19811. /**
  19812. * Instantiate a new shader material.
  19813. * 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.
  19814. * This returned material effects how the mesh will look based on the code in the shaders.
  19815. * @see http://doc.babylonjs.com/how_to/shader_material
  19816. * @param name Define the name of the material in the scene
  19817. * @param scene Define the scene the material belongs to
  19818. * @param shaderPath Defines the route to the shader code in one of three ways:
  19819. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19820. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19821. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19822. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19823. * @param options Define the options used to create the shader
  19824. */
  19825. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19826. /**
  19827. * Gets the shader path used to define the shader code
  19828. * It can be modified to trigger a new compilation
  19829. */
  19830. /**
  19831. * Sets the shader path used to define the shader code
  19832. * It can be modified to trigger a new compilation
  19833. */
  19834. shaderPath: any;
  19835. /**
  19836. * Gets the options used to compile the shader.
  19837. * They can be modified to trigger a new compilation
  19838. */
  19839. readonly options: IShaderMaterialOptions;
  19840. /**
  19841. * Gets the current class name of the material e.g. "ShaderMaterial"
  19842. * Mainly use in serialization.
  19843. * @returns the class name
  19844. */
  19845. getClassName(): string;
  19846. /**
  19847. * Specifies if the material will require alpha blending
  19848. * @returns a boolean specifying if alpha blending is needed
  19849. */
  19850. needAlphaBlending(): boolean;
  19851. /**
  19852. * Specifies if this material should be rendered in alpha test mode
  19853. * @returns a boolean specifying if an alpha test is needed.
  19854. */
  19855. needAlphaTesting(): boolean;
  19856. private _checkUniform;
  19857. /**
  19858. * Set a texture in the shader.
  19859. * @param name Define the name of the uniform samplers as defined in the shader
  19860. * @param texture Define the texture to bind to this sampler
  19861. * @return the material itself allowing "fluent" like uniform updates
  19862. */
  19863. setTexture(name: string, texture: Texture): ShaderMaterial;
  19864. /**
  19865. * Set a texture array in the shader.
  19866. * @param name Define the name of the uniform sampler array as defined in the shader
  19867. * @param textures Define the list of textures to bind to this sampler
  19868. * @return the material itself allowing "fluent" like uniform updates
  19869. */
  19870. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19871. /**
  19872. * Set a float in the shader.
  19873. * @param name Define the name of the uniform as defined in the shader
  19874. * @param value Define the value to give to the uniform
  19875. * @return the material itself allowing "fluent" like uniform updates
  19876. */
  19877. setFloat(name: string, value: number): ShaderMaterial;
  19878. /**
  19879. * Set a int in the shader.
  19880. * @param name Define the name of the uniform as defined in the shader
  19881. * @param value Define the value to give to the uniform
  19882. * @return the material itself allowing "fluent" like uniform updates
  19883. */
  19884. setInt(name: string, value: number): ShaderMaterial;
  19885. /**
  19886. * Set an array of floats in the shader.
  19887. * @param name Define the name of the uniform as defined in the shader
  19888. * @param value Define the value to give to the uniform
  19889. * @return the material itself allowing "fluent" like uniform updates
  19890. */
  19891. setFloats(name: string, value: number[]): ShaderMaterial;
  19892. /**
  19893. * Set a vec3 in the shader from a Color3.
  19894. * @param name Define the name of the uniform as defined in the shader
  19895. * @param value Define the value to give to the uniform
  19896. * @return the material itself allowing "fluent" like uniform updates
  19897. */
  19898. setColor3(name: string, value: Color3): ShaderMaterial;
  19899. /**
  19900. * Set a vec3 array in the shader from a Color3 array.
  19901. * @param name Define the name of the uniform as defined in the shader
  19902. * @param value Define the value to give to the uniform
  19903. * @return the material itself allowing "fluent" like uniform updates
  19904. */
  19905. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19906. /**
  19907. * Set a vec4 in the shader from a Color4.
  19908. * @param name Define the name of the uniform as defined in the shader
  19909. * @param value Define the value to give to the uniform
  19910. * @return the material itself allowing "fluent" like uniform updates
  19911. */
  19912. setColor4(name: string, value: Color4): ShaderMaterial;
  19913. /**
  19914. * Set a vec4 array in the shader from a Color4 array.
  19915. * @param name Define the name of the uniform as defined in the shader
  19916. * @param value Define the value to give to the uniform
  19917. * @return the material itself allowing "fluent" like uniform updates
  19918. */
  19919. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19920. /**
  19921. * Set a vec2 in the shader from a Vector2.
  19922. * @param name Define the name of the uniform as defined in the shader
  19923. * @param value Define the value to give to the uniform
  19924. * @return the material itself allowing "fluent" like uniform updates
  19925. */
  19926. setVector2(name: string, value: Vector2): ShaderMaterial;
  19927. /**
  19928. * Set a vec3 in the shader from a Vector3.
  19929. * @param name Define the name of the uniform as defined in the shader
  19930. * @param value Define the value to give to the uniform
  19931. * @return the material itself allowing "fluent" like uniform updates
  19932. */
  19933. setVector3(name: string, value: Vector3): ShaderMaterial;
  19934. /**
  19935. * Set a vec4 in the shader from a Vector4.
  19936. * @param name Define the name of the uniform as defined in the shader
  19937. * @param value Define the value to give to the uniform
  19938. * @return the material itself allowing "fluent" like uniform updates
  19939. */
  19940. setVector4(name: string, value: Vector4): ShaderMaterial;
  19941. /**
  19942. * Set a mat4 in the shader from a Matrix.
  19943. * @param name Define the name of the uniform as defined in the shader
  19944. * @param value Define the value to give to the uniform
  19945. * @return the material itself allowing "fluent" like uniform updates
  19946. */
  19947. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19948. /**
  19949. * Set a float32Array in the shader from a matrix array.
  19950. * @param name Define the name of the uniform as defined in the shader
  19951. * @param value Define the value to give to the uniform
  19952. * @return the material itself allowing "fluent" like uniform updates
  19953. */
  19954. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  19955. /**
  19956. * Set a mat3 in the shader from a Float32Array.
  19957. * @param name Define the name of the uniform as defined in the shader
  19958. * @param value Define the value to give to the uniform
  19959. * @return the material itself allowing "fluent" like uniform updates
  19960. */
  19961. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19962. /**
  19963. * Set a mat2 in the shader from a Float32Array.
  19964. * @param name Define the name of the uniform as defined in the shader
  19965. * @param value Define the value to give to the uniform
  19966. * @return the material itself allowing "fluent" like uniform updates
  19967. */
  19968. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19969. /**
  19970. * Set a vec2 array in the shader from a number array.
  19971. * @param name Define the name of the uniform as defined in the shader
  19972. * @param value Define the value to give to the uniform
  19973. * @return the material itself allowing "fluent" like uniform updates
  19974. */
  19975. setArray2(name: string, value: number[]): ShaderMaterial;
  19976. /**
  19977. * Set a vec3 array in the shader from a number array.
  19978. * @param name Define the name of the uniform as defined in the shader
  19979. * @param value Define the value to give to the uniform
  19980. * @return the material itself allowing "fluent" like uniform updates
  19981. */
  19982. setArray3(name: string, value: number[]): ShaderMaterial;
  19983. /**
  19984. * Set a vec4 array in the shader from a number array.
  19985. * @param name Define the name of the uniform as defined in the shader
  19986. * @param value Define the value to give to the uniform
  19987. * @return the material itself allowing "fluent" like uniform updates
  19988. */
  19989. setArray4(name: string, value: number[]): ShaderMaterial;
  19990. private _checkCache;
  19991. /**
  19992. * Specifies that the submesh is ready to be used
  19993. * @param mesh defines the mesh to check
  19994. * @param subMesh defines which submesh to check
  19995. * @param useInstances specifies that instances should be used
  19996. * @returns a boolean indicating that the submesh is ready or not
  19997. */
  19998. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19999. /**
  20000. * Checks if the material is ready to render the requested mesh
  20001. * @param mesh Define the mesh to render
  20002. * @param useInstances Define whether or not the material is used with instances
  20003. * @returns true if ready, otherwise false
  20004. */
  20005. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20006. /**
  20007. * Binds the world matrix to the material
  20008. * @param world defines the world transformation matrix
  20009. */
  20010. bindOnlyWorldMatrix(world: Matrix): void;
  20011. /**
  20012. * Binds the material to the mesh
  20013. * @param world defines the world transformation matrix
  20014. * @param mesh defines the mesh to bind the material to
  20015. */
  20016. bind(world: Matrix, mesh?: Mesh): void;
  20017. /**
  20018. * Gets the active textures from the material
  20019. * @returns an array of textures
  20020. */
  20021. getActiveTextures(): BaseTexture[];
  20022. /**
  20023. * Specifies if the material uses a texture
  20024. * @param texture defines the texture to check against the material
  20025. * @returns a boolean specifying if the material uses the texture
  20026. */
  20027. hasTexture(texture: BaseTexture): boolean;
  20028. /**
  20029. * Makes a duplicate of the material, and gives it a new name
  20030. * @param name defines the new name for the duplicated material
  20031. * @returns the cloned material
  20032. */
  20033. clone(name: string): ShaderMaterial;
  20034. /**
  20035. * Disposes the material
  20036. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20037. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20038. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20039. */
  20040. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20041. /**
  20042. * Serializes this material in a JSON representation
  20043. * @returns the serialized material object
  20044. */
  20045. serialize(): any;
  20046. /**
  20047. * Creates a shader material from parsed shader material data
  20048. * @param source defines the JSON represnetation of the material
  20049. * @param scene defines the hosting scene
  20050. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  20051. * @returns a new material
  20052. */
  20053. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  20054. }
  20055. }
  20056. declare module "babylonjs/Shaders/color.fragment" {
  20057. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  20058. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  20059. /** @hidden */
  20060. export var colorPixelShader: {
  20061. name: string;
  20062. shader: string;
  20063. };
  20064. }
  20065. declare module "babylonjs/Shaders/color.vertex" {
  20066. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  20067. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  20068. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  20069. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  20070. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  20071. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  20072. /** @hidden */
  20073. export var colorVertexShader: {
  20074. name: string;
  20075. shader: string;
  20076. };
  20077. }
  20078. declare module "babylonjs/Meshes/linesMesh" {
  20079. import { Nullable } from "babylonjs/types";
  20080. import { Scene } from "babylonjs/scene";
  20081. import { Color3 } from "babylonjs/Maths/math.color";
  20082. import { Node } from "babylonjs/node";
  20083. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20084. import { Mesh } from "babylonjs/Meshes/mesh";
  20085. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20086. import { Effect } from "babylonjs/Materials/effect";
  20087. import { Material } from "babylonjs/Materials/material";
  20088. import "babylonjs/Shaders/color.fragment";
  20089. import "babylonjs/Shaders/color.vertex";
  20090. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20091. /**
  20092. * Line mesh
  20093. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  20094. */
  20095. export class LinesMesh extends Mesh {
  20096. /**
  20097. * If vertex color should be applied to the mesh
  20098. */
  20099. readonly useVertexColor?: boolean | undefined;
  20100. /**
  20101. * If vertex alpha should be applied to the mesh
  20102. */
  20103. readonly useVertexAlpha?: boolean | undefined;
  20104. /**
  20105. * Color of the line (Default: White)
  20106. */
  20107. color: Color3;
  20108. /**
  20109. * Alpha of the line (Default: 1)
  20110. */
  20111. alpha: number;
  20112. /**
  20113. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20114. * This margin is expressed in world space coordinates, so its value may vary.
  20115. * Default value is 0.1
  20116. */
  20117. intersectionThreshold: number;
  20118. private _colorShader;
  20119. private color4;
  20120. /**
  20121. * Creates a new LinesMesh
  20122. * @param name defines the name
  20123. * @param scene defines the hosting scene
  20124. * @param parent defines the parent mesh if any
  20125. * @param source defines the optional source LinesMesh used to clone data from
  20126. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20127. * When false, achieved by calling a clone(), also passing False.
  20128. * This will make creation of children, recursive.
  20129. * @param useVertexColor defines if this LinesMesh supports vertex color
  20130. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  20131. */
  20132. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  20133. /**
  20134. * If vertex color should be applied to the mesh
  20135. */
  20136. useVertexColor?: boolean | undefined,
  20137. /**
  20138. * If vertex alpha should be applied to the mesh
  20139. */
  20140. useVertexAlpha?: boolean | undefined);
  20141. private _addClipPlaneDefine;
  20142. private _removeClipPlaneDefine;
  20143. isReady(): boolean;
  20144. /**
  20145. * Returns the string "LineMesh"
  20146. */
  20147. getClassName(): string;
  20148. /**
  20149. * @hidden
  20150. */
  20151. /**
  20152. * @hidden
  20153. */
  20154. material: Material;
  20155. /**
  20156. * @hidden
  20157. */
  20158. readonly checkCollisions: boolean;
  20159. /** @hidden */
  20160. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20161. /** @hidden */
  20162. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20163. /**
  20164. * Disposes of the line mesh
  20165. * @param doNotRecurse If children should be disposed
  20166. */
  20167. dispose(doNotRecurse?: boolean): void;
  20168. /**
  20169. * Returns a new LineMesh object cloned from the current one.
  20170. */
  20171. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  20172. /**
  20173. * Creates a new InstancedLinesMesh object from the mesh model.
  20174. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20175. * @param name defines the name of the new instance
  20176. * @returns a new InstancedLinesMesh
  20177. */
  20178. createInstance(name: string): InstancedLinesMesh;
  20179. }
  20180. /**
  20181. * Creates an instance based on a source LinesMesh
  20182. */
  20183. export class InstancedLinesMesh extends InstancedMesh {
  20184. /**
  20185. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20186. * This margin is expressed in world space coordinates, so its value may vary.
  20187. * Initilized with the intersectionThreshold value of the source LinesMesh
  20188. */
  20189. intersectionThreshold: number;
  20190. constructor(name: string, source: LinesMesh);
  20191. /**
  20192. * Returns the string "InstancedLinesMesh".
  20193. */
  20194. getClassName(): string;
  20195. }
  20196. }
  20197. declare module "babylonjs/Shaders/line.fragment" {
  20198. /** @hidden */
  20199. export var linePixelShader: {
  20200. name: string;
  20201. shader: string;
  20202. };
  20203. }
  20204. declare module "babylonjs/Shaders/line.vertex" {
  20205. /** @hidden */
  20206. export var lineVertexShader: {
  20207. name: string;
  20208. shader: string;
  20209. };
  20210. }
  20211. declare module "babylonjs/Rendering/edgesRenderer" {
  20212. import { Nullable } from "babylonjs/types";
  20213. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20214. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20215. import { Vector3 } from "babylonjs/Maths/math.vector";
  20216. import { IDisposable } from "babylonjs/scene";
  20217. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  20218. import "babylonjs/Shaders/line.fragment";
  20219. import "babylonjs/Shaders/line.vertex";
  20220. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  20221. module "babylonjs/Meshes/abstractMesh" {
  20222. interface AbstractMesh {
  20223. /**
  20224. * Gets the edgesRenderer associated with the mesh
  20225. */
  20226. edgesRenderer: Nullable<EdgesRenderer>;
  20227. }
  20228. }
  20229. module "babylonjs/Meshes/linesMesh" {
  20230. interface LinesMesh {
  20231. /**
  20232. * Enables the edge rendering mode on the mesh.
  20233. * This mode makes the mesh edges visible
  20234. * @param epsilon defines the maximal distance between two angles to detect a face
  20235. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20236. * @returns the currentAbstractMesh
  20237. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20238. */
  20239. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20240. }
  20241. }
  20242. module "babylonjs/Meshes/linesMesh" {
  20243. interface InstancedLinesMesh {
  20244. /**
  20245. * Enables the edge rendering mode on the mesh.
  20246. * This mode makes the mesh edges visible
  20247. * @param epsilon defines the maximal distance between two angles to detect a face
  20248. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20249. * @returns the current InstancedLinesMesh
  20250. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20251. */
  20252. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20253. }
  20254. }
  20255. /**
  20256. * Defines the minimum contract an Edges renderer should follow.
  20257. */
  20258. export interface IEdgesRenderer extends IDisposable {
  20259. /**
  20260. * Gets or sets a boolean indicating if the edgesRenderer is active
  20261. */
  20262. isEnabled: boolean;
  20263. /**
  20264. * Renders the edges of the attached mesh,
  20265. */
  20266. render(): void;
  20267. /**
  20268. * Checks wether or not the edges renderer is ready to render.
  20269. * @return true if ready, otherwise false.
  20270. */
  20271. isReady(): boolean;
  20272. }
  20273. /**
  20274. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20275. */
  20276. export class EdgesRenderer implements IEdgesRenderer {
  20277. /**
  20278. * Define the size of the edges with an orthographic camera
  20279. */
  20280. edgesWidthScalerForOrthographic: number;
  20281. /**
  20282. * Define the size of the edges with a perspective camera
  20283. */
  20284. edgesWidthScalerForPerspective: number;
  20285. protected _source: AbstractMesh;
  20286. protected _linesPositions: number[];
  20287. protected _linesNormals: number[];
  20288. protected _linesIndices: number[];
  20289. protected _epsilon: number;
  20290. protected _indicesCount: number;
  20291. protected _lineShader: ShaderMaterial;
  20292. protected _ib: DataBuffer;
  20293. protected _buffers: {
  20294. [key: string]: Nullable<VertexBuffer>;
  20295. };
  20296. protected _checkVerticesInsteadOfIndices: boolean;
  20297. private _meshRebuildObserver;
  20298. private _meshDisposeObserver;
  20299. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20300. isEnabled: boolean;
  20301. /**
  20302. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20303. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20304. * @param source Mesh used to create edges
  20305. * @param epsilon sum of angles in adjacency to check for edge
  20306. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20307. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20308. */
  20309. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20310. protected _prepareRessources(): void;
  20311. /** @hidden */
  20312. _rebuild(): void;
  20313. /**
  20314. * Releases the required resources for the edges renderer
  20315. */
  20316. dispose(): void;
  20317. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20318. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20319. /**
  20320. * Checks if the pair of p0 and p1 is en edge
  20321. * @param faceIndex
  20322. * @param edge
  20323. * @param faceNormals
  20324. * @param p0
  20325. * @param p1
  20326. * @private
  20327. */
  20328. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20329. /**
  20330. * push line into the position, normal and index buffer
  20331. * @protected
  20332. */
  20333. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20334. /**
  20335. * Generates lines edges from adjacencjes
  20336. * @private
  20337. */
  20338. _generateEdgesLines(): void;
  20339. /**
  20340. * Checks wether or not the edges renderer is ready to render.
  20341. * @return true if ready, otherwise false.
  20342. */
  20343. isReady(): boolean;
  20344. /**
  20345. * Renders the edges of the attached mesh,
  20346. */
  20347. render(): void;
  20348. }
  20349. /**
  20350. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20351. */
  20352. export class LineEdgesRenderer extends EdgesRenderer {
  20353. /**
  20354. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20355. * @param source LineMesh used to generate edges
  20356. * @param epsilon not important (specified angle for edge detection)
  20357. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20358. */
  20359. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20360. /**
  20361. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20362. */
  20363. _generateEdgesLines(): void;
  20364. }
  20365. }
  20366. declare module "babylonjs/Rendering/renderingGroup" {
  20367. import { SmartArray } from "babylonjs/Misc/smartArray";
  20368. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20369. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20370. import { Nullable } from "babylonjs/types";
  20371. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20372. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20373. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20374. import { Material } from "babylonjs/Materials/material";
  20375. import { Scene } from "babylonjs/scene";
  20376. /**
  20377. * This represents the object necessary to create a rendering group.
  20378. * This is exclusively used and created by the rendering manager.
  20379. * To modify the behavior, you use the available helpers in your scene or meshes.
  20380. * @hidden
  20381. */
  20382. export class RenderingGroup {
  20383. index: number;
  20384. private static _zeroVector;
  20385. private _scene;
  20386. private _opaqueSubMeshes;
  20387. private _transparentSubMeshes;
  20388. private _alphaTestSubMeshes;
  20389. private _depthOnlySubMeshes;
  20390. private _particleSystems;
  20391. private _spriteManagers;
  20392. private _opaqueSortCompareFn;
  20393. private _alphaTestSortCompareFn;
  20394. private _transparentSortCompareFn;
  20395. private _renderOpaque;
  20396. private _renderAlphaTest;
  20397. private _renderTransparent;
  20398. /** @hidden */
  20399. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20400. onBeforeTransparentRendering: () => void;
  20401. /**
  20402. * Set the opaque sort comparison function.
  20403. * If null the sub meshes will be render in the order they were created
  20404. */
  20405. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20406. /**
  20407. * Set the alpha test sort comparison function.
  20408. * If null the sub meshes will be render in the order they were created
  20409. */
  20410. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20411. /**
  20412. * Set the transparent sort comparison function.
  20413. * If null the sub meshes will be render in the order they were created
  20414. */
  20415. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20416. /**
  20417. * Creates a new rendering group.
  20418. * @param index The rendering group index
  20419. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20420. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20421. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20422. */
  20423. 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>);
  20424. /**
  20425. * Render all the sub meshes contained in the group.
  20426. * @param customRenderFunction Used to override the default render behaviour of the group.
  20427. * @returns true if rendered some submeshes.
  20428. */
  20429. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20430. /**
  20431. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20432. * @param subMeshes The submeshes to render
  20433. */
  20434. private renderOpaqueSorted;
  20435. /**
  20436. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20437. * @param subMeshes The submeshes to render
  20438. */
  20439. private renderAlphaTestSorted;
  20440. /**
  20441. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20442. * @param subMeshes The submeshes to render
  20443. */
  20444. private renderTransparentSorted;
  20445. /**
  20446. * Renders the submeshes in a specified order.
  20447. * @param subMeshes The submeshes to sort before render
  20448. * @param sortCompareFn The comparison function use to sort
  20449. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20450. * @param transparent Specifies to activate blending if true
  20451. */
  20452. private static renderSorted;
  20453. /**
  20454. * Renders the submeshes in the order they were dispatched (no sort applied).
  20455. * @param subMeshes The submeshes to render
  20456. */
  20457. private static renderUnsorted;
  20458. /**
  20459. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20460. * are rendered back to front if in the same alpha index.
  20461. *
  20462. * @param a The first submesh
  20463. * @param b The second submesh
  20464. * @returns The result of the comparison
  20465. */
  20466. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20467. /**
  20468. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20469. * are rendered back to front.
  20470. *
  20471. * @param a The first submesh
  20472. * @param b The second submesh
  20473. * @returns The result of the comparison
  20474. */
  20475. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20476. /**
  20477. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20478. * are rendered front to back (prevent overdraw).
  20479. *
  20480. * @param a The first submesh
  20481. * @param b The second submesh
  20482. * @returns The result of the comparison
  20483. */
  20484. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20485. /**
  20486. * Resets the different lists of submeshes to prepare a new frame.
  20487. */
  20488. prepare(): void;
  20489. dispose(): void;
  20490. /**
  20491. * Inserts the submesh in its correct queue depending on its material.
  20492. * @param subMesh The submesh to dispatch
  20493. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20494. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20495. */
  20496. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20497. dispatchSprites(spriteManager: ISpriteManager): void;
  20498. dispatchParticles(particleSystem: IParticleSystem): void;
  20499. private _renderParticles;
  20500. private _renderSprites;
  20501. }
  20502. }
  20503. declare module "babylonjs/Rendering/renderingManager" {
  20504. import { Nullable } from "babylonjs/types";
  20505. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20506. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20507. import { SmartArray } from "babylonjs/Misc/smartArray";
  20508. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20509. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20510. import { Material } from "babylonjs/Materials/material";
  20511. import { Scene } from "babylonjs/scene";
  20512. import { Camera } from "babylonjs/Cameras/camera";
  20513. /**
  20514. * Interface describing the different options available in the rendering manager
  20515. * regarding Auto Clear between groups.
  20516. */
  20517. export interface IRenderingManagerAutoClearSetup {
  20518. /**
  20519. * Defines whether or not autoclear is enable.
  20520. */
  20521. autoClear: boolean;
  20522. /**
  20523. * Defines whether or not to autoclear the depth buffer.
  20524. */
  20525. depth: boolean;
  20526. /**
  20527. * Defines whether or not to autoclear the stencil buffer.
  20528. */
  20529. stencil: boolean;
  20530. }
  20531. /**
  20532. * This class is used by the onRenderingGroupObservable
  20533. */
  20534. export class RenderingGroupInfo {
  20535. /**
  20536. * The Scene that being rendered
  20537. */
  20538. scene: Scene;
  20539. /**
  20540. * The camera currently used for the rendering pass
  20541. */
  20542. camera: Nullable<Camera>;
  20543. /**
  20544. * The ID of the renderingGroup being processed
  20545. */
  20546. renderingGroupId: number;
  20547. }
  20548. /**
  20549. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20550. * It is enable to manage the different groups as well as the different necessary sort functions.
  20551. * This should not be used directly aside of the few static configurations
  20552. */
  20553. export class RenderingManager {
  20554. /**
  20555. * The max id used for rendering groups (not included)
  20556. */
  20557. static MAX_RENDERINGGROUPS: number;
  20558. /**
  20559. * The min id used for rendering groups (included)
  20560. */
  20561. static MIN_RENDERINGGROUPS: number;
  20562. /**
  20563. * Used to globally prevent autoclearing scenes.
  20564. */
  20565. static AUTOCLEAR: boolean;
  20566. /**
  20567. * @hidden
  20568. */
  20569. _useSceneAutoClearSetup: boolean;
  20570. private _scene;
  20571. private _renderingGroups;
  20572. private _depthStencilBufferAlreadyCleaned;
  20573. private _autoClearDepthStencil;
  20574. private _customOpaqueSortCompareFn;
  20575. private _customAlphaTestSortCompareFn;
  20576. private _customTransparentSortCompareFn;
  20577. private _renderingGroupInfo;
  20578. /**
  20579. * Instantiates a new rendering group for a particular scene
  20580. * @param scene Defines the scene the groups belongs to
  20581. */
  20582. constructor(scene: Scene);
  20583. private _clearDepthStencilBuffer;
  20584. /**
  20585. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20586. * @hidden
  20587. */
  20588. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20589. /**
  20590. * Resets the different information of the group to prepare a new frame
  20591. * @hidden
  20592. */
  20593. reset(): void;
  20594. /**
  20595. * Dispose and release the group and its associated resources.
  20596. * @hidden
  20597. */
  20598. dispose(): void;
  20599. /**
  20600. * Clear the info related to rendering groups preventing retention points during dispose.
  20601. */
  20602. freeRenderingGroups(): void;
  20603. private _prepareRenderingGroup;
  20604. /**
  20605. * Add a sprite manager to the rendering manager in order to render it this frame.
  20606. * @param spriteManager Define the sprite manager to render
  20607. */
  20608. dispatchSprites(spriteManager: ISpriteManager): void;
  20609. /**
  20610. * Add a particle system to the rendering manager in order to render it this frame.
  20611. * @param particleSystem Define the particle system to render
  20612. */
  20613. dispatchParticles(particleSystem: IParticleSystem): void;
  20614. /**
  20615. * Add a submesh to the manager in order to render it this frame
  20616. * @param subMesh The submesh to dispatch
  20617. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20618. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20619. */
  20620. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20621. /**
  20622. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20623. * This allowed control for front to back rendering or reversly depending of the special needs.
  20624. *
  20625. * @param renderingGroupId The rendering group id corresponding to its index
  20626. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20627. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20628. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20629. */
  20630. 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;
  20631. /**
  20632. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20633. *
  20634. * @param renderingGroupId The rendering group id corresponding to its index
  20635. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20636. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20637. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20638. */
  20639. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20640. /**
  20641. * Gets the current auto clear configuration for one rendering group of the rendering
  20642. * manager.
  20643. * @param index the rendering group index to get the information for
  20644. * @returns The auto clear setup for the requested rendering group
  20645. */
  20646. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20647. }
  20648. }
  20649. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20650. import { Observable } from "babylonjs/Misc/observable";
  20651. import { SmartArray } from "babylonjs/Misc/smartArray";
  20652. import { Nullable } from "babylonjs/types";
  20653. import { Camera } from "babylonjs/Cameras/camera";
  20654. import { Scene } from "babylonjs/scene";
  20655. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20656. import { Color4 } from "babylonjs/Maths/math.color";
  20657. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20658. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20659. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20660. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20661. import { Texture } from "babylonjs/Materials/Textures/texture";
  20662. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20663. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20664. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20665. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20666. import { Engine } from "babylonjs/Engines/engine";
  20667. /**
  20668. * This Helps creating a texture that will be created from a camera in your scene.
  20669. * It is basically a dynamic texture that could be used to create special effects for instance.
  20670. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20671. */
  20672. export class RenderTargetTexture extends Texture {
  20673. isCube: boolean;
  20674. /**
  20675. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20676. */
  20677. static readonly REFRESHRATE_RENDER_ONCE: number;
  20678. /**
  20679. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20680. */
  20681. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20682. /**
  20683. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20684. * the central point of your effect and can save a lot of performances.
  20685. */
  20686. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20687. /**
  20688. * Use this predicate to dynamically define the list of mesh you want to render.
  20689. * If set, the renderList property will be overwritten.
  20690. */
  20691. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20692. private _renderList;
  20693. /**
  20694. * Use this list to define the list of mesh you want to render.
  20695. */
  20696. renderList: Nullable<Array<AbstractMesh>>;
  20697. private _hookArray;
  20698. /**
  20699. * Define if particles should be rendered in your texture.
  20700. */
  20701. renderParticles: boolean;
  20702. /**
  20703. * Define if sprites should be rendered in your texture.
  20704. */
  20705. renderSprites: boolean;
  20706. /**
  20707. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20708. */
  20709. coordinatesMode: number;
  20710. /**
  20711. * Define the camera used to render the texture.
  20712. */
  20713. activeCamera: Nullable<Camera>;
  20714. /**
  20715. * Override the render function of the texture with your own one.
  20716. */
  20717. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20718. /**
  20719. * Define if camera post processes should be use while rendering the texture.
  20720. */
  20721. useCameraPostProcesses: boolean;
  20722. /**
  20723. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20724. */
  20725. ignoreCameraViewport: boolean;
  20726. private _postProcessManager;
  20727. private _postProcesses;
  20728. private _resizeObserver;
  20729. /**
  20730. * An event triggered when the texture is unbind.
  20731. */
  20732. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20733. /**
  20734. * An event triggered when the texture is unbind.
  20735. */
  20736. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20737. private _onAfterUnbindObserver;
  20738. /**
  20739. * Set a after unbind callback in the texture.
  20740. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20741. */
  20742. onAfterUnbind: () => void;
  20743. /**
  20744. * An event triggered before rendering the texture
  20745. */
  20746. onBeforeRenderObservable: Observable<number>;
  20747. private _onBeforeRenderObserver;
  20748. /**
  20749. * Set a before render callback in the texture.
  20750. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20751. */
  20752. onBeforeRender: (faceIndex: number) => void;
  20753. /**
  20754. * An event triggered after rendering the texture
  20755. */
  20756. onAfterRenderObservable: Observable<number>;
  20757. private _onAfterRenderObserver;
  20758. /**
  20759. * Set a after render callback in the texture.
  20760. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20761. */
  20762. onAfterRender: (faceIndex: number) => void;
  20763. /**
  20764. * An event triggered after the texture clear
  20765. */
  20766. onClearObservable: Observable<Engine>;
  20767. private _onClearObserver;
  20768. /**
  20769. * Set a clear callback in the texture.
  20770. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20771. */
  20772. onClear: (Engine: Engine) => void;
  20773. /**
  20774. * An event triggered when the texture is resized.
  20775. */
  20776. onResizeObservable: Observable<RenderTargetTexture>;
  20777. /**
  20778. * Define the clear color of the Render Target if it should be different from the scene.
  20779. */
  20780. clearColor: Color4;
  20781. protected _size: number | {
  20782. width: number;
  20783. height: number;
  20784. };
  20785. protected _initialSizeParameter: number | {
  20786. width: number;
  20787. height: number;
  20788. } | {
  20789. ratio: number;
  20790. };
  20791. protected _sizeRatio: Nullable<number>;
  20792. /** @hidden */
  20793. _generateMipMaps: boolean;
  20794. protected _renderingManager: RenderingManager;
  20795. /** @hidden */
  20796. _waitingRenderList: string[];
  20797. protected _doNotChangeAspectRatio: boolean;
  20798. protected _currentRefreshId: number;
  20799. protected _refreshRate: number;
  20800. protected _textureMatrix: Matrix;
  20801. protected _samples: number;
  20802. protected _renderTargetOptions: RenderTargetCreationOptions;
  20803. /**
  20804. * Gets render target creation options that were used.
  20805. */
  20806. readonly renderTargetOptions: RenderTargetCreationOptions;
  20807. protected _engine: Engine;
  20808. protected _onRatioRescale(): void;
  20809. /**
  20810. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20811. * It must define where the camera used to render the texture is set
  20812. */
  20813. boundingBoxPosition: Vector3;
  20814. private _boundingBoxSize;
  20815. /**
  20816. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20817. * When defined, the cubemap will switch to local mode
  20818. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20819. * @example https://www.babylonjs-playground.com/#RNASML
  20820. */
  20821. boundingBoxSize: Vector3;
  20822. /**
  20823. * In case the RTT has been created with a depth texture, get the associated
  20824. * depth texture.
  20825. * Otherwise, return null.
  20826. */
  20827. depthStencilTexture: Nullable<InternalTexture>;
  20828. /**
  20829. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20830. * or used a shadow, depth texture...
  20831. * @param name The friendly name of the texture
  20832. * @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)
  20833. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20834. * @param generateMipMaps True if mip maps need to be generated after render.
  20835. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20836. * @param type The type of the buffer in the RTT (int, half float, float...)
  20837. * @param isCube True if a cube texture needs to be created
  20838. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20839. * @param generateDepthBuffer True to generate a depth buffer
  20840. * @param generateStencilBuffer True to generate a stencil buffer
  20841. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20842. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20843. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20844. */
  20845. constructor(name: string, size: number | {
  20846. width: number;
  20847. height: number;
  20848. } | {
  20849. ratio: number;
  20850. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20851. /**
  20852. * Creates a depth stencil texture.
  20853. * This is only available in WebGL 2 or with the depth texture extension available.
  20854. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20855. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20856. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20857. */
  20858. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20859. private _processSizeParameter;
  20860. /**
  20861. * Define the number of samples to use in case of MSAA.
  20862. * It defaults to one meaning no MSAA has been enabled.
  20863. */
  20864. samples: number;
  20865. /**
  20866. * Resets the refresh counter of the texture and start bak from scratch.
  20867. * Could be useful to regenerate the texture if it is setup to render only once.
  20868. */
  20869. resetRefreshCounter(): void;
  20870. /**
  20871. * Define the refresh rate of the texture or the rendering frequency.
  20872. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20873. */
  20874. refreshRate: number;
  20875. /**
  20876. * Adds a post process to the render target rendering passes.
  20877. * @param postProcess define the post process to add
  20878. */
  20879. addPostProcess(postProcess: PostProcess): void;
  20880. /**
  20881. * Clear all the post processes attached to the render target
  20882. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20883. */
  20884. clearPostProcesses(dispose?: boolean): void;
  20885. /**
  20886. * Remove one of the post process from the list of attached post processes to the texture
  20887. * @param postProcess define the post process to remove from the list
  20888. */
  20889. removePostProcess(postProcess: PostProcess): void;
  20890. /** @hidden */
  20891. _shouldRender(): boolean;
  20892. /**
  20893. * Gets the actual render size of the texture.
  20894. * @returns the width of the render size
  20895. */
  20896. getRenderSize(): number;
  20897. /**
  20898. * Gets the actual render width of the texture.
  20899. * @returns the width of the render size
  20900. */
  20901. getRenderWidth(): number;
  20902. /**
  20903. * Gets the actual render height of the texture.
  20904. * @returns the height of the render size
  20905. */
  20906. getRenderHeight(): number;
  20907. /**
  20908. * Get if the texture can be rescaled or not.
  20909. */
  20910. readonly canRescale: boolean;
  20911. /**
  20912. * Resize the texture using a ratio.
  20913. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20914. */
  20915. scale(ratio: number): void;
  20916. /**
  20917. * Get the texture reflection matrix used to rotate/transform the reflection.
  20918. * @returns the reflection matrix
  20919. */
  20920. getReflectionTextureMatrix(): Matrix;
  20921. /**
  20922. * Resize the texture to a new desired size.
  20923. * Be carrefull as it will recreate all the data in the new texture.
  20924. * @param size Define the new size. It can be:
  20925. * - a number for squared texture,
  20926. * - an object containing { width: number, height: number }
  20927. * - or an object containing a ratio { ratio: number }
  20928. */
  20929. resize(size: number | {
  20930. width: number;
  20931. height: number;
  20932. } | {
  20933. ratio: number;
  20934. }): void;
  20935. /**
  20936. * Renders all the objects from the render list into the texture.
  20937. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20938. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20939. */
  20940. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20941. private _bestReflectionRenderTargetDimension;
  20942. /**
  20943. * @hidden
  20944. * @param faceIndex face index to bind to if this is a cubetexture
  20945. */
  20946. _bindFrameBuffer(faceIndex?: number): void;
  20947. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20948. private renderToTarget;
  20949. /**
  20950. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20951. * This allowed control for front to back rendering or reversly depending of the special needs.
  20952. *
  20953. * @param renderingGroupId The rendering group id corresponding to its index
  20954. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20955. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20956. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20957. */
  20958. 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;
  20959. /**
  20960. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20961. *
  20962. * @param renderingGroupId The rendering group id corresponding to its index
  20963. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20964. */
  20965. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20966. /**
  20967. * Clones the texture.
  20968. * @returns the cloned texture
  20969. */
  20970. clone(): RenderTargetTexture;
  20971. /**
  20972. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20973. * @returns The JSON representation of the texture
  20974. */
  20975. serialize(): any;
  20976. /**
  20977. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20978. */
  20979. disposeFramebufferObjects(): void;
  20980. /**
  20981. * Dispose the texture and release its associated resources.
  20982. */
  20983. dispose(): void;
  20984. /** @hidden */
  20985. _rebuild(): void;
  20986. /**
  20987. * Clear the info related to rendering groups preventing retention point in material dispose.
  20988. */
  20989. freeRenderingGroups(): void;
  20990. /**
  20991. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20992. * @returns the view count
  20993. */
  20994. getViewCount(): number;
  20995. }
  20996. }
  20997. declare module "babylonjs/Materials/material" {
  20998. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20999. import { SmartArray } from "babylonjs/Misc/smartArray";
  21000. import { Observable } from "babylonjs/Misc/observable";
  21001. import { Nullable } from "babylonjs/types";
  21002. import { Scene } from "babylonjs/scene";
  21003. import { Matrix } from "babylonjs/Maths/math.vector";
  21004. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21005. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21006. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21007. import { Effect } from "babylonjs/Materials/effect";
  21008. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21009. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21010. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21011. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21012. import { Mesh } from "babylonjs/Meshes/mesh";
  21013. import { Animation } from "babylonjs/Animations/animation";
  21014. /**
  21015. * Options for compiling materials.
  21016. */
  21017. export interface IMaterialCompilationOptions {
  21018. /**
  21019. * Defines whether clip planes are enabled.
  21020. */
  21021. clipPlane: boolean;
  21022. /**
  21023. * Defines whether instances are enabled.
  21024. */
  21025. useInstances: boolean;
  21026. }
  21027. /**
  21028. * Base class for the main features of a material in Babylon.js
  21029. */
  21030. export class Material implements IAnimatable {
  21031. /**
  21032. * Returns the triangle fill mode
  21033. */
  21034. static readonly TriangleFillMode: number;
  21035. /**
  21036. * Returns the wireframe mode
  21037. */
  21038. static readonly WireFrameFillMode: number;
  21039. /**
  21040. * Returns the point fill mode
  21041. */
  21042. static readonly PointFillMode: number;
  21043. /**
  21044. * Returns the point list draw mode
  21045. */
  21046. static readonly PointListDrawMode: number;
  21047. /**
  21048. * Returns the line list draw mode
  21049. */
  21050. static readonly LineListDrawMode: number;
  21051. /**
  21052. * Returns the line loop draw mode
  21053. */
  21054. static readonly LineLoopDrawMode: number;
  21055. /**
  21056. * Returns the line strip draw mode
  21057. */
  21058. static readonly LineStripDrawMode: number;
  21059. /**
  21060. * Returns the triangle strip draw mode
  21061. */
  21062. static readonly TriangleStripDrawMode: number;
  21063. /**
  21064. * Returns the triangle fan draw mode
  21065. */
  21066. static readonly TriangleFanDrawMode: number;
  21067. /**
  21068. * Stores the clock-wise side orientation
  21069. */
  21070. static readonly ClockWiseSideOrientation: number;
  21071. /**
  21072. * Stores the counter clock-wise side orientation
  21073. */
  21074. static readonly CounterClockWiseSideOrientation: number;
  21075. /**
  21076. * The dirty texture flag value
  21077. */
  21078. static readonly TextureDirtyFlag: number;
  21079. /**
  21080. * The dirty light flag value
  21081. */
  21082. static readonly LightDirtyFlag: number;
  21083. /**
  21084. * The dirty fresnel flag value
  21085. */
  21086. static readonly FresnelDirtyFlag: number;
  21087. /**
  21088. * The dirty attribute flag value
  21089. */
  21090. static readonly AttributesDirtyFlag: number;
  21091. /**
  21092. * The dirty misc flag value
  21093. */
  21094. static readonly MiscDirtyFlag: number;
  21095. /**
  21096. * The all dirty flag value
  21097. */
  21098. static readonly AllDirtyFlag: number;
  21099. /**
  21100. * The ID of the material
  21101. */
  21102. id: string;
  21103. /**
  21104. * Gets or sets the unique id of the material
  21105. */
  21106. uniqueId: number;
  21107. /**
  21108. * The name of the material
  21109. */
  21110. name: string;
  21111. /**
  21112. * Gets or sets user defined metadata
  21113. */
  21114. metadata: any;
  21115. /**
  21116. * For internal use only. Please do not use.
  21117. */
  21118. reservedDataStore: any;
  21119. /**
  21120. * Specifies if the ready state should be checked on each call
  21121. */
  21122. checkReadyOnEveryCall: boolean;
  21123. /**
  21124. * Specifies if the ready state should be checked once
  21125. */
  21126. checkReadyOnlyOnce: boolean;
  21127. /**
  21128. * The state of the material
  21129. */
  21130. state: string;
  21131. /**
  21132. * The alpha value of the material
  21133. */
  21134. protected _alpha: number;
  21135. /**
  21136. * List of inspectable custom properties (used by the Inspector)
  21137. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21138. */
  21139. inspectableCustomProperties: IInspectable[];
  21140. /**
  21141. * Sets the alpha value of the material
  21142. */
  21143. /**
  21144. * Gets the alpha value of the material
  21145. */
  21146. alpha: number;
  21147. /**
  21148. * Specifies if back face culling is enabled
  21149. */
  21150. protected _backFaceCulling: boolean;
  21151. /**
  21152. * Sets the back-face culling state
  21153. */
  21154. /**
  21155. * Gets the back-face culling state
  21156. */
  21157. backFaceCulling: boolean;
  21158. /**
  21159. * Stores the value for side orientation
  21160. */
  21161. sideOrientation: number;
  21162. /**
  21163. * Callback triggered when the material is compiled
  21164. */
  21165. onCompiled: Nullable<(effect: Effect) => void>;
  21166. /**
  21167. * Callback triggered when an error occurs
  21168. */
  21169. onError: Nullable<(effect: Effect, errors: string) => void>;
  21170. /**
  21171. * Callback triggered to get the render target textures
  21172. */
  21173. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21174. /**
  21175. * Gets a boolean indicating that current material needs to register RTT
  21176. */
  21177. readonly hasRenderTargetTextures: boolean;
  21178. /**
  21179. * Specifies if the material should be serialized
  21180. */
  21181. doNotSerialize: boolean;
  21182. /**
  21183. * @hidden
  21184. */
  21185. _storeEffectOnSubMeshes: boolean;
  21186. /**
  21187. * Stores the animations for the material
  21188. */
  21189. animations: Nullable<Array<Animation>>;
  21190. /**
  21191. * An event triggered when the material is disposed
  21192. */
  21193. onDisposeObservable: Observable<Material>;
  21194. /**
  21195. * An observer which watches for dispose events
  21196. */
  21197. private _onDisposeObserver;
  21198. private _onUnBindObservable;
  21199. /**
  21200. * Called during a dispose event
  21201. */
  21202. onDispose: () => void;
  21203. private _onBindObservable;
  21204. /**
  21205. * An event triggered when the material is bound
  21206. */
  21207. readonly onBindObservable: Observable<AbstractMesh>;
  21208. /**
  21209. * An observer which watches for bind events
  21210. */
  21211. private _onBindObserver;
  21212. /**
  21213. * Called during a bind event
  21214. */
  21215. onBind: (Mesh: AbstractMesh) => void;
  21216. /**
  21217. * An event triggered when the material is unbound
  21218. */
  21219. readonly onUnBindObservable: Observable<Material>;
  21220. /**
  21221. * Stores the value of the alpha mode
  21222. */
  21223. private _alphaMode;
  21224. /**
  21225. * Sets the value of the alpha mode.
  21226. *
  21227. * | Value | Type | Description |
  21228. * | --- | --- | --- |
  21229. * | 0 | ALPHA_DISABLE | |
  21230. * | 1 | ALPHA_ADD | |
  21231. * | 2 | ALPHA_COMBINE | |
  21232. * | 3 | ALPHA_SUBTRACT | |
  21233. * | 4 | ALPHA_MULTIPLY | |
  21234. * | 5 | ALPHA_MAXIMIZED | |
  21235. * | 6 | ALPHA_ONEONE | |
  21236. * | 7 | ALPHA_PREMULTIPLIED | |
  21237. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21238. * | 9 | ALPHA_INTERPOLATE | |
  21239. * | 10 | ALPHA_SCREENMODE | |
  21240. *
  21241. */
  21242. /**
  21243. * Gets the value of the alpha mode
  21244. */
  21245. alphaMode: number;
  21246. /**
  21247. * Stores the state of the need depth pre-pass value
  21248. */
  21249. private _needDepthPrePass;
  21250. /**
  21251. * Sets the need depth pre-pass value
  21252. */
  21253. /**
  21254. * Gets the depth pre-pass value
  21255. */
  21256. needDepthPrePass: boolean;
  21257. /**
  21258. * Specifies if depth writing should be disabled
  21259. */
  21260. disableDepthWrite: boolean;
  21261. /**
  21262. * Specifies if depth writing should be forced
  21263. */
  21264. forceDepthWrite: boolean;
  21265. /**
  21266. * Specifies the depth function that should be used. 0 means the default engine function
  21267. */
  21268. depthFunction: number;
  21269. /**
  21270. * Specifies if there should be a separate pass for culling
  21271. */
  21272. separateCullingPass: boolean;
  21273. /**
  21274. * Stores the state specifing if fog should be enabled
  21275. */
  21276. private _fogEnabled;
  21277. /**
  21278. * Sets the state for enabling fog
  21279. */
  21280. /**
  21281. * Gets the value of the fog enabled state
  21282. */
  21283. fogEnabled: boolean;
  21284. /**
  21285. * Stores the size of points
  21286. */
  21287. pointSize: number;
  21288. /**
  21289. * Stores the z offset value
  21290. */
  21291. zOffset: number;
  21292. /**
  21293. * Gets a value specifying if wireframe mode is enabled
  21294. */
  21295. /**
  21296. * Sets the state of wireframe mode
  21297. */
  21298. wireframe: boolean;
  21299. /**
  21300. * Gets the value specifying if point clouds are enabled
  21301. */
  21302. /**
  21303. * Sets the state of point cloud mode
  21304. */
  21305. pointsCloud: boolean;
  21306. /**
  21307. * Gets the material fill mode
  21308. */
  21309. /**
  21310. * Sets the material fill mode
  21311. */
  21312. fillMode: number;
  21313. /**
  21314. * @hidden
  21315. * Stores the effects for the material
  21316. */
  21317. _effect: Nullable<Effect>;
  21318. /**
  21319. * @hidden
  21320. * Specifies if the material was previously ready
  21321. */
  21322. _wasPreviouslyReady: boolean;
  21323. /**
  21324. * Specifies if uniform buffers should be used
  21325. */
  21326. private _useUBO;
  21327. /**
  21328. * Stores a reference to the scene
  21329. */
  21330. private _scene;
  21331. /**
  21332. * Stores the fill mode state
  21333. */
  21334. private _fillMode;
  21335. /**
  21336. * Specifies if the depth write state should be cached
  21337. */
  21338. private _cachedDepthWriteState;
  21339. /**
  21340. * Specifies if the depth function state should be cached
  21341. */
  21342. private _cachedDepthFunctionState;
  21343. /**
  21344. * Stores the uniform buffer
  21345. */
  21346. protected _uniformBuffer: UniformBuffer;
  21347. /** @hidden */
  21348. _indexInSceneMaterialArray: number;
  21349. /** @hidden */
  21350. meshMap: Nullable<{
  21351. [id: string]: AbstractMesh | undefined;
  21352. }>;
  21353. /**
  21354. * Creates a material instance
  21355. * @param name defines the name of the material
  21356. * @param scene defines the scene to reference
  21357. * @param doNotAdd specifies if the material should be added to the scene
  21358. */
  21359. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21360. /**
  21361. * Returns a string representation of the current material
  21362. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21363. * @returns a string with material information
  21364. */
  21365. toString(fullDetails?: boolean): string;
  21366. /**
  21367. * Gets the class name of the material
  21368. * @returns a string with the class name of the material
  21369. */
  21370. getClassName(): string;
  21371. /**
  21372. * Specifies if updates for the material been locked
  21373. */
  21374. readonly isFrozen: boolean;
  21375. /**
  21376. * Locks updates for the material
  21377. */
  21378. freeze(): void;
  21379. /**
  21380. * Unlocks updates for the material
  21381. */
  21382. unfreeze(): void;
  21383. /**
  21384. * Specifies if the material is ready to be used
  21385. * @param mesh defines the mesh to check
  21386. * @param useInstances specifies if instances should be used
  21387. * @returns a boolean indicating if the material is ready to be used
  21388. */
  21389. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21390. /**
  21391. * Specifies that the submesh is ready to be used
  21392. * @param mesh defines the mesh to check
  21393. * @param subMesh defines which submesh to check
  21394. * @param useInstances specifies that instances should be used
  21395. * @returns a boolean indicating that the submesh is ready or not
  21396. */
  21397. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21398. /**
  21399. * Returns the material effect
  21400. * @returns the effect associated with the material
  21401. */
  21402. getEffect(): Nullable<Effect>;
  21403. /**
  21404. * Returns the current scene
  21405. * @returns a Scene
  21406. */
  21407. getScene(): Scene;
  21408. /**
  21409. * Specifies if the material will require alpha blending
  21410. * @returns a boolean specifying if alpha blending is needed
  21411. */
  21412. needAlphaBlending(): boolean;
  21413. /**
  21414. * Specifies if the mesh will require alpha blending
  21415. * @param mesh defines the mesh to check
  21416. * @returns a boolean specifying if alpha blending is needed for the mesh
  21417. */
  21418. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21419. /**
  21420. * Specifies if this material should be rendered in alpha test mode
  21421. * @returns a boolean specifying if an alpha test is needed.
  21422. */
  21423. needAlphaTesting(): boolean;
  21424. /**
  21425. * Gets the texture used for the alpha test
  21426. * @returns the texture to use for alpha testing
  21427. */
  21428. getAlphaTestTexture(): Nullable<BaseTexture>;
  21429. /**
  21430. * Marks the material to indicate that it needs to be re-calculated
  21431. */
  21432. markDirty(): void;
  21433. /** @hidden */
  21434. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21435. /**
  21436. * Binds the material to the mesh
  21437. * @param world defines the world transformation matrix
  21438. * @param mesh defines the mesh to bind the material to
  21439. */
  21440. bind(world: Matrix, mesh?: Mesh): void;
  21441. /**
  21442. * Binds the submesh to the material
  21443. * @param world defines the world transformation matrix
  21444. * @param mesh defines the mesh containing the submesh
  21445. * @param subMesh defines the submesh to bind the material to
  21446. */
  21447. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21448. /**
  21449. * Binds the world matrix to the material
  21450. * @param world defines the world transformation matrix
  21451. */
  21452. bindOnlyWorldMatrix(world: Matrix): void;
  21453. /**
  21454. * Binds the scene's uniform buffer to the effect.
  21455. * @param effect defines the effect to bind to the scene uniform buffer
  21456. * @param sceneUbo defines the uniform buffer storing scene data
  21457. */
  21458. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21459. /**
  21460. * Binds the view matrix to the effect
  21461. * @param effect defines the effect to bind the view matrix to
  21462. */
  21463. bindView(effect: Effect): void;
  21464. /**
  21465. * Binds the view projection matrix to the effect
  21466. * @param effect defines the effect to bind the view projection matrix to
  21467. */
  21468. bindViewProjection(effect: Effect): void;
  21469. /**
  21470. * Specifies if material alpha testing should be turned on for the mesh
  21471. * @param mesh defines the mesh to check
  21472. */
  21473. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21474. /**
  21475. * Processes to execute after binding the material to a mesh
  21476. * @param mesh defines the rendered mesh
  21477. */
  21478. protected _afterBind(mesh?: Mesh): void;
  21479. /**
  21480. * Unbinds the material from the mesh
  21481. */
  21482. unbind(): void;
  21483. /**
  21484. * Gets the active textures from the material
  21485. * @returns an array of textures
  21486. */
  21487. getActiveTextures(): BaseTexture[];
  21488. /**
  21489. * Specifies if the material uses a texture
  21490. * @param texture defines the texture to check against the material
  21491. * @returns a boolean specifying if the material uses the texture
  21492. */
  21493. hasTexture(texture: BaseTexture): boolean;
  21494. /**
  21495. * Makes a duplicate of the material, and gives it a new name
  21496. * @param name defines the new name for the duplicated material
  21497. * @returns the cloned material
  21498. */
  21499. clone(name: string): Nullable<Material>;
  21500. /**
  21501. * Gets the meshes bound to the material
  21502. * @returns an array of meshes bound to the material
  21503. */
  21504. getBindedMeshes(): AbstractMesh[];
  21505. /**
  21506. * Force shader compilation
  21507. * @param mesh defines the mesh associated with this material
  21508. * @param onCompiled defines a function to execute once the material is compiled
  21509. * @param options defines the options to configure the compilation
  21510. * @param onError defines a function to execute if the material fails compiling
  21511. */
  21512. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21513. /**
  21514. * Force shader compilation
  21515. * @param mesh defines the mesh that will use this material
  21516. * @param options defines additional options for compiling the shaders
  21517. * @returns a promise that resolves when the compilation completes
  21518. */
  21519. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21520. private static readonly _AllDirtyCallBack;
  21521. private static readonly _ImageProcessingDirtyCallBack;
  21522. private static readonly _TextureDirtyCallBack;
  21523. private static readonly _FresnelDirtyCallBack;
  21524. private static readonly _MiscDirtyCallBack;
  21525. private static readonly _LightsDirtyCallBack;
  21526. private static readonly _AttributeDirtyCallBack;
  21527. private static _FresnelAndMiscDirtyCallBack;
  21528. private static _TextureAndMiscDirtyCallBack;
  21529. private static readonly _DirtyCallbackArray;
  21530. private static readonly _RunDirtyCallBacks;
  21531. /**
  21532. * Marks a define in the material to indicate that it needs to be re-computed
  21533. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21534. */
  21535. markAsDirty(flag: number): void;
  21536. /**
  21537. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21538. * @param func defines a function which checks material defines against the submeshes
  21539. */
  21540. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21541. /**
  21542. * Indicates that we need to re-calculated for all submeshes
  21543. */
  21544. protected _markAllSubMeshesAsAllDirty(): void;
  21545. /**
  21546. * Indicates that image processing needs to be re-calculated for all submeshes
  21547. */
  21548. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21549. /**
  21550. * Indicates that textures need to be re-calculated for all submeshes
  21551. */
  21552. protected _markAllSubMeshesAsTexturesDirty(): void;
  21553. /**
  21554. * Indicates that fresnel needs to be re-calculated for all submeshes
  21555. */
  21556. protected _markAllSubMeshesAsFresnelDirty(): void;
  21557. /**
  21558. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21559. */
  21560. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21561. /**
  21562. * Indicates that lights need to be re-calculated for all submeshes
  21563. */
  21564. protected _markAllSubMeshesAsLightsDirty(): void;
  21565. /**
  21566. * Indicates that attributes need to be re-calculated for all submeshes
  21567. */
  21568. protected _markAllSubMeshesAsAttributesDirty(): void;
  21569. /**
  21570. * Indicates that misc needs to be re-calculated for all submeshes
  21571. */
  21572. protected _markAllSubMeshesAsMiscDirty(): void;
  21573. /**
  21574. * Indicates that textures and misc need to be re-calculated for all submeshes
  21575. */
  21576. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21577. /**
  21578. * Disposes the material
  21579. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21580. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21581. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21582. */
  21583. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21584. /** @hidden */
  21585. private releaseVertexArrayObject;
  21586. /**
  21587. * Serializes this material
  21588. * @returns the serialized material object
  21589. */
  21590. serialize(): any;
  21591. /**
  21592. * Creates a material from parsed material data
  21593. * @param parsedMaterial defines parsed material data
  21594. * @param scene defines the hosting scene
  21595. * @param rootUrl defines the root URL to use to load textures
  21596. * @returns a new material
  21597. */
  21598. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21599. }
  21600. }
  21601. declare module "babylonjs/Materials/multiMaterial" {
  21602. import { Nullable } from "babylonjs/types";
  21603. import { Scene } from "babylonjs/scene";
  21604. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21605. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21606. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21607. import { Material } from "babylonjs/Materials/material";
  21608. /**
  21609. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21610. * separate meshes. This can be use to improve performances.
  21611. * @see http://doc.babylonjs.com/how_to/multi_materials
  21612. */
  21613. export class MultiMaterial extends Material {
  21614. private _subMaterials;
  21615. /**
  21616. * Gets or Sets the list of Materials used within the multi material.
  21617. * They need to be ordered according to the submeshes order in the associated mesh
  21618. */
  21619. subMaterials: Nullable<Material>[];
  21620. /**
  21621. * Function used to align with Node.getChildren()
  21622. * @returns the list of Materials used within the multi material
  21623. */
  21624. getChildren(): Nullable<Material>[];
  21625. /**
  21626. * Instantiates a new Multi Material
  21627. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21628. * separate meshes. This can be use to improve performances.
  21629. * @see http://doc.babylonjs.com/how_to/multi_materials
  21630. * @param name Define the name in the scene
  21631. * @param scene Define the scene the material belongs to
  21632. */
  21633. constructor(name: string, scene: Scene);
  21634. private _hookArray;
  21635. /**
  21636. * Get one of the submaterial by its index in the submaterials array
  21637. * @param index The index to look the sub material at
  21638. * @returns The Material if the index has been defined
  21639. */
  21640. getSubMaterial(index: number): Nullable<Material>;
  21641. /**
  21642. * Get the list of active textures for the whole sub materials list.
  21643. * @returns All the textures that will be used during the rendering
  21644. */
  21645. getActiveTextures(): BaseTexture[];
  21646. /**
  21647. * Gets the current class name of the material e.g. "MultiMaterial"
  21648. * Mainly use in serialization.
  21649. * @returns the class name
  21650. */
  21651. getClassName(): string;
  21652. /**
  21653. * Checks if the material is ready to render the requested sub mesh
  21654. * @param mesh Define the mesh the submesh belongs to
  21655. * @param subMesh Define the sub mesh to look readyness for
  21656. * @param useInstances Define whether or not the material is used with instances
  21657. * @returns true if ready, otherwise false
  21658. */
  21659. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21660. /**
  21661. * Clones the current material and its related sub materials
  21662. * @param name Define the name of the newly cloned material
  21663. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21664. * @returns the cloned material
  21665. */
  21666. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21667. /**
  21668. * Serializes the materials into a JSON representation.
  21669. * @returns the JSON representation
  21670. */
  21671. serialize(): any;
  21672. /**
  21673. * Dispose the material and release its associated resources
  21674. * @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)
  21675. * @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)
  21676. * @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)
  21677. */
  21678. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21679. /**
  21680. * Creates a MultiMaterial from parsed MultiMaterial data.
  21681. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21682. * @param scene defines the hosting scene
  21683. * @returns a new MultiMaterial
  21684. */
  21685. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21686. }
  21687. }
  21688. declare module "babylonjs/Meshes/subMesh" {
  21689. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21690. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21691. import { Engine } from "babylonjs/Engines/engine";
  21692. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21693. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21694. import { Effect } from "babylonjs/Materials/effect";
  21695. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21696. import { Plane } from "babylonjs/Maths/math.plane";
  21697. import { Collider } from "babylonjs/Collisions/collider";
  21698. import { Material } from "babylonjs/Materials/material";
  21699. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21700. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21701. import { Mesh } from "babylonjs/Meshes/mesh";
  21702. import { Ray } from "babylonjs/Culling/ray";
  21703. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21704. /**
  21705. * Base class for submeshes
  21706. */
  21707. export class BaseSubMesh {
  21708. /** @hidden */
  21709. _materialDefines: Nullable<MaterialDefines>;
  21710. /** @hidden */
  21711. _materialEffect: Nullable<Effect>;
  21712. /**
  21713. * Gets material defines used by the effect associated to the sub mesh
  21714. */
  21715. /**
  21716. * Sets material defines used by the effect associated to the sub mesh
  21717. */
  21718. materialDefines: Nullable<MaterialDefines>;
  21719. /**
  21720. * Gets associated effect
  21721. */
  21722. readonly effect: Nullable<Effect>;
  21723. /**
  21724. * Sets associated effect (effect used to render this submesh)
  21725. * @param effect defines the effect to associate with
  21726. * @param defines defines the set of defines used to compile this effect
  21727. */
  21728. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21729. }
  21730. /**
  21731. * Defines a subdivision inside a mesh
  21732. */
  21733. export class SubMesh extends BaseSubMesh implements ICullable {
  21734. /** the material index to use */
  21735. materialIndex: number;
  21736. /** vertex index start */
  21737. verticesStart: number;
  21738. /** vertices count */
  21739. verticesCount: number;
  21740. /** index start */
  21741. indexStart: number;
  21742. /** indices count */
  21743. indexCount: number;
  21744. /** @hidden */
  21745. _linesIndexCount: number;
  21746. private _mesh;
  21747. private _renderingMesh;
  21748. private _boundingInfo;
  21749. private _linesIndexBuffer;
  21750. /** @hidden */
  21751. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21752. /** @hidden */
  21753. _trianglePlanes: Plane[];
  21754. /** @hidden */
  21755. _lastColliderTransformMatrix: Nullable<Matrix>;
  21756. /** @hidden */
  21757. _renderId: number;
  21758. /** @hidden */
  21759. _alphaIndex: number;
  21760. /** @hidden */
  21761. _distanceToCamera: number;
  21762. /** @hidden */
  21763. _id: number;
  21764. private _currentMaterial;
  21765. /**
  21766. * Add a new submesh to a mesh
  21767. * @param materialIndex defines the material index to use
  21768. * @param verticesStart defines vertex index start
  21769. * @param verticesCount defines vertices count
  21770. * @param indexStart defines index start
  21771. * @param indexCount defines indices count
  21772. * @param mesh defines the parent mesh
  21773. * @param renderingMesh defines an optional rendering mesh
  21774. * @param createBoundingBox defines if bounding box should be created for this submesh
  21775. * @returns the new submesh
  21776. */
  21777. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21778. /**
  21779. * Creates a new submesh
  21780. * @param materialIndex defines the material index to use
  21781. * @param verticesStart defines vertex index start
  21782. * @param verticesCount defines vertices count
  21783. * @param indexStart defines index start
  21784. * @param indexCount defines indices count
  21785. * @param mesh defines the parent mesh
  21786. * @param renderingMesh defines an optional rendering mesh
  21787. * @param createBoundingBox defines if bounding box should be created for this submesh
  21788. */
  21789. constructor(
  21790. /** the material index to use */
  21791. materialIndex: number,
  21792. /** vertex index start */
  21793. verticesStart: number,
  21794. /** vertices count */
  21795. verticesCount: number,
  21796. /** index start */
  21797. indexStart: number,
  21798. /** indices count */
  21799. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21800. /**
  21801. * Returns true if this submesh covers the entire parent mesh
  21802. * @ignorenaming
  21803. */
  21804. readonly IsGlobal: boolean;
  21805. /**
  21806. * Returns the submesh BoudingInfo object
  21807. * @returns current bounding info (or mesh's one if the submesh is global)
  21808. */
  21809. getBoundingInfo(): BoundingInfo;
  21810. /**
  21811. * Sets the submesh BoundingInfo
  21812. * @param boundingInfo defines the new bounding info to use
  21813. * @returns the SubMesh
  21814. */
  21815. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21816. /**
  21817. * Returns the mesh of the current submesh
  21818. * @return the parent mesh
  21819. */
  21820. getMesh(): AbstractMesh;
  21821. /**
  21822. * Returns the rendering mesh of the submesh
  21823. * @returns the rendering mesh (could be different from parent mesh)
  21824. */
  21825. getRenderingMesh(): Mesh;
  21826. /**
  21827. * Returns the submesh material
  21828. * @returns null or the current material
  21829. */
  21830. getMaterial(): Nullable<Material>;
  21831. /**
  21832. * Sets a new updated BoundingInfo object to the submesh
  21833. * @param data defines an optional position array to use to determine the bounding info
  21834. * @returns the SubMesh
  21835. */
  21836. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21837. /** @hidden */
  21838. _checkCollision(collider: Collider): boolean;
  21839. /**
  21840. * Updates the submesh BoundingInfo
  21841. * @param world defines the world matrix to use to update the bounding info
  21842. * @returns the submesh
  21843. */
  21844. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21845. /**
  21846. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21847. * @param frustumPlanes defines the frustum planes
  21848. * @returns true if the submesh is intersecting with the frustum
  21849. */
  21850. isInFrustum(frustumPlanes: Plane[]): boolean;
  21851. /**
  21852. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21853. * @param frustumPlanes defines the frustum planes
  21854. * @returns true if the submesh is inside the frustum
  21855. */
  21856. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21857. /**
  21858. * Renders the submesh
  21859. * @param enableAlphaMode defines if alpha needs to be used
  21860. * @returns the submesh
  21861. */
  21862. render(enableAlphaMode: boolean): SubMesh;
  21863. /**
  21864. * @hidden
  21865. */
  21866. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21867. /**
  21868. * Checks if the submesh intersects with a ray
  21869. * @param ray defines the ray to test
  21870. * @returns true is the passed ray intersects the submesh bounding box
  21871. */
  21872. canIntersects(ray: Ray): boolean;
  21873. /**
  21874. * Intersects current submesh with a ray
  21875. * @param ray defines the ray to test
  21876. * @param positions defines mesh's positions array
  21877. * @param indices defines mesh's indices array
  21878. * @param fastCheck defines if only bounding info should be used
  21879. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21880. * @returns intersection info or null if no intersection
  21881. */
  21882. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21883. /** @hidden */
  21884. private _intersectLines;
  21885. /** @hidden */
  21886. private _intersectUnIndexedLines;
  21887. /** @hidden */
  21888. private _intersectTriangles;
  21889. /** @hidden */
  21890. private _intersectUnIndexedTriangles;
  21891. /** @hidden */
  21892. _rebuild(): void;
  21893. /**
  21894. * Creates a new submesh from the passed mesh
  21895. * @param newMesh defines the new hosting mesh
  21896. * @param newRenderingMesh defines an optional rendering mesh
  21897. * @returns the new submesh
  21898. */
  21899. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21900. /**
  21901. * Release associated resources
  21902. */
  21903. dispose(): void;
  21904. /**
  21905. * Gets the class name
  21906. * @returns the string "SubMesh".
  21907. */
  21908. getClassName(): string;
  21909. /**
  21910. * Creates a new submesh from indices data
  21911. * @param materialIndex the index of the main mesh material
  21912. * @param startIndex the index where to start the copy in the mesh indices array
  21913. * @param indexCount the number of indices to copy then from the startIndex
  21914. * @param mesh the main mesh to create the submesh from
  21915. * @param renderingMesh the optional rendering mesh
  21916. * @returns a new submesh
  21917. */
  21918. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21919. }
  21920. }
  21921. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21922. /**
  21923. * Class used to represent data loading progression
  21924. */
  21925. export class SceneLoaderFlags {
  21926. private static _ForceFullSceneLoadingForIncremental;
  21927. private static _ShowLoadingScreen;
  21928. private static _CleanBoneMatrixWeights;
  21929. private static _loggingLevel;
  21930. /**
  21931. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21932. */
  21933. static ForceFullSceneLoadingForIncremental: boolean;
  21934. /**
  21935. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21936. */
  21937. static ShowLoadingScreen: boolean;
  21938. /**
  21939. * Defines the current logging level (while loading the scene)
  21940. * @ignorenaming
  21941. */
  21942. static loggingLevel: number;
  21943. /**
  21944. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21945. */
  21946. static CleanBoneMatrixWeights: boolean;
  21947. }
  21948. }
  21949. declare module "babylonjs/Meshes/geometry" {
  21950. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21951. import { Scene } from "babylonjs/scene";
  21952. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21953. import { Engine } from "babylonjs/Engines/engine";
  21954. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21955. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21956. import { Effect } from "babylonjs/Materials/effect";
  21957. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21958. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21959. import { Mesh } from "babylonjs/Meshes/mesh";
  21960. /**
  21961. * Class used to store geometry data (vertex buffers + index buffer)
  21962. */
  21963. export class Geometry implements IGetSetVerticesData {
  21964. /**
  21965. * Gets or sets the ID of the geometry
  21966. */
  21967. id: string;
  21968. /**
  21969. * Gets or sets the unique ID of the geometry
  21970. */
  21971. uniqueId: number;
  21972. /**
  21973. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21974. */
  21975. delayLoadState: number;
  21976. /**
  21977. * Gets the file containing the data to load when running in delay load state
  21978. */
  21979. delayLoadingFile: Nullable<string>;
  21980. /**
  21981. * Callback called when the geometry is updated
  21982. */
  21983. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21984. private _scene;
  21985. private _engine;
  21986. private _meshes;
  21987. private _totalVertices;
  21988. /** @hidden */
  21989. _indices: IndicesArray;
  21990. /** @hidden */
  21991. _vertexBuffers: {
  21992. [key: string]: VertexBuffer;
  21993. };
  21994. private _isDisposed;
  21995. private _extend;
  21996. private _boundingBias;
  21997. /** @hidden */
  21998. _delayInfo: Array<string>;
  21999. private _indexBuffer;
  22000. private _indexBufferIsUpdatable;
  22001. /** @hidden */
  22002. _boundingInfo: Nullable<BoundingInfo>;
  22003. /** @hidden */
  22004. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22005. /** @hidden */
  22006. _softwareSkinningFrameId: number;
  22007. private _vertexArrayObjects;
  22008. private _updatable;
  22009. /** @hidden */
  22010. _positions: Nullable<Vector3[]>;
  22011. /**
  22012. * 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
  22013. */
  22014. /**
  22015. * 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
  22016. */
  22017. boundingBias: Vector2;
  22018. /**
  22019. * Static function used to attach a new empty geometry to a mesh
  22020. * @param mesh defines the mesh to attach the geometry to
  22021. * @returns the new Geometry
  22022. */
  22023. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22024. /**
  22025. * Creates a new geometry
  22026. * @param id defines the unique ID
  22027. * @param scene defines the hosting scene
  22028. * @param vertexData defines the VertexData used to get geometry data
  22029. * @param updatable defines if geometry must be updatable (false by default)
  22030. * @param mesh defines the mesh that will be associated with the geometry
  22031. */
  22032. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22033. /**
  22034. * Gets the current extend of the geometry
  22035. */
  22036. readonly extend: {
  22037. minimum: Vector3;
  22038. maximum: Vector3;
  22039. };
  22040. /**
  22041. * Gets the hosting scene
  22042. * @returns the hosting Scene
  22043. */
  22044. getScene(): Scene;
  22045. /**
  22046. * Gets the hosting engine
  22047. * @returns the hosting Engine
  22048. */
  22049. getEngine(): Engine;
  22050. /**
  22051. * Defines if the geometry is ready to use
  22052. * @returns true if the geometry is ready to be used
  22053. */
  22054. isReady(): boolean;
  22055. /**
  22056. * Gets a value indicating that the geometry should not be serialized
  22057. */
  22058. readonly doNotSerialize: boolean;
  22059. /** @hidden */
  22060. _rebuild(): void;
  22061. /**
  22062. * Affects all geometry data in one call
  22063. * @param vertexData defines the geometry data
  22064. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22065. */
  22066. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22067. /**
  22068. * Set specific vertex data
  22069. * @param kind defines the data kind (Position, normal, etc...)
  22070. * @param data defines the vertex data to use
  22071. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22072. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22073. */
  22074. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22075. /**
  22076. * Removes a specific vertex data
  22077. * @param kind defines the data kind (Position, normal, etc...)
  22078. */
  22079. removeVerticesData(kind: string): void;
  22080. /**
  22081. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22082. * @param buffer defines the vertex buffer to use
  22083. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22084. */
  22085. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22086. /**
  22087. * Update a specific vertex buffer
  22088. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22089. * It will do nothing if the buffer is not updatable
  22090. * @param kind defines the data kind (Position, normal, etc...)
  22091. * @param data defines the data to use
  22092. * @param offset defines the offset in the target buffer where to store the data
  22093. * @param useBytes set to true if the offset is in bytes
  22094. */
  22095. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22096. /**
  22097. * Update a specific vertex buffer
  22098. * This function will create a new buffer if the current one is not updatable
  22099. * @param kind defines the data kind (Position, normal, etc...)
  22100. * @param data defines the data to use
  22101. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22102. */
  22103. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22104. private _updateBoundingInfo;
  22105. /** @hidden */
  22106. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22107. /**
  22108. * Gets total number of vertices
  22109. * @returns the total number of vertices
  22110. */
  22111. getTotalVertices(): number;
  22112. /**
  22113. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22114. * @param kind defines the data kind (Position, normal, etc...)
  22115. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22116. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22117. * @returns a float array containing vertex data
  22118. */
  22119. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22120. /**
  22121. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22122. * @param kind defines the data kind (Position, normal, etc...)
  22123. * @returns true if the vertex buffer with the specified kind is updatable
  22124. */
  22125. isVertexBufferUpdatable(kind: string): boolean;
  22126. /**
  22127. * Gets a specific vertex buffer
  22128. * @param kind defines the data kind (Position, normal, etc...)
  22129. * @returns a VertexBuffer
  22130. */
  22131. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22132. /**
  22133. * Returns all vertex buffers
  22134. * @return an object holding all vertex buffers indexed by kind
  22135. */
  22136. getVertexBuffers(): Nullable<{
  22137. [key: string]: VertexBuffer;
  22138. }>;
  22139. /**
  22140. * Gets a boolean indicating if specific vertex buffer is present
  22141. * @param kind defines the data kind (Position, normal, etc...)
  22142. * @returns true if data is present
  22143. */
  22144. isVerticesDataPresent(kind: string): boolean;
  22145. /**
  22146. * Gets a list of all attached data kinds (Position, normal, etc...)
  22147. * @returns a list of string containing all kinds
  22148. */
  22149. getVerticesDataKinds(): string[];
  22150. /**
  22151. * Update index buffer
  22152. * @param indices defines the indices to store in the index buffer
  22153. * @param offset defines the offset in the target buffer where to store the data
  22154. * @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)
  22155. */
  22156. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22157. /**
  22158. * Creates a new index buffer
  22159. * @param indices defines the indices to store in the index buffer
  22160. * @param totalVertices defines the total number of vertices (could be null)
  22161. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22162. */
  22163. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22164. /**
  22165. * Return the total number of indices
  22166. * @returns the total number of indices
  22167. */
  22168. getTotalIndices(): number;
  22169. /**
  22170. * Gets the index buffer array
  22171. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22172. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22173. * @returns the index buffer array
  22174. */
  22175. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22176. /**
  22177. * Gets the index buffer
  22178. * @return the index buffer
  22179. */
  22180. getIndexBuffer(): Nullable<DataBuffer>;
  22181. /** @hidden */
  22182. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22183. /**
  22184. * Release the associated resources for a specific mesh
  22185. * @param mesh defines the source mesh
  22186. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22187. */
  22188. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22189. /**
  22190. * Apply current geometry to a given mesh
  22191. * @param mesh defines the mesh to apply geometry to
  22192. */
  22193. applyToMesh(mesh: Mesh): void;
  22194. private _updateExtend;
  22195. private _applyToMesh;
  22196. private notifyUpdate;
  22197. /**
  22198. * Load the geometry if it was flagged as delay loaded
  22199. * @param scene defines the hosting scene
  22200. * @param onLoaded defines a callback called when the geometry is loaded
  22201. */
  22202. load(scene: Scene, onLoaded?: () => void): void;
  22203. private _queueLoad;
  22204. /**
  22205. * Invert the geometry to move from a right handed system to a left handed one.
  22206. */
  22207. toLeftHanded(): void;
  22208. /** @hidden */
  22209. _resetPointsArrayCache(): void;
  22210. /** @hidden */
  22211. _generatePointsArray(): boolean;
  22212. /**
  22213. * Gets a value indicating if the geometry is disposed
  22214. * @returns true if the geometry was disposed
  22215. */
  22216. isDisposed(): boolean;
  22217. private _disposeVertexArrayObjects;
  22218. /**
  22219. * Free all associated resources
  22220. */
  22221. dispose(): void;
  22222. /**
  22223. * Clone the current geometry into a new geometry
  22224. * @param id defines the unique ID of the new geometry
  22225. * @returns a new geometry object
  22226. */
  22227. copy(id: string): Geometry;
  22228. /**
  22229. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22230. * @return a JSON representation of the current geometry data (without the vertices data)
  22231. */
  22232. serialize(): any;
  22233. private toNumberArray;
  22234. /**
  22235. * Serialize all vertices data into a JSON oject
  22236. * @returns a JSON representation of the current geometry data
  22237. */
  22238. serializeVerticeData(): any;
  22239. /**
  22240. * Extracts a clone of a mesh geometry
  22241. * @param mesh defines the source mesh
  22242. * @param id defines the unique ID of the new geometry object
  22243. * @returns the new geometry object
  22244. */
  22245. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22246. /**
  22247. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22248. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22249. * Be aware Math.random() could cause collisions, but:
  22250. * "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"
  22251. * @returns a string containing a new GUID
  22252. */
  22253. static RandomId(): string;
  22254. /** @hidden */
  22255. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22256. private static _CleanMatricesWeights;
  22257. /**
  22258. * Create a new geometry from persisted data (Using .babylon file format)
  22259. * @param parsedVertexData defines the persisted data
  22260. * @param scene defines the hosting scene
  22261. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22262. * @returns the new geometry object
  22263. */
  22264. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22265. }
  22266. }
  22267. declare module "babylonjs/Meshes/mesh.vertexData" {
  22268. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22269. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22270. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22271. import { Geometry } from "babylonjs/Meshes/geometry";
  22272. import { Mesh } from "babylonjs/Meshes/mesh";
  22273. /**
  22274. * Define an interface for all classes that will get and set the data on vertices
  22275. */
  22276. export interface IGetSetVerticesData {
  22277. /**
  22278. * Gets a boolean indicating if specific vertex data is present
  22279. * @param kind defines the vertex data kind to use
  22280. * @returns true is data kind is present
  22281. */
  22282. isVerticesDataPresent(kind: string): boolean;
  22283. /**
  22284. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22285. * @param kind defines the data kind (Position, normal, etc...)
  22286. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22287. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22288. * @returns a float array containing vertex data
  22289. */
  22290. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22291. /**
  22292. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22293. * @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.
  22294. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22295. * @returns the indices array or an empty array if the mesh has no geometry
  22296. */
  22297. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22298. /**
  22299. * Set specific vertex data
  22300. * @param kind defines the data kind (Position, normal, etc...)
  22301. * @param data defines the vertex data to use
  22302. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22303. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22304. */
  22305. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22306. /**
  22307. * Update a specific associated vertex buffer
  22308. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22309. * - VertexBuffer.PositionKind
  22310. * - VertexBuffer.UVKind
  22311. * - VertexBuffer.UV2Kind
  22312. * - VertexBuffer.UV3Kind
  22313. * - VertexBuffer.UV4Kind
  22314. * - VertexBuffer.UV5Kind
  22315. * - VertexBuffer.UV6Kind
  22316. * - VertexBuffer.ColorKind
  22317. * - VertexBuffer.MatricesIndicesKind
  22318. * - VertexBuffer.MatricesIndicesExtraKind
  22319. * - VertexBuffer.MatricesWeightsKind
  22320. * - VertexBuffer.MatricesWeightsExtraKind
  22321. * @param data defines the data source
  22322. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22323. * @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)
  22324. */
  22325. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22326. /**
  22327. * Creates a new index buffer
  22328. * @param indices defines the indices to store in the index buffer
  22329. * @param totalVertices defines the total number of vertices (could be null)
  22330. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22331. */
  22332. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22333. }
  22334. /**
  22335. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22336. */
  22337. export class VertexData {
  22338. /**
  22339. * Mesh side orientation : usually the external or front surface
  22340. */
  22341. static readonly FRONTSIDE: number;
  22342. /**
  22343. * Mesh side orientation : usually the internal or back surface
  22344. */
  22345. static readonly BACKSIDE: number;
  22346. /**
  22347. * Mesh side orientation : both internal and external or front and back surfaces
  22348. */
  22349. static readonly DOUBLESIDE: number;
  22350. /**
  22351. * Mesh side orientation : by default, `FRONTSIDE`
  22352. */
  22353. static readonly DEFAULTSIDE: number;
  22354. /**
  22355. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22356. */
  22357. positions: Nullable<FloatArray>;
  22358. /**
  22359. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22360. */
  22361. normals: Nullable<FloatArray>;
  22362. /**
  22363. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22364. */
  22365. tangents: Nullable<FloatArray>;
  22366. /**
  22367. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22368. */
  22369. uvs: Nullable<FloatArray>;
  22370. /**
  22371. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22372. */
  22373. uvs2: Nullable<FloatArray>;
  22374. /**
  22375. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22376. */
  22377. uvs3: Nullable<FloatArray>;
  22378. /**
  22379. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22380. */
  22381. uvs4: Nullable<FloatArray>;
  22382. /**
  22383. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22384. */
  22385. uvs5: Nullable<FloatArray>;
  22386. /**
  22387. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22388. */
  22389. uvs6: Nullable<FloatArray>;
  22390. /**
  22391. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22392. */
  22393. colors: Nullable<FloatArray>;
  22394. /**
  22395. * 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).
  22396. */
  22397. matricesIndices: Nullable<FloatArray>;
  22398. /**
  22399. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22400. */
  22401. matricesWeights: Nullable<FloatArray>;
  22402. /**
  22403. * An array extending the number of possible indices
  22404. */
  22405. matricesIndicesExtra: Nullable<FloatArray>;
  22406. /**
  22407. * An array extending the number of possible weights when the number of indices is extended
  22408. */
  22409. matricesWeightsExtra: Nullable<FloatArray>;
  22410. /**
  22411. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22412. */
  22413. indices: Nullable<IndicesArray>;
  22414. /**
  22415. * Uses the passed data array to set the set the values for the specified kind of data
  22416. * @param data a linear array of floating numbers
  22417. * @param kind the type of data that is being set, eg positions, colors etc
  22418. */
  22419. set(data: FloatArray, kind: string): void;
  22420. /**
  22421. * Associates the vertexData to the passed Mesh.
  22422. * Sets it as updatable or not (default `false`)
  22423. * @param mesh the mesh the vertexData is applied to
  22424. * @param updatable when used and having the value true allows new data to update the vertexData
  22425. * @returns the VertexData
  22426. */
  22427. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22428. /**
  22429. * Associates the vertexData to the passed Geometry.
  22430. * Sets it as updatable or not (default `false`)
  22431. * @param geometry the geometry the vertexData is applied to
  22432. * @param updatable when used and having the value true allows new data to update the vertexData
  22433. * @returns VertexData
  22434. */
  22435. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22436. /**
  22437. * Updates the associated mesh
  22438. * @param mesh the mesh to be updated
  22439. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22440. * @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
  22441. * @returns VertexData
  22442. */
  22443. updateMesh(mesh: Mesh): VertexData;
  22444. /**
  22445. * Updates the associated geometry
  22446. * @param geometry the geometry to be updated
  22447. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22448. * @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
  22449. * @returns VertexData.
  22450. */
  22451. updateGeometry(geometry: Geometry): VertexData;
  22452. private _applyTo;
  22453. private _update;
  22454. /**
  22455. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22456. * @param matrix the transforming matrix
  22457. * @returns the VertexData
  22458. */
  22459. transform(matrix: Matrix): VertexData;
  22460. /**
  22461. * Merges the passed VertexData into the current one
  22462. * @param other the VertexData to be merged into the current one
  22463. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22464. * @returns the modified VertexData
  22465. */
  22466. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22467. private _mergeElement;
  22468. private _validate;
  22469. /**
  22470. * Serializes the VertexData
  22471. * @returns a serialized object
  22472. */
  22473. serialize(): any;
  22474. /**
  22475. * Extracts the vertexData from a mesh
  22476. * @param mesh the mesh from which to extract the VertexData
  22477. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22478. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22479. * @returns the object VertexData associated to the passed mesh
  22480. */
  22481. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22482. /**
  22483. * Extracts the vertexData from the geometry
  22484. * @param geometry the geometry from which to extract the VertexData
  22485. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22486. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22487. * @returns the object VertexData associated to the passed mesh
  22488. */
  22489. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22490. private static _ExtractFrom;
  22491. /**
  22492. * Creates the VertexData for a Ribbon
  22493. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22494. * * pathArray array of paths, each of which an array of successive Vector3
  22495. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22496. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22497. * * 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
  22498. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22499. * * 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)
  22500. * * 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)
  22501. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22502. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22503. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22504. * @returns the VertexData of the ribbon
  22505. */
  22506. static CreateRibbon(options: {
  22507. pathArray: Vector3[][];
  22508. closeArray?: boolean;
  22509. closePath?: boolean;
  22510. offset?: number;
  22511. sideOrientation?: number;
  22512. frontUVs?: Vector4;
  22513. backUVs?: Vector4;
  22514. invertUV?: boolean;
  22515. uvs?: Vector2[];
  22516. colors?: Color4[];
  22517. }): VertexData;
  22518. /**
  22519. * Creates the VertexData for a box
  22520. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22521. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22522. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22523. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22524. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22525. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22526. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22527. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22528. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22529. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22530. * @returns the VertexData of the box
  22531. */
  22532. static CreateBox(options: {
  22533. size?: number;
  22534. width?: number;
  22535. height?: number;
  22536. depth?: number;
  22537. faceUV?: Vector4[];
  22538. faceColors?: Color4[];
  22539. sideOrientation?: number;
  22540. frontUVs?: Vector4;
  22541. backUVs?: Vector4;
  22542. }): VertexData;
  22543. /**
  22544. * Creates the VertexData for a tiled box
  22545. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22546. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22547. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22548. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22549. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22550. * @returns the VertexData of the box
  22551. */
  22552. static CreateTiledBox(options: {
  22553. pattern?: number;
  22554. width?: number;
  22555. height?: number;
  22556. depth?: number;
  22557. tileSize?: number;
  22558. tileWidth?: number;
  22559. tileHeight?: number;
  22560. alignHorizontal?: number;
  22561. alignVertical?: number;
  22562. faceUV?: Vector4[];
  22563. faceColors?: Color4[];
  22564. sideOrientation?: number;
  22565. }): VertexData;
  22566. /**
  22567. * Creates the VertexData for a tiled plane
  22568. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22569. * * pattern a limited pattern arrangement depending on the number
  22570. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22571. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22572. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22573. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22574. * * 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)
  22575. * * 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)
  22576. * @returns the VertexData of the tiled plane
  22577. */
  22578. static CreateTiledPlane(options: {
  22579. pattern?: number;
  22580. tileSize?: number;
  22581. tileWidth?: number;
  22582. tileHeight?: number;
  22583. size?: number;
  22584. width?: number;
  22585. height?: number;
  22586. alignHorizontal?: number;
  22587. alignVertical?: number;
  22588. sideOrientation?: number;
  22589. frontUVs?: Vector4;
  22590. backUVs?: Vector4;
  22591. }): VertexData;
  22592. /**
  22593. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22594. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22595. * * segments sets the number of horizontal strips optional, default 32
  22596. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22597. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22598. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22599. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22600. * * 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
  22601. * * 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
  22602. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22603. * * 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)
  22604. * * 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)
  22605. * @returns the VertexData of the ellipsoid
  22606. */
  22607. static CreateSphere(options: {
  22608. segments?: number;
  22609. diameter?: number;
  22610. diameterX?: number;
  22611. diameterY?: number;
  22612. diameterZ?: number;
  22613. arc?: number;
  22614. slice?: number;
  22615. sideOrientation?: number;
  22616. frontUVs?: Vector4;
  22617. backUVs?: Vector4;
  22618. }): VertexData;
  22619. /**
  22620. * Creates the VertexData for a cylinder, cone or prism
  22621. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22622. * * height sets the height (y direction) of the cylinder, optional, default 2
  22623. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22624. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22625. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22626. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22627. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22628. * * 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
  22629. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22630. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22631. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22632. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22633. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22634. * * 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)
  22635. * * 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)
  22636. * @returns the VertexData of the cylinder, cone or prism
  22637. */
  22638. static CreateCylinder(options: {
  22639. height?: number;
  22640. diameterTop?: number;
  22641. diameterBottom?: number;
  22642. diameter?: number;
  22643. tessellation?: number;
  22644. subdivisions?: number;
  22645. arc?: number;
  22646. faceColors?: Color4[];
  22647. faceUV?: Vector4[];
  22648. hasRings?: boolean;
  22649. enclose?: boolean;
  22650. sideOrientation?: number;
  22651. frontUVs?: Vector4;
  22652. backUVs?: Vector4;
  22653. }): VertexData;
  22654. /**
  22655. * Creates the VertexData for a torus
  22656. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22657. * * diameter the diameter of the torus, optional default 1
  22658. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22659. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22660. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22661. * * 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)
  22662. * * 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)
  22663. * @returns the VertexData of the torus
  22664. */
  22665. static CreateTorus(options: {
  22666. diameter?: number;
  22667. thickness?: number;
  22668. tessellation?: number;
  22669. sideOrientation?: number;
  22670. frontUVs?: Vector4;
  22671. backUVs?: Vector4;
  22672. }): VertexData;
  22673. /**
  22674. * Creates the VertexData of the LineSystem
  22675. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22676. * - lines an array of lines, each line being an array of successive Vector3
  22677. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22678. * @returns the VertexData of the LineSystem
  22679. */
  22680. static CreateLineSystem(options: {
  22681. lines: Vector3[][];
  22682. colors?: Nullable<Color4[][]>;
  22683. }): VertexData;
  22684. /**
  22685. * Create the VertexData for a DashedLines
  22686. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22687. * - points an array successive Vector3
  22688. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22689. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22690. * - dashNb the intended total number of dashes, optional, default 200
  22691. * @returns the VertexData for the DashedLines
  22692. */
  22693. static CreateDashedLines(options: {
  22694. points: Vector3[];
  22695. dashSize?: number;
  22696. gapSize?: number;
  22697. dashNb?: number;
  22698. }): VertexData;
  22699. /**
  22700. * Creates the VertexData for a Ground
  22701. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22702. * - width the width (x direction) of the ground, optional, default 1
  22703. * - height the height (z direction) of the ground, optional, default 1
  22704. * - subdivisions the number of subdivisions per side, optional, default 1
  22705. * @returns the VertexData of the Ground
  22706. */
  22707. static CreateGround(options: {
  22708. width?: number;
  22709. height?: number;
  22710. subdivisions?: number;
  22711. subdivisionsX?: number;
  22712. subdivisionsY?: number;
  22713. }): VertexData;
  22714. /**
  22715. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22716. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22717. * * xmin the ground minimum X coordinate, optional, default -1
  22718. * * zmin the ground minimum Z coordinate, optional, default -1
  22719. * * xmax the ground maximum X coordinate, optional, default 1
  22720. * * zmax the ground maximum Z coordinate, optional, default 1
  22721. * * 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}
  22722. * * 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}
  22723. * @returns the VertexData of the TiledGround
  22724. */
  22725. static CreateTiledGround(options: {
  22726. xmin: number;
  22727. zmin: number;
  22728. xmax: number;
  22729. zmax: number;
  22730. subdivisions?: {
  22731. w: number;
  22732. h: number;
  22733. };
  22734. precision?: {
  22735. w: number;
  22736. h: number;
  22737. };
  22738. }): VertexData;
  22739. /**
  22740. * Creates the VertexData of the Ground designed from a heightmap
  22741. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22742. * * width the width (x direction) of the ground
  22743. * * height the height (z direction) of the ground
  22744. * * subdivisions the number of subdivisions per side
  22745. * * minHeight the minimum altitude on the ground, optional, default 0
  22746. * * maxHeight the maximum altitude on the ground, optional default 1
  22747. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22748. * * buffer the array holding the image color data
  22749. * * bufferWidth the width of image
  22750. * * bufferHeight the height of image
  22751. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22752. * @returns the VertexData of the Ground designed from a heightmap
  22753. */
  22754. static CreateGroundFromHeightMap(options: {
  22755. width: number;
  22756. height: number;
  22757. subdivisions: number;
  22758. minHeight: number;
  22759. maxHeight: number;
  22760. colorFilter: Color3;
  22761. buffer: Uint8Array;
  22762. bufferWidth: number;
  22763. bufferHeight: number;
  22764. alphaFilter: number;
  22765. }): VertexData;
  22766. /**
  22767. * Creates the VertexData for a Plane
  22768. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22769. * * size sets the width and height of the plane to the value of size, optional default 1
  22770. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22771. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22772. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22773. * * 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)
  22774. * * 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)
  22775. * @returns the VertexData of the box
  22776. */
  22777. static CreatePlane(options: {
  22778. size?: number;
  22779. width?: number;
  22780. height?: number;
  22781. sideOrientation?: number;
  22782. frontUVs?: Vector4;
  22783. backUVs?: Vector4;
  22784. }): VertexData;
  22785. /**
  22786. * Creates the VertexData of the Disc or regular Polygon
  22787. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22788. * * radius the radius of the disc, optional default 0.5
  22789. * * tessellation the number of polygon sides, optional, default 64
  22790. * * 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
  22791. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22792. * * 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)
  22793. * * 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)
  22794. * @returns the VertexData of the box
  22795. */
  22796. static CreateDisc(options: {
  22797. radius?: number;
  22798. tessellation?: number;
  22799. arc?: number;
  22800. sideOrientation?: number;
  22801. frontUVs?: Vector4;
  22802. backUVs?: Vector4;
  22803. }): VertexData;
  22804. /**
  22805. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22806. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22807. * @param polygon a mesh built from polygonTriangulation.build()
  22808. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22809. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22810. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22811. * @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)
  22812. * @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)
  22813. * @returns the VertexData of the Polygon
  22814. */
  22815. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22816. /**
  22817. * Creates the VertexData of the IcoSphere
  22818. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22819. * * radius the radius of the IcoSphere, optional default 1
  22820. * * radiusX allows stretching in the x direction, optional, default radius
  22821. * * radiusY allows stretching in the y direction, optional, default radius
  22822. * * radiusZ allows stretching in the z direction, optional, default radius
  22823. * * flat when true creates a flat shaded mesh, optional, default true
  22824. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22825. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22826. * * 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)
  22827. * * 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)
  22828. * @returns the VertexData of the IcoSphere
  22829. */
  22830. static CreateIcoSphere(options: {
  22831. radius?: number;
  22832. radiusX?: number;
  22833. radiusY?: number;
  22834. radiusZ?: number;
  22835. flat?: boolean;
  22836. subdivisions?: number;
  22837. sideOrientation?: number;
  22838. frontUVs?: Vector4;
  22839. backUVs?: Vector4;
  22840. }): VertexData;
  22841. /**
  22842. * Creates the VertexData for a Polyhedron
  22843. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22844. * * type provided types are:
  22845. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22846. * * 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)
  22847. * * size the size of the IcoSphere, optional default 1
  22848. * * sizeX allows stretching in the x direction, optional, default size
  22849. * * sizeY allows stretching in the y direction, optional, default size
  22850. * * sizeZ allows stretching in the z direction, optional, default size
  22851. * * 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
  22852. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22853. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22854. * * flat when true creates a flat shaded mesh, optional, default true
  22855. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22856. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22857. * * 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)
  22858. * * 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)
  22859. * @returns the VertexData of the Polyhedron
  22860. */
  22861. static CreatePolyhedron(options: {
  22862. type?: number;
  22863. size?: number;
  22864. sizeX?: number;
  22865. sizeY?: number;
  22866. sizeZ?: number;
  22867. custom?: any;
  22868. faceUV?: Vector4[];
  22869. faceColors?: Color4[];
  22870. flat?: boolean;
  22871. sideOrientation?: number;
  22872. frontUVs?: Vector4;
  22873. backUVs?: Vector4;
  22874. }): VertexData;
  22875. /**
  22876. * Creates the VertexData for a TorusKnot
  22877. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22878. * * radius the radius of the torus knot, optional, default 2
  22879. * * tube the thickness of the tube, optional, default 0.5
  22880. * * radialSegments the number of sides on each tube segments, optional, default 32
  22881. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22882. * * p the number of windings around the z axis, optional, default 2
  22883. * * q the number of windings around the x axis, optional, default 3
  22884. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22885. * * 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)
  22886. * * 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)
  22887. * @returns the VertexData of the Torus Knot
  22888. */
  22889. static CreateTorusKnot(options: {
  22890. radius?: number;
  22891. tube?: number;
  22892. radialSegments?: number;
  22893. tubularSegments?: number;
  22894. p?: number;
  22895. q?: number;
  22896. sideOrientation?: number;
  22897. frontUVs?: Vector4;
  22898. backUVs?: Vector4;
  22899. }): VertexData;
  22900. /**
  22901. * Compute normals for given positions and indices
  22902. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22903. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22904. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22905. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22906. * * facetNormals : optional array of facet normals (vector3)
  22907. * * facetPositions : optional array of facet positions (vector3)
  22908. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22909. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22910. * * bInfo : optional bounding info, required for facetPartitioning computation
  22911. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22912. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22913. * * useRightHandedSystem: optional boolean to for right handed system computation
  22914. * * depthSort : optional boolean to enable the facet depth sort computation
  22915. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22916. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22917. */
  22918. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22919. facetNormals?: any;
  22920. facetPositions?: any;
  22921. facetPartitioning?: any;
  22922. ratio?: number;
  22923. bInfo?: any;
  22924. bbSize?: Vector3;
  22925. subDiv?: any;
  22926. useRightHandedSystem?: boolean;
  22927. depthSort?: boolean;
  22928. distanceTo?: Vector3;
  22929. depthSortedFacets?: any;
  22930. }): void;
  22931. /** @hidden */
  22932. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22933. /**
  22934. * Applies VertexData created from the imported parameters to the geometry
  22935. * @param parsedVertexData the parsed data from an imported file
  22936. * @param geometry the geometry to apply the VertexData to
  22937. */
  22938. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22939. }
  22940. }
  22941. declare module "babylonjs/Morph/morphTarget" {
  22942. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22943. import { Observable } from "babylonjs/Misc/observable";
  22944. import { Nullable, FloatArray } from "babylonjs/types";
  22945. import { Scene } from "babylonjs/scene";
  22946. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22947. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22948. /**
  22949. * Defines a target to use with MorphTargetManager
  22950. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22951. */
  22952. export class MorphTarget implements IAnimatable {
  22953. /** defines the name of the target */
  22954. name: string;
  22955. /**
  22956. * Gets or sets the list of animations
  22957. */
  22958. animations: import("babylonjs/Animations/animation").Animation[];
  22959. private _scene;
  22960. private _positions;
  22961. private _normals;
  22962. private _tangents;
  22963. private _uvs;
  22964. private _influence;
  22965. private _uniqueId;
  22966. /**
  22967. * Observable raised when the influence changes
  22968. */
  22969. onInfluenceChanged: Observable<boolean>;
  22970. /** @hidden */
  22971. _onDataLayoutChanged: Observable<void>;
  22972. /**
  22973. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22974. */
  22975. influence: number;
  22976. /**
  22977. * Gets or sets the id of the morph Target
  22978. */
  22979. id: string;
  22980. private _animationPropertiesOverride;
  22981. /**
  22982. * Gets or sets the animation properties override
  22983. */
  22984. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22985. /**
  22986. * Creates a new MorphTarget
  22987. * @param name defines the name of the target
  22988. * @param influence defines the influence to use
  22989. * @param scene defines the scene the morphtarget belongs to
  22990. */
  22991. constructor(
  22992. /** defines the name of the target */
  22993. name: string, influence?: number, scene?: Nullable<Scene>);
  22994. /**
  22995. * Gets the unique ID of this manager
  22996. */
  22997. readonly uniqueId: number;
  22998. /**
  22999. * Gets a boolean defining if the target contains position data
  23000. */
  23001. readonly hasPositions: boolean;
  23002. /**
  23003. * Gets a boolean defining if the target contains normal data
  23004. */
  23005. readonly hasNormals: boolean;
  23006. /**
  23007. * Gets a boolean defining if the target contains tangent data
  23008. */
  23009. readonly hasTangents: boolean;
  23010. /**
  23011. * Gets a boolean defining if the target contains texture coordinates data
  23012. */
  23013. readonly hasUVs: boolean;
  23014. /**
  23015. * Affects position data to this target
  23016. * @param data defines the position data to use
  23017. */
  23018. setPositions(data: Nullable<FloatArray>): void;
  23019. /**
  23020. * Gets the position data stored in this target
  23021. * @returns a FloatArray containing the position data (or null if not present)
  23022. */
  23023. getPositions(): Nullable<FloatArray>;
  23024. /**
  23025. * Affects normal data to this target
  23026. * @param data defines the normal data to use
  23027. */
  23028. setNormals(data: Nullable<FloatArray>): void;
  23029. /**
  23030. * Gets the normal data stored in this target
  23031. * @returns a FloatArray containing the normal data (or null if not present)
  23032. */
  23033. getNormals(): Nullable<FloatArray>;
  23034. /**
  23035. * Affects tangent data to this target
  23036. * @param data defines the tangent data to use
  23037. */
  23038. setTangents(data: Nullable<FloatArray>): void;
  23039. /**
  23040. * Gets the tangent data stored in this target
  23041. * @returns a FloatArray containing the tangent data (or null if not present)
  23042. */
  23043. getTangents(): Nullable<FloatArray>;
  23044. /**
  23045. * Affects texture coordinates data to this target
  23046. * @param data defines the texture coordinates data to use
  23047. */
  23048. setUVs(data: Nullable<FloatArray>): void;
  23049. /**
  23050. * Gets the texture coordinates data stored in this target
  23051. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23052. */
  23053. getUVs(): Nullable<FloatArray>;
  23054. /**
  23055. * Clone the current target
  23056. * @returns a new MorphTarget
  23057. */
  23058. clone(): MorphTarget;
  23059. /**
  23060. * Serializes the current target into a Serialization object
  23061. * @returns the serialized object
  23062. */
  23063. serialize(): any;
  23064. /**
  23065. * Returns the string "MorphTarget"
  23066. * @returns "MorphTarget"
  23067. */
  23068. getClassName(): string;
  23069. /**
  23070. * Creates a new target from serialized data
  23071. * @param serializationObject defines the serialized data to use
  23072. * @returns a new MorphTarget
  23073. */
  23074. static Parse(serializationObject: any): MorphTarget;
  23075. /**
  23076. * Creates a MorphTarget from mesh data
  23077. * @param mesh defines the source mesh
  23078. * @param name defines the name to use for the new target
  23079. * @param influence defines the influence to attach to the target
  23080. * @returns a new MorphTarget
  23081. */
  23082. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23083. }
  23084. }
  23085. declare module "babylonjs/Morph/morphTargetManager" {
  23086. import { Nullable } from "babylonjs/types";
  23087. import { Scene } from "babylonjs/scene";
  23088. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23089. /**
  23090. * This class is used to deform meshes using morphing between different targets
  23091. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23092. */
  23093. export class MorphTargetManager {
  23094. private _targets;
  23095. private _targetInfluenceChangedObservers;
  23096. private _targetDataLayoutChangedObservers;
  23097. private _activeTargets;
  23098. private _scene;
  23099. private _influences;
  23100. private _supportsNormals;
  23101. private _supportsTangents;
  23102. private _supportsUVs;
  23103. private _vertexCount;
  23104. private _uniqueId;
  23105. private _tempInfluences;
  23106. /**
  23107. * Gets or sets a boolean indicating if normals must be morphed
  23108. */
  23109. enableNormalMorphing: boolean;
  23110. /**
  23111. * Gets or sets a boolean indicating if tangents must be morphed
  23112. */
  23113. enableTangentMorphing: boolean;
  23114. /**
  23115. * Gets or sets a boolean indicating if UV must be morphed
  23116. */
  23117. enableUVMorphing: boolean;
  23118. /**
  23119. * Creates a new MorphTargetManager
  23120. * @param scene defines the current scene
  23121. */
  23122. constructor(scene?: Nullable<Scene>);
  23123. /**
  23124. * Gets the unique ID of this manager
  23125. */
  23126. readonly uniqueId: number;
  23127. /**
  23128. * Gets the number of vertices handled by this manager
  23129. */
  23130. readonly vertexCount: number;
  23131. /**
  23132. * Gets a boolean indicating if this manager supports morphing of normals
  23133. */
  23134. readonly supportsNormals: boolean;
  23135. /**
  23136. * Gets a boolean indicating if this manager supports morphing of tangents
  23137. */
  23138. readonly supportsTangents: boolean;
  23139. /**
  23140. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23141. */
  23142. readonly supportsUVs: boolean;
  23143. /**
  23144. * Gets the number of targets stored in this manager
  23145. */
  23146. readonly numTargets: number;
  23147. /**
  23148. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23149. */
  23150. readonly numInfluencers: number;
  23151. /**
  23152. * Gets the list of influences (one per target)
  23153. */
  23154. readonly influences: Float32Array;
  23155. /**
  23156. * Gets the active target at specified index. An active target is a target with an influence > 0
  23157. * @param index defines the index to check
  23158. * @returns the requested target
  23159. */
  23160. getActiveTarget(index: number): MorphTarget;
  23161. /**
  23162. * Gets the target at specified index
  23163. * @param index defines the index to check
  23164. * @returns the requested target
  23165. */
  23166. getTarget(index: number): MorphTarget;
  23167. /**
  23168. * Add a new target to this manager
  23169. * @param target defines the target to add
  23170. */
  23171. addTarget(target: MorphTarget): void;
  23172. /**
  23173. * Removes a target from the manager
  23174. * @param target defines the target to remove
  23175. */
  23176. removeTarget(target: MorphTarget): void;
  23177. /**
  23178. * Clone the current manager
  23179. * @returns a new MorphTargetManager
  23180. */
  23181. clone(): MorphTargetManager;
  23182. /**
  23183. * Serializes the current manager into a Serialization object
  23184. * @returns the serialized object
  23185. */
  23186. serialize(): any;
  23187. private _syncActiveTargets;
  23188. /**
  23189. * Syncrhonize the targets with all the meshes using this morph target manager
  23190. */
  23191. synchronize(): void;
  23192. /**
  23193. * Creates a new MorphTargetManager from serialized data
  23194. * @param serializationObject defines the serialized data
  23195. * @param scene defines the hosting scene
  23196. * @returns the new MorphTargetManager
  23197. */
  23198. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23199. }
  23200. }
  23201. declare module "babylonjs/Meshes/meshLODLevel" {
  23202. import { Mesh } from "babylonjs/Meshes/mesh";
  23203. import { Nullable } from "babylonjs/types";
  23204. /**
  23205. * Class used to represent a specific level of detail of a mesh
  23206. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23207. */
  23208. export class MeshLODLevel {
  23209. /** Defines the distance where this level should start being displayed */
  23210. distance: number;
  23211. /** Defines the mesh to use to render this level */
  23212. mesh: Nullable<Mesh>;
  23213. /**
  23214. * Creates a new LOD level
  23215. * @param distance defines the distance where this level should star being displayed
  23216. * @param mesh defines the mesh to use to render this level
  23217. */
  23218. constructor(
  23219. /** Defines the distance where this level should start being displayed */
  23220. distance: number,
  23221. /** Defines the mesh to use to render this level */
  23222. mesh: Nullable<Mesh>);
  23223. }
  23224. }
  23225. declare module "babylonjs/Meshes/groundMesh" {
  23226. import { Scene } from "babylonjs/scene";
  23227. import { Vector3 } from "babylonjs/Maths/math.vector";
  23228. import { Mesh } from "babylonjs/Meshes/mesh";
  23229. /**
  23230. * Mesh representing the gorund
  23231. */
  23232. export class GroundMesh extends Mesh {
  23233. /** If octree should be generated */
  23234. generateOctree: boolean;
  23235. private _heightQuads;
  23236. /** @hidden */
  23237. _subdivisionsX: number;
  23238. /** @hidden */
  23239. _subdivisionsY: number;
  23240. /** @hidden */
  23241. _width: number;
  23242. /** @hidden */
  23243. _height: number;
  23244. /** @hidden */
  23245. _minX: number;
  23246. /** @hidden */
  23247. _maxX: number;
  23248. /** @hidden */
  23249. _minZ: number;
  23250. /** @hidden */
  23251. _maxZ: number;
  23252. constructor(name: string, scene: Scene);
  23253. /**
  23254. * "GroundMesh"
  23255. * @returns "GroundMesh"
  23256. */
  23257. getClassName(): string;
  23258. /**
  23259. * The minimum of x and y subdivisions
  23260. */
  23261. readonly subdivisions: number;
  23262. /**
  23263. * X subdivisions
  23264. */
  23265. readonly subdivisionsX: number;
  23266. /**
  23267. * Y subdivisions
  23268. */
  23269. readonly subdivisionsY: number;
  23270. /**
  23271. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23272. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23273. * @param chunksCount the number of subdivisions for x and y
  23274. * @param octreeBlocksSize (Default: 32)
  23275. */
  23276. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23277. /**
  23278. * Returns a height (y) value in the Worl system :
  23279. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23280. * @param x x coordinate
  23281. * @param z z coordinate
  23282. * @returns the ground y position if (x, z) are outside the ground surface.
  23283. */
  23284. getHeightAtCoordinates(x: number, z: number): number;
  23285. /**
  23286. * Returns a normalized vector (Vector3) orthogonal to the ground
  23287. * at the ground coordinates (x, z) expressed in the World system.
  23288. * @param x x coordinate
  23289. * @param z z coordinate
  23290. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23291. */
  23292. getNormalAtCoordinates(x: number, z: number): Vector3;
  23293. /**
  23294. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23295. * at the ground coordinates (x, z) expressed in the World system.
  23296. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23297. * @param x x coordinate
  23298. * @param z z coordinate
  23299. * @param ref vector to store the result
  23300. * @returns the GroundMesh.
  23301. */
  23302. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23303. /**
  23304. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23305. * if the ground has been updated.
  23306. * This can be used in the render loop.
  23307. * @returns the GroundMesh.
  23308. */
  23309. updateCoordinateHeights(): GroundMesh;
  23310. private _getFacetAt;
  23311. private _initHeightQuads;
  23312. private _computeHeightQuads;
  23313. /**
  23314. * Serializes this ground mesh
  23315. * @param serializationObject object to write serialization to
  23316. */
  23317. serialize(serializationObject: any): void;
  23318. /**
  23319. * Parses a serialized ground mesh
  23320. * @param parsedMesh the serialized mesh
  23321. * @param scene the scene to create the ground mesh in
  23322. * @returns the created ground mesh
  23323. */
  23324. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23325. }
  23326. }
  23327. declare module "babylonjs/Physics/physicsJoint" {
  23328. import { Vector3 } from "babylonjs/Maths/math.vector";
  23329. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23330. /**
  23331. * Interface for Physics-Joint data
  23332. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23333. */
  23334. export interface PhysicsJointData {
  23335. /**
  23336. * The main pivot of the joint
  23337. */
  23338. mainPivot?: Vector3;
  23339. /**
  23340. * The connected pivot of the joint
  23341. */
  23342. connectedPivot?: Vector3;
  23343. /**
  23344. * The main axis of the joint
  23345. */
  23346. mainAxis?: Vector3;
  23347. /**
  23348. * The connected axis of the joint
  23349. */
  23350. connectedAxis?: Vector3;
  23351. /**
  23352. * The collision of the joint
  23353. */
  23354. collision?: boolean;
  23355. /**
  23356. * Native Oimo/Cannon/Energy data
  23357. */
  23358. nativeParams?: any;
  23359. }
  23360. /**
  23361. * This is a holder class for the physics joint created by the physics plugin
  23362. * It holds a set of functions to control the underlying joint
  23363. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23364. */
  23365. export class PhysicsJoint {
  23366. /**
  23367. * The type of the physics joint
  23368. */
  23369. type: number;
  23370. /**
  23371. * The data for the physics joint
  23372. */
  23373. jointData: PhysicsJointData;
  23374. private _physicsJoint;
  23375. protected _physicsPlugin: IPhysicsEnginePlugin;
  23376. /**
  23377. * Initializes the physics joint
  23378. * @param type The type of the physics joint
  23379. * @param jointData The data for the physics joint
  23380. */
  23381. constructor(
  23382. /**
  23383. * The type of the physics joint
  23384. */
  23385. type: number,
  23386. /**
  23387. * The data for the physics joint
  23388. */
  23389. jointData: PhysicsJointData);
  23390. /**
  23391. * Gets the physics joint
  23392. */
  23393. /**
  23394. * Sets the physics joint
  23395. */
  23396. physicsJoint: any;
  23397. /**
  23398. * Sets the physics plugin
  23399. */
  23400. physicsPlugin: IPhysicsEnginePlugin;
  23401. /**
  23402. * Execute a function that is physics-plugin specific.
  23403. * @param {Function} func the function that will be executed.
  23404. * It accepts two parameters: the physics world and the physics joint
  23405. */
  23406. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23407. /**
  23408. * Distance-Joint type
  23409. */
  23410. static DistanceJoint: number;
  23411. /**
  23412. * Hinge-Joint type
  23413. */
  23414. static HingeJoint: number;
  23415. /**
  23416. * Ball-and-Socket joint type
  23417. */
  23418. static BallAndSocketJoint: number;
  23419. /**
  23420. * Wheel-Joint type
  23421. */
  23422. static WheelJoint: number;
  23423. /**
  23424. * Slider-Joint type
  23425. */
  23426. static SliderJoint: number;
  23427. /**
  23428. * Prismatic-Joint type
  23429. */
  23430. static PrismaticJoint: number;
  23431. /**
  23432. * Universal-Joint type
  23433. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23434. */
  23435. static UniversalJoint: number;
  23436. /**
  23437. * Hinge-Joint 2 type
  23438. */
  23439. static Hinge2Joint: number;
  23440. /**
  23441. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23442. */
  23443. static PointToPointJoint: number;
  23444. /**
  23445. * Spring-Joint type
  23446. */
  23447. static SpringJoint: number;
  23448. /**
  23449. * Lock-Joint type
  23450. */
  23451. static LockJoint: number;
  23452. }
  23453. /**
  23454. * A class representing a physics distance joint
  23455. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23456. */
  23457. export class DistanceJoint extends PhysicsJoint {
  23458. /**
  23459. *
  23460. * @param jointData The data for the Distance-Joint
  23461. */
  23462. constructor(jointData: DistanceJointData);
  23463. /**
  23464. * Update the predefined distance.
  23465. * @param maxDistance The maximum preferred distance
  23466. * @param minDistance The minimum preferred distance
  23467. */
  23468. updateDistance(maxDistance: number, minDistance?: number): void;
  23469. }
  23470. /**
  23471. * Represents a Motor-Enabled Joint
  23472. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23473. */
  23474. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23475. /**
  23476. * Initializes the Motor-Enabled Joint
  23477. * @param type The type of the joint
  23478. * @param jointData The physica joint data for the joint
  23479. */
  23480. constructor(type: number, jointData: PhysicsJointData);
  23481. /**
  23482. * Set the motor values.
  23483. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23484. * @param force the force to apply
  23485. * @param maxForce max force for this motor.
  23486. */
  23487. setMotor(force?: number, maxForce?: number): void;
  23488. /**
  23489. * Set the motor's limits.
  23490. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23491. * @param upperLimit The upper limit of the motor
  23492. * @param lowerLimit The lower limit of the motor
  23493. */
  23494. setLimit(upperLimit: number, lowerLimit?: number): void;
  23495. }
  23496. /**
  23497. * This class represents a single physics Hinge-Joint
  23498. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23499. */
  23500. export class HingeJoint extends MotorEnabledJoint {
  23501. /**
  23502. * Initializes the Hinge-Joint
  23503. * @param jointData The joint data for the Hinge-Joint
  23504. */
  23505. constructor(jointData: PhysicsJointData);
  23506. /**
  23507. * Set the motor values.
  23508. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23509. * @param {number} force the force to apply
  23510. * @param {number} maxForce max force for this motor.
  23511. */
  23512. setMotor(force?: number, maxForce?: number): void;
  23513. /**
  23514. * Set the motor's limits.
  23515. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23516. * @param upperLimit The upper limit of the motor
  23517. * @param lowerLimit The lower limit of the motor
  23518. */
  23519. setLimit(upperLimit: number, lowerLimit?: number): void;
  23520. }
  23521. /**
  23522. * This class represents a dual hinge physics joint (same as wheel joint)
  23523. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23524. */
  23525. export class Hinge2Joint extends MotorEnabledJoint {
  23526. /**
  23527. * Initializes the Hinge2-Joint
  23528. * @param jointData The joint data for the Hinge2-Joint
  23529. */
  23530. constructor(jointData: PhysicsJointData);
  23531. /**
  23532. * Set the motor values.
  23533. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23534. * @param {number} targetSpeed the speed the motor is to reach
  23535. * @param {number} maxForce max force for this motor.
  23536. * @param {motorIndex} the motor's index, 0 or 1.
  23537. */
  23538. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23539. /**
  23540. * Set the motor limits.
  23541. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23542. * @param {number} upperLimit the upper limit
  23543. * @param {number} lowerLimit lower limit
  23544. * @param {motorIndex} the motor's index, 0 or 1.
  23545. */
  23546. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23547. }
  23548. /**
  23549. * Interface for a motor enabled joint
  23550. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23551. */
  23552. export interface IMotorEnabledJoint {
  23553. /**
  23554. * Physics joint
  23555. */
  23556. physicsJoint: any;
  23557. /**
  23558. * Sets the motor of the motor-enabled joint
  23559. * @param force The force of the motor
  23560. * @param maxForce The maximum force of the motor
  23561. * @param motorIndex The index of the motor
  23562. */
  23563. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23564. /**
  23565. * Sets the limit of the motor
  23566. * @param upperLimit The upper limit of the motor
  23567. * @param lowerLimit The lower limit of the motor
  23568. * @param motorIndex The index of the motor
  23569. */
  23570. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23571. }
  23572. /**
  23573. * Joint data for a Distance-Joint
  23574. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23575. */
  23576. export interface DistanceJointData extends PhysicsJointData {
  23577. /**
  23578. * Max distance the 2 joint objects can be apart
  23579. */
  23580. maxDistance: number;
  23581. }
  23582. /**
  23583. * Joint data from a spring joint
  23584. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23585. */
  23586. export interface SpringJointData extends PhysicsJointData {
  23587. /**
  23588. * Length of the spring
  23589. */
  23590. length: number;
  23591. /**
  23592. * Stiffness of the spring
  23593. */
  23594. stiffness: number;
  23595. /**
  23596. * Damping of the spring
  23597. */
  23598. damping: number;
  23599. /** this callback will be called when applying the force to the impostors. */
  23600. forceApplicationCallback: () => void;
  23601. }
  23602. }
  23603. declare module "babylonjs/Physics/physicsRaycastResult" {
  23604. import { Vector3 } from "babylonjs/Maths/math.vector";
  23605. /**
  23606. * Holds the data for the raycast result
  23607. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23608. */
  23609. export class PhysicsRaycastResult {
  23610. private _hasHit;
  23611. private _hitDistance;
  23612. private _hitNormalWorld;
  23613. private _hitPointWorld;
  23614. private _rayFromWorld;
  23615. private _rayToWorld;
  23616. /**
  23617. * Gets if there was a hit
  23618. */
  23619. readonly hasHit: boolean;
  23620. /**
  23621. * Gets the distance from the hit
  23622. */
  23623. readonly hitDistance: number;
  23624. /**
  23625. * Gets the hit normal/direction in the world
  23626. */
  23627. readonly hitNormalWorld: Vector3;
  23628. /**
  23629. * Gets the hit point in the world
  23630. */
  23631. readonly hitPointWorld: Vector3;
  23632. /**
  23633. * Gets the ray "start point" of the ray in the world
  23634. */
  23635. readonly rayFromWorld: Vector3;
  23636. /**
  23637. * Gets the ray "end point" of the ray in the world
  23638. */
  23639. readonly rayToWorld: Vector3;
  23640. /**
  23641. * Sets the hit data (normal & point in world space)
  23642. * @param hitNormalWorld defines the normal in world space
  23643. * @param hitPointWorld defines the point in world space
  23644. */
  23645. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23646. /**
  23647. * Sets the distance from the start point to the hit point
  23648. * @param distance
  23649. */
  23650. setHitDistance(distance: number): void;
  23651. /**
  23652. * Calculates the distance manually
  23653. */
  23654. calculateHitDistance(): void;
  23655. /**
  23656. * Resets all the values to default
  23657. * @param from The from point on world space
  23658. * @param to The to point on world space
  23659. */
  23660. reset(from?: Vector3, to?: Vector3): void;
  23661. }
  23662. /**
  23663. * Interface for the size containing width and height
  23664. */
  23665. interface IXYZ {
  23666. /**
  23667. * X
  23668. */
  23669. x: number;
  23670. /**
  23671. * Y
  23672. */
  23673. y: number;
  23674. /**
  23675. * Z
  23676. */
  23677. z: number;
  23678. }
  23679. }
  23680. declare module "babylonjs/Physics/IPhysicsEngine" {
  23681. import { Nullable } from "babylonjs/types";
  23682. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23683. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23684. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23685. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23686. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23687. /**
  23688. * Interface used to describe a physics joint
  23689. */
  23690. export interface PhysicsImpostorJoint {
  23691. /** Defines the main impostor to which the joint is linked */
  23692. mainImpostor: PhysicsImpostor;
  23693. /** Defines the impostor that is connected to the main impostor using this joint */
  23694. connectedImpostor: PhysicsImpostor;
  23695. /** Defines the joint itself */
  23696. joint: PhysicsJoint;
  23697. }
  23698. /** @hidden */
  23699. export interface IPhysicsEnginePlugin {
  23700. world: any;
  23701. name: string;
  23702. setGravity(gravity: Vector3): void;
  23703. setTimeStep(timeStep: number): void;
  23704. getTimeStep(): number;
  23705. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23706. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23707. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23708. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23709. removePhysicsBody(impostor: PhysicsImpostor): void;
  23710. generateJoint(joint: PhysicsImpostorJoint): void;
  23711. removeJoint(joint: PhysicsImpostorJoint): void;
  23712. isSupported(): boolean;
  23713. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23714. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23715. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23716. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23717. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23718. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23719. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23720. getBodyMass(impostor: PhysicsImpostor): number;
  23721. getBodyFriction(impostor: PhysicsImpostor): number;
  23722. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23723. getBodyRestitution(impostor: PhysicsImpostor): number;
  23724. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23725. getBodyPressure?(impostor: PhysicsImpostor): number;
  23726. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23727. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23728. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23729. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23730. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23731. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23732. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23733. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23734. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23735. sleepBody(impostor: PhysicsImpostor): void;
  23736. wakeUpBody(impostor: PhysicsImpostor): void;
  23737. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23738. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23739. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23740. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23741. getRadius(impostor: PhysicsImpostor): number;
  23742. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23743. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23744. dispose(): void;
  23745. }
  23746. /**
  23747. * Interface used to define a physics engine
  23748. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23749. */
  23750. export interface IPhysicsEngine {
  23751. /**
  23752. * Gets the gravity vector used by the simulation
  23753. */
  23754. gravity: Vector3;
  23755. /**
  23756. * Sets the gravity vector used by the simulation
  23757. * @param gravity defines the gravity vector to use
  23758. */
  23759. setGravity(gravity: Vector3): void;
  23760. /**
  23761. * Set the time step of the physics engine.
  23762. * Default is 1/60.
  23763. * To slow it down, enter 1/600 for example.
  23764. * To speed it up, 1/30
  23765. * @param newTimeStep the new timestep to apply to this world.
  23766. */
  23767. setTimeStep(newTimeStep: number): void;
  23768. /**
  23769. * Get the time step of the physics engine.
  23770. * @returns the current time step
  23771. */
  23772. getTimeStep(): number;
  23773. /**
  23774. * Set the sub time step of the physics engine.
  23775. * Default is 0 meaning there is no sub steps
  23776. * To increase physics resolution precision, set a small value (like 1 ms)
  23777. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23778. */
  23779. setSubTimeStep(subTimeStep: number): void;
  23780. /**
  23781. * Get the sub time step of the physics engine.
  23782. * @returns the current sub time step
  23783. */
  23784. getSubTimeStep(): number;
  23785. /**
  23786. * Release all resources
  23787. */
  23788. dispose(): void;
  23789. /**
  23790. * Gets the name of the current physics plugin
  23791. * @returns the name of the plugin
  23792. */
  23793. getPhysicsPluginName(): string;
  23794. /**
  23795. * Adding a new impostor for the impostor tracking.
  23796. * This will be done by the impostor itself.
  23797. * @param impostor the impostor to add
  23798. */
  23799. addImpostor(impostor: PhysicsImpostor): void;
  23800. /**
  23801. * Remove an impostor from the engine.
  23802. * This impostor and its mesh will not longer be updated by the physics engine.
  23803. * @param impostor the impostor to remove
  23804. */
  23805. removeImpostor(impostor: PhysicsImpostor): void;
  23806. /**
  23807. * Add a joint to the physics engine
  23808. * @param mainImpostor defines the main impostor to which the joint is added.
  23809. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23810. * @param joint defines the joint that will connect both impostors.
  23811. */
  23812. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23813. /**
  23814. * Removes a joint from the simulation
  23815. * @param mainImpostor defines the impostor used with the joint
  23816. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23817. * @param joint defines the joint to remove
  23818. */
  23819. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23820. /**
  23821. * Gets the current plugin used to run the simulation
  23822. * @returns current plugin
  23823. */
  23824. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23825. /**
  23826. * Gets the list of physic impostors
  23827. * @returns an array of PhysicsImpostor
  23828. */
  23829. getImpostors(): Array<PhysicsImpostor>;
  23830. /**
  23831. * Gets the impostor for a physics enabled object
  23832. * @param object defines the object impersonated by the impostor
  23833. * @returns the PhysicsImpostor or null if not found
  23834. */
  23835. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23836. /**
  23837. * Gets the impostor for a physics body object
  23838. * @param body defines physics body used by the impostor
  23839. * @returns the PhysicsImpostor or null if not found
  23840. */
  23841. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23842. /**
  23843. * Does a raycast in the physics world
  23844. * @param from when should the ray start?
  23845. * @param to when should the ray end?
  23846. * @returns PhysicsRaycastResult
  23847. */
  23848. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23849. /**
  23850. * Called by the scene. No need to call it.
  23851. * @param delta defines the timespam between frames
  23852. */
  23853. _step(delta: number): void;
  23854. }
  23855. }
  23856. declare module "babylonjs/Physics/physicsImpostor" {
  23857. import { Nullable, IndicesArray } from "babylonjs/types";
  23858. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23859. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23860. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23861. import { Scene } from "babylonjs/scene";
  23862. import { Bone } from "babylonjs/Bones/bone";
  23863. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23864. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23865. import { Space } from "babylonjs/Maths/math.axis";
  23866. /**
  23867. * The interface for the physics imposter parameters
  23868. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23869. */
  23870. export interface PhysicsImpostorParameters {
  23871. /**
  23872. * The mass of the physics imposter
  23873. */
  23874. mass: number;
  23875. /**
  23876. * The friction of the physics imposter
  23877. */
  23878. friction?: number;
  23879. /**
  23880. * The coefficient of restitution of the physics imposter
  23881. */
  23882. restitution?: number;
  23883. /**
  23884. * The native options of the physics imposter
  23885. */
  23886. nativeOptions?: any;
  23887. /**
  23888. * Specifies if the parent should be ignored
  23889. */
  23890. ignoreParent?: boolean;
  23891. /**
  23892. * Specifies if bi-directional transformations should be disabled
  23893. */
  23894. disableBidirectionalTransformation?: boolean;
  23895. /**
  23896. * The pressure inside the physics imposter, soft object only
  23897. */
  23898. pressure?: number;
  23899. /**
  23900. * The stiffness the physics imposter, soft object only
  23901. */
  23902. stiffness?: number;
  23903. /**
  23904. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23905. */
  23906. velocityIterations?: number;
  23907. /**
  23908. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23909. */
  23910. positionIterations?: number;
  23911. /**
  23912. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23913. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23914. * Add to fix multiple points
  23915. */
  23916. fixedPoints?: number;
  23917. /**
  23918. * The collision margin around a soft object
  23919. */
  23920. margin?: number;
  23921. /**
  23922. * The collision margin around a soft object
  23923. */
  23924. damping?: number;
  23925. /**
  23926. * The path for a rope based on an extrusion
  23927. */
  23928. path?: any;
  23929. /**
  23930. * The shape of an extrusion used for a rope based on an extrusion
  23931. */
  23932. shape?: any;
  23933. }
  23934. /**
  23935. * Interface for a physics-enabled object
  23936. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23937. */
  23938. export interface IPhysicsEnabledObject {
  23939. /**
  23940. * The position of the physics-enabled object
  23941. */
  23942. position: Vector3;
  23943. /**
  23944. * The rotation of the physics-enabled object
  23945. */
  23946. rotationQuaternion: Nullable<Quaternion>;
  23947. /**
  23948. * The scale of the physics-enabled object
  23949. */
  23950. scaling: Vector3;
  23951. /**
  23952. * The rotation of the physics-enabled object
  23953. */
  23954. rotation?: Vector3;
  23955. /**
  23956. * The parent of the physics-enabled object
  23957. */
  23958. parent?: any;
  23959. /**
  23960. * The bounding info of the physics-enabled object
  23961. * @returns The bounding info of the physics-enabled object
  23962. */
  23963. getBoundingInfo(): BoundingInfo;
  23964. /**
  23965. * Computes the world matrix
  23966. * @param force Specifies if the world matrix should be computed by force
  23967. * @returns A world matrix
  23968. */
  23969. computeWorldMatrix(force: boolean): Matrix;
  23970. /**
  23971. * Gets the world matrix
  23972. * @returns A world matrix
  23973. */
  23974. getWorldMatrix?(): Matrix;
  23975. /**
  23976. * Gets the child meshes
  23977. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23978. * @returns An array of abstract meshes
  23979. */
  23980. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23981. /**
  23982. * Gets the vertex data
  23983. * @param kind The type of vertex data
  23984. * @returns A nullable array of numbers, or a float32 array
  23985. */
  23986. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23987. /**
  23988. * Gets the indices from the mesh
  23989. * @returns A nullable array of index arrays
  23990. */
  23991. getIndices?(): Nullable<IndicesArray>;
  23992. /**
  23993. * Gets the scene from the mesh
  23994. * @returns the indices array or null
  23995. */
  23996. getScene?(): Scene;
  23997. /**
  23998. * Gets the absolute position from the mesh
  23999. * @returns the absolute position
  24000. */
  24001. getAbsolutePosition(): Vector3;
  24002. /**
  24003. * Gets the absolute pivot point from the mesh
  24004. * @returns the absolute pivot point
  24005. */
  24006. getAbsolutePivotPoint(): Vector3;
  24007. /**
  24008. * Rotates the mesh
  24009. * @param axis The axis of rotation
  24010. * @param amount The amount of rotation
  24011. * @param space The space of the rotation
  24012. * @returns The rotation transform node
  24013. */
  24014. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24015. /**
  24016. * Translates the mesh
  24017. * @param axis The axis of translation
  24018. * @param distance The distance of translation
  24019. * @param space The space of the translation
  24020. * @returns The transform node
  24021. */
  24022. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24023. /**
  24024. * Sets the absolute position of the mesh
  24025. * @param absolutePosition The absolute position of the mesh
  24026. * @returns The transform node
  24027. */
  24028. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24029. /**
  24030. * Gets the class name of the mesh
  24031. * @returns The class name
  24032. */
  24033. getClassName(): string;
  24034. }
  24035. /**
  24036. * Represents a physics imposter
  24037. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24038. */
  24039. export class PhysicsImpostor {
  24040. /**
  24041. * The physics-enabled object used as the physics imposter
  24042. */
  24043. object: IPhysicsEnabledObject;
  24044. /**
  24045. * The type of the physics imposter
  24046. */
  24047. type: number;
  24048. private _options;
  24049. private _scene?;
  24050. /**
  24051. * The default object size of the imposter
  24052. */
  24053. static DEFAULT_OBJECT_SIZE: Vector3;
  24054. /**
  24055. * The identity quaternion of the imposter
  24056. */
  24057. static IDENTITY_QUATERNION: Quaternion;
  24058. /** @hidden */
  24059. _pluginData: any;
  24060. private _physicsEngine;
  24061. private _physicsBody;
  24062. private _bodyUpdateRequired;
  24063. private _onBeforePhysicsStepCallbacks;
  24064. private _onAfterPhysicsStepCallbacks;
  24065. /** @hidden */
  24066. _onPhysicsCollideCallbacks: Array<{
  24067. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24068. otherImpostors: Array<PhysicsImpostor>;
  24069. }>;
  24070. private _deltaPosition;
  24071. private _deltaRotation;
  24072. private _deltaRotationConjugated;
  24073. /** @hidden */
  24074. _isFromLine: boolean;
  24075. private _parent;
  24076. private _isDisposed;
  24077. private static _tmpVecs;
  24078. private static _tmpQuat;
  24079. /**
  24080. * Specifies if the physics imposter is disposed
  24081. */
  24082. readonly isDisposed: boolean;
  24083. /**
  24084. * Gets the mass of the physics imposter
  24085. */
  24086. mass: number;
  24087. /**
  24088. * Gets the coefficient of friction
  24089. */
  24090. /**
  24091. * Sets the coefficient of friction
  24092. */
  24093. friction: number;
  24094. /**
  24095. * Gets the coefficient of restitution
  24096. */
  24097. /**
  24098. * Sets the coefficient of restitution
  24099. */
  24100. restitution: number;
  24101. /**
  24102. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24103. */
  24104. /**
  24105. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24106. */
  24107. pressure: number;
  24108. /**
  24109. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24110. */
  24111. /**
  24112. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24113. */
  24114. stiffness: number;
  24115. /**
  24116. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24117. */
  24118. /**
  24119. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24120. */
  24121. velocityIterations: number;
  24122. /**
  24123. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24124. */
  24125. /**
  24126. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24127. */
  24128. positionIterations: number;
  24129. /**
  24130. * The unique id of the physics imposter
  24131. * set by the physics engine when adding this impostor to the array
  24132. */
  24133. uniqueId: number;
  24134. /**
  24135. * @hidden
  24136. */
  24137. soft: boolean;
  24138. /**
  24139. * @hidden
  24140. */
  24141. segments: number;
  24142. private _joints;
  24143. /**
  24144. * Initializes the physics imposter
  24145. * @param object The physics-enabled object used as the physics imposter
  24146. * @param type The type of the physics imposter
  24147. * @param _options The options for the physics imposter
  24148. * @param _scene The Babylon scene
  24149. */
  24150. constructor(
  24151. /**
  24152. * The physics-enabled object used as the physics imposter
  24153. */
  24154. object: IPhysicsEnabledObject,
  24155. /**
  24156. * The type of the physics imposter
  24157. */
  24158. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24159. /**
  24160. * This function will completly initialize this impostor.
  24161. * It will create a new body - but only if this mesh has no parent.
  24162. * If it has, this impostor will not be used other than to define the impostor
  24163. * of the child mesh.
  24164. * @hidden
  24165. */
  24166. _init(): void;
  24167. private _getPhysicsParent;
  24168. /**
  24169. * Should a new body be generated.
  24170. * @returns boolean specifying if body initialization is required
  24171. */
  24172. isBodyInitRequired(): boolean;
  24173. /**
  24174. * Sets the updated scaling
  24175. * @param updated Specifies if the scaling is updated
  24176. */
  24177. setScalingUpdated(): void;
  24178. /**
  24179. * Force a regeneration of this or the parent's impostor's body.
  24180. * Use under cautious - This will remove all joints already implemented.
  24181. */
  24182. forceUpdate(): void;
  24183. /**
  24184. * Gets the body that holds this impostor. Either its own, or its parent.
  24185. */
  24186. /**
  24187. * Set the physics body. Used mainly by the physics engine/plugin
  24188. */
  24189. physicsBody: any;
  24190. /**
  24191. * Get the parent of the physics imposter
  24192. * @returns Physics imposter or null
  24193. */
  24194. /**
  24195. * Sets the parent of the physics imposter
  24196. */
  24197. parent: Nullable<PhysicsImpostor>;
  24198. /**
  24199. * Resets the update flags
  24200. */
  24201. resetUpdateFlags(): void;
  24202. /**
  24203. * Gets the object extend size
  24204. * @returns the object extend size
  24205. */
  24206. getObjectExtendSize(): Vector3;
  24207. /**
  24208. * Gets the object center
  24209. * @returns The object center
  24210. */
  24211. getObjectCenter(): Vector3;
  24212. /**
  24213. * Get a specific parametes from the options parameter
  24214. * @param paramName The object parameter name
  24215. * @returns The object parameter
  24216. */
  24217. getParam(paramName: string): any;
  24218. /**
  24219. * Sets a specific parameter in the options given to the physics plugin
  24220. * @param paramName The parameter name
  24221. * @param value The value of the parameter
  24222. */
  24223. setParam(paramName: string, value: number): void;
  24224. /**
  24225. * Specifically change the body's mass option. Won't recreate the physics body object
  24226. * @param mass The mass of the physics imposter
  24227. */
  24228. setMass(mass: number): void;
  24229. /**
  24230. * Gets the linear velocity
  24231. * @returns linear velocity or null
  24232. */
  24233. getLinearVelocity(): Nullable<Vector3>;
  24234. /**
  24235. * Sets the linear velocity
  24236. * @param velocity linear velocity or null
  24237. */
  24238. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24239. /**
  24240. * Gets the angular velocity
  24241. * @returns angular velocity or null
  24242. */
  24243. getAngularVelocity(): Nullable<Vector3>;
  24244. /**
  24245. * Sets the angular velocity
  24246. * @param velocity The velocity or null
  24247. */
  24248. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24249. /**
  24250. * Execute a function with the physics plugin native code
  24251. * Provide a function the will have two variables - the world object and the physics body object
  24252. * @param func The function to execute with the physics plugin native code
  24253. */
  24254. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24255. /**
  24256. * Register a function that will be executed before the physics world is stepping forward
  24257. * @param func The function to execute before the physics world is stepped forward
  24258. */
  24259. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24260. /**
  24261. * Unregister a function that will be executed before the physics world is stepping forward
  24262. * @param func The function to execute before the physics world is stepped forward
  24263. */
  24264. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24265. /**
  24266. * Register a function that will be executed after the physics step
  24267. * @param func The function to execute after physics step
  24268. */
  24269. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24270. /**
  24271. * Unregisters a function that will be executed after the physics step
  24272. * @param func The function to execute after physics step
  24273. */
  24274. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24275. /**
  24276. * register a function that will be executed when this impostor collides against a different body
  24277. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24278. * @param func Callback that is executed on collision
  24279. */
  24280. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24281. /**
  24282. * Unregisters the physics imposter on contact
  24283. * @param collideAgainst The physics object to collide against
  24284. * @param func Callback to execute on collision
  24285. */
  24286. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24287. private _tmpQuat;
  24288. private _tmpQuat2;
  24289. /**
  24290. * Get the parent rotation
  24291. * @returns The parent rotation
  24292. */
  24293. getParentsRotation(): Quaternion;
  24294. /**
  24295. * this function is executed by the physics engine.
  24296. */
  24297. beforeStep: () => void;
  24298. /**
  24299. * this function is executed by the physics engine
  24300. */
  24301. afterStep: () => void;
  24302. /**
  24303. * Legacy collision detection event support
  24304. */
  24305. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24306. /**
  24307. * event and body object due to cannon's event-based architecture.
  24308. */
  24309. onCollide: (e: {
  24310. body: any;
  24311. }) => void;
  24312. /**
  24313. * Apply a force
  24314. * @param force The force to apply
  24315. * @param contactPoint The contact point for the force
  24316. * @returns The physics imposter
  24317. */
  24318. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24319. /**
  24320. * Apply an impulse
  24321. * @param force The impulse force
  24322. * @param contactPoint The contact point for the impulse force
  24323. * @returns The physics imposter
  24324. */
  24325. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24326. /**
  24327. * A help function to create a joint
  24328. * @param otherImpostor A physics imposter used to create a joint
  24329. * @param jointType The type of joint
  24330. * @param jointData The data for the joint
  24331. * @returns The physics imposter
  24332. */
  24333. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24334. /**
  24335. * Add a joint to this impostor with a different impostor
  24336. * @param otherImpostor A physics imposter used to add a joint
  24337. * @param joint The joint to add
  24338. * @returns The physics imposter
  24339. */
  24340. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24341. /**
  24342. * Add an anchor to a cloth impostor
  24343. * @param otherImpostor rigid impostor to anchor to
  24344. * @param width ratio across width from 0 to 1
  24345. * @param height ratio up height from 0 to 1
  24346. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24347. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24348. * @returns impostor the soft imposter
  24349. */
  24350. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24351. /**
  24352. * Add a hook to a rope impostor
  24353. * @param otherImpostor rigid impostor to anchor to
  24354. * @param length ratio across rope from 0 to 1
  24355. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24356. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24357. * @returns impostor the rope imposter
  24358. */
  24359. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24360. /**
  24361. * Will keep this body still, in a sleep mode.
  24362. * @returns the physics imposter
  24363. */
  24364. sleep(): PhysicsImpostor;
  24365. /**
  24366. * Wake the body up.
  24367. * @returns The physics imposter
  24368. */
  24369. wakeUp(): PhysicsImpostor;
  24370. /**
  24371. * Clones the physics imposter
  24372. * @param newObject The physics imposter clones to this physics-enabled object
  24373. * @returns A nullable physics imposter
  24374. */
  24375. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24376. /**
  24377. * Disposes the physics imposter
  24378. */
  24379. dispose(): void;
  24380. /**
  24381. * Sets the delta position
  24382. * @param position The delta position amount
  24383. */
  24384. setDeltaPosition(position: Vector3): void;
  24385. /**
  24386. * Sets the delta rotation
  24387. * @param rotation The delta rotation amount
  24388. */
  24389. setDeltaRotation(rotation: Quaternion): void;
  24390. /**
  24391. * Gets the box size of the physics imposter and stores the result in the input parameter
  24392. * @param result Stores the box size
  24393. * @returns The physics imposter
  24394. */
  24395. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24396. /**
  24397. * Gets the radius of the physics imposter
  24398. * @returns Radius of the physics imposter
  24399. */
  24400. getRadius(): number;
  24401. /**
  24402. * Sync a bone with this impostor
  24403. * @param bone The bone to sync to the impostor.
  24404. * @param boneMesh The mesh that the bone is influencing.
  24405. * @param jointPivot The pivot of the joint / bone in local space.
  24406. * @param distToJoint Optional distance from the impostor to the joint.
  24407. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24408. */
  24409. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24410. /**
  24411. * Sync impostor to a bone
  24412. * @param bone The bone that the impostor will be synced to.
  24413. * @param boneMesh The mesh that the bone is influencing.
  24414. * @param jointPivot The pivot of the joint / bone in local space.
  24415. * @param distToJoint Optional distance from the impostor to the joint.
  24416. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24417. * @param boneAxis Optional vector3 axis the bone is aligned with
  24418. */
  24419. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24420. /**
  24421. * No-Imposter type
  24422. */
  24423. static NoImpostor: number;
  24424. /**
  24425. * Sphere-Imposter type
  24426. */
  24427. static SphereImpostor: number;
  24428. /**
  24429. * Box-Imposter type
  24430. */
  24431. static BoxImpostor: number;
  24432. /**
  24433. * Plane-Imposter type
  24434. */
  24435. static PlaneImpostor: number;
  24436. /**
  24437. * Mesh-imposter type
  24438. */
  24439. static MeshImpostor: number;
  24440. /**
  24441. * Capsule-Impostor type (Ammo.js plugin only)
  24442. */
  24443. static CapsuleImpostor: number;
  24444. /**
  24445. * Cylinder-Imposter type
  24446. */
  24447. static CylinderImpostor: number;
  24448. /**
  24449. * Particle-Imposter type
  24450. */
  24451. static ParticleImpostor: number;
  24452. /**
  24453. * Heightmap-Imposter type
  24454. */
  24455. static HeightmapImpostor: number;
  24456. /**
  24457. * ConvexHull-Impostor type (Ammo.js plugin only)
  24458. */
  24459. static ConvexHullImpostor: number;
  24460. /**
  24461. * Custom-Imposter type (Ammo.js plugin only)
  24462. */
  24463. static CustomImpostor: number;
  24464. /**
  24465. * Rope-Imposter type
  24466. */
  24467. static RopeImpostor: number;
  24468. /**
  24469. * Cloth-Imposter type
  24470. */
  24471. static ClothImpostor: number;
  24472. /**
  24473. * Softbody-Imposter type
  24474. */
  24475. static SoftbodyImpostor: number;
  24476. }
  24477. }
  24478. declare module "babylonjs/Meshes/mesh" {
  24479. import { Observable } from "babylonjs/Misc/observable";
  24480. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24481. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24482. import { Camera } from "babylonjs/Cameras/camera";
  24483. import { Scene } from "babylonjs/scene";
  24484. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24485. import { Color4 } from "babylonjs/Maths/math.color";
  24486. import { Engine } from "babylonjs/Engines/engine";
  24487. import { Node } from "babylonjs/node";
  24488. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24489. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24490. import { Buffer } from "babylonjs/Meshes/buffer";
  24491. import { Geometry } from "babylonjs/Meshes/geometry";
  24492. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24493. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24494. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24495. import { Effect } from "babylonjs/Materials/effect";
  24496. import { Material } from "babylonjs/Materials/material";
  24497. import { Skeleton } from "babylonjs/Bones/skeleton";
  24498. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24499. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24500. import { Path3D } from "babylonjs/Maths/math.path";
  24501. import { Plane } from "babylonjs/Maths/math.plane";
  24502. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24503. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24504. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24505. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24506. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24507. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24508. /**
  24509. * @hidden
  24510. **/
  24511. export class _CreationDataStorage {
  24512. closePath?: boolean;
  24513. closeArray?: boolean;
  24514. idx: number[];
  24515. dashSize: number;
  24516. gapSize: number;
  24517. path3D: Path3D;
  24518. pathArray: Vector3[][];
  24519. arc: number;
  24520. radius: number;
  24521. cap: number;
  24522. tessellation: number;
  24523. }
  24524. /**
  24525. * @hidden
  24526. **/
  24527. class _InstanceDataStorage {
  24528. visibleInstances: any;
  24529. batchCache: _InstancesBatch;
  24530. instancesBufferSize: number;
  24531. instancesBuffer: Nullable<Buffer>;
  24532. instancesData: Float32Array;
  24533. overridenInstanceCount: number;
  24534. isFrozen: boolean;
  24535. previousBatch: Nullable<_InstancesBatch>;
  24536. hardwareInstancedRendering: boolean;
  24537. sideOrientation: number;
  24538. manualUpdate: boolean;
  24539. }
  24540. /**
  24541. * @hidden
  24542. **/
  24543. export class _InstancesBatch {
  24544. mustReturn: boolean;
  24545. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24546. renderSelf: boolean[];
  24547. hardwareInstancedRendering: boolean[];
  24548. }
  24549. /**
  24550. * Class used to represent renderable models
  24551. */
  24552. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24553. /**
  24554. * Mesh side orientation : usually the external or front surface
  24555. */
  24556. static readonly FRONTSIDE: number;
  24557. /**
  24558. * Mesh side orientation : usually the internal or back surface
  24559. */
  24560. static readonly BACKSIDE: number;
  24561. /**
  24562. * Mesh side orientation : both internal and external or front and back surfaces
  24563. */
  24564. static readonly DOUBLESIDE: number;
  24565. /**
  24566. * Mesh side orientation : by default, `FRONTSIDE`
  24567. */
  24568. static readonly DEFAULTSIDE: number;
  24569. /**
  24570. * Mesh cap setting : no cap
  24571. */
  24572. static readonly NO_CAP: number;
  24573. /**
  24574. * Mesh cap setting : one cap at the beginning of the mesh
  24575. */
  24576. static readonly CAP_START: number;
  24577. /**
  24578. * Mesh cap setting : one cap at the end of the mesh
  24579. */
  24580. static readonly CAP_END: number;
  24581. /**
  24582. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24583. */
  24584. static readonly CAP_ALL: number;
  24585. /**
  24586. * Mesh pattern setting : no flip or rotate
  24587. */
  24588. static readonly NO_FLIP: number;
  24589. /**
  24590. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24591. */
  24592. static readonly FLIP_TILE: number;
  24593. /**
  24594. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24595. */
  24596. static readonly ROTATE_TILE: number;
  24597. /**
  24598. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24599. */
  24600. static readonly FLIP_ROW: number;
  24601. /**
  24602. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24603. */
  24604. static readonly ROTATE_ROW: number;
  24605. /**
  24606. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24607. */
  24608. static readonly FLIP_N_ROTATE_TILE: number;
  24609. /**
  24610. * Mesh pattern setting : rotate pattern and rotate
  24611. */
  24612. static readonly FLIP_N_ROTATE_ROW: number;
  24613. /**
  24614. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24615. */
  24616. static readonly CENTER: number;
  24617. /**
  24618. * Mesh tile positioning : part tiles on left
  24619. */
  24620. static readonly LEFT: number;
  24621. /**
  24622. * Mesh tile positioning : part tiles on right
  24623. */
  24624. static readonly RIGHT: number;
  24625. /**
  24626. * Mesh tile positioning : part tiles on top
  24627. */
  24628. static readonly TOP: number;
  24629. /**
  24630. * Mesh tile positioning : part tiles on bottom
  24631. */
  24632. static readonly BOTTOM: number;
  24633. /**
  24634. * Gets the default side orientation.
  24635. * @param orientation the orientation to value to attempt to get
  24636. * @returns the default orientation
  24637. * @hidden
  24638. */
  24639. static _GetDefaultSideOrientation(orientation?: number): number;
  24640. private _internalMeshDataInfo;
  24641. /**
  24642. * An event triggered before rendering the mesh
  24643. */
  24644. readonly onBeforeRenderObservable: Observable<Mesh>;
  24645. /**
  24646. * An event triggered before binding the mesh
  24647. */
  24648. readonly onBeforeBindObservable: Observable<Mesh>;
  24649. /**
  24650. * An event triggered after rendering the mesh
  24651. */
  24652. readonly onAfterRenderObservable: Observable<Mesh>;
  24653. /**
  24654. * An event triggered before drawing the mesh
  24655. */
  24656. readonly onBeforeDrawObservable: Observable<Mesh>;
  24657. private _onBeforeDrawObserver;
  24658. /**
  24659. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24660. */
  24661. onBeforeDraw: () => void;
  24662. readonly hasInstances: boolean;
  24663. /**
  24664. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24665. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24666. */
  24667. delayLoadState: number;
  24668. /**
  24669. * Gets the list of instances created from this mesh
  24670. * it is not supposed to be modified manually.
  24671. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24672. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24673. */
  24674. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24675. /**
  24676. * Gets the file containing delay loading data for this mesh
  24677. */
  24678. delayLoadingFile: string;
  24679. /** @hidden */
  24680. _binaryInfo: any;
  24681. /**
  24682. * User defined function used to change how LOD level selection is done
  24683. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24684. */
  24685. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24686. /**
  24687. * Gets or sets the morph target manager
  24688. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24689. */
  24690. morphTargetManager: Nullable<MorphTargetManager>;
  24691. /** @hidden */
  24692. _creationDataStorage: Nullable<_CreationDataStorage>;
  24693. /** @hidden */
  24694. _geometry: Nullable<Geometry>;
  24695. /** @hidden */
  24696. _delayInfo: Array<string>;
  24697. /** @hidden */
  24698. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24699. /** @hidden */
  24700. _instanceDataStorage: _InstanceDataStorage;
  24701. private _effectiveMaterial;
  24702. /** @hidden */
  24703. _shouldGenerateFlatShading: boolean;
  24704. /** @hidden */
  24705. _originalBuilderSideOrientation: number;
  24706. /**
  24707. * Use this property to change the original side orientation defined at construction time
  24708. */
  24709. overrideMaterialSideOrientation: Nullable<number>;
  24710. /**
  24711. * Gets the source mesh (the one used to clone this one from)
  24712. */
  24713. readonly source: Nullable<Mesh>;
  24714. /**
  24715. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24716. */
  24717. isUnIndexed: boolean;
  24718. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24719. readonly worldMatrixInstancedBuffer: Float32Array;
  24720. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24721. manualUpdateOfWorldMatrixInstancedBuffer: boolean;
  24722. /**
  24723. * @constructor
  24724. * @param name The value used by scene.getMeshByName() to do a lookup.
  24725. * @param scene The scene to add this mesh to.
  24726. * @param parent The parent of this mesh, if it has one
  24727. * @param source An optional Mesh from which geometry is shared, cloned.
  24728. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24729. * When false, achieved by calling a clone(), also passing False.
  24730. * This will make creation of children, recursive.
  24731. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24732. */
  24733. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24734. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24735. doNotInstantiate: boolean;
  24736. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24737. /**
  24738. * Gets the class name
  24739. * @returns the string "Mesh".
  24740. */
  24741. getClassName(): string;
  24742. /** @hidden */
  24743. readonly _isMesh: boolean;
  24744. /**
  24745. * Returns a description of this mesh
  24746. * @param fullDetails define if full details about this mesh must be used
  24747. * @returns a descriptive string representing this mesh
  24748. */
  24749. toString(fullDetails?: boolean): string;
  24750. /** @hidden */
  24751. _unBindEffect(): void;
  24752. /**
  24753. * Gets a boolean indicating if this mesh has LOD
  24754. */
  24755. readonly hasLODLevels: boolean;
  24756. /**
  24757. * Gets the list of MeshLODLevel associated with the current mesh
  24758. * @returns an array of MeshLODLevel
  24759. */
  24760. getLODLevels(): MeshLODLevel[];
  24761. private _sortLODLevels;
  24762. /**
  24763. * Add a mesh as LOD level triggered at the given distance.
  24764. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24765. * @param distance The distance from the center of the object to show this level
  24766. * @param mesh The mesh to be added as LOD level (can be null)
  24767. * @return This mesh (for chaining)
  24768. */
  24769. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24770. /**
  24771. * Returns the LOD level mesh at the passed distance or null if not found.
  24772. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24773. * @param distance The distance from the center of the object to show this level
  24774. * @returns a Mesh or `null`
  24775. */
  24776. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24777. /**
  24778. * Remove a mesh from the LOD array
  24779. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24780. * @param mesh defines the mesh to be removed
  24781. * @return This mesh (for chaining)
  24782. */
  24783. removeLODLevel(mesh: Mesh): Mesh;
  24784. /**
  24785. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24786. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24787. * @param camera defines the camera to use to compute distance
  24788. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24789. * @return This mesh (for chaining)
  24790. */
  24791. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24792. /**
  24793. * Gets the mesh internal Geometry object
  24794. */
  24795. readonly geometry: Nullable<Geometry>;
  24796. /**
  24797. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24798. * @returns the total number of vertices
  24799. */
  24800. getTotalVertices(): number;
  24801. /**
  24802. * Returns the content of an associated vertex buffer
  24803. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24804. * - VertexBuffer.PositionKind
  24805. * - VertexBuffer.UVKind
  24806. * - VertexBuffer.UV2Kind
  24807. * - VertexBuffer.UV3Kind
  24808. * - VertexBuffer.UV4Kind
  24809. * - VertexBuffer.UV5Kind
  24810. * - VertexBuffer.UV6Kind
  24811. * - VertexBuffer.ColorKind
  24812. * - VertexBuffer.MatricesIndicesKind
  24813. * - VertexBuffer.MatricesIndicesExtraKind
  24814. * - VertexBuffer.MatricesWeightsKind
  24815. * - VertexBuffer.MatricesWeightsExtraKind
  24816. * @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
  24817. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24818. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24819. */
  24820. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24821. /**
  24822. * Returns the mesh VertexBuffer object from the requested `kind`
  24823. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24824. * - VertexBuffer.PositionKind
  24825. * - VertexBuffer.NormalKind
  24826. * - VertexBuffer.UVKind
  24827. * - VertexBuffer.UV2Kind
  24828. * - VertexBuffer.UV3Kind
  24829. * - VertexBuffer.UV4Kind
  24830. * - VertexBuffer.UV5Kind
  24831. * - VertexBuffer.UV6Kind
  24832. * - VertexBuffer.ColorKind
  24833. * - VertexBuffer.MatricesIndicesKind
  24834. * - VertexBuffer.MatricesIndicesExtraKind
  24835. * - VertexBuffer.MatricesWeightsKind
  24836. * - VertexBuffer.MatricesWeightsExtraKind
  24837. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24838. */
  24839. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24840. /**
  24841. * Tests if a specific vertex buffer is associated with this mesh
  24842. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24843. * - VertexBuffer.PositionKind
  24844. * - VertexBuffer.NormalKind
  24845. * - VertexBuffer.UVKind
  24846. * - VertexBuffer.UV2Kind
  24847. * - VertexBuffer.UV3Kind
  24848. * - VertexBuffer.UV4Kind
  24849. * - VertexBuffer.UV5Kind
  24850. * - VertexBuffer.UV6Kind
  24851. * - VertexBuffer.ColorKind
  24852. * - VertexBuffer.MatricesIndicesKind
  24853. * - VertexBuffer.MatricesIndicesExtraKind
  24854. * - VertexBuffer.MatricesWeightsKind
  24855. * - VertexBuffer.MatricesWeightsExtraKind
  24856. * @returns a boolean
  24857. */
  24858. isVerticesDataPresent(kind: string): boolean;
  24859. /**
  24860. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24861. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24862. * - VertexBuffer.PositionKind
  24863. * - VertexBuffer.UVKind
  24864. * - VertexBuffer.UV2Kind
  24865. * - VertexBuffer.UV3Kind
  24866. * - VertexBuffer.UV4Kind
  24867. * - VertexBuffer.UV5Kind
  24868. * - VertexBuffer.UV6Kind
  24869. * - VertexBuffer.ColorKind
  24870. * - VertexBuffer.MatricesIndicesKind
  24871. * - VertexBuffer.MatricesIndicesExtraKind
  24872. * - VertexBuffer.MatricesWeightsKind
  24873. * - VertexBuffer.MatricesWeightsExtraKind
  24874. * @returns a boolean
  24875. */
  24876. isVertexBufferUpdatable(kind: string): boolean;
  24877. /**
  24878. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24879. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24880. * - VertexBuffer.PositionKind
  24881. * - VertexBuffer.NormalKind
  24882. * - VertexBuffer.UVKind
  24883. * - VertexBuffer.UV2Kind
  24884. * - VertexBuffer.UV3Kind
  24885. * - VertexBuffer.UV4Kind
  24886. * - VertexBuffer.UV5Kind
  24887. * - VertexBuffer.UV6Kind
  24888. * - VertexBuffer.ColorKind
  24889. * - VertexBuffer.MatricesIndicesKind
  24890. * - VertexBuffer.MatricesIndicesExtraKind
  24891. * - VertexBuffer.MatricesWeightsKind
  24892. * - VertexBuffer.MatricesWeightsExtraKind
  24893. * @returns an array of strings
  24894. */
  24895. getVerticesDataKinds(): string[];
  24896. /**
  24897. * Returns a positive integer : the total number of indices in this mesh geometry.
  24898. * @returns the numner of indices or zero if the mesh has no geometry.
  24899. */
  24900. getTotalIndices(): number;
  24901. /**
  24902. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24903. * @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.
  24904. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24905. * @returns the indices array or an empty array if the mesh has no geometry
  24906. */
  24907. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24908. readonly isBlocked: boolean;
  24909. /**
  24910. * Determine if the current mesh is ready to be rendered
  24911. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24912. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24913. * @returns true if all associated assets are ready (material, textures, shaders)
  24914. */
  24915. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24916. /**
  24917. * 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.
  24918. */
  24919. readonly areNormalsFrozen: boolean;
  24920. /**
  24921. * 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.
  24922. * @returns the current mesh
  24923. */
  24924. freezeNormals(): Mesh;
  24925. /**
  24926. * 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
  24927. * @returns the current mesh
  24928. */
  24929. unfreezeNormals(): Mesh;
  24930. /**
  24931. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24932. */
  24933. overridenInstanceCount: number;
  24934. /** @hidden */
  24935. _preActivate(): Mesh;
  24936. /** @hidden */
  24937. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24938. /** @hidden */
  24939. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24940. /**
  24941. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24942. * This means the mesh underlying bounding box and sphere are recomputed.
  24943. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24944. * @returns the current mesh
  24945. */
  24946. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24947. /** @hidden */
  24948. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24949. /**
  24950. * This function will subdivide the mesh into multiple submeshes
  24951. * @param count defines the expected number of submeshes
  24952. */
  24953. subdivide(count: number): void;
  24954. /**
  24955. * Copy a FloatArray into a specific associated vertex buffer
  24956. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24957. * - VertexBuffer.PositionKind
  24958. * - VertexBuffer.UVKind
  24959. * - VertexBuffer.UV2Kind
  24960. * - VertexBuffer.UV3Kind
  24961. * - VertexBuffer.UV4Kind
  24962. * - VertexBuffer.UV5Kind
  24963. * - VertexBuffer.UV6Kind
  24964. * - VertexBuffer.ColorKind
  24965. * - VertexBuffer.MatricesIndicesKind
  24966. * - VertexBuffer.MatricesIndicesExtraKind
  24967. * - VertexBuffer.MatricesWeightsKind
  24968. * - VertexBuffer.MatricesWeightsExtraKind
  24969. * @param data defines the data source
  24970. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24971. * @param stride defines the data stride size (can be null)
  24972. * @returns the current mesh
  24973. */
  24974. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24975. /**
  24976. * Delete a vertex buffer associated with this mesh
  24977. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24978. * - VertexBuffer.PositionKind
  24979. * - VertexBuffer.UVKind
  24980. * - VertexBuffer.UV2Kind
  24981. * - VertexBuffer.UV3Kind
  24982. * - VertexBuffer.UV4Kind
  24983. * - VertexBuffer.UV5Kind
  24984. * - VertexBuffer.UV6Kind
  24985. * - VertexBuffer.ColorKind
  24986. * - VertexBuffer.MatricesIndicesKind
  24987. * - VertexBuffer.MatricesIndicesExtraKind
  24988. * - VertexBuffer.MatricesWeightsKind
  24989. * - VertexBuffer.MatricesWeightsExtraKind
  24990. */
  24991. removeVerticesData(kind: string): void;
  24992. /**
  24993. * Flags an associated vertex buffer as updatable
  24994. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24995. * - VertexBuffer.PositionKind
  24996. * - VertexBuffer.UVKind
  24997. * - VertexBuffer.UV2Kind
  24998. * - VertexBuffer.UV3Kind
  24999. * - VertexBuffer.UV4Kind
  25000. * - VertexBuffer.UV5Kind
  25001. * - VertexBuffer.UV6Kind
  25002. * - VertexBuffer.ColorKind
  25003. * - VertexBuffer.MatricesIndicesKind
  25004. * - VertexBuffer.MatricesIndicesExtraKind
  25005. * - VertexBuffer.MatricesWeightsKind
  25006. * - VertexBuffer.MatricesWeightsExtraKind
  25007. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25008. */
  25009. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25010. /**
  25011. * Sets the mesh global Vertex Buffer
  25012. * @param buffer defines the buffer to use
  25013. * @returns the current mesh
  25014. */
  25015. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25016. /**
  25017. * Update a specific associated vertex buffer
  25018. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25019. * - VertexBuffer.PositionKind
  25020. * - VertexBuffer.UVKind
  25021. * - VertexBuffer.UV2Kind
  25022. * - VertexBuffer.UV3Kind
  25023. * - VertexBuffer.UV4Kind
  25024. * - VertexBuffer.UV5Kind
  25025. * - VertexBuffer.UV6Kind
  25026. * - VertexBuffer.ColorKind
  25027. * - VertexBuffer.MatricesIndicesKind
  25028. * - VertexBuffer.MatricesIndicesExtraKind
  25029. * - VertexBuffer.MatricesWeightsKind
  25030. * - VertexBuffer.MatricesWeightsExtraKind
  25031. * @param data defines the data source
  25032. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25033. * @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)
  25034. * @returns the current mesh
  25035. */
  25036. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25037. /**
  25038. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25039. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25040. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25041. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25042. * @returns the current mesh
  25043. */
  25044. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25045. /**
  25046. * Creates a un-shared specific occurence of the geometry for the mesh.
  25047. * @returns the current mesh
  25048. */
  25049. makeGeometryUnique(): Mesh;
  25050. /**
  25051. * Set the index buffer of this mesh
  25052. * @param indices defines the source data
  25053. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25054. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25055. * @returns the current mesh
  25056. */
  25057. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25058. /**
  25059. * Update the current index buffer
  25060. * @param indices defines the source data
  25061. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25062. * @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)
  25063. * @returns the current mesh
  25064. */
  25065. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25066. /**
  25067. * Invert the geometry to move from a right handed system to a left handed one.
  25068. * @returns the current mesh
  25069. */
  25070. toLeftHanded(): Mesh;
  25071. /** @hidden */
  25072. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25073. /** @hidden */
  25074. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25075. /**
  25076. * Registers for this mesh a javascript function called just before the rendering process
  25077. * @param func defines the function to call before rendering this mesh
  25078. * @returns the current mesh
  25079. */
  25080. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25081. /**
  25082. * Disposes a previously registered javascript function called before the rendering
  25083. * @param func defines the function to remove
  25084. * @returns the current mesh
  25085. */
  25086. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25087. /**
  25088. * Registers for this mesh a javascript function called just after the rendering is complete
  25089. * @param func defines the function to call after rendering this mesh
  25090. * @returns the current mesh
  25091. */
  25092. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25093. /**
  25094. * Disposes a previously registered javascript function called after the rendering.
  25095. * @param func defines the function to remove
  25096. * @returns the current mesh
  25097. */
  25098. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25099. /** @hidden */
  25100. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25101. /** @hidden */
  25102. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25103. /** @hidden */
  25104. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25105. /** @hidden */
  25106. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25107. /** @hidden */
  25108. _rebuild(): void;
  25109. /** @hidden */
  25110. _freeze(): void;
  25111. /** @hidden */
  25112. _unFreeze(): void;
  25113. /**
  25114. * 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
  25115. * @param subMesh defines the subMesh to render
  25116. * @param enableAlphaMode defines if alpha mode can be changed
  25117. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25118. * @returns the current mesh
  25119. */
  25120. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25121. private _onBeforeDraw;
  25122. /**
  25123. * Renormalize the mesh and patch it up if there are no weights
  25124. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25125. * However in the case of zero weights then we set just a single influence to 1.
  25126. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25127. */
  25128. cleanMatrixWeights(): void;
  25129. private normalizeSkinFourWeights;
  25130. private normalizeSkinWeightsAndExtra;
  25131. /**
  25132. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25133. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25134. * the user know there was an issue with importing the mesh
  25135. * @returns a validation object with skinned, valid and report string
  25136. */
  25137. validateSkinning(): {
  25138. skinned: boolean;
  25139. valid: boolean;
  25140. report: string;
  25141. };
  25142. /** @hidden */
  25143. _checkDelayState(): Mesh;
  25144. private _queueLoad;
  25145. /**
  25146. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25147. * A mesh is in the frustum if its bounding box intersects the frustum
  25148. * @param frustumPlanes defines the frustum to test
  25149. * @returns true if the mesh is in the frustum planes
  25150. */
  25151. isInFrustum(frustumPlanes: Plane[]): boolean;
  25152. /**
  25153. * Sets the mesh material by the material or multiMaterial `id` property
  25154. * @param id is a string identifying the material or the multiMaterial
  25155. * @returns the current mesh
  25156. */
  25157. setMaterialByID(id: string): Mesh;
  25158. /**
  25159. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25160. * @returns an array of IAnimatable
  25161. */
  25162. getAnimatables(): IAnimatable[];
  25163. /**
  25164. * Modifies the mesh geometry according to the passed transformation matrix.
  25165. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25166. * The mesh normals are modified using the same transformation.
  25167. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25168. * @param transform defines the transform matrix to use
  25169. * @see http://doc.babylonjs.com/resources/baking_transformations
  25170. * @returns the current mesh
  25171. */
  25172. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25173. /**
  25174. * Modifies the mesh geometry according to its own current World Matrix.
  25175. * The mesh World Matrix is then reset.
  25176. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25177. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25178. * @see http://doc.babylonjs.com/resources/baking_transformations
  25179. * @returns the current mesh
  25180. */
  25181. bakeCurrentTransformIntoVertices(): Mesh;
  25182. /** @hidden */
  25183. readonly _positions: Nullable<Vector3[]>;
  25184. /** @hidden */
  25185. _resetPointsArrayCache(): Mesh;
  25186. /** @hidden */
  25187. _generatePointsArray(): boolean;
  25188. /**
  25189. * Returns a new Mesh object generated from the current mesh properties.
  25190. * This method must not get confused with createInstance()
  25191. * @param name is a string, the name given to the new mesh
  25192. * @param newParent can be any Node object (default `null`)
  25193. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25194. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25195. * @returns a new mesh
  25196. */
  25197. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  25198. /**
  25199. * Releases resources associated with this mesh.
  25200. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25201. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25202. */
  25203. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25204. /** @hidden */
  25205. _disposeInstanceSpecificData(): void;
  25206. /**
  25207. * Modifies the mesh geometry according to a displacement map.
  25208. * 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.
  25209. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25210. * @param url is a string, the URL from the image file is to be downloaded.
  25211. * @param minHeight is the lower limit of the displacement.
  25212. * @param maxHeight is the upper limit of the displacement.
  25213. * @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.
  25214. * @param uvOffset is an optional vector2 used to offset UV.
  25215. * @param uvScale is an optional vector2 used to scale UV.
  25216. * @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.
  25217. * @returns the Mesh.
  25218. */
  25219. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25220. /**
  25221. * Modifies the mesh geometry according to a displacementMap buffer.
  25222. * 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.
  25223. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25224. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25225. * @param heightMapWidth is the width of the buffer image.
  25226. * @param heightMapHeight is the height of the buffer image.
  25227. * @param minHeight is the lower limit of the displacement.
  25228. * @param maxHeight is the upper limit of the displacement.
  25229. * @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.
  25230. * @param uvOffset is an optional vector2 used to offset UV.
  25231. * @param uvScale is an optional vector2 used to scale UV.
  25232. * @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.
  25233. * @returns the Mesh.
  25234. */
  25235. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25236. /**
  25237. * Modify the mesh to get a flat shading rendering.
  25238. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25239. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25240. * @returns current mesh
  25241. */
  25242. convertToFlatShadedMesh(): Mesh;
  25243. /**
  25244. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25245. * In other words, more vertices, no more indices and a single bigger VBO.
  25246. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25247. * @returns current mesh
  25248. */
  25249. convertToUnIndexedMesh(): Mesh;
  25250. /**
  25251. * Inverses facet orientations.
  25252. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25253. * @param flipNormals will also inverts the normals
  25254. * @returns current mesh
  25255. */
  25256. flipFaces(flipNormals?: boolean): Mesh;
  25257. /**
  25258. * Increase the number of facets and hence vertices in a mesh
  25259. * Vertex normals are interpolated from existing vertex normals
  25260. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25261. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25262. */
  25263. increaseVertices(numberPerEdge: number): void;
  25264. /**
  25265. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25266. * This will undo any application of covertToFlatShadedMesh
  25267. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25268. */
  25269. forceSharedVertices(): void;
  25270. /** @hidden */
  25271. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25272. /** @hidden */
  25273. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25274. /**
  25275. * Creates a new InstancedMesh object from the mesh model.
  25276. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25277. * @param name defines the name of the new instance
  25278. * @returns a new InstancedMesh
  25279. */
  25280. createInstance(name: string): InstancedMesh;
  25281. /**
  25282. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25283. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25284. * @returns the current mesh
  25285. */
  25286. synchronizeInstances(): Mesh;
  25287. /**
  25288. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25289. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25290. * This should be used together with the simplification to avoid disappearing triangles.
  25291. * @param successCallback an optional success callback to be called after the optimization finished.
  25292. * @returns the current mesh
  25293. */
  25294. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25295. /**
  25296. * Serialize current mesh
  25297. * @param serializationObject defines the object which will receive the serialization data
  25298. */
  25299. serialize(serializationObject: any): void;
  25300. /** @hidden */
  25301. _syncGeometryWithMorphTargetManager(): void;
  25302. /** @hidden */
  25303. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25304. /**
  25305. * Returns a new Mesh object parsed from the source provided.
  25306. * @param parsedMesh is the source
  25307. * @param scene defines the hosting scene
  25308. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25309. * @returns a new Mesh
  25310. */
  25311. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25312. /**
  25313. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25314. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25315. * @param name defines the name of the mesh to create
  25316. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25317. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25318. * @param closePath creates a seam between the first and the last points of each path of the path array
  25319. * @param offset is taken in account only if the `pathArray` is containing a single path
  25320. * @param scene defines the hosting scene
  25321. * @param updatable defines if the mesh must be flagged as updatable
  25322. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25323. * @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)
  25324. * @returns a new Mesh
  25325. */
  25326. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25327. /**
  25328. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25329. * @param name defines the name of the mesh to create
  25330. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25331. * @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
  25332. * @param scene defines the hosting scene
  25333. * @param updatable defines if the mesh must be flagged as updatable
  25334. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25335. * @returns a new Mesh
  25336. */
  25337. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25338. /**
  25339. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25340. * @param name defines the name of the mesh to create
  25341. * @param size sets the size (float) of each box side (default 1)
  25342. * @param scene defines the hosting scene
  25343. * @param updatable defines if the mesh must be flagged as updatable
  25344. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25345. * @returns a new Mesh
  25346. */
  25347. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25348. /**
  25349. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25350. * @param name defines the name of the mesh to create
  25351. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25352. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25353. * @param scene defines the hosting scene
  25354. * @param updatable defines if the mesh must be flagged as updatable
  25355. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25356. * @returns a new Mesh
  25357. */
  25358. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25359. /**
  25360. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25361. * @param name defines the name of the mesh to create
  25362. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25363. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25364. * @param scene defines the hosting scene
  25365. * @returns a new Mesh
  25366. */
  25367. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25368. /**
  25369. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25370. * @param name defines the name of the mesh to create
  25371. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25372. * @param diameterTop set the top cap diameter (floats, default 1)
  25373. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25374. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25375. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25376. * @param scene defines the hosting scene
  25377. * @param updatable defines if the mesh must be flagged as updatable
  25378. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25379. * @returns a new Mesh
  25380. */
  25381. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25382. /**
  25383. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25384. * @param name defines the name of the mesh to create
  25385. * @param diameter sets the diameter size (float) of the torus (default 1)
  25386. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25387. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25388. * @param scene defines the hosting scene
  25389. * @param updatable defines if the mesh must be flagged as updatable
  25390. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25391. * @returns a new Mesh
  25392. */
  25393. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25394. /**
  25395. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25396. * @param name defines the name of the mesh to create
  25397. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25398. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25399. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25400. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25401. * @param p the number of windings on X axis (positive integers, default 2)
  25402. * @param q the number of windings on Y axis (positive integers, default 3)
  25403. * @param scene defines the hosting scene
  25404. * @param updatable defines if the mesh must be flagged as updatable
  25405. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25406. * @returns a new Mesh
  25407. */
  25408. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25409. /**
  25410. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25411. * @param name defines the name of the mesh to create
  25412. * @param points is an array successive Vector3
  25413. * @param scene defines the hosting scene
  25414. * @param updatable defines if the mesh must be flagged as updatable
  25415. * @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).
  25416. * @returns a new Mesh
  25417. */
  25418. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25419. /**
  25420. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25421. * @param name defines the name of the mesh to create
  25422. * @param points is an array successive Vector3
  25423. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25424. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25425. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25426. * @param scene defines the hosting scene
  25427. * @param updatable defines if the mesh must be flagged as updatable
  25428. * @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)
  25429. * @returns a new Mesh
  25430. */
  25431. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25432. /**
  25433. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25434. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25435. * 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.
  25436. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25437. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25438. * Remember you can only change the shape positions, not their number when updating a polygon.
  25439. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25440. * @param name defines the name of the mesh to create
  25441. * @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
  25442. * @param scene defines the hosting scene
  25443. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25444. * @param updatable defines if the mesh must be flagged as updatable
  25445. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25446. * @param earcutInjection can be used to inject your own earcut reference
  25447. * @returns a new Mesh
  25448. */
  25449. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25450. /**
  25451. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25452. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25453. * @param name defines the name of the mesh to create
  25454. * @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
  25455. * @param depth defines the height of extrusion
  25456. * @param scene defines the hosting scene
  25457. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25458. * @param updatable defines if the mesh must be flagged as updatable
  25459. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25460. * @param earcutInjection can be used to inject your own earcut reference
  25461. * @returns a new Mesh
  25462. */
  25463. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25464. /**
  25465. * Creates an extruded shape mesh.
  25466. * 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
  25467. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25468. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25469. * @param name defines the name of the mesh to create
  25470. * @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
  25471. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25472. * @param scale is the value to scale the shape
  25473. * @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
  25474. * @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
  25475. * @param scene defines the hosting scene
  25476. * @param updatable defines if the mesh must be flagged as updatable
  25477. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25478. * @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)
  25479. * @returns a new Mesh
  25480. */
  25481. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25482. /**
  25483. * Creates an custom extruded shape mesh.
  25484. * The custom extrusion is a parametric shape.
  25485. * It has no predefined shape. Its final shape will depend on the input parameters.
  25486. * Please consider using the same method from the MeshBuilder class instead
  25487. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25488. * @param name defines the name of the mesh to create
  25489. * @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
  25490. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25491. * @param scaleFunction is a custom Javascript function called on each path point
  25492. * @param rotationFunction is a custom Javascript function called on each path point
  25493. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25494. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25495. * @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
  25496. * @param scene defines the hosting scene
  25497. * @param updatable defines if the mesh must be flagged as updatable
  25498. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25499. * @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)
  25500. * @returns a new Mesh
  25501. */
  25502. 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;
  25503. /**
  25504. * Creates lathe mesh.
  25505. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25506. * Please consider using the same method from the MeshBuilder class instead
  25507. * @param name defines the name of the mesh to create
  25508. * @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
  25509. * @param radius is the radius value of the lathe
  25510. * @param tessellation is the side number of the lathe.
  25511. * @param scene defines the hosting scene
  25512. * @param updatable defines if the mesh must be flagged as updatable
  25513. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25514. * @returns a new Mesh
  25515. */
  25516. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25517. /**
  25518. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25519. * @param name defines the name of the mesh to create
  25520. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25521. * @param scene defines the hosting scene
  25522. * @param updatable defines if the mesh must be flagged as updatable
  25523. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25524. * @returns a new Mesh
  25525. */
  25526. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25527. /**
  25528. * Creates a ground mesh.
  25529. * Please consider using the same method from the MeshBuilder class instead
  25530. * @param name defines the name of the mesh to create
  25531. * @param width set the width of the ground
  25532. * @param height set the height of the ground
  25533. * @param subdivisions sets the number of subdivisions per side
  25534. * @param scene defines the hosting scene
  25535. * @param updatable defines if the mesh must be flagged as updatable
  25536. * @returns a new Mesh
  25537. */
  25538. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25539. /**
  25540. * Creates a tiled ground mesh.
  25541. * Please consider using the same method from the MeshBuilder class instead
  25542. * @param name defines the name of the mesh to create
  25543. * @param xmin set the ground minimum X coordinate
  25544. * @param zmin set the ground minimum Y coordinate
  25545. * @param xmax set the ground maximum X coordinate
  25546. * @param zmax set the ground maximum Z coordinate
  25547. * @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
  25548. * @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
  25549. * @param scene defines the hosting scene
  25550. * @param updatable defines if the mesh must be flagged as updatable
  25551. * @returns a new Mesh
  25552. */
  25553. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25554. w: number;
  25555. h: number;
  25556. }, precision: {
  25557. w: number;
  25558. h: number;
  25559. }, scene: Scene, updatable?: boolean): Mesh;
  25560. /**
  25561. * Creates a ground mesh from a height map.
  25562. * Please consider using the same method from the MeshBuilder class instead
  25563. * @see http://doc.babylonjs.com/babylon101/height_map
  25564. * @param name defines the name of the mesh to create
  25565. * @param url sets the URL of the height map image resource
  25566. * @param width set the ground width size
  25567. * @param height set the ground height size
  25568. * @param subdivisions sets the number of subdivision per side
  25569. * @param minHeight is the minimum altitude on the ground
  25570. * @param maxHeight is the maximum altitude on the ground
  25571. * @param scene defines the hosting scene
  25572. * @param updatable defines if the mesh must be flagged as updatable
  25573. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25574. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25575. * @returns a new Mesh
  25576. */
  25577. 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;
  25578. /**
  25579. * Creates a tube mesh.
  25580. * The tube is a parametric shape.
  25581. * It has no predefined shape. Its final shape will depend on the input parameters.
  25582. * Please consider using the same method from the MeshBuilder class instead
  25583. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25584. * @param name defines the name of the mesh to create
  25585. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25586. * @param radius sets the tube radius size
  25587. * @param tessellation is the number of sides on the tubular surface
  25588. * @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
  25589. * @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
  25590. * @param scene defines the hosting scene
  25591. * @param updatable defines if the mesh must be flagged as updatable
  25592. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25593. * @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)
  25594. * @returns a new Mesh
  25595. */
  25596. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25597. (i: number, distance: number): number;
  25598. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25599. /**
  25600. * Creates a polyhedron mesh.
  25601. * Please consider using the same method from the MeshBuilder class instead.
  25602. * * 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
  25603. * * The parameter `size` (positive float, default 1) sets the polygon size
  25604. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25605. * * 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`
  25606. * * 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
  25607. * * 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)`)
  25608. * * 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
  25609. * * 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
  25610. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25611. * * If you create a double-sided mesh, you can choose what parts of 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
  25612. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25613. * @param name defines the name of the mesh to create
  25614. * @param options defines the options used to create the mesh
  25615. * @param scene defines the hosting scene
  25616. * @returns a new Mesh
  25617. */
  25618. static CreatePolyhedron(name: string, options: {
  25619. type?: number;
  25620. size?: number;
  25621. sizeX?: number;
  25622. sizeY?: number;
  25623. sizeZ?: number;
  25624. custom?: any;
  25625. faceUV?: Vector4[];
  25626. faceColors?: Color4[];
  25627. updatable?: boolean;
  25628. sideOrientation?: number;
  25629. }, scene: Scene): Mesh;
  25630. /**
  25631. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25632. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25633. * * 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`)
  25634. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25635. * * 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
  25636. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25637. * * If you create a double-sided mesh, you can choose what parts of 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
  25638. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25639. * @param name defines the name of the mesh
  25640. * @param options defines the options used to create the mesh
  25641. * @param scene defines the hosting scene
  25642. * @returns a new Mesh
  25643. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25644. */
  25645. static CreateIcoSphere(name: string, options: {
  25646. radius?: number;
  25647. flat?: boolean;
  25648. subdivisions?: number;
  25649. sideOrientation?: number;
  25650. updatable?: boolean;
  25651. }, scene: Scene): Mesh;
  25652. /**
  25653. * Creates a decal mesh.
  25654. * Please consider using the same method from the MeshBuilder class instead.
  25655. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25656. * @param name defines the name of the mesh
  25657. * @param sourceMesh defines the mesh receiving the decal
  25658. * @param position sets the position of the decal in world coordinates
  25659. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25660. * @param size sets the decal scaling
  25661. * @param angle sets the angle to rotate the decal
  25662. * @returns a new Mesh
  25663. */
  25664. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25665. /**
  25666. * Prepare internal position array for software CPU skinning
  25667. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25668. */
  25669. setPositionsForCPUSkinning(): Float32Array;
  25670. /**
  25671. * Prepare internal normal array for software CPU skinning
  25672. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25673. */
  25674. setNormalsForCPUSkinning(): Float32Array;
  25675. /**
  25676. * Updates the vertex buffer by applying transformation from the bones
  25677. * @param skeleton defines the skeleton to apply to current mesh
  25678. * @returns the current mesh
  25679. */
  25680. applySkeleton(skeleton: Skeleton): Mesh;
  25681. /**
  25682. * 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
  25683. * @param meshes defines the list of meshes to scan
  25684. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25685. */
  25686. static MinMax(meshes: AbstractMesh[]): {
  25687. min: Vector3;
  25688. max: Vector3;
  25689. };
  25690. /**
  25691. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25692. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25693. * @returns a vector3
  25694. */
  25695. static Center(meshesOrMinMaxVector: {
  25696. min: Vector3;
  25697. max: Vector3;
  25698. } | AbstractMesh[]): Vector3;
  25699. /**
  25700. * Merge the array of meshes into a single mesh for performance reasons.
  25701. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25702. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25703. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25704. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25705. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25706. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25707. * @returns a new mesh
  25708. */
  25709. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25710. /** @hidden */
  25711. addInstance(instance: InstancedMesh): void;
  25712. /** @hidden */
  25713. removeInstance(instance: InstancedMesh): void;
  25714. }
  25715. }
  25716. declare module "babylonjs/Cameras/camera" {
  25717. import { SmartArray } from "babylonjs/Misc/smartArray";
  25718. import { Observable } from "babylonjs/Misc/observable";
  25719. import { Nullable } from "babylonjs/types";
  25720. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25721. import { Scene } from "babylonjs/scene";
  25722. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25723. import { Node } from "babylonjs/node";
  25724. import { Mesh } from "babylonjs/Meshes/mesh";
  25725. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25726. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25727. import { Viewport } from "babylonjs/Maths/math.viewport";
  25728. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25729. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25730. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25731. import { Ray } from "babylonjs/Culling/ray";
  25732. /**
  25733. * This is the base class of all the camera used in the application.
  25734. * @see http://doc.babylonjs.com/features/cameras
  25735. */
  25736. export class Camera extends Node {
  25737. /** @hidden */
  25738. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25739. /**
  25740. * This is the default projection mode used by the cameras.
  25741. * It helps recreating a feeling of perspective and better appreciate depth.
  25742. * This is the best way to simulate real life cameras.
  25743. */
  25744. static readonly PERSPECTIVE_CAMERA: number;
  25745. /**
  25746. * This helps creating camera with an orthographic mode.
  25747. * 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.
  25748. */
  25749. static readonly ORTHOGRAPHIC_CAMERA: number;
  25750. /**
  25751. * This is the default FOV mode for perspective cameras.
  25752. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25753. */
  25754. static readonly FOVMODE_VERTICAL_FIXED: number;
  25755. /**
  25756. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25757. */
  25758. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25759. /**
  25760. * This specifies ther is no need for a camera rig.
  25761. * Basically only one eye is rendered corresponding to the camera.
  25762. */
  25763. static readonly RIG_MODE_NONE: number;
  25764. /**
  25765. * Simulates a camera Rig with one blue eye and one red eye.
  25766. * This can be use with 3d blue and red glasses.
  25767. */
  25768. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25769. /**
  25770. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25771. */
  25772. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25773. /**
  25774. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25775. */
  25776. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25777. /**
  25778. * Defines that both eyes of the camera will be rendered over under each other.
  25779. */
  25780. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25781. /**
  25782. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25783. */
  25784. static readonly RIG_MODE_VR: number;
  25785. /**
  25786. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25787. */
  25788. static readonly RIG_MODE_WEBVR: number;
  25789. /**
  25790. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25791. */
  25792. static readonly RIG_MODE_CUSTOM: number;
  25793. /**
  25794. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25795. */
  25796. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25797. /**
  25798. * Define the input manager associated with the camera.
  25799. */
  25800. inputs: CameraInputsManager<Camera>;
  25801. /** @hidden */
  25802. _position: Vector3;
  25803. /**
  25804. * Define the current local position of the camera in the scene
  25805. */
  25806. position: Vector3;
  25807. /**
  25808. * The vector the camera should consider as up.
  25809. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25810. */
  25811. upVector: Vector3;
  25812. /**
  25813. * Define the current limit on the left side for an orthographic camera
  25814. * In scene unit
  25815. */
  25816. orthoLeft: Nullable<number>;
  25817. /**
  25818. * Define the current limit on the right side for an orthographic camera
  25819. * In scene unit
  25820. */
  25821. orthoRight: Nullable<number>;
  25822. /**
  25823. * Define the current limit on the bottom side for an orthographic camera
  25824. * In scene unit
  25825. */
  25826. orthoBottom: Nullable<number>;
  25827. /**
  25828. * Define the current limit on the top side for an orthographic camera
  25829. * In scene unit
  25830. */
  25831. orthoTop: Nullable<number>;
  25832. /**
  25833. * Field Of View is set in Radians. (default is 0.8)
  25834. */
  25835. fov: number;
  25836. /**
  25837. * Define the minimum distance the camera can see from.
  25838. * This is important to note that the depth buffer are not infinite and the closer it starts
  25839. * the more your scene might encounter depth fighting issue.
  25840. */
  25841. minZ: number;
  25842. /**
  25843. * Define the maximum distance the camera can see to.
  25844. * This is important to note that the depth buffer are not infinite and the further it end
  25845. * the more your scene might encounter depth fighting issue.
  25846. */
  25847. maxZ: number;
  25848. /**
  25849. * Define the default inertia of the camera.
  25850. * This helps giving a smooth feeling to the camera movement.
  25851. */
  25852. inertia: number;
  25853. /**
  25854. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25855. */
  25856. mode: number;
  25857. /**
  25858. * Define wether the camera is intermediate.
  25859. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25860. */
  25861. isIntermediate: boolean;
  25862. /**
  25863. * Define the viewport of the camera.
  25864. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25865. */
  25866. viewport: Viewport;
  25867. /**
  25868. * Restricts the camera to viewing objects with the same layerMask.
  25869. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25870. */
  25871. layerMask: number;
  25872. /**
  25873. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25874. */
  25875. fovMode: number;
  25876. /**
  25877. * Rig mode of the camera.
  25878. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25879. * This is normally controlled byt the camera themselves as internal use.
  25880. */
  25881. cameraRigMode: number;
  25882. /**
  25883. * Defines the distance between both "eyes" in case of a RIG
  25884. */
  25885. interaxialDistance: number;
  25886. /**
  25887. * Defines if stereoscopic rendering is done side by side or over under.
  25888. */
  25889. isStereoscopicSideBySide: boolean;
  25890. /**
  25891. * 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
  25892. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25893. * else in the scene. (Eg. security camera)
  25894. *
  25895. * 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)
  25896. */
  25897. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25898. /**
  25899. * When set, the camera will render to this render target instead of the default canvas
  25900. *
  25901. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25902. */
  25903. outputRenderTarget: Nullable<RenderTargetTexture>;
  25904. /**
  25905. * Observable triggered when the camera view matrix has changed.
  25906. */
  25907. onViewMatrixChangedObservable: Observable<Camera>;
  25908. /**
  25909. * Observable triggered when the camera Projection matrix has changed.
  25910. */
  25911. onProjectionMatrixChangedObservable: Observable<Camera>;
  25912. /**
  25913. * Observable triggered when the inputs have been processed.
  25914. */
  25915. onAfterCheckInputsObservable: Observable<Camera>;
  25916. /**
  25917. * Observable triggered when reset has been called and applied to the camera.
  25918. */
  25919. onRestoreStateObservable: Observable<Camera>;
  25920. /** @hidden */
  25921. _cameraRigParams: any;
  25922. /** @hidden */
  25923. _rigCameras: Camera[];
  25924. /** @hidden */
  25925. _rigPostProcess: Nullable<PostProcess>;
  25926. protected _webvrViewMatrix: Matrix;
  25927. /** @hidden */
  25928. _skipRendering: boolean;
  25929. /** @hidden */
  25930. _projectionMatrix: Matrix;
  25931. /** @hidden */
  25932. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25933. /** @hidden */
  25934. _activeMeshes: SmartArray<AbstractMesh>;
  25935. protected _globalPosition: Vector3;
  25936. /** @hidden */
  25937. _computedViewMatrix: Matrix;
  25938. private _doNotComputeProjectionMatrix;
  25939. private _transformMatrix;
  25940. private _frustumPlanes;
  25941. private _refreshFrustumPlanes;
  25942. private _storedFov;
  25943. private _stateStored;
  25944. /**
  25945. * Instantiates a new camera object.
  25946. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25947. * @see http://doc.babylonjs.com/features/cameras
  25948. * @param name Defines the name of the camera in the scene
  25949. * @param position Defines the position of the camera
  25950. * @param scene Defines the scene the camera belongs too
  25951. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25952. */
  25953. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25954. /**
  25955. * Store current camera state (fov, position, etc..)
  25956. * @returns the camera
  25957. */
  25958. storeState(): Camera;
  25959. /**
  25960. * Restores the camera state values if it has been stored. You must call storeState() first
  25961. */
  25962. protected _restoreStateValues(): boolean;
  25963. /**
  25964. * Restored camera state. You must call storeState() first.
  25965. * @returns true if restored and false otherwise
  25966. */
  25967. restoreState(): boolean;
  25968. /**
  25969. * Gets the class name of the camera.
  25970. * @returns the class name
  25971. */
  25972. getClassName(): string;
  25973. /** @hidden */
  25974. readonly _isCamera: boolean;
  25975. /**
  25976. * Gets a string representation of the camera useful for debug purpose.
  25977. * @param fullDetails Defines that a more verboe level of logging is required
  25978. * @returns the string representation
  25979. */
  25980. toString(fullDetails?: boolean): string;
  25981. /**
  25982. * Gets the current world space position of the camera.
  25983. */
  25984. readonly globalPosition: Vector3;
  25985. /**
  25986. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25987. * @returns the active meshe list
  25988. */
  25989. getActiveMeshes(): SmartArray<AbstractMesh>;
  25990. /**
  25991. * Check wether a mesh is part of the current active mesh list of the camera
  25992. * @param mesh Defines the mesh to check
  25993. * @returns true if active, false otherwise
  25994. */
  25995. isActiveMesh(mesh: Mesh): boolean;
  25996. /**
  25997. * Is this camera ready to be used/rendered
  25998. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25999. * @return true if the camera is ready
  26000. */
  26001. isReady(completeCheck?: boolean): boolean;
  26002. /** @hidden */
  26003. _initCache(): void;
  26004. /** @hidden */
  26005. _updateCache(ignoreParentClass?: boolean): void;
  26006. /** @hidden */
  26007. _isSynchronized(): boolean;
  26008. /** @hidden */
  26009. _isSynchronizedViewMatrix(): boolean;
  26010. /** @hidden */
  26011. _isSynchronizedProjectionMatrix(): boolean;
  26012. /**
  26013. * Attach the input controls to a specific dom element to get the input from.
  26014. * @param element Defines the element the controls should be listened from
  26015. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26016. */
  26017. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26018. /**
  26019. * Detach the current controls from the specified dom element.
  26020. * @param element Defines the element to stop listening the inputs from
  26021. */
  26022. detachControl(element: HTMLElement): void;
  26023. /**
  26024. * Update the camera state according to the different inputs gathered during the frame.
  26025. */
  26026. update(): void;
  26027. /** @hidden */
  26028. _checkInputs(): void;
  26029. /** @hidden */
  26030. readonly rigCameras: Camera[];
  26031. /**
  26032. * Gets the post process used by the rig cameras
  26033. */
  26034. readonly rigPostProcess: Nullable<PostProcess>;
  26035. /**
  26036. * Internal, gets the first post proces.
  26037. * @returns the first post process to be run on this camera.
  26038. */
  26039. _getFirstPostProcess(): Nullable<PostProcess>;
  26040. private _cascadePostProcessesToRigCams;
  26041. /**
  26042. * Attach a post process to the camera.
  26043. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26044. * @param postProcess The post process to attach to the camera
  26045. * @param insertAt The position of the post process in case several of them are in use in the scene
  26046. * @returns the position the post process has been inserted at
  26047. */
  26048. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26049. /**
  26050. * Detach a post process to the camera.
  26051. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26052. * @param postProcess The post process to detach from the camera
  26053. */
  26054. detachPostProcess(postProcess: PostProcess): void;
  26055. /**
  26056. * Gets the current world matrix of the camera
  26057. */
  26058. getWorldMatrix(): Matrix;
  26059. /** @hidden */
  26060. _getViewMatrix(): Matrix;
  26061. /**
  26062. * Gets the current view matrix of the camera.
  26063. * @param force forces the camera to recompute the matrix without looking at the cached state
  26064. * @returns the view matrix
  26065. */
  26066. getViewMatrix(force?: boolean): Matrix;
  26067. /**
  26068. * Freeze the projection matrix.
  26069. * It will prevent the cache check of the camera projection compute and can speed up perf
  26070. * if no parameter of the camera are meant to change
  26071. * @param projection Defines manually a projection if necessary
  26072. */
  26073. freezeProjectionMatrix(projection?: Matrix): void;
  26074. /**
  26075. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26076. */
  26077. unfreezeProjectionMatrix(): void;
  26078. /**
  26079. * Gets the current projection matrix of the camera.
  26080. * @param force forces the camera to recompute the matrix without looking at the cached state
  26081. * @returns the projection matrix
  26082. */
  26083. getProjectionMatrix(force?: boolean): Matrix;
  26084. /**
  26085. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26086. * @returns a Matrix
  26087. */
  26088. getTransformationMatrix(): Matrix;
  26089. private _updateFrustumPlanes;
  26090. /**
  26091. * Checks if a cullable object (mesh...) is in the camera frustum
  26092. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26093. * @param target The object to check
  26094. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26095. * @returns true if the object is in frustum otherwise false
  26096. */
  26097. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26098. /**
  26099. * Checks if a cullable object (mesh...) is in the camera frustum
  26100. * Unlike isInFrustum this cheks the full bounding box
  26101. * @param target The object to check
  26102. * @returns true if the object is in frustum otherwise false
  26103. */
  26104. isCompletelyInFrustum(target: ICullable): boolean;
  26105. /**
  26106. * Gets a ray in the forward direction from the camera.
  26107. * @param length Defines the length of the ray to create
  26108. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26109. * @param origin Defines the start point of the ray which defaults to the camera position
  26110. * @returns the forward ray
  26111. */
  26112. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26113. /**
  26114. * Releases resources associated with this node.
  26115. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26116. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26117. */
  26118. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26119. /** @hidden */
  26120. _isLeftCamera: boolean;
  26121. /**
  26122. * Gets the left camera of a rig setup in case of Rigged Camera
  26123. */
  26124. readonly isLeftCamera: boolean;
  26125. /** @hidden */
  26126. _isRightCamera: boolean;
  26127. /**
  26128. * Gets the right camera of a rig setup in case of Rigged Camera
  26129. */
  26130. readonly isRightCamera: boolean;
  26131. /**
  26132. * Gets the left camera of a rig setup in case of Rigged Camera
  26133. */
  26134. readonly leftCamera: Nullable<FreeCamera>;
  26135. /**
  26136. * Gets the right camera of a rig setup in case of Rigged Camera
  26137. */
  26138. readonly rightCamera: Nullable<FreeCamera>;
  26139. /**
  26140. * Gets the left camera target of a rig setup in case of Rigged Camera
  26141. * @returns the target position
  26142. */
  26143. getLeftTarget(): Nullable<Vector3>;
  26144. /**
  26145. * Gets the right camera target of a rig setup in case of Rigged Camera
  26146. * @returns the target position
  26147. */
  26148. getRightTarget(): Nullable<Vector3>;
  26149. /**
  26150. * @hidden
  26151. */
  26152. setCameraRigMode(mode: number, rigParams: any): void;
  26153. /** @hidden */
  26154. static _setStereoscopicRigMode(camera: Camera): void;
  26155. /** @hidden */
  26156. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26157. /** @hidden */
  26158. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26159. /** @hidden */
  26160. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26161. /** @hidden */
  26162. _getVRProjectionMatrix(): Matrix;
  26163. protected _updateCameraRotationMatrix(): void;
  26164. protected _updateWebVRCameraRotationMatrix(): void;
  26165. /**
  26166. * This function MUST be overwritten by the different WebVR cameras available.
  26167. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26168. * @hidden
  26169. */
  26170. _getWebVRProjectionMatrix(): Matrix;
  26171. /**
  26172. * This function MUST be overwritten by the different WebVR cameras available.
  26173. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26174. * @hidden
  26175. */
  26176. _getWebVRViewMatrix(): Matrix;
  26177. /** @hidden */
  26178. setCameraRigParameter(name: string, value: any): void;
  26179. /**
  26180. * needs to be overridden by children so sub has required properties to be copied
  26181. * @hidden
  26182. */
  26183. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26184. /**
  26185. * May need to be overridden by children
  26186. * @hidden
  26187. */
  26188. _updateRigCameras(): void;
  26189. /** @hidden */
  26190. _setupInputs(): void;
  26191. /**
  26192. * Serialiaze the camera setup to a json represention
  26193. * @returns the JSON representation
  26194. */
  26195. serialize(): any;
  26196. /**
  26197. * Clones the current camera.
  26198. * @param name The cloned camera name
  26199. * @returns the cloned camera
  26200. */
  26201. clone(name: string): Camera;
  26202. /**
  26203. * Gets the direction of the camera relative to a given local axis.
  26204. * @param localAxis Defines the reference axis to provide a relative direction.
  26205. * @return the direction
  26206. */
  26207. getDirection(localAxis: Vector3): Vector3;
  26208. /**
  26209. * Returns the current camera absolute rotation
  26210. */
  26211. readonly absoluteRotation: Quaternion;
  26212. /**
  26213. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26214. * @param localAxis Defines the reference axis to provide a relative direction.
  26215. * @param result Defines the vector to store the result in
  26216. */
  26217. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26218. /**
  26219. * Gets a camera constructor for a given camera type
  26220. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26221. * @param name The name of the camera the result will be able to instantiate
  26222. * @param scene The scene the result will construct the camera in
  26223. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26224. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26225. * @returns a factory method to construc the camera
  26226. */
  26227. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26228. /**
  26229. * Compute the world matrix of the camera.
  26230. * @returns the camera world matrix
  26231. */
  26232. computeWorldMatrix(): Matrix;
  26233. /**
  26234. * Parse a JSON and creates the camera from the parsed information
  26235. * @param parsedCamera The JSON to parse
  26236. * @param scene The scene to instantiate the camera in
  26237. * @returns the newly constructed camera
  26238. */
  26239. static Parse(parsedCamera: any, scene: Scene): Camera;
  26240. }
  26241. }
  26242. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26243. import { Nullable } from "babylonjs/types";
  26244. import { Scene } from "babylonjs/scene";
  26245. import { Vector4 } from "babylonjs/Maths/math.vector";
  26246. import { Mesh } from "babylonjs/Meshes/mesh";
  26247. /**
  26248. * Class containing static functions to help procedurally build meshes
  26249. */
  26250. export class DiscBuilder {
  26251. /**
  26252. * Creates a plane polygonal mesh. By default, this is a disc
  26253. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26254. * * 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
  26255. * * 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
  26256. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26257. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26258. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26259. * @param name defines the name of the mesh
  26260. * @param options defines the options used to create the mesh
  26261. * @param scene defines the hosting scene
  26262. * @returns the plane polygonal mesh
  26263. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26264. */
  26265. static CreateDisc(name: string, options: {
  26266. radius?: number;
  26267. tessellation?: number;
  26268. arc?: number;
  26269. updatable?: boolean;
  26270. sideOrientation?: number;
  26271. frontUVs?: Vector4;
  26272. backUVs?: Vector4;
  26273. }, scene?: Nullable<Scene>): Mesh;
  26274. }
  26275. }
  26276. declare module "babylonjs/Materials/fresnelParameters" {
  26277. import { Color3 } from "babylonjs/Maths/math.color";
  26278. /**
  26279. * This represents all the required information to add a fresnel effect on a material:
  26280. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26281. */
  26282. export class FresnelParameters {
  26283. private _isEnabled;
  26284. /**
  26285. * Define if the fresnel effect is enable or not.
  26286. */
  26287. isEnabled: boolean;
  26288. /**
  26289. * Define the color used on edges (grazing angle)
  26290. */
  26291. leftColor: Color3;
  26292. /**
  26293. * Define the color used on center
  26294. */
  26295. rightColor: Color3;
  26296. /**
  26297. * Define bias applied to computed fresnel term
  26298. */
  26299. bias: number;
  26300. /**
  26301. * Defined the power exponent applied to fresnel term
  26302. */
  26303. power: number;
  26304. /**
  26305. * Clones the current fresnel and its valuues
  26306. * @returns a clone fresnel configuration
  26307. */
  26308. clone(): FresnelParameters;
  26309. /**
  26310. * Serializes the current fresnel parameters to a JSON representation.
  26311. * @return the JSON serialization
  26312. */
  26313. serialize(): any;
  26314. /**
  26315. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26316. * @param parsedFresnelParameters Define the JSON representation
  26317. * @returns the parsed parameters
  26318. */
  26319. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26320. }
  26321. }
  26322. declare module "babylonjs/Materials/pushMaterial" {
  26323. import { Nullable } from "babylonjs/types";
  26324. import { Scene } from "babylonjs/scene";
  26325. import { Matrix } from "babylonjs/Maths/math.vector";
  26326. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26327. import { Mesh } from "babylonjs/Meshes/mesh";
  26328. import { Material } from "babylonjs/Materials/material";
  26329. import { Effect } from "babylonjs/Materials/effect";
  26330. /**
  26331. * Base class of materials working in push mode in babylon JS
  26332. * @hidden
  26333. */
  26334. export class PushMaterial extends Material {
  26335. protected _activeEffect: Effect;
  26336. protected _normalMatrix: Matrix;
  26337. /**
  26338. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26339. * This means that the material can keep using a previous shader while a new one is being compiled.
  26340. * This is mostly used when shader parallel compilation is supported (true by default)
  26341. */
  26342. allowShaderHotSwapping: boolean;
  26343. constructor(name: string, scene: Scene);
  26344. getEffect(): Effect;
  26345. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26346. /**
  26347. * Binds the given world matrix to the active effect
  26348. *
  26349. * @param world the matrix to bind
  26350. */
  26351. bindOnlyWorldMatrix(world: Matrix): void;
  26352. /**
  26353. * Binds the given normal matrix to the active effect
  26354. *
  26355. * @param normalMatrix the matrix to bind
  26356. */
  26357. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26358. bind(world: Matrix, mesh?: Mesh): void;
  26359. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26360. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26361. }
  26362. }
  26363. declare module "babylonjs/Materials/materialFlags" {
  26364. /**
  26365. * This groups all the flags used to control the materials channel.
  26366. */
  26367. export class MaterialFlags {
  26368. private static _DiffuseTextureEnabled;
  26369. /**
  26370. * Are diffuse textures enabled in the application.
  26371. */
  26372. static DiffuseTextureEnabled: boolean;
  26373. private static _AmbientTextureEnabled;
  26374. /**
  26375. * Are ambient textures enabled in the application.
  26376. */
  26377. static AmbientTextureEnabled: boolean;
  26378. private static _OpacityTextureEnabled;
  26379. /**
  26380. * Are opacity textures enabled in the application.
  26381. */
  26382. static OpacityTextureEnabled: boolean;
  26383. private static _ReflectionTextureEnabled;
  26384. /**
  26385. * Are reflection textures enabled in the application.
  26386. */
  26387. static ReflectionTextureEnabled: boolean;
  26388. private static _EmissiveTextureEnabled;
  26389. /**
  26390. * Are emissive textures enabled in the application.
  26391. */
  26392. static EmissiveTextureEnabled: boolean;
  26393. private static _SpecularTextureEnabled;
  26394. /**
  26395. * Are specular textures enabled in the application.
  26396. */
  26397. static SpecularTextureEnabled: boolean;
  26398. private static _BumpTextureEnabled;
  26399. /**
  26400. * Are bump textures enabled in the application.
  26401. */
  26402. static BumpTextureEnabled: boolean;
  26403. private static _LightmapTextureEnabled;
  26404. /**
  26405. * Are lightmap textures enabled in the application.
  26406. */
  26407. static LightmapTextureEnabled: boolean;
  26408. private static _RefractionTextureEnabled;
  26409. /**
  26410. * Are refraction textures enabled in the application.
  26411. */
  26412. static RefractionTextureEnabled: boolean;
  26413. private static _ColorGradingTextureEnabled;
  26414. /**
  26415. * Are color grading textures enabled in the application.
  26416. */
  26417. static ColorGradingTextureEnabled: boolean;
  26418. private static _FresnelEnabled;
  26419. /**
  26420. * Are fresnels enabled in the application.
  26421. */
  26422. static FresnelEnabled: boolean;
  26423. private static _ClearCoatTextureEnabled;
  26424. /**
  26425. * Are clear coat textures enabled in the application.
  26426. */
  26427. static ClearCoatTextureEnabled: boolean;
  26428. private static _ClearCoatBumpTextureEnabled;
  26429. /**
  26430. * Are clear coat bump textures enabled in the application.
  26431. */
  26432. static ClearCoatBumpTextureEnabled: boolean;
  26433. private static _ClearCoatTintTextureEnabled;
  26434. /**
  26435. * Are clear coat tint textures enabled in the application.
  26436. */
  26437. static ClearCoatTintTextureEnabled: boolean;
  26438. private static _SheenTextureEnabled;
  26439. /**
  26440. * Are sheen textures enabled in the application.
  26441. */
  26442. static SheenTextureEnabled: boolean;
  26443. private static _AnisotropicTextureEnabled;
  26444. /**
  26445. * Are anisotropic textures enabled in the application.
  26446. */
  26447. static AnisotropicTextureEnabled: boolean;
  26448. private static _ThicknessTextureEnabled;
  26449. /**
  26450. * Are thickness textures enabled in the application.
  26451. */
  26452. static ThicknessTextureEnabled: boolean;
  26453. }
  26454. }
  26455. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  26456. /** @hidden */
  26457. export var defaultFragmentDeclaration: {
  26458. name: string;
  26459. shader: string;
  26460. };
  26461. }
  26462. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  26463. /** @hidden */
  26464. export var defaultUboDeclaration: {
  26465. name: string;
  26466. shader: string;
  26467. };
  26468. }
  26469. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  26470. /** @hidden */
  26471. export var lightFragmentDeclaration: {
  26472. name: string;
  26473. shader: string;
  26474. };
  26475. }
  26476. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  26477. /** @hidden */
  26478. export var lightUboDeclaration: {
  26479. name: string;
  26480. shader: string;
  26481. };
  26482. }
  26483. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  26484. /** @hidden */
  26485. export var lightsFragmentFunctions: {
  26486. name: string;
  26487. shader: string;
  26488. };
  26489. }
  26490. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  26491. /** @hidden */
  26492. export var shadowsFragmentFunctions: {
  26493. name: string;
  26494. shader: string;
  26495. };
  26496. }
  26497. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  26498. /** @hidden */
  26499. export var fresnelFunction: {
  26500. name: string;
  26501. shader: string;
  26502. };
  26503. }
  26504. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  26505. /** @hidden */
  26506. export var reflectionFunction: {
  26507. name: string;
  26508. shader: string;
  26509. };
  26510. }
  26511. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  26512. /** @hidden */
  26513. export var bumpFragmentFunctions: {
  26514. name: string;
  26515. shader: string;
  26516. };
  26517. }
  26518. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  26519. /** @hidden */
  26520. export var logDepthDeclaration: {
  26521. name: string;
  26522. shader: string;
  26523. };
  26524. }
  26525. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  26526. /** @hidden */
  26527. export var bumpFragment: {
  26528. name: string;
  26529. shader: string;
  26530. };
  26531. }
  26532. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  26533. /** @hidden */
  26534. export var depthPrePass: {
  26535. name: string;
  26536. shader: string;
  26537. };
  26538. }
  26539. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  26540. /** @hidden */
  26541. export var lightFragment: {
  26542. name: string;
  26543. shader: string;
  26544. };
  26545. }
  26546. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  26547. /** @hidden */
  26548. export var logDepthFragment: {
  26549. name: string;
  26550. shader: string;
  26551. };
  26552. }
  26553. declare module "babylonjs/Shaders/default.fragment" {
  26554. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  26555. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26556. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26557. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26558. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26559. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  26560. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  26561. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  26562. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  26563. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  26564. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  26565. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  26566. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  26567. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26568. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  26569. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  26570. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  26571. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  26572. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  26573. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  26574. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  26575. /** @hidden */
  26576. export var defaultPixelShader: {
  26577. name: string;
  26578. shader: string;
  26579. };
  26580. }
  26581. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  26582. /** @hidden */
  26583. export var defaultVertexDeclaration: {
  26584. name: string;
  26585. shader: string;
  26586. };
  26587. }
  26588. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  26589. /** @hidden */
  26590. export var bumpVertexDeclaration: {
  26591. name: string;
  26592. shader: string;
  26593. };
  26594. }
  26595. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  26596. /** @hidden */
  26597. export var bumpVertex: {
  26598. name: string;
  26599. shader: string;
  26600. };
  26601. }
  26602. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  26603. /** @hidden */
  26604. export var fogVertex: {
  26605. name: string;
  26606. shader: string;
  26607. };
  26608. }
  26609. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  26610. /** @hidden */
  26611. export var shadowsVertex: {
  26612. name: string;
  26613. shader: string;
  26614. };
  26615. }
  26616. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  26617. /** @hidden */
  26618. export var pointCloudVertex: {
  26619. name: string;
  26620. shader: string;
  26621. };
  26622. }
  26623. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  26624. /** @hidden */
  26625. export var logDepthVertex: {
  26626. name: string;
  26627. shader: string;
  26628. };
  26629. }
  26630. declare module "babylonjs/Shaders/default.vertex" {
  26631. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  26632. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26633. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26634. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  26635. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  26636. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  26637. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  26638. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  26639. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26640. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26641. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  26642. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  26643. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26644. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  26645. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  26646. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  26647. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  26648. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  26649. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  26650. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  26651. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  26652. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  26653. /** @hidden */
  26654. export var defaultVertexShader: {
  26655. name: string;
  26656. shader: string;
  26657. };
  26658. }
  26659. declare module "babylonjs/Materials/standardMaterial" {
  26660. import { SmartArray } from "babylonjs/Misc/smartArray";
  26661. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26662. import { Nullable } from "babylonjs/types";
  26663. import { Scene } from "babylonjs/scene";
  26664. import { Matrix } from "babylonjs/Maths/math.vector";
  26665. import { Color3 } from "babylonjs/Maths/math.color";
  26666. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26667. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26668. import { Mesh } from "babylonjs/Meshes/mesh";
  26669. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  26670. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  26671. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  26672. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26673. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  26674. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26675. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26676. import "babylonjs/Shaders/default.fragment";
  26677. import "babylonjs/Shaders/default.vertex";
  26678. /** @hidden */
  26679. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26680. MAINUV1: boolean;
  26681. MAINUV2: boolean;
  26682. DIFFUSE: boolean;
  26683. DIFFUSEDIRECTUV: number;
  26684. AMBIENT: boolean;
  26685. AMBIENTDIRECTUV: number;
  26686. OPACITY: boolean;
  26687. OPACITYDIRECTUV: number;
  26688. OPACITYRGB: boolean;
  26689. REFLECTION: boolean;
  26690. EMISSIVE: boolean;
  26691. EMISSIVEDIRECTUV: number;
  26692. SPECULAR: boolean;
  26693. SPECULARDIRECTUV: number;
  26694. BUMP: boolean;
  26695. BUMPDIRECTUV: number;
  26696. PARALLAX: boolean;
  26697. PARALLAXOCCLUSION: boolean;
  26698. SPECULAROVERALPHA: boolean;
  26699. CLIPPLANE: boolean;
  26700. CLIPPLANE2: boolean;
  26701. CLIPPLANE3: boolean;
  26702. CLIPPLANE4: boolean;
  26703. ALPHATEST: boolean;
  26704. DEPTHPREPASS: boolean;
  26705. ALPHAFROMDIFFUSE: boolean;
  26706. POINTSIZE: boolean;
  26707. FOG: boolean;
  26708. SPECULARTERM: boolean;
  26709. DIFFUSEFRESNEL: boolean;
  26710. OPACITYFRESNEL: boolean;
  26711. REFLECTIONFRESNEL: boolean;
  26712. REFRACTIONFRESNEL: boolean;
  26713. EMISSIVEFRESNEL: boolean;
  26714. FRESNEL: boolean;
  26715. NORMAL: boolean;
  26716. UV1: boolean;
  26717. UV2: boolean;
  26718. VERTEXCOLOR: boolean;
  26719. VERTEXALPHA: boolean;
  26720. NUM_BONE_INFLUENCERS: number;
  26721. BonesPerMesh: number;
  26722. BONETEXTURE: boolean;
  26723. INSTANCES: boolean;
  26724. GLOSSINESS: boolean;
  26725. ROUGHNESS: boolean;
  26726. EMISSIVEASILLUMINATION: boolean;
  26727. LINKEMISSIVEWITHDIFFUSE: boolean;
  26728. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26729. LIGHTMAP: boolean;
  26730. LIGHTMAPDIRECTUV: number;
  26731. OBJECTSPACE_NORMALMAP: boolean;
  26732. USELIGHTMAPASSHADOWMAP: boolean;
  26733. REFLECTIONMAP_3D: boolean;
  26734. REFLECTIONMAP_SPHERICAL: boolean;
  26735. REFLECTIONMAP_PLANAR: boolean;
  26736. REFLECTIONMAP_CUBIC: boolean;
  26737. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26738. REFLECTIONMAP_PROJECTION: boolean;
  26739. REFLECTIONMAP_SKYBOX: boolean;
  26740. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  26741. REFLECTIONMAP_EXPLICIT: boolean;
  26742. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26743. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26744. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26745. INVERTCUBICMAP: boolean;
  26746. LOGARITHMICDEPTH: boolean;
  26747. REFRACTION: boolean;
  26748. REFRACTIONMAP_3D: boolean;
  26749. REFLECTIONOVERALPHA: boolean;
  26750. TWOSIDEDLIGHTING: boolean;
  26751. SHADOWFLOAT: boolean;
  26752. MORPHTARGETS: boolean;
  26753. MORPHTARGETS_NORMAL: boolean;
  26754. MORPHTARGETS_TANGENT: boolean;
  26755. MORPHTARGETS_UV: boolean;
  26756. NUM_MORPH_INFLUENCERS: number;
  26757. NONUNIFORMSCALING: boolean;
  26758. PREMULTIPLYALPHA: boolean;
  26759. IMAGEPROCESSING: boolean;
  26760. VIGNETTE: boolean;
  26761. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26762. VIGNETTEBLENDMODEOPAQUE: boolean;
  26763. TONEMAPPING: boolean;
  26764. TONEMAPPING_ACES: boolean;
  26765. CONTRAST: boolean;
  26766. COLORCURVES: boolean;
  26767. COLORGRADING: boolean;
  26768. COLORGRADING3D: boolean;
  26769. SAMPLER3DGREENDEPTH: boolean;
  26770. SAMPLER3DBGRMAP: boolean;
  26771. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26772. MULTIVIEW: boolean;
  26773. /**
  26774. * If the reflection texture on this material is in linear color space
  26775. * @hidden
  26776. */
  26777. IS_REFLECTION_LINEAR: boolean;
  26778. /**
  26779. * If the refraction texture on this material is in linear color space
  26780. * @hidden
  26781. */
  26782. IS_REFRACTION_LINEAR: boolean;
  26783. EXPOSURE: boolean;
  26784. constructor();
  26785. setReflectionMode(modeToEnable: string): void;
  26786. }
  26787. /**
  26788. * This is the default material used in Babylon. It is the best trade off between quality
  26789. * and performances.
  26790. * @see http://doc.babylonjs.com/babylon101/materials
  26791. */
  26792. export class StandardMaterial extends PushMaterial {
  26793. private _diffuseTexture;
  26794. /**
  26795. * The basic texture of the material as viewed under a light.
  26796. */
  26797. diffuseTexture: Nullable<BaseTexture>;
  26798. private _ambientTexture;
  26799. /**
  26800. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26801. */
  26802. ambientTexture: Nullable<BaseTexture>;
  26803. private _opacityTexture;
  26804. /**
  26805. * Define the transparency of the material from a texture.
  26806. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26807. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26808. */
  26809. opacityTexture: Nullable<BaseTexture>;
  26810. private _reflectionTexture;
  26811. /**
  26812. * Define the texture used to display the reflection.
  26813. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26814. */
  26815. reflectionTexture: Nullable<BaseTexture>;
  26816. private _emissiveTexture;
  26817. /**
  26818. * Define texture of the material as if self lit.
  26819. * This will be mixed in the final result even in the absence of light.
  26820. */
  26821. emissiveTexture: Nullable<BaseTexture>;
  26822. private _specularTexture;
  26823. /**
  26824. * Define how the color and intensity of the highlight given by the light in the material.
  26825. */
  26826. specularTexture: Nullable<BaseTexture>;
  26827. private _bumpTexture;
  26828. /**
  26829. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26830. * 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.
  26831. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26832. */
  26833. bumpTexture: Nullable<BaseTexture>;
  26834. private _lightmapTexture;
  26835. /**
  26836. * Complex lighting can be computationally expensive to compute at runtime.
  26837. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26838. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26839. */
  26840. lightmapTexture: Nullable<BaseTexture>;
  26841. private _refractionTexture;
  26842. /**
  26843. * Define the texture used to display the refraction.
  26844. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26845. */
  26846. refractionTexture: Nullable<BaseTexture>;
  26847. /**
  26848. * The color of the material lit by the environmental background lighting.
  26849. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26850. */
  26851. ambientColor: Color3;
  26852. /**
  26853. * The basic color of the material as viewed under a light.
  26854. */
  26855. diffuseColor: Color3;
  26856. /**
  26857. * Define how the color and intensity of the highlight given by the light in the material.
  26858. */
  26859. specularColor: Color3;
  26860. /**
  26861. * Define the color of the material as if self lit.
  26862. * This will be mixed in the final result even in the absence of light.
  26863. */
  26864. emissiveColor: Color3;
  26865. /**
  26866. * Defines how sharp are the highlights in the material.
  26867. * The bigger the value the sharper giving a more glossy feeling to the result.
  26868. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26869. */
  26870. specularPower: number;
  26871. private _useAlphaFromDiffuseTexture;
  26872. /**
  26873. * Does the transparency come from the diffuse texture alpha channel.
  26874. */
  26875. useAlphaFromDiffuseTexture: boolean;
  26876. private _useEmissiveAsIllumination;
  26877. /**
  26878. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26879. */
  26880. useEmissiveAsIllumination: boolean;
  26881. private _linkEmissiveWithDiffuse;
  26882. /**
  26883. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26884. * the emissive level when the final color is close to one.
  26885. */
  26886. linkEmissiveWithDiffuse: boolean;
  26887. private _useSpecularOverAlpha;
  26888. /**
  26889. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26890. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26891. */
  26892. useSpecularOverAlpha: boolean;
  26893. private _useReflectionOverAlpha;
  26894. /**
  26895. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26896. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26897. */
  26898. useReflectionOverAlpha: boolean;
  26899. private _disableLighting;
  26900. /**
  26901. * Does lights from the scene impacts this material.
  26902. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26903. */
  26904. disableLighting: boolean;
  26905. private _useObjectSpaceNormalMap;
  26906. /**
  26907. * Allows using an object space normal map (instead of tangent space).
  26908. */
  26909. useObjectSpaceNormalMap: boolean;
  26910. private _useParallax;
  26911. /**
  26912. * Is parallax enabled or not.
  26913. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26914. */
  26915. useParallax: boolean;
  26916. private _useParallaxOcclusion;
  26917. /**
  26918. * Is parallax occlusion enabled or not.
  26919. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26920. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26921. */
  26922. useParallaxOcclusion: boolean;
  26923. /**
  26924. * 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.
  26925. */
  26926. parallaxScaleBias: number;
  26927. private _roughness;
  26928. /**
  26929. * Helps to define how blurry the reflections should appears in the material.
  26930. */
  26931. roughness: number;
  26932. /**
  26933. * In case of refraction, define the value of the index of refraction.
  26934. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26935. */
  26936. indexOfRefraction: number;
  26937. /**
  26938. * Invert the refraction texture alongside the y axis.
  26939. * It can be useful with procedural textures or probe for instance.
  26940. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26941. */
  26942. invertRefractionY: boolean;
  26943. /**
  26944. * Defines the alpha limits in alpha test mode.
  26945. */
  26946. alphaCutOff: number;
  26947. private _useLightmapAsShadowmap;
  26948. /**
  26949. * In case of light mapping, define whether the map contains light or shadow informations.
  26950. */
  26951. useLightmapAsShadowmap: boolean;
  26952. private _diffuseFresnelParameters;
  26953. /**
  26954. * Define the diffuse fresnel parameters of the material.
  26955. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26956. */
  26957. diffuseFresnelParameters: FresnelParameters;
  26958. private _opacityFresnelParameters;
  26959. /**
  26960. * Define the opacity fresnel parameters of the material.
  26961. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26962. */
  26963. opacityFresnelParameters: FresnelParameters;
  26964. private _reflectionFresnelParameters;
  26965. /**
  26966. * Define the reflection fresnel parameters of the material.
  26967. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26968. */
  26969. reflectionFresnelParameters: FresnelParameters;
  26970. private _refractionFresnelParameters;
  26971. /**
  26972. * Define the refraction fresnel parameters of the material.
  26973. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26974. */
  26975. refractionFresnelParameters: FresnelParameters;
  26976. private _emissiveFresnelParameters;
  26977. /**
  26978. * Define the emissive fresnel parameters of the material.
  26979. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26980. */
  26981. emissiveFresnelParameters: FresnelParameters;
  26982. private _useReflectionFresnelFromSpecular;
  26983. /**
  26984. * If true automatically deducts the fresnels values from the material specularity.
  26985. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26986. */
  26987. useReflectionFresnelFromSpecular: boolean;
  26988. private _useGlossinessFromSpecularMapAlpha;
  26989. /**
  26990. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26991. */
  26992. useGlossinessFromSpecularMapAlpha: boolean;
  26993. private _maxSimultaneousLights;
  26994. /**
  26995. * Defines the maximum number of lights that can be used in the material
  26996. */
  26997. maxSimultaneousLights: number;
  26998. private _invertNormalMapX;
  26999. /**
  27000. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27001. */
  27002. invertNormalMapX: boolean;
  27003. private _invertNormalMapY;
  27004. /**
  27005. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27006. */
  27007. invertNormalMapY: boolean;
  27008. private _twoSidedLighting;
  27009. /**
  27010. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27011. */
  27012. twoSidedLighting: boolean;
  27013. /**
  27014. * Default configuration related to image processing available in the standard Material.
  27015. */
  27016. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27017. /**
  27018. * Gets the image processing configuration used either in this material.
  27019. */
  27020. /**
  27021. * Sets the Default image processing configuration used either in the this material.
  27022. *
  27023. * If sets to null, the scene one is in use.
  27024. */
  27025. imageProcessingConfiguration: ImageProcessingConfiguration;
  27026. /**
  27027. * Keep track of the image processing observer to allow dispose and replace.
  27028. */
  27029. private _imageProcessingObserver;
  27030. /**
  27031. * Attaches a new image processing configuration to the Standard Material.
  27032. * @param configuration
  27033. */
  27034. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27035. /**
  27036. * Gets wether the color curves effect is enabled.
  27037. */
  27038. /**
  27039. * Sets wether the color curves effect is enabled.
  27040. */
  27041. cameraColorCurvesEnabled: boolean;
  27042. /**
  27043. * Gets wether the color grading effect is enabled.
  27044. */
  27045. /**
  27046. * Gets wether the color grading effect is enabled.
  27047. */
  27048. cameraColorGradingEnabled: boolean;
  27049. /**
  27050. * Gets wether tonemapping is enabled or not.
  27051. */
  27052. /**
  27053. * Sets wether tonemapping is enabled or not
  27054. */
  27055. cameraToneMappingEnabled: boolean;
  27056. /**
  27057. * The camera exposure used on this material.
  27058. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27059. * This corresponds to a photographic exposure.
  27060. */
  27061. /**
  27062. * The camera exposure used on this material.
  27063. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27064. * This corresponds to a photographic exposure.
  27065. */
  27066. cameraExposure: number;
  27067. /**
  27068. * Gets The camera contrast used on this material.
  27069. */
  27070. /**
  27071. * Sets The camera contrast used on this material.
  27072. */
  27073. cameraContrast: number;
  27074. /**
  27075. * Gets the Color Grading 2D Lookup Texture.
  27076. */
  27077. /**
  27078. * Sets the Color Grading 2D Lookup Texture.
  27079. */
  27080. cameraColorGradingTexture: Nullable<BaseTexture>;
  27081. /**
  27082. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27083. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27084. * 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;
  27085. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27086. */
  27087. /**
  27088. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27089. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27090. * 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;
  27091. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27092. */
  27093. cameraColorCurves: Nullable<ColorCurves>;
  27094. /**
  27095. * Custom callback helping to override the default shader used in the material.
  27096. */
  27097. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  27098. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27099. protected _worldViewProjectionMatrix: Matrix;
  27100. protected _globalAmbientColor: Color3;
  27101. protected _useLogarithmicDepth: boolean;
  27102. protected _rebuildInParallel: boolean;
  27103. /**
  27104. * Instantiates a new standard material.
  27105. * This is the default material used in Babylon. It is the best trade off between quality
  27106. * and performances.
  27107. * @see http://doc.babylonjs.com/babylon101/materials
  27108. * @param name Define the name of the material in the scene
  27109. * @param scene Define the scene the material belong to
  27110. */
  27111. constructor(name: string, scene: Scene);
  27112. /**
  27113. * Gets a boolean indicating that current material needs to register RTT
  27114. */
  27115. readonly hasRenderTargetTextures: boolean;
  27116. /**
  27117. * Gets the current class name of the material e.g. "StandardMaterial"
  27118. * Mainly use in serialization.
  27119. * @returns the class name
  27120. */
  27121. getClassName(): string;
  27122. /**
  27123. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27124. * You can try switching to logarithmic depth.
  27125. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27126. */
  27127. useLogarithmicDepth: boolean;
  27128. /**
  27129. * Specifies if the material will require alpha blending
  27130. * @returns a boolean specifying if alpha blending is needed
  27131. */
  27132. needAlphaBlending(): boolean;
  27133. /**
  27134. * Specifies if this material should be rendered in alpha test mode
  27135. * @returns a boolean specifying if an alpha test is needed.
  27136. */
  27137. needAlphaTesting(): boolean;
  27138. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27139. /**
  27140. * Get the texture used for alpha test purpose.
  27141. * @returns the diffuse texture in case of the standard material.
  27142. */
  27143. getAlphaTestTexture(): Nullable<BaseTexture>;
  27144. /**
  27145. * Get if the submesh is ready to be used and all its information available.
  27146. * Child classes can use it to update shaders
  27147. * @param mesh defines the mesh to check
  27148. * @param subMesh defines which submesh to check
  27149. * @param useInstances specifies that instances should be used
  27150. * @returns a boolean indicating that the submesh is ready or not
  27151. */
  27152. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27153. /**
  27154. * Builds the material UBO layouts.
  27155. * Used internally during the effect preparation.
  27156. */
  27157. buildUniformLayout(): void;
  27158. /**
  27159. * Unbinds the material from the mesh
  27160. */
  27161. unbind(): void;
  27162. /**
  27163. * Binds the submesh to this material by preparing the effect and shader to draw
  27164. * @param world defines the world transformation matrix
  27165. * @param mesh defines the mesh containing the submesh
  27166. * @param subMesh defines the submesh to bind the material to
  27167. */
  27168. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27169. /**
  27170. * Get the list of animatables in the material.
  27171. * @returns the list of animatables object used in the material
  27172. */
  27173. getAnimatables(): IAnimatable[];
  27174. /**
  27175. * Gets the active textures from the material
  27176. * @returns an array of textures
  27177. */
  27178. getActiveTextures(): BaseTexture[];
  27179. /**
  27180. * Specifies if the material uses a texture
  27181. * @param texture defines the texture to check against the material
  27182. * @returns a boolean specifying if the material uses the texture
  27183. */
  27184. hasTexture(texture: BaseTexture): boolean;
  27185. /**
  27186. * Disposes the material
  27187. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27188. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27189. */
  27190. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27191. /**
  27192. * Makes a duplicate of the material, and gives it a new name
  27193. * @param name defines the new name for the duplicated material
  27194. * @returns the cloned material
  27195. */
  27196. clone(name: string): StandardMaterial;
  27197. /**
  27198. * Serializes this material in a JSON representation
  27199. * @returns the serialized material object
  27200. */
  27201. serialize(): any;
  27202. /**
  27203. * Creates a standard material from parsed material data
  27204. * @param source defines the JSON representation of the material
  27205. * @param scene defines the hosting scene
  27206. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27207. * @returns a new standard material
  27208. */
  27209. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27210. /**
  27211. * Are diffuse textures enabled in the application.
  27212. */
  27213. static DiffuseTextureEnabled: boolean;
  27214. /**
  27215. * Are ambient textures enabled in the application.
  27216. */
  27217. static AmbientTextureEnabled: boolean;
  27218. /**
  27219. * Are opacity textures enabled in the application.
  27220. */
  27221. static OpacityTextureEnabled: boolean;
  27222. /**
  27223. * Are reflection textures enabled in the application.
  27224. */
  27225. static ReflectionTextureEnabled: boolean;
  27226. /**
  27227. * Are emissive textures enabled in the application.
  27228. */
  27229. static EmissiveTextureEnabled: boolean;
  27230. /**
  27231. * Are specular textures enabled in the application.
  27232. */
  27233. static SpecularTextureEnabled: boolean;
  27234. /**
  27235. * Are bump textures enabled in the application.
  27236. */
  27237. static BumpTextureEnabled: boolean;
  27238. /**
  27239. * Are lightmap textures enabled in the application.
  27240. */
  27241. static LightmapTextureEnabled: boolean;
  27242. /**
  27243. * Are refraction textures enabled in the application.
  27244. */
  27245. static RefractionTextureEnabled: boolean;
  27246. /**
  27247. * Are color grading textures enabled in the application.
  27248. */
  27249. static ColorGradingTextureEnabled: boolean;
  27250. /**
  27251. * Are fresnels enabled in the application.
  27252. */
  27253. static FresnelEnabled: boolean;
  27254. }
  27255. }
  27256. declare module "babylonjs/Particles/solidParticleSystem" {
  27257. import { Nullable } from "babylonjs/types";
  27258. import { Vector3 } from "babylonjs/Maths/math.vector";
  27259. import { Mesh } from "babylonjs/Meshes/mesh";
  27260. import { Scene, IDisposable } from "babylonjs/scene";
  27261. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  27262. import { Material } from "babylonjs/Materials/material";
  27263. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  27264. /**
  27265. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27266. *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.
  27267. * The SPS is also a particle system. It provides some methods to manage the particles.
  27268. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27269. *
  27270. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27271. */
  27272. export class SolidParticleSystem implements IDisposable {
  27273. /**
  27274. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27275. * Example : var p = SPS.particles[i];
  27276. */
  27277. particles: SolidParticle[];
  27278. /**
  27279. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27280. */
  27281. nbParticles: number;
  27282. /**
  27283. * If the particles must ever face the camera (default false). Useful for planar particles.
  27284. */
  27285. billboard: boolean;
  27286. /**
  27287. * Recompute normals when adding a shape
  27288. */
  27289. recomputeNormals: boolean;
  27290. /**
  27291. * This a counter ofr your own usage. It's not set by any SPS functions.
  27292. */
  27293. counter: number;
  27294. /**
  27295. * The SPS name. This name is also given to the underlying mesh.
  27296. */
  27297. name: string;
  27298. /**
  27299. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27300. */
  27301. mesh: Mesh;
  27302. /**
  27303. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27304. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27305. */
  27306. vars: any;
  27307. /**
  27308. * This array is populated when the SPS is set as 'pickable'.
  27309. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27310. * Each element of this array is an object `{idx: int, faceId: int}`.
  27311. * `idx` is the picked particle index in the `SPS.particles` array
  27312. * `faceId` is the picked face index counted within this particle.
  27313. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27314. */
  27315. pickedParticles: {
  27316. idx: number;
  27317. faceId: number;
  27318. }[];
  27319. /**
  27320. * This array is populated when `enableDepthSort` is set to true.
  27321. * Each element of this array is an instance of the class DepthSortedParticle.
  27322. */
  27323. depthSortedParticles: DepthSortedParticle[];
  27324. /**
  27325. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27326. * @hidden
  27327. */
  27328. _bSphereOnly: boolean;
  27329. /**
  27330. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27331. * @hidden
  27332. */
  27333. _bSphereRadiusFactor: number;
  27334. private _scene;
  27335. private _positions;
  27336. private _indices;
  27337. private _normals;
  27338. private _colors;
  27339. private _uvs;
  27340. private _indices32;
  27341. private _positions32;
  27342. private _normals32;
  27343. private _fixedNormal32;
  27344. private _colors32;
  27345. private _uvs32;
  27346. private _index;
  27347. private _updatable;
  27348. private _pickable;
  27349. private _isVisibilityBoxLocked;
  27350. private _alwaysVisible;
  27351. private _depthSort;
  27352. private _expandable;
  27353. private _shapeCounter;
  27354. private _copy;
  27355. private _color;
  27356. private _computeParticleColor;
  27357. private _computeParticleTexture;
  27358. private _computeParticleRotation;
  27359. private _computeParticleVertex;
  27360. private _computeBoundingBox;
  27361. private _depthSortParticles;
  27362. private _camera;
  27363. private _mustUnrotateFixedNormals;
  27364. private _particlesIntersect;
  27365. private _needs32Bits;
  27366. private _isNotBuilt;
  27367. private _lastParticleId;
  27368. private _idxOfId;
  27369. private _multimaterialEnabled;
  27370. private _useModelMaterial;
  27371. private _indicesByMaterial;
  27372. private _materialIndexes;
  27373. private _depthSortFunction;
  27374. private _materialSortFunction;
  27375. private _materials;
  27376. private _multimaterial;
  27377. private _materialIndexesById;
  27378. private _defaultMaterial;
  27379. private _autoUpdateSubMeshes;
  27380. /**
  27381. * Creates a SPS (Solid Particle System) object.
  27382. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27383. * @param scene (Scene) is the scene in which the SPS is added.
  27384. * @param options defines the options of the sps e.g.
  27385. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27386. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27387. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27388. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  27389. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27390. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27391. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27392. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27393. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27394. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27395. */
  27396. constructor(name: string, scene: Scene, options?: {
  27397. updatable?: boolean;
  27398. isPickable?: boolean;
  27399. enableDepthSort?: boolean;
  27400. particleIntersection?: boolean;
  27401. boundingSphereOnly?: boolean;
  27402. bSphereRadiusFactor?: number;
  27403. expandable?: boolean;
  27404. useModelMaterial?: boolean;
  27405. enableMultiMaterial?: boolean;
  27406. });
  27407. /**
  27408. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27409. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27410. * @returns the created mesh
  27411. */
  27412. buildMesh(): Mesh;
  27413. /**
  27414. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27415. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27416. * Thus the particles generated from `digest()` have their property `position` set yet.
  27417. * @param mesh ( Mesh ) is the mesh to be digested
  27418. * @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
  27419. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27420. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27421. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27422. * @returns the current SPS
  27423. */
  27424. digest(mesh: Mesh, options?: {
  27425. facetNb?: number;
  27426. number?: number;
  27427. delta?: number;
  27428. storage?: [];
  27429. }): SolidParticleSystem;
  27430. /**
  27431. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27432. * @hidden
  27433. */
  27434. private _unrotateFixedNormals;
  27435. /**
  27436. * Resets the temporary working copy particle
  27437. * @hidden
  27438. */
  27439. private _resetCopy;
  27440. /**
  27441. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27442. * @param p the current index in the positions array to be updated
  27443. * @param ind the current index in the indices array
  27444. * @param shape a Vector3 array, the shape geometry
  27445. * @param positions the positions array to be updated
  27446. * @param meshInd the shape indices array
  27447. * @param indices the indices array to be updated
  27448. * @param meshUV the shape uv array
  27449. * @param uvs the uv array to be updated
  27450. * @param meshCol the shape color array
  27451. * @param colors the color array to be updated
  27452. * @param meshNor the shape normals array
  27453. * @param normals the normals array to be updated
  27454. * @param idx the particle index
  27455. * @param idxInShape the particle index in its shape
  27456. * @param options the addShape() method passed options
  27457. * @model the particle model
  27458. * @hidden
  27459. */
  27460. private _meshBuilder;
  27461. /**
  27462. * Returns a shape Vector3 array from positions float array
  27463. * @param positions float array
  27464. * @returns a vector3 array
  27465. * @hidden
  27466. */
  27467. private _posToShape;
  27468. /**
  27469. * Returns a shapeUV array from a float uvs (array deep copy)
  27470. * @param uvs as a float array
  27471. * @returns a shapeUV array
  27472. * @hidden
  27473. */
  27474. private _uvsToShapeUV;
  27475. /**
  27476. * Adds a new particle object in the particles array
  27477. * @param idx particle index in particles array
  27478. * @param id particle id
  27479. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27480. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27481. * @param model particle ModelShape object
  27482. * @param shapeId model shape identifier
  27483. * @param idxInShape index of the particle in the current model
  27484. * @param bInfo model bounding info object
  27485. * @param storage target storage array, if any
  27486. * @hidden
  27487. */
  27488. private _addParticle;
  27489. /**
  27490. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27491. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27492. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27493. * @param nb (positive integer) the number of particles to be created from this model
  27494. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27495. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27496. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27497. * @returns the number of shapes in the system
  27498. */
  27499. addShape(mesh: Mesh, nb: number, options?: {
  27500. positionFunction?: any;
  27501. vertexFunction?: any;
  27502. storage?: [];
  27503. }): number;
  27504. /**
  27505. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27506. * @hidden
  27507. */
  27508. private _rebuildParticle;
  27509. /**
  27510. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27511. * @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.
  27512. * @returns the SPS.
  27513. */
  27514. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27515. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27516. * Returns an array with the removed particles.
  27517. * 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.
  27518. * The SPS can't be empty so at least one particle needs to remain in place.
  27519. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27520. * @param start index of the first particle to remove
  27521. * @param end index of the last particle to remove (included)
  27522. * @returns an array populated with the removed particles
  27523. */
  27524. removeParticles(start: number, end: number): SolidParticle[];
  27525. /**
  27526. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27527. * @param solidParticleArray an array populated with Solid Particles objects
  27528. * @returns the SPS
  27529. */
  27530. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27531. /**
  27532. * Creates a new particle and modifies the SPS mesh geometry :
  27533. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27534. * - calls _addParticle() to populate the particle array
  27535. * factorized code from addShape() and insertParticlesFromArray()
  27536. * @param idx particle index in the particles array
  27537. * @param i particle index in its shape
  27538. * @param modelShape particle ModelShape object
  27539. * @param shape shape vertex array
  27540. * @param meshInd shape indices array
  27541. * @param meshUV shape uv array
  27542. * @param meshCol shape color array
  27543. * @param meshNor shape normals array
  27544. * @param bbInfo shape bounding info
  27545. * @param storage target particle storage
  27546. * @options addShape() passed options
  27547. * @hidden
  27548. */
  27549. private _insertNewParticle;
  27550. /**
  27551. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27552. * This method calls `updateParticle()` for each particle of the SPS.
  27553. * For an animated SPS, it is usually called within the render loop.
  27554. * 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.
  27555. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27556. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27557. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27558. * @returns the SPS.
  27559. */
  27560. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27561. /**
  27562. * Disposes the SPS.
  27563. */
  27564. dispose(): void;
  27565. /**
  27566. * Returns a SolidParticle object from its identifier : particle.id
  27567. * @param id (integer) the particle Id
  27568. * @returns the searched particle or null if not found in the SPS.
  27569. */
  27570. getParticleById(id: number): Nullable<SolidParticle>;
  27571. /**
  27572. * Returns a new array populated with the particles having the passed shapeId.
  27573. * @param shapeId (integer) the shape identifier
  27574. * @returns a new solid particle array
  27575. */
  27576. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27577. /**
  27578. * Populates the passed array "ref" with the particles having the passed shapeId.
  27579. * @param shapeId the shape identifier
  27580. * @returns the SPS
  27581. * @param ref
  27582. */
  27583. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27584. /**
  27585. * Computes the required SubMeshes according the materials assigned to the particles.
  27586. * @returns the solid particle system.
  27587. * Does nothing if called before the SPS mesh is built.
  27588. */
  27589. computeSubMeshes(): SolidParticleSystem;
  27590. /**
  27591. * Sorts the solid particles by material when MultiMaterial is enabled.
  27592. * Updates the indices32 array.
  27593. * Updates the indicesByMaterial array.
  27594. * Updates the mesh indices array.
  27595. * @returns the SPS
  27596. * @hidden
  27597. */
  27598. private _sortParticlesByMaterial;
  27599. /**
  27600. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27601. * @hidden
  27602. */
  27603. private _setMaterialIndexesById;
  27604. /**
  27605. * Returns an array with unique values of Materials from the passed array
  27606. * @param array the material array to be checked and filtered
  27607. * @hidden
  27608. */
  27609. private _filterUniqueMaterialId;
  27610. /**
  27611. * Sets a new Standard Material as _defaultMaterial if not already set.
  27612. * @hidden
  27613. */
  27614. private _setDefaultMaterial;
  27615. /**
  27616. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27617. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27618. * @returns the SPS.
  27619. */
  27620. refreshVisibleSize(): SolidParticleSystem;
  27621. /**
  27622. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27623. * @param size the size (float) of the visibility box
  27624. * note : this doesn't lock the SPS mesh bounding box.
  27625. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27626. */
  27627. setVisibilityBox(size: number): void;
  27628. /**
  27629. * Gets whether the SPS as always visible or not
  27630. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27631. */
  27632. /**
  27633. * Sets the SPS as always visible or not
  27634. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27635. */
  27636. isAlwaysVisible: boolean;
  27637. /**
  27638. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27639. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27640. */
  27641. /**
  27642. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27643. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27644. */
  27645. isVisibilityBoxLocked: boolean;
  27646. /**
  27647. * Tells to `setParticles()` to compute the particle rotations or not.
  27648. * Default value : true. The SPS is faster when it's set to false.
  27649. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27650. */
  27651. /**
  27652. * Gets if `setParticles()` computes the particle rotations or not.
  27653. * Default value : true. The SPS is faster when it's set to false.
  27654. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27655. */
  27656. computeParticleRotation: boolean;
  27657. /**
  27658. * Tells to `setParticles()` to compute the particle colors or not.
  27659. * Default value : true. The SPS is faster when it's set to false.
  27660. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27661. */
  27662. /**
  27663. * Gets if `setParticles()` computes the particle colors or not.
  27664. * Default value : true. The SPS is faster when it's set to false.
  27665. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27666. */
  27667. computeParticleColor: boolean;
  27668. /**
  27669. * Gets if `setParticles()` computes the particle textures or not.
  27670. * Default value : true. The SPS is faster when it's set to false.
  27671. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27672. */
  27673. computeParticleTexture: boolean;
  27674. /**
  27675. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27676. * Default value : false. The SPS is faster when it's set to false.
  27677. * Note : the particle custom vertex positions aren't stored values.
  27678. */
  27679. /**
  27680. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27681. * Default value : false. The SPS is faster when it's set to false.
  27682. * Note : the particle custom vertex positions aren't stored values.
  27683. */
  27684. computeParticleVertex: boolean;
  27685. /**
  27686. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27687. */
  27688. /**
  27689. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27690. */
  27691. computeBoundingBox: boolean;
  27692. /**
  27693. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27694. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27695. * Default : `true`
  27696. */
  27697. /**
  27698. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27699. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27700. * Default : `true`
  27701. */
  27702. depthSortParticles: boolean;
  27703. /**
  27704. * Gets if the SPS is created as expandable at construction time.
  27705. * Default : `false`
  27706. */
  27707. readonly expandable: boolean;
  27708. /**
  27709. * Gets if the SPS supports the Multi Materials
  27710. */
  27711. readonly multimaterialEnabled: boolean;
  27712. /**
  27713. * Gets if the SPS uses the model materials for its own multimaterial.
  27714. */
  27715. readonly useModelMaterial: boolean;
  27716. /**
  27717. * The SPS used material array.
  27718. */
  27719. readonly materials: Material[];
  27720. /**
  27721. * Sets the SPS MultiMaterial from the passed materials.
  27722. * Note : the passed array is internally copied and not used then by reference.
  27723. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27724. */
  27725. setMultiMaterial(materials: Material[]): void;
  27726. /**
  27727. * The SPS computed multimaterial object
  27728. */
  27729. multimaterial: MultiMaterial;
  27730. /**
  27731. * If the subMeshes must be updated on the next call to setParticles()
  27732. */
  27733. autoUpdateSubMeshes: boolean;
  27734. /**
  27735. * This function does nothing. It may be overwritten to set all the particle first values.
  27736. * The SPS doesn't call this function, you may have to call it by your own.
  27737. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27738. */
  27739. initParticles(): void;
  27740. /**
  27741. * This function does nothing. It may be overwritten to recycle a particle.
  27742. * The SPS doesn't call this function, you may have to call it by your own.
  27743. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27744. * @param particle The particle to recycle
  27745. * @returns the recycled particle
  27746. */
  27747. recycleParticle(particle: SolidParticle): SolidParticle;
  27748. /**
  27749. * Updates a particle : this function should be overwritten by the user.
  27750. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27751. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27752. * @example : just set a particle position or velocity and recycle conditions
  27753. * @param particle The particle to update
  27754. * @returns the updated particle
  27755. */
  27756. updateParticle(particle: SolidParticle): SolidParticle;
  27757. /**
  27758. * Updates a vertex of a particle : it can be overwritten by the user.
  27759. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27760. * @param particle the current particle
  27761. * @param vertex the current index of the current particle
  27762. * @param pt the index of the current vertex in the particle shape
  27763. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27764. * @example : just set a vertex particle position
  27765. * @returns the updated vertex
  27766. */
  27767. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27768. /**
  27769. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27770. * This does nothing and may be overwritten by the user.
  27771. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27772. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27773. * @param update the boolean update value actually passed to setParticles()
  27774. */
  27775. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27776. /**
  27777. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27778. * This will be passed three parameters.
  27779. * This does nothing and may be overwritten by the user.
  27780. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27781. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27782. * @param update the boolean update value actually passed to setParticles()
  27783. */
  27784. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27785. }
  27786. }
  27787. declare module "babylonjs/Particles/solidParticle" {
  27788. import { Nullable } from "babylonjs/types";
  27789. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  27790. import { Color4 } from "babylonjs/Maths/math.color";
  27791. import { Mesh } from "babylonjs/Meshes/mesh";
  27792. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  27793. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  27794. import { Plane } from "babylonjs/Maths/math.plane";
  27795. import { Material } from "babylonjs/Materials/material";
  27796. /**
  27797. * Represents one particle of a solid particle system.
  27798. */
  27799. export class SolidParticle {
  27800. /**
  27801. * particle global index
  27802. */
  27803. idx: number;
  27804. /**
  27805. * particle identifier
  27806. */
  27807. id: number;
  27808. /**
  27809. * The color of the particle
  27810. */
  27811. color: Nullable<Color4>;
  27812. /**
  27813. * The world space position of the particle.
  27814. */
  27815. position: Vector3;
  27816. /**
  27817. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27818. */
  27819. rotation: Vector3;
  27820. /**
  27821. * The world space rotation quaternion of the particle.
  27822. */
  27823. rotationQuaternion: Nullable<Quaternion>;
  27824. /**
  27825. * The scaling of the particle.
  27826. */
  27827. scaling: Vector3;
  27828. /**
  27829. * The uvs of the particle.
  27830. */
  27831. uvs: Vector4;
  27832. /**
  27833. * The current speed of the particle.
  27834. */
  27835. velocity: Vector3;
  27836. /**
  27837. * The pivot point in the particle local space.
  27838. */
  27839. pivot: Vector3;
  27840. /**
  27841. * Must the particle be translated from its pivot point in its local space ?
  27842. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27843. * Default : false
  27844. */
  27845. translateFromPivot: boolean;
  27846. /**
  27847. * Is the particle active or not ?
  27848. */
  27849. alive: boolean;
  27850. /**
  27851. * Is the particle visible or not ?
  27852. */
  27853. isVisible: boolean;
  27854. /**
  27855. * Index of this particle in the global "positions" array (Internal use)
  27856. * @hidden
  27857. */
  27858. _pos: number;
  27859. /**
  27860. * @hidden Index of this particle in the global "indices" array (Internal use)
  27861. */
  27862. _ind: number;
  27863. /**
  27864. * @hidden ModelShape of this particle (Internal use)
  27865. */
  27866. _model: ModelShape;
  27867. /**
  27868. * ModelShape id of this particle
  27869. */
  27870. shapeId: number;
  27871. /**
  27872. * Index of the particle in its shape id
  27873. */
  27874. idxInShape: number;
  27875. /**
  27876. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27877. */
  27878. _modelBoundingInfo: BoundingInfo;
  27879. /**
  27880. * @hidden Particle BoundingInfo object (Internal use)
  27881. */
  27882. _boundingInfo: BoundingInfo;
  27883. /**
  27884. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27885. */
  27886. _sps: SolidParticleSystem;
  27887. /**
  27888. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27889. */
  27890. _stillInvisible: boolean;
  27891. /**
  27892. * @hidden Last computed particle rotation matrix
  27893. */
  27894. _rotationMatrix: number[];
  27895. /**
  27896. * Parent particle Id, if any.
  27897. * Default null.
  27898. */
  27899. parentId: Nullable<number>;
  27900. /**
  27901. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27902. */
  27903. materialIndex: Nullable<number>;
  27904. /**
  27905. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27906. * The possible values are :
  27907. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27908. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27909. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27910. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27911. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27912. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27913. * */
  27914. cullingStrategy: number;
  27915. /**
  27916. * @hidden Internal global position in the SPS.
  27917. */
  27918. _globalPosition: Vector3;
  27919. /**
  27920. * Creates a Solid Particle object.
  27921. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27922. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27923. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27924. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27925. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27926. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27927. * @param shapeId (integer) is the model shape identifier in the SPS.
  27928. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27929. * @param sps defines the sps it is associated to
  27930. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27931. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27932. */
  27933. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27934. /**
  27935. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27936. * @param target the particle target
  27937. * @returns the current particle
  27938. */
  27939. copyToRef(target: SolidParticle): SolidParticle;
  27940. /**
  27941. * Legacy support, changed scale to scaling
  27942. */
  27943. /**
  27944. * Legacy support, changed scale to scaling
  27945. */
  27946. scale: Vector3;
  27947. /**
  27948. * Legacy support, changed quaternion to rotationQuaternion
  27949. */
  27950. /**
  27951. * Legacy support, changed quaternion to rotationQuaternion
  27952. */
  27953. quaternion: Nullable<Quaternion>;
  27954. /**
  27955. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27956. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27957. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27958. * @returns true if it intersects
  27959. */
  27960. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27961. /**
  27962. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27963. * A particle is in the frustum if its bounding box intersects the frustum
  27964. * @param frustumPlanes defines the frustum to test
  27965. * @returns true if the particle is in the frustum planes
  27966. */
  27967. isInFrustum(frustumPlanes: Plane[]): boolean;
  27968. /**
  27969. * get the rotation matrix of the particle
  27970. * @hidden
  27971. */
  27972. getRotationMatrix(m: Matrix): void;
  27973. }
  27974. /**
  27975. * Represents the shape of the model used by one particle of a solid particle system.
  27976. * SPS internal tool, don't use it manually.
  27977. */
  27978. export class ModelShape {
  27979. /**
  27980. * The shape id
  27981. * @hidden
  27982. */
  27983. shapeID: number;
  27984. /**
  27985. * flat array of model positions (internal use)
  27986. * @hidden
  27987. */
  27988. _shape: Vector3[];
  27989. /**
  27990. * flat array of model UVs (internal use)
  27991. * @hidden
  27992. */
  27993. _shapeUV: number[];
  27994. /**
  27995. * color array of the model
  27996. * @hidden
  27997. */
  27998. _shapeColors: number[];
  27999. /**
  28000. * indices array of the model
  28001. * @hidden
  28002. */
  28003. _indices: number[];
  28004. /**
  28005. * normals array of the model
  28006. * @hidden
  28007. */
  28008. _normals: number[];
  28009. /**
  28010. * length of the shape in the model indices array (internal use)
  28011. * @hidden
  28012. */
  28013. _indicesLength: number;
  28014. /**
  28015. * Custom position function (internal use)
  28016. * @hidden
  28017. */
  28018. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28019. /**
  28020. * Custom vertex function (internal use)
  28021. * @hidden
  28022. */
  28023. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28024. /**
  28025. * Model material (internal use)
  28026. * @hidden
  28027. */
  28028. _material: Nullable<Material>;
  28029. /**
  28030. * 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.
  28031. * SPS internal tool, don't use it manually.
  28032. * @hidden
  28033. */
  28034. 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>, material: Nullable<Material>);
  28035. }
  28036. /**
  28037. * Represents a Depth Sorted Particle in the solid particle system.
  28038. * @hidden
  28039. */
  28040. export class DepthSortedParticle {
  28041. /**
  28042. * Index of the particle in the "indices" array
  28043. */
  28044. ind: number;
  28045. /**
  28046. * Length of the particle shape in the "indices" array
  28047. */
  28048. indicesLength: number;
  28049. /**
  28050. * Squared distance from the particle to the camera
  28051. */
  28052. sqDistance: number;
  28053. /**
  28054. * Material index when used with MultiMaterials
  28055. */
  28056. materialIndex: number;
  28057. /**
  28058. * Creates a new sorted particle
  28059. * @param materialIndex
  28060. */
  28061. constructor(ind: number, indLength: number, materialIndex: number);
  28062. }
  28063. }
  28064. declare module "babylonjs/Collisions/meshCollisionData" {
  28065. import { Collider } from "babylonjs/Collisions/collider";
  28066. import { Vector3 } from "babylonjs/Maths/math.vector";
  28067. import { Nullable } from "babylonjs/types";
  28068. import { Observer } from "babylonjs/Misc/observable";
  28069. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28070. /**
  28071. * @hidden
  28072. */
  28073. export class _MeshCollisionData {
  28074. _checkCollisions: boolean;
  28075. _collisionMask: number;
  28076. _collisionGroup: number;
  28077. _collider: Nullable<Collider>;
  28078. _oldPositionForCollisions: Vector3;
  28079. _diffPositionForCollisions: Vector3;
  28080. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28081. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28082. }
  28083. }
  28084. declare module "babylonjs/Meshes/abstractMesh" {
  28085. import { Observable } from "babylonjs/Misc/observable";
  28086. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  28087. import { Camera } from "babylonjs/Cameras/camera";
  28088. import { Scene, IDisposable } from "babylonjs/scene";
  28089. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  28090. import { Node } from "babylonjs/node";
  28091. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28092. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28093. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28094. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28095. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28096. import { Material } from "babylonjs/Materials/material";
  28097. import { Light } from "babylonjs/Lights/light";
  28098. import { Skeleton } from "babylonjs/Bones/skeleton";
  28099. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  28100. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  28101. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28102. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  28103. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28104. import { Plane } from "babylonjs/Maths/math.plane";
  28105. import { Ray } from "babylonjs/Culling/ray";
  28106. import { Collider } from "babylonjs/Collisions/collider";
  28107. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  28108. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  28109. /** @hidden */
  28110. class _FacetDataStorage {
  28111. facetPositions: Vector3[];
  28112. facetNormals: Vector3[];
  28113. facetPartitioning: number[][];
  28114. facetNb: number;
  28115. partitioningSubdivisions: number;
  28116. partitioningBBoxRatio: number;
  28117. facetDataEnabled: boolean;
  28118. facetParameters: any;
  28119. bbSize: Vector3;
  28120. subDiv: {
  28121. max: number;
  28122. X: number;
  28123. Y: number;
  28124. Z: number;
  28125. };
  28126. facetDepthSort: boolean;
  28127. facetDepthSortEnabled: boolean;
  28128. depthSortedIndices: IndicesArray;
  28129. depthSortedFacets: {
  28130. ind: number;
  28131. sqDistance: number;
  28132. }[];
  28133. facetDepthSortFunction: (f1: {
  28134. ind: number;
  28135. sqDistance: number;
  28136. }, f2: {
  28137. ind: number;
  28138. sqDistance: number;
  28139. }) => number;
  28140. facetDepthSortFrom: Vector3;
  28141. facetDepthSortOrigin: Vector3;
  28142. invertedMatrix: Matrix;
  28143. }
  28144. /**
  28145. * @hidden
  28146. **/
  28147. class _InternalAbstractMeshDataInfo {
  28148. _hasVertexAlpha: boolean;
  28149. _useVertexColors: boolean;
  28150. _numBoneInfluencers: number;
  28151. _applyFog: boolean;
  28152. _receiveShadows: boolean;
  28153. _facetData: _FacetDataStorage;
  28154. _visibility: number;
  28155. _skeleton: Nullable<Skeleton>;
  28156. _layerMask: number;
  28157. _computeBonesUsingShaders: boolean;
  28158. _isActive: boolean;
  28159. _onlyForInstances: boolean;
  28160. _isActiveIntermediate: boolean;
  28161. _onlyForInstancesIntermediate: boolean;
  28162. _actAsRegularMesh: boolean;
  28163. }
  28164. /**
  28165. * Class used to store all common mesh properties
  28166. */
  28167. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28168. /** No occlusion */
  28169. static OCCLUSION_TYPE_NONE: number;
  28170. /** Occlusion set to optimisitic */
  28171. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28172. /** Occlusion set to strict */
  28173. static OCCLUSION_TYPE_STRICT: number;
  28174. /** Use an accurante occlusion algorithm */
  28175. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28176. /** Use a conservative occlusion algorithm */
  28177. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28178. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28179. * Test order :
  28180. * Is the bounding sphere outside the frustum ?
  28181. * If not, are the bounding box vertices outside the frustum ?
  28182. * It not, then the cullable object is in the frustum.
  28183. */
  28184. static readonly CULLINGSTRATEGY_STANDARD: number;
  28185. /** Culling strategy : Bounding Sphere Only.
  28186. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28187. * It's also less accurate than the standard because some not visible objects can still be selected.
  28188. * Test : is the bounding sphere outside the frustum ?
  28189. * If not, then the cullable object is in the frustum.
  28190. */
  28191. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28192. /** Culling strategy : Optimistic Inclusion.
  28193. * This in an inclusion test first, then the standard exclusion test.
  28194. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28195. * 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.
  28196. * Anyway, it's as accurate as the standard strategy.
  28197. * Test :
  28198. * Is the cullable object bounding sphere center in the frustum ?
  28199. * If not, apply the default culling strategy.
  28200. */
  28201. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28202. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28203. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28204. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28205. * 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.
  28206. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28207. * Test :
  28208. * Is the cullable object bounding sphere center in the frustum ?
  28209. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28210. */
  28211. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28212. /**
  28213. * No billboard
  28214. */
  28215. static readonly BILLBOARDMODE_NONE: number;
  28216. /** Billboard on X axis */
  28217. static readonly BILLBOARDMODE_X: number;
  28218. /** Billboard on Y axis */
  28219. static readonly BILLBOARDMODE_Y: number;
  28220. /** Billboard on Z axis */
  28221. static readonly BILLBOARDMODE_Z: number;
  28222. /** Billboard on all axes */
  28223. static readonly BILLBOARDMODE_ALL: number;
  28224. /** Billboard on using position instead of orientation */
  28225. static readonly BILLBOARDMODE_USE_POSITION: number;
  28226. /** @hidden */
  28227. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28228. /**
  28229. * The culling strategy to use to check whether the mesh must be rendered or not.
  28230. * This value can be changed at any time and will be used on the next render mesh selection.
  28231. * The possible values are :
  28232. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28233. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28234. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28235. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28236. * Please read each static variable documentation to get details about the culling process.
  28237. * */
  28238. cullingStrategy: number;
  28239. /**
  28240. * Gets the number of facets in the mesh
  28241. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28242. */
  28243. readonly facetNb: number;
  28244. /**
  28245. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28246. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28247. */
  28248. partitioningSubdivisions: number;
  28249. /**
  28250. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28251. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28252. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28253. */
  28254. partitioningBBoxRatio: number;
  28255. /**
  28256. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28257. * Works only for updatable meshes.
  28258. * Doesn't work with multi-materials
  28259. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28260. */
  28261. mustDepthSortFacets: boolean;
  28262. /**
  28263. * The location (Vector3) where the facet depth sort must be computed from.
  28264. * By default, the active camera position.
  28265. * Used only when facet depth sort is enabled
  28266. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28267. */
  28268. facetDepthSortFrom: Vector3;
  28269. /**
  28270. * gets a boolean indicating if facetData is enabled
  28271. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28272. */
  28273. readonly isFacetDataEnabled: boolean;
  28274. /** @hidden */
  28275. _updateNonUniformScalingState(value: boolean): boolean;
  28276. /**
  28277. * An event triggered when this mesh collides with another one
  28278. */
  28279. onCollideObservable: Observable<AbstractMesh>;
  28280. /** Set a function to call when this mesh collides with another one */
  28281. onCollide: () => void;
  28282. /**
  28283. * An event triggered when the collision's position changes
  28284. */
  28285. onCollisionPositionChangeObservable: Observable<Vector3>;
  28286. /** Set a function to call when the collision's position changes */
  28287. onCollisionPositionChange: () => void;
  28288. /**
  28289. * An event triggered when material is changed
  28290. */
  28291. onMaterialChangedObservable: Observable<AbstractMesh>;
  28292. /**
  28293. * Gets or sets the orientation for POV movement & rotation
  28294. */
  28295. definedFacingForward: boolean;
  28296. /** @hidden */
  28297. _occlusionQuery: Nullable<WebGLQuery>;
  28298. /** @hidden */
  28299. _renderingGroup: Nullable<RenderingGroup>;
  28300. /**
  28301. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28302. */
  28303. /**
  28304. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28305. */
  28306. visibility: number;
  28307. /** Gets or sets the alpha index used to sort transparent meshes
  28308. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28309. */
  28310. alphaIndex: number;
  28311. /**
  28312. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28313. */
  28314. isVisible: boolean;
  28315. /**
  28316. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28317. */
  28318. isPickable: boolean;
  28319. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28320. showSubMeshesBoundingBox: boolean;
  28321. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28322. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28323. */
  28324. isBlocker: boolean;
  28325. /**
  28326. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28327. */
  28328. enablePointerMoveEvents: boolean;
  28329. /**
  28330. * Specifies the rendering group id for this mesh (0 by default)
  28331. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28332. */
  28333. renderingGroupId: number;
  28334. private _material;
  28335. /** Gets or sets current material */
  28336. material: Nullable<Material>;
  28337. /**
  28338. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28339. * @see http://doc.babylonjs.com/babylon101/shadows
  28340. */
  28341. receiveShadows: boolean;
  28342. /** Defines color to use when rendering outline */
  28343. outlineColor: Color3;
  28344. /** Define width to use when rendering outline */
  28345. outlineWidth: number;
  28346. /** Defines color to use when rendering overlay */
  28347. overlayColor: Color3;
  28348. /** Defines alpha to use when rendering overlay */
  28349. overlayAlpha: number;
  28350. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28351. hasVertexAlpha: boolean;
  28352. /** 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) */
  28353. useVertexColors: boolean;
  28354. /**
  28355. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28356. */
  28357. computeBonesUsingShaders: boolean;
  28358. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28359. numBoneInfluencers: number;
  28360. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28361. applyFog: boolean;
  28362. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28363. useOctreeForRenderingSelection: boolean;
  28364. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28365. useOctreeForPicking: boolean;
  28366. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28367. useOctreeForCollisions: boolean;
  28368. /**
  28369. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28370. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28371. */
  28372. layerMask: number;
  28373. /**
  28374. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28375. */
  28376. alwaysSelectAsActiveMesh: boolean;
  28377. /**
  28378. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28379. */
  28380. doNotSyncBoundingInfo: boolean;
  28381. /**
  28382. * Gets or sets the current action manager
  28383. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28384. */
  28385. actionManager: Nullable<AbstractActionManager>;
  28386. private _meshCollisionData;
  28387. /**
  28388. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28389. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28390. */
  28391. ellipsoid: Vector3;
  28392. /**
  28393. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28394. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28395. */
  28396. ellipsoidOffset: Vector3;
  28397. /**
  28398. * Gets or sets a collision mask used to mask collisions (default is -1).
  28399. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28400. */
  28401. collisionMask: number;
  28402. /**
  28403. * Gets or sets the current collision group mask (-1 by default).
  28404. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28405. */
  28406. collisionGroup: number;
  28407. /**
  28408. * Defines edge width used when edgesRenderer is enabled
  28409. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28410. */
  28411. edgesWidth: number;
  28412. /**
  28413. * Defines edge color used when edgesRenderer is enabled
  28414. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28415. */
  28416. edgesColor: Color4;
  28417. /** @hidden */
  28418. _edgesRenderer: Nullable<IEdgesRenderer>;
  28419. /** @hidden */
  28420. _masterMesh: Nullable<AbstractMesh>;
  28421. /** @hidden */
  28422. _boundingInfo: Nullable<BoundingInfo>;
  28423. /** @hidden */
  28424. _renderId: number;
  28425. /**
  28426. * Gets or sets the list of subMeshes
  28427. * @see http://doc.babylonjs.com/how_to/multi_materials
  28428. */
  28429. subMeshes: SubMesh[];
  28430. /** @hidden */
  28431. _intersectionsInProgress: AbstractMesh[];
  28432. /** @hidden */
  28433. _unIndexed: boolean;
  28434. /** @hidden */
  28435. _lightSources: Light[];
  28436. /** Gets the list of lights affecting that mesh */
  28437. readonly lightSources: Light[];
  28438. /** @hidden */
  28439. readonly _positions: Nullable<Vector3[]>;
  28440. /** @hidden */
  28441. _waitingData: {
  28442. lods: Nullable<any>;
  28443. actions: Nullable<any>;
  28444. freezeWorldMatrix: Nullable<boolean>;
  28445. };
  28446. /** @hidden */
  28447. _bonesTransformMatrices: Nullable<Float32Array>;
  28448. /** @hidden */
  28449. _transformMatrixTexture: Nullable<RawTexture>;
  28450. /**
  28451. * Gets or sets a skeleton to apply skining transformations
  28452. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28453. */
  28454. skeleton: Nullable<Skeleton>;
  28455. /**
  28456. * An event triggered when the mesh is rebuilt.
  28457. */
  28458. onRebuildObservable: Observable<AbstractMesh>;
  28459. /**
  28460. * Creates a new AbstractMesh
  28461. * @param name defines the name of the mesh
  28462. * @param scene defines the hosting scene
  28463. */
  28464. constructor(name: string, scene?: Nullable<Scene>);
  28465. /**
  28466. * Returns the string "AbstractMesh"
  28467. * @returns "AbstractMesh"
  28468. */
  28469. getClassName(): string;
  28470. /**
  28471. * Gets a string representation of the current mesh
  28472. * @param fullDetails defines a boolean indicating if full details must be included
  28473. * @returns a string representation of the current mesh
  28474. */
  28475. toString(fullDetails?: boolean): string;
  28476. /**
  28477. * @hidden
  28478. */
  28479. protected _getEffectiveParent(): Nullable<Node>;
  28480. /** @hidden */
  28481. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28482. /** @hidden */
  28483. _rebuild(): void;
  28484. /** @hidden */
  28485. _resyncLightSources(): void;
  28486. /** @hidden */
  28487. _resyncLightSource(light: Light): void;
  28488. /** @hidden */
  28489. _unBindEffect(): void;
  28490. /** @hidden */
  28491. _removeLightSource(light: Light, dispose: boolean): void;
  28492. private _markSubMeshesAsDirty;
  28493. /** @hidden */
  28494. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28495. /** @hidden */
  28496. _markSubMeshesAsAttributesDirty(): void;
  28497. /** @hidden */
  28498. _markSubMeshesAsMiscDirty(): void;
  28499. /**
  28500. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28501. */
  28502. scaling: Vector3;
  28503. /**
  28504. * Returns true if the mesh is blocked. Implemented by child classes
  28505. */
  28506. readonly isBlocked: boolean;
  28507. /**
  28508. * Returns the mesh itself by default. Implemented by child classes
  28509. * @param camera defines the camera to use to pick the right LOD level
  28510. * @returns the currentAbstractMesh
  28511. */
  28512. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28513. /**
  28514. * Returns 0 by default. Implemented by child classes
  28515. * @returns an integer
  28516. */
  28517. getTotalVertices(): number;
  28518. /**
  28519. * Returns a positive integer : the total number of indices in this mesh geometry.
  28520. * @returns the numner of indices or zero if the mesh has no geometry.
  28521. */
  28522. getTotalIndices(): number;
  28523. /**
  28524. * Returns null by default. Implemented by child classes
  28525. * @returns null
  28526. */
  28527. getIndices(): Nullable<IndicesArray>;
  28528. /**
  28529. * Returns the array of the requested vertex data kind. Implemented by child classes
  28530. * @param kind defines the vertex data kind to use
  28531. * @returns null
  28532. */
  28533. getVerticesData(kind: string): Nullable<FloatArray>;
  28534. /**
  28535. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28536. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28537. * Note that a new underlying VertexBuffer object is created each call.
  28538. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28539. * @param kind defines vertex data kind:
  28540. * * VertexBuffer.PositionKind
  28541. * * VertexBuffer.UVKind
  28542. * * VertexBuffer.UV2Kind
  28543. * * VertexBuffer.UV3Kind
  28544. * * VertexBuffer.UV4Kind
  28545. * * VertexBuffer.UV5Kind
  28546. * * VertexBuffer.UV6Kind
  28547. * * VertexBuffer.ColorKind
  28548. * * VertexBuffer.MatricesIndicesKind
  28549. * * VertexBuffer.MatricesIndicesExtraKind
  28550. * * VertexBuffer.MatricesWeightsKind
  28551. * * VertexBuffer.MatricesWeightsExtraKind
  28552. * @param data defines the data source
  28553. * @param updatable defines if the data must be flagged as updatable (or static)
  28554. * @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
  28555. * @returns the current mesh
  28556. */
  28557. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28558. /**
  28559. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28560. * If the mesh has no geometry, it is simply returned as it is.
  28561. * @param kind defines vertex data kind:
  28562. * * VertexBuffer.PositionKind
  28563. * * VertexBuffer.UVKind
  28564. * * VertexBuffer.UV2Kind
  28565. * * VertexBuffer.UV3Kind
  28566. * * VertexBuffer.UV4Kind
  28567. * * VertexBuffer.UV5Kind
  28568. * * VertexBuffer.UV6Kind
  28569. * * VertexBuffer.ColorKind
  28570. * * VertexBuffer.MatricesIndicesKind
  28571. * * VertexBuffer.MatricesIndicesExtraKind
  28572. * * VertexBuffer.MatricesWeightsKind
  28573. * * VertexBuffer.MatricesWeightsExtraKind
  28574. * @param data defines the data source
  28575. * @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
  28576. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28577. * @returns the current mesh
  28578. */
  28579. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28580. /**
  28581. * Sets the mesh indices,
  28582. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28583. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28584. * @param totalVertices Defines the total number of vertices
  28585. * @returns the current mesh
  28586. */
  28587. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28588. /**
  28589. * Gets a boolean indicating if specific vertex data is present
  28590. * @param kind defines the vertex data kind to use
  28591. * @returns true is data kind is present
  28592. */
  28593. isVerticesDataPresent(kind: string): boolean;
  28594. /**
  28595. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28596. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28597. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28598. * @returns a BoundingInfo
  28599. */
  28600. getBoundingInfo(): BoundingInfo;
  28601. /**
  28602. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28603. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28604. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28605. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28606. * @returns the current mesh
  28607. */
  28608. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28609. /**
  28610. * Overwrite the current bounding info
  28611. * @param boundingInfo defines the new bounding info
  28612. * @returns the current mesh
  28613. */
  28614. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28615. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28616. readonly useBones: boolean;
  28617. /** @hidden */
  28618. _preActivate(): void;
  28619. /** @hidden */
  28620. _preActivateForIntermediateRendering(renderId: number): void;
  28621. /** @hidden */
  28622. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28623. /** @hidden */
  28624. _postActivate(): void;
  28625. /** @hidden */
  28626. _freeze(): void;
  28627. /** @hidden */
  28628. _unFreeze(): void;
  28629. /**
  28630. * Gets the current world matrix
  28631. * @returns a Matrix
  28632. */
  28633. getWorldMatrix(): Matrix;
  28634. /** @hidden */
  28635. _getWorldMatrixDeterminant(): number;
  28636. /**
  28637. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28638. */
  28639. readonly isAnInstance: boolean;
  28640. /**
  28641. * Gets a boolean indicating if this mesh has instances
  28642. */
  28643. readonly hasInstances: boolean;
  28644. /**
  28645. * Perform relative position change from the point of view of behind the front of the mesh.
  28646. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28647. * Supports definition of mesh facing forward or backward
  28648. * @param amountRight defines the distance on the right axis
  28649. * @param amountUp defines the distance on the up axis
  28650. * @param amountForward defines the distance on the forward axis
  28651. * @returns the current mesh
  28652. */
  28653. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28654. /**
  28655. * Calculate relative position change from the point of view of behind the front of the mesh.
  28656. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28657. * Supports definition of mesh facing forward or backward
  28658. * @param amountRight defines the distance on the right axis
  28659. * @param amountUp defines the distance on the up axis
  28660. * @param amountForward defines the distance on the forward axis
  28661. * @returns the new displacement vector
  28662. */
  28663. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28664. /**
  28665. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28666. * Supports definition of mesh facing forward or backward
  28667. * @param flipBack defines the flip
  28668. * @param twirlClockwise defines the twirl
  28669. * @param tiltRight defines the tilt
  28670. * @returns the current mesh
  28671. */
  28672. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28673. /**
  28674. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28675. * Supports definition of mesh facing forward or backward.
  28676. * @param flipBack defines the flip
  28677. * @param twirlClockwise defines the twirl
  28678. * @param tiltRight defines the tilt
  28679. * @returns the new rotation vector
  28680. */
  28681. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28682. /**
  28683. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28684. * This means the mesh underlying bounding box and sphere are recomputed.
  28685. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28686. * @returns the current mesh
  28687. */
  28688. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28689. /** @hidden */
  28690. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28691. /** @hidden */
  28692. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28693. /** @hidden */
  28694. _updateBoundingInfo(): AbstractMesh;
  28695. /** @hidden */
  28696. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28697. /** @hidden */
  28698. protected _afterComputeWorldMatrix(): void;
  28699. /** @hidden */
  28700. readonly _effectiveMesh: AbstractMesh;
  28701. /**
  28702. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28703. * A mesh is in the frustum if its bounding box intersects the frustum
  28704. * @param frustumPlanes defines the frustum to test
  28705. * @returns true if the mesh is in the frustum planes
  28706. */
  28707. isInFrustum(frustumPlanes: Plane[]): boolean;
  28708. /**
  28709. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28710. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28711. * @param frustumPlanes defines the frustum to test
  28712. * @returns true if the mesh is completely in the frustum planes
  28713. */
  28714. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28715. /**
  28716. * True if the mesh intersects another mesh or a SolidParticle object
  28717. * @param mesh defines a target mesh or SolidParticle to test
  28718. * @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)
  28719. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28720. * @returns true if there is an intersection
  28721. */
  28722. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28723. /**
  28724. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28725. * @param point defines the point to test
  28726. * @returns true if there is an intersection
  28727. */
  28728. intersectsPoint(point: Vector3): boolean;
  28729. /**
  28730. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28731. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28732. */
  28733. checkCollisions: boolean;
  28734. /**
  28735. * Gets Collider object used to compute collisions (not physics)
  28736. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28737. */
  28738. readonly collider: Nullable<Collider>;
  28739. /**
  28740. * Move the mesh using collision engine
  28741. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28742. * @param displacement defines the requested displacement vector
  28743. * @returns the current mesh
  28744. */
  28745. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28746. private _onCollisionPositionChange;
  28747. /** @hidden */
  28748. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28749. /** @hidden */
  28750. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28751. /** @hidden */
  28752. _checkCollision(collider: Collider): AbstractMesh;
  28753. /** @hidden */
  28754. _generatePointsArray(): boolean;
  28755. /**
  28756. * Checks if the passed Ray intersects with the mesh
  28757. * @param ray defines the ray to use
  28758. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28759. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28760. * @returns the picking info
  28761. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28762. */
  28763. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28764. /**
  28765. * Clones the current mesh
  28766. * @param name defines the mesh name
  28767. * @param newParent defines the new mesh parent
  28768. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28769. * @returns the new mesh
  28770. */
  28771. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28772. /**
  28773. * Disposes all the submeshes of the current meshnp
  28774. * @returns the current mesh
  28775. */
  28776. releaseSubMeshes(): AbstractMesh;
  28777. /**
  28778. * Releases resources associated with this abstract mesh.
  28779. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28780. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28781. */
  28782. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28783. /**
  28784. * Adds the passed mesh as a child to the current mesh
  28785. * @param mesh defines the child mesh
  28786. * @returns the current mesh
  28787. */
  28788. addChild(mesh: AbstractMesh): AbstractMesh;
  28789. /**
  28790. * Removes the passed mesh from the current mesh children list
  28791. * @param mesh defines the child mesh
  28792. * @returns the current mesh
  28793. */
  28794. removeChild(mesh: AbstractMesh): AbstractMesh;
  28795. /** @hidden */
  28796. private _initFacetData;
  28797. /**
  28798. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28799. * This method can be called within the render loop.
  28800. * 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
  28801. * @returns the current mesh
  28802. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28803. */
  28804. updateFacetData(): AbstractMesh;
  28805. /**
  28806. * Returns the facetLocalNormals array.
  28807. * The normals are expressed in the mesh local spac
  28808. * @returns an array of Vector3
  28809. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28810. */
  28811. getFacetLocalNormals(): Vector3[];
  28812. /**
  28813. * Returns the facetLocalPositions array.
  28814. * The facet positions are expressed in the mesh local space
  28815. * @returns an array of Vector3
  28816. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28817. */
  28818. getFacetLocalPositions(): Vector3[];
  28819. /**
  28820. * Returns the facetLocalPartioning array
  28821. * @returns an array of array of numbers
  28822. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28823. */
  28824. getFacetLocalPartitioning(): number[][];
  28825. /**
  28826. * Returns the i-th facet position in the world system.
  28827. * This method allocates a new Vector3 per call
  28828. * @param i defines the facet index
  28829. * @returns a new Vector3
  28830. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28831. */
  28832. getFacetPosition(i: number): Vector3;
  28833. /**
  28834. * Sets the reference Vector3 with the i-th facet position in the world system
  28835. * @param i defines the facet index
  28836. * @param ref defines the target vector
  28837. * @returns the current mesh
  28838. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28839. */
  28840. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28841. /**
  28842. * Returns the i-th facet normal in the world system.
  28843. * This method allocates a new Vector3 per call
  28844. * @param i defines the facet index
  28845. * @returns a new Vector3
  28846. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28847. */
  28848. getFacetNormal(i: number): Vector3;
  28849. /**
  28850. * Sets the reference Vector3 with the i-th facet normal in the world system
  28851. * @param i defines the facet index
  28852. * @param ref defines the target vector
  28853. * @returns the current mesh
  28854. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28855. */
  28856. getFacetNormalToRef(i: number, ref: Vector3): this;
  28857. /**
  28858. * 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)
  28859. * @param x defines x coordinate
  28860. * @param y defines y coordinate
  28861. * @param z defines z coordinate
  28862. * @returns the array of facet indexes
  28863. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28864. */
  28865. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28866. /**
  28867. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28868. * @param projected sets as the (x,y,z) world projection on the facet
  28869. * @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
  28870. * @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
  28871. * @param x defines x coordinate
  28872. * @param y defines y coordinate
  28873. * @param z defines z coordinate
  28874. * @returns the face index if found (or null instead)
  28875. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28876. */
  28877. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28878. /**
  28879. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28880. * @param projected sets as the (x,y,z) local projection on the facet
  28881. * @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
  28882. * @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
  28883. * @param x defines x coordinate
  28884. * @param y defines y coordinate
  28885. * @param z defines z coordinate
  28886. * @returns the face index if found (or null instead)
  28887. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28888. */
  28889. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28890. /**
  28891. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28892. * @returns the parameters
  28893. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28894. */
  28895. getFacetDataParameters(): any;
  28896. /**
  28897. * Disables the feature FacetData and frees the related memory
  28898. * @returns the current mesh
  28899. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28900. */
  28901. disableFacetData(): AbstractMesh;
  28902. /**
  28903. * Updates the AbstractMesh indices array
  28904. * @param indices defines the data source
  28905. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28906. * @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)
  28907. * @returns the current mesh
  28908. */
  28909. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28910. /**
  28911. * Creates new normals data for the mesh
  28912. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28913. * @returns the current mesh
  28914. */
  28915. createNormals(updatable: boolean): AbstractMesh;
  28916. /**
  28917. * Align the mesh with a normal
  28918. * @param normal defines the normal to use
  28919. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28920. * @returns the current mesh
  28921. */
  28922. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28923. /** @hidden */
  28924. _checkOcclusionQuery(): boolean;
  28925. /**
  28926. * Disables the mesh edge rendering mode
  28927. * @returns the currentAbstractMesh
  28928. */
  28929. disableEdgesRendering(): AbstractMesh;
  28930. /**
  28931. * Enables the edge rendering mode on the mesh.
  28932. * This mode makes the mesh edges visible
  28933. * @param epsilon defines the maximal distance between two angles to detect a face
  28934. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28935. * @returns the currentAbstractMesh
  28936. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28937. */
  28938. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28939. }
  28940. }
  28941. declare module "babylonjs/Actions/actionEvent" {
  28942. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28943. import { Nullable } from "babylonjs/types";
  28944. import { Sprite } from "babylonjs/Sprites/sprite";
  28945. import { Scene } from "babylonjs/scene";
  28946. import { Vector2 } from "babylonjs/Maths/math.vector";
  28947. /**
  28948. * Interface used to define ActionEvent
  28949. */
  28950. export interface IActionEvent {
  28951. /** The mesh or sprite that triggered the action */
  28952. source: any;
  28953. /** The X mouse cursor position at the time of the event */
  28954. pointerX: number;
  28955. /** The Y mouse cursor position at the time of the event */
  28956. pointerY: number;
  28957. /** The mesh that is currently pointed at (can be null) */
  28958. meshUnderPointer: Nullable<AbstractMesh>;
  28959. /** the original (browser) event that triggered the ActionEvent */
  28960. sourceEvent?: any;
  28961. /** additional data for the event */
  28962. additionalData?: any;
  28963. }
  28964. /**
  28965. * ActionEvent is the event being sent when an action is triggered.
  28966. */
  28967. export class ActionEvent implements IActionEvent {
  28968. /** The mesh or sprite that triggered the action */
  28969. source: any;
  28970. /** The X mouse cursor position at the time of the event */
  28971. pointerX: number;
  28972. /** The Y mouse cursor position at the time of the event */
  28973. pointerY: number;
  28974. /** The mesh that is currently pointed at (can be null) */
  28975. meshUnderPointer: Nullable<AbstractMesh>;
  28976. /** the original (browser) event that triggered the ActionEvent */
  28977. sourceEvent?: any;
  28978. /** additional data for the event */
  28979. additionalData?: any;
  28980. /**
  28981. * Creates a new ActionEvent
  28982. * @param source The mesh or sprite that triggered the action
  28983. * @param pointerX The X mouse cursor position at the time of the event
  28984. * @param pointerY The Y mouse cursor position at the time of the event
  28985. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28986. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28987. * @param additionalData additional data for the event
  28988. */
  28989. constructor(
  28990. /** The mesh or sprite that triggered the action */
  28991. source: any,
  28992. /** The X mouse cursor position at the time of the event */
  28993. pointerX: number,
  28994. /** The Y mouse cursor position at the time of the event */
  28995. pointerY: number,
  28996. /** The mesh that is currently pointed at (can be null) */
  28997. meshUnderPointer: Nullable<AbstractMesh>,
  28998. /** the original (browser) event that triggered the ActionEvent */
  28999. sourceEvent?: any,
  29000. /** additional data for the event */
  29001. additionalData?: any);
  29002. /**
  29003. * Helper function to auto-create an ActionEvent from a source mesh.
  29004. * @param source The source mesh that triggered the event
  29005. * @param evt The original (browser) event
  29006. * @param additionalData additional data for the event
  29007. * @returns the new ActionEvent
  29008. */
  29009. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29010. /**
  29011. * Helper function to auto-create an ActionEvent from a source sprite
  29012. * @param source The source sprite that triggered the event
  29013. * @param scene Scene associated with the sprite
  29014. * @param evt The original (browser) event
  29015. * @param additionalData additional data for the event
  29016. * @returns the new ActionEvent
  29017. */
  29018. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29019. /**
  29020. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29021. * @param scene the scene where the event occurred
  29022. * @param evt The original (browser) event
  29023. * @returns the new ActionEvent
  29024. */
  29025. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29026. /**
  29027. * Helper function to auto-create an ActionEvent from a primitive
  29028. * @param prim defines the target primitive
  29029. * @param pointerPos defines the pointer position
  29030. * @param evt The original (browser) event
  29031. * @param additionalData additional data for the event
  29032. * @returns the new ActionEvent
  29033. */
  29034. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29035. }
  29036. }
  29037. declare module "babylonjs/Actions/abstractActionManager" {
  29038. import { IDisposable } from "babylonjs/scene";
  29039. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  29040. import { IAction } from "babylonjs/Actions/action";
  29041. import { Nullable } from "babylonjs/types";
  29042. /**
  29043. * Abstract class used to decouple action Manager from scene and meshes.
  29044. * Do not instantiate.
  29045. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29046. */
  29047. export abstract class AbstractActionManager implements IDisposable {
  29048. /** Gets the list of active triggers */
  29049. static Triggers: {
  29050. [key: string]: number;
  29051. };
  29052. /** Gets the cursor to use when hovering items */
  29053. hoverCursor: string;
  29054. /** Gets the list of actions */
  29055. actions: IAction[];
  29056. /**
  29057. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29058. */
  29059. isRecursive: boolean;
  29060. /**
  29061. * Releases all associated resources
  29062. */
  29063. abstract dispose(): void;
  29064. /**
  29065. * Does this action manager has pointer triggers
  29066. */
  29067. abstract readonly hasPointerTriggers: boolean;
  29068. /**
  29069. * Does this action manager has pick triggers
  29070. */
  29071. abstract readonly hasPickTriggers: boolean;
  29072. /**
  29073. * Process a specific trigger
  29074. * @param trigger defines the trigger to process
  29075. * @param evt defines the event details to be processed
  29076. */
  29077. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29078. /**
  29079. * Does this action manager handles actions of any of the given triggers
  29080. * @param triggers defines the triggers to be tested
  29081. * @return a boolean indicating whether one (or more) of the triggers is handled
  29082. */
  29083. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29084. /**
  29085. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29086. * speed.
  29087. * @param triggerA defines the trigger to be tested
  29088. * @param triggerB defines the trigger to be tested
  29089. * @return a boolean indicating whether one (or more) of the triggers is handled
  29090. */
  29091. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29092. /**
  29093. * Does this action manager handles actions of a given trigger
  29094. * @param trigger defines the trigger to be tested
  29095. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29096. * @return whether the trigger is handled
  29097. */
  29098. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29099. /**
  29100. * Serialize this manager to a JSON object
  29101. * @param name defines the property name to store this manager
  29102. * @returns a JSON representation of this manager
  29103. */
  29104. abstract serialize(name: string): any;
  29105. /**
  29106. * Registers an action to this action manager
  29107. * @param action defines the action to be registered
  29108. * @return the action amended (prepared) after registration
  29109. */
  29110. abstract registerAction(action: IAction): Nullable<IAction>;
  29111. /**
  29112. * Unregisters an action to this action manager
  29113. * @param action defines the action to be unregistered
  29114. * @return a boolean indicating whether the action has been unregistered
  29115. */
  29116. abstract unregisterAction(action: IAction): Boolean;
  29117. /**
  29118. * Does exist one action manager with at least one trigger
  29119. **/
  29120. static readonly HasTriggers: boolean;
  29121. /**
  29122. * Does exist one action manager with at least one pick trigger
  29123. **/
  29124. static readonly HasPickTriggers: boolean;
  29125. /**
  29126. * Does exist one action manager that handles actions of a given trigger
  29127. * @param trigger defines the trigger to be tested
  29128. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29129. **/
  29130. static HasSpecificTrigger(trigger: number): boolean;
  29131. }
  29132. }
  29133. declare module "babylonjs/node" {
  29134. import { Scene } from "babylonjs/scene";
  29135. import { Nullable } from "babylonjs/types";
  29136. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29137. import { Engine } from "babylonjs/Engines/engine";
  29138. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  29139. import { Observable } from "babylonjs/Misc/observable";
  29140. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29141. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29142. import { Animatable } from "babylonjs/Animations/animatable";
  29143. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  29144. import { Animation } from "babylonjs/Animations/animation";
  29145. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29147. /**
  29148. * Defines how a node can be built from a string name.
  29149. */
  29150. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29151. /**
  29152. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29153. */
  29154. export class Node implements IBehaviorAware<Node> {
  29155. /** @hidden */
  29156. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  29157. private static _NodeConstructors;
  29158. /**
  29159. * Add a new node constructor
  29160. * @param type defines the type name of the node to construct
  29161. * @param constructorFunc defines the constructor function
  29162. */
  29163. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29164. /**
  29165. * Returns a node constructor based on type name
  29166. * @param type defines the type name
  29167. * @param name defines the new node name
  29168. * @param scene defines the hosting scene
  29169. * @param options defines optional options to transmit to constructors
  29170. * @returns the new constructor or null
  29171. */
  29172. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29173. /**
  29174. * Gets or sets the name of the node
  29175. */
  29176. name: string;
  29177. /**
  29178. * Gets or sets the id of the node
  29179. */
  29180. id: string;
  29181. /**
  29182. * Gets or sets the unique id of the node
  29183. */
  29184. uniqueId: number;
  29185. /**
  29186. * Gets or sets a string used to store user defined state for the node
  29187. */
  29188. state: string;
  29189. /**
  29190. * Gets or sets an object used to store user defined information for the node
  29191. */
  29192. metadata: any;
  29193. /**
  29194. * For internal use only. Please do not use.
  29195. */
  29196. reservedDataStore: any;
  29197. /**
  29198. * List of inspectable custom properties (used by the Inspector)
  29199. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29200. */
  29201. inspectableCustomProperties: IInspectable[];
  29202. private _doNotSerialize;
  29203. /**
  29204. * Gets or sets a boolean used to define if the node must be serialized
  29205. */
  29206. doNotSerialize: boolean;
  29207. /** @hidden */
  29208. _isDisposed: boolean;
  29209. /**
  29210. * Gets a list of Animations associated with the node
  29211. */
  29212. animations: import("babylonjs/Animations/animation").Animation[];
  29213. protected _ranges: {
  29214. [name: string]: Nullable<AnimationRange>;
  29215. };
  29216. /**
  29217. * Callback raised when the node is ready to be used
  29218. */
  29219. onReady: Nullable<(node: Node) => void>;
  29220. private _isEnabled;
  29221. private _isParentEnabled;
  29222. private _isReady;
  29223. /** @hidden */
  29224. _currentRenderId: number;
  29225. private _parentUpdateId;
  29226. /** @hidden */
  29227. _childUpdateId: number;
  29228. /** @hidden */
  29229. _waitingParentId: Nullable<string>;
  29230. /** @hidden */
  29231. _scene: Scene;
  29232. /** @hidden */
  29233. _cache: any;
  29234. private _parentNode;
  29235. private _children;
  29236. /** @hidden */
  29237. _worldMatrix: Matrix;
  29238. /** @hidden */
  29239. _worldMatrixDeterminant: number;
  29240. /** @hidden */
  29241. _worldMatrixDeterminantIsDirty: boolean;
  29242. /** @hidden */
  29243. private _sceneRootNodesIndex;
  29244. /**
  29245. * Gets a boolean indicating if the node has been disposed
  29246. * @returns true if the node was disposed
  29247. */
  29248. isDisposed(): boolean;
  29249. /**
  29250. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29251. * @see https://doc.babylonjs.com/how_to/parenting
  29252. */
  29253. parent: Nullable<Node>;
  29254. /** @hidden */
  29255. _addToSceneRootNodes(): void;
  29256. /** @hidden */
  29257. _removeFromSceneRootNodes(): void;
  29258. private _animationPropertiesOverride;
  29259. /**
  29260. * Gets or sets the animation properties override
  29261. */
  29262. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  29263. /**
  29264. * Gets a string idenfifying the name of the class
  29265. * @returns "Node" string
  29266. */
  29267. getClassName(): string;
  29268. /** @hidden */
  29269. readonly _isNode: boolean;
  29270. /**
  29271. * An event triggered when the mesh is disposed
  29272. */
  29273. onDisposeObservable: Observable<Node>;
  29274. private _onDisposeObserver;
  29275. /**
  29276. * Sets a callback that will be raised when the node will be disposed
  29277. */
  29278. onDispose: () => void;
  29279. /**
  29280. * Creates a new Node
  29281. * @param name the name and id to be given to this node
  29282. * @param scene the scene this node will be added to
  29283. */
  29284. constructor(name: string, scene?: Nullable<Scene>);
  29285. /**
  29286. * Gets the scene of the node
  29287. * @returns a scene
  29288. */
  29289. getScene(): Scene;
  29290. /**
  29291. * Gets the engine of the node
  29292. * @returns a Engine
  29293. */
  29294. getEngine(): Engine;
  29295. private _behaviors;
  29296. /**
  29297. * Attach a behavior to the node
  29298. * @see http://doc.babylonjs.com/features/behaviour
  29299. * @param behavior defines the behavior to attach
  29300. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29301. * @returns the current Node
  29302. */
  29303. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29304. /**
  29305. * Remove an attached behavior
  29306. * @see http://doc.babylonjs.com/features/behaviour
  29307. * @param behavior defines the behavior to attach
  29308. * @returns the current Node
  29309. */
  29310. removeBehavior(behavior: Behavior<Node>): Node;
  29311. /**
  29312. * Gets the list of attached behaviors
  29313. * @see http://doc.babylonjs.com/features/behaviour
  29314. */
  29315. readonly behaviors: Behavior<Node>[];
  29316. /**
  29317. * Gets an attached behavior by name
  29318. * @param name defines the name of the behavior to look for
  29319. * @see http://doc.babylonjs.com/features/behaviour
  29320. * @returns null if behavior was not found else the requested behavior
  29321. */
  29322. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29323. /**
  29324. * Returns the latest update of the World matrix
  29325. * @returns a Matrix
  29326. */
  29327. getWorldMatrix(): Matrix;
  29328. /** @hidden */
  29329. _getWorldMatrixDeterminant(): number;
  29330. /**
  29331. * Returns directly the latest state of the mesh World matrix.
  29332. * A Matrix is returned.
  29333. */
  29334. readonly worldMatrixFromCache: Matrix;
  29335. /** @hidden */
  29336. _initCache(): void;
  29337. /** @hidden */
  29338. updateCache(force?: boolean): void;
  29339. /** @hidden */
  29340. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29341. /** @hidden */
  29342. _updateCache(ignoreParentClass?: boolean): void;
  29343. /** @hidden */
  29344. _isSynchronized(): boolean;
  29345. /** @hidden */
  29346. _markSyncedWithParent(): void;
  29347. /** @hidden */
  29348. isSynchronizedWithParent(): boolean;
  29349. /** @hidden */
  29350. isSynchronized(): boolean;
  29351. /**
  29352. * Is this node ready to be used/rendered
  29353. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29354. * @return true if the node is ready
  29355. */
  29356. isReady(completeCheck?: boolean): boolean;
  29357. /**
  29358. * Is this node enabled?
  29359. * 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
  29360. * @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
  29361. * @return whether this node (and its parent) is enabled
  29362. */
  29363. isEnabled(checkAncestors?: boolean): boolean;
  29364. /** @hidden */
  29365. protected _syncParentEnabledState(): void;
  29366. /**
  29367. * Set the enabled state of this node
  29368. * @param value defines the new enabled state
  29369. */
  29370. setEnabled(value: boolean): void;
  29371. /**
  29372. * Is this node a descendant of the given node?
  29373. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29374. * @param ancestor defines the parent node to inspect
  29375. * @returns a boolean indicating if this node is a descendant of the given node
  29376. */
  29377. isDescendantOf(ancestor: Node): boolean;
  29378. /** @hidden */
  29379. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29380. /**
  29381. * Will return all nodes that have this node as ascendant
  29382. * @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
  29383. * @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
  29384. * @return all children nodes of all types
  29385. */
  29386. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29387. /**
  29388. * Get all child-meshes of this node
  29389. * @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)
  29390. * @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
  29391. * @returns an array of AbstractMesh
  29392. */
  29393. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29394. /**
  29395. * Get all direct children of this node
  29396. * @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
  29397. * @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)
  29398. * @returns an array of Node
  29399. */
  29400. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29401. /** @hidden */
  29402. _setReady(state: boolean): void;
  29403. /**
  29404. * Get an animation by name
  29405. * @param name defines the name of the animation to look for
  29406. * @returns null if not found else the requested animation
  29407. */
  29408. getAnimationByName(name: string): Nullable<Animation>;
  29409. /**
  29410. * Creates an animation range for this node
  29411. * @param name defines the name of the range
  29412. * @param from defines the starting key
  29413. * @param to defines the end key
  29414. */
  29415. createAnimationRange(name: string, from: number, to: number): void;
  29416. /**
  29417. * Delete a specific animation range
  29418. * @param name defines the name of the range to delete
  29419. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29420. */
  29421. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29422. /**
  29423. * Get an animation range by name
  29424. * @param name defines the name of the animation range to look for
  29425. * @returns null if not found else the requested animation range
  29426. */
  29427. getAnimationRange(name: string): Nullable<AnimationRange>;
  29428. /**
  29429. * Gets the list of all animation ranges defined on this node
  29430. * @returns an array
  29431. */
  29432. getAnimationRanges(): Nullable<AnimationRange>[];
  29433. /**
  29434. * Will start the animation sequence
  29435. * @param name defines the range frames for animation sequence
  29436. * @param loop defines if the animation should loop (false by default)
  29437. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29438. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29439. * @returns the object created for this animation. If range does not exist, it will return null
  29440. */
  29441. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29442. /**
  29443. * Serialize animation ranges into a JSON compatible object
  29444. * @returns serialization object
  29445. */
  29446. serializeAnimationRanges(): any;
  29447. /**
  29448. * Computes the world matrix of the node
  29449. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29450. * @returns the world matrix
  29451. */
  29452. computeWorldMatrix(force?: boolean): Matrix;
  29453. /**
  29454. * Releases resources associated with this node.
  29455. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29456. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29457. */
  29458. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29459. /**
  29460. * Parse animation range data from a serialization object and store them into a given node
  29461. * @param node defines where to store the animation ranges
  29462. * @param parsedNode defines the serialization object to read data from
  29463. * @param scene defines the hosting scene
  29464. */
  29465. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29466. /**
  29467. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29468. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29469. * @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
  29470. * @returns the new bounding vectors
  29471. */
  29472. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29473. min: Vector3;
  29474. max: Vector3;
  29475. };
  29476. }
  29477. }
  29478. declare module "babylonjs/Animations/animation" {
  29479. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  29480. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  29481. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29482. import { Nullable } from "babylonjs/types";
  29483. import { Scene } from "babylonjs/scene";
  29484. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  29485. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29486. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  29487. import { Node } from "babylonjs/node";
  29488. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29489. import { Size } from "babylonjs/Maths/math.size";
  29490. import { Animatable } from "babylonjs/Animations/animatable";
  29491. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  29492. /**
  29493. * @hidden
  29494. */
  29495. export class _IAnimationState {
  29496. key: number;
  29497. repeatCount: number;
  29498. workValue?: any;
  29499. loopMode?: number;
  29500. offsetValue?: any;
  29501. highLimitValue?: any;
  29502. }
  29503. /**
  29504. * Class used to store any kind of animation
  29505. */
  29506. export class Animation {
  29507. /**Name of the animation */
  29508. name: string;
  29509. /**Property to animate */
  29510. targetProperty: string;
  29511. /**The frames per second of the animation */
  29512. framePerSecond: number;
  29513. /**The data type of the animation */
  29514. dataType: number;
  29515. /**The loop mode of the animation */
  29516. loopMode?: number | undefined;
  29517. /**Specifies if blending should be enabled */
  29518. enableBlending?: boolean | undefined;
  29519. /**
  29520. * Use matrix interpolation instead of using direct key value when animating matrices
  29521. */
  29522. static AllowMatricesInterpolation: boolean;
  29523. /**
  29524. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29525. */
  29526. static AllowMatrixDecomposeForInterpolation: boolean;
  29527. /**
  29528. * Stores the key frames of the animation
  29529. */
  29530. private _keys;
  29531. /**
  29532. * Stores the easing function of the animation
  29533. */
  29534. private _easingFunction;
  29535. /**
  29536. * @hidden Internal use only
  29537. */
  29538. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  29539. /**
  29540. * The set of event that will be linked to this animation
  29541. */
  29542. private _events;
  29543. /**
  29544. * Stores an array of target property paths
  29545. */
  29546. targetPropertyPath: string[];
  29547. /**
  29548. * Stores the blending speed of the animation
  29549. */
  29550. blendingSpeed: number;
  29551. /**
  29552. * Stores the animation ranges for the animation
  29553. */
  29554. private _ranges;
  29555. /**
  29556. * @hidden Internal use
  29557. */
  29558. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29559. /**
  29560. * Sets up an animation
  29561. * @param property The property to animate
  29562. * @param animationType The animation type to apply
  29563. * @param framePerSecond The frames per second of the animation
  29564. * @param easingFunction The easing function used in the animation
  29565. * @returns The created animation
  29566. */
  29567. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29568. /**
  29569. * Create and start an animation on a node
  29570. * @param name defines the name of the global animation that will be run on all nodes
  29571. * @param node defines the root node where the animation will take place
  29572. * @param targetProperty defines property to animate
  29573. * @param framePerSecond defines the number of frame per second yo use
  29574. * @param totalFrame defines the number of frames in total
  29575. * @param from defines the initial value
  29576. * @param to defines the final value
  29577. * @param loopMode defines which loop mode you want to use (off by default)
  29578. * @param easingFunction defines the easing function to use (linear by default)
  29579. * @param onAnimationEnd defines the callback to call when animation end
  29580. * @returns the animatable created for this animation
  29581. */
  29582. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29583. /**
  29584. * Create and start an animation on a node and its descendants
  29585. * @param name defines the name of the global animation that will be run on all nodes
  29586. * @param node defines the root node where the animation will take place
  29587. * @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
  29588. * @param targetProperty defines property to animate
  29589. * @param framePerSecond defines the number of frame per second to use
  29590. * @param totalFrame defines the number of frames in total
  29591. * @param from defines the initial value
  29592. * @param to defines the final value
  29593. * @param loopMode defines which loop mode you want to use (off by default)
  29594. * @param easingFunction defines the easing function to use (linear by default)
  29595. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29596. * @returns the list of animatables created for all nodes
  29597. * @example https://www.babylonjs-playground.com/#MH0VLI
  29598. */
  29599. 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[]>;
  29600. /**
  29601. * Creates a new animation, merges it with the existing animations and starts it
  29602. * @param name Name of the animation
  29603. * @param node Node which contains the scene that begins the animations
  29604. * @param targetProperty Specifies which property to animate
  29605. * @param framePerSecond The frames per second of the animation
  29606. * @param totalFrame The total number of frames
  29607. * @param from The frame at the beginning of the animation
  29608. * @param to The frame at the end of the animation
  29609. * @param loopMode Specifies the loop mode of the animation
  29610. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29611. * @param onAnimationEnd Callback to run once the animation is complete
  29612. * @returns Nullable animation
  29613. */
  29614. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29615. /**
  29616. * Transition property of an host to the target Value
  29617. * @param property The property to transition
  29618. * @param targetValue The target Value of the property
  29619. * @param host The object where the property to animate belongs
  29620. * @param scene Scene used to run the animation
  29621. * @param frameRate Framerate (in frame/s) to use
  29622. * @param transition The transition type we want to use
  29623. * @param duration The duration of the animation, in milliseconds
  29624. * @param onAnimationEnd Callback trigger at the end of the animation
  29625. * @returns Nullable animation
  29626. */
  29627. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29628. /**
  29629. * Return the array of runtime animations currently using this animation
  29630. */
  29631. readonly runtimeAnimations: RuntimeAnimation[];
  29632. /**
  29633. * Specifies if any of the runtime animations are currently running
  29634. */
  29635. readonly hasRunningRuntimeAnimations: boolean;
  29636. /**
  29637. * Initializes the animation
  29638. * @param name Name of the animation
  29639. * @param targetProperty Property to animate
  29640. * @param framePerSecond The frames per second of the animation
  29641. * @param dataType The data type of the animation
  29642. * @param loopMode The loop mode of the animation
  29643. * @param enableBlending Specifies if blending should be enabled
  29644. */
  29645. constructor(
  29646. /**Name of the animation */
  29647. name: string,
  29648. /**Property to animate */
  29649. targetProperty: string,
  29650. /**The frames per second of the animation */
  29651. framePerSecond: number,
  29652. /**The data type of the animation */
  29653. dataType: number,
  29654. /**The loop mode of the animation */
  29655. loopMode?: number | undefined,
  29656. /**Specifies if blending should be enabled */
  29657. enableBlending?: boolean | undefined);
  29658. /**
  29659. * Converts the animation to a string
  29660. * @param fullDetails support for multiple levels of logging within scene loading
  29661. * @returns String form of the animation
  29662. */
  29663. toString(fullDetails?: boolean): string;
  29664. /**
  29665. * Add an event to this animation
  29666. * @param event Event to add
  29667. */
  29668. addEvent(event: AnimationEvent): void;
  29669. /**
  29670. * Remove all events found at the given frame
  29671. * @param frame The frame to remove events from
  29672. */
  29673. removeEvents(frame: number): void;
  29674. /**
  29675. * Retrieves all the events from the animation
  29676. * @returns Events from the animation
  29677. */
  29678. getEvents(): AnimationEvent[];
  29679. /**
  29680. * Creates an animation range
  29681. * @param name Name of the animation range
  29682. * @param from Starting frame of the animation range
  29683. * @param to Ending frame of the animation
  29684. */
  29685. createRange(name: string, from: number, to: number): void;
  29686. /**
  29687. * Deletes an animation range by name
  29688. * @param name Name of the animation range to delete
  29689. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29690. */
  29691. deleteRange(name: string, deleteFrames?: boolean): void;
  29692. /**
  29693. * Gets the animation range by name, or null if not defined
  29694. * @param name Name of the animation range
  29695. * @returns Nullable animation range
  29696. */
  29697. getRange(name: string): Nullable<AnimationRange>;
  29698. /**
  29699. * Gets the key frames from the animation
  29700. * @returns The key frames of the animation
  29701. */
  29702. getKeys(): Array<IAnimationKey>;
  29703. /**
  29704. * Gets the highest frame rate of the animation
  29705. * @returns Highest frame rate of the animation
  29706. */
  29707. getHighestFrame(): number;
  29708. /**
  29709. * Gets the easing function of the animation
  29710. * @returns Easing function of the animation
  29711. */
  29712. getEasingFunction(): IEasingFunction;
  29713. /**
  29714. * Sets the easing function of the animation
  29715. * @param easingFunction A custom mathematical formula for animation
  29716. */
  29717. setEasingFunction(easingFunction: EasingFunction): void;
  29718. /**
  29719. * Interpolates a scalar linearly
  29720. * @param startValue Start value of the animation curve
  29721. * @param endValue End value of the animation curve
  29722. * @param gradient Scalar amount to interpolate
  29723. * @returns Interpolated scalar value
  29724. */
  29725. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29726. /**
  29727. * Interpolates a scalar cubically
  29728. * @param startValue Start value of the animation curve
  29729. * @param outTangent End tangent of the animation
  29730. * @param endValue End value of the animation curve
  29731. * @param inTangent Start tangent of the animation curve
  29732. * @param gradient Scalar amount to interpolate
  29733. * @returns Interpolated scalar value
  29734. */
  29735. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29736. /**
  29737. * Interpolates a quaternion using a spherical linear interpolation
  29738. * @param startValue Start value of the animation curve
  29739. * @param endValue End value of the animation curve
  29740. * @param gradient Scalar amount to interpolate
  29741. * @returns Interpolated quaternion value
  29742. */
  29743. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29744. /**
  29745. * Interpolates a quaternion cubically
  29746. * @param startValue Start value of the animation curve
  29747. * @param outTangent End tangent of the animation curve
  29748. * @param endValue End value of the animation curve
  29749. * @param inTangent Start tangent of the animation curve
  29750. * @param gradient Scalar amount to interpolate
  29751. * @returns Interpolated quaternion value
  29752. */
  29753. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29754. /**
  29755. * Interpolates a Vector3 linearl
  29756. * @param startValue Start value of the animation curve
  29757. * @param endValue End value of the animation curve
  29758. * @param gradient Scalar amount to interpolate
  29759. * @returns Interpolated scalar value
  29760. */
  29761. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29762. /**
  29763. * Interpolates a Vector3 cubically
  29764. * @param startValue Start value of the animation curve
  29765. * @param outTangent End tangent of the animation
  29766. * @param endValue End value of the animation curve
  29767. * @param inTangent Start tangent of the animation curve
  29768. * @param gradient Scalar amount to interpolate
  29769. * @returns InterpolatedVector3 value
  29770. */
  29771. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29772. /**
  29773. * Interpolates a Vector2 linearly
  29774. * @param startValue Start value of the animation curve
  29775. * @param endValue End value of the animation curve
  29776. * @param gradient Scalar amount to interpolate
  29777. * @returns Interpolated Vector2 value
  29778. */
  29779. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29780. /**
  29781. * Interpolates a Vector2 cubically
  29782. * @param startValue Start value of the animation curve
  29783. * @param outTangent End tangent of the animation
  29784. * @param endValue End value of the animation curve
  29785. * @param inTangent Start tangent of the animation curve
  29786. * @param gradient Scalar amount to interpolate
  29787. * @returns Interpolated Vector2 value
  29788. */
  29789. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29790. /**
  29791. * Interpolates a size linearly
  29792. * @param startValue Start value of the animation curve
  29793. * @param endValue End value of the animation curve
  29794. * @param gradient Scalar amount to interpolate
  29795. * @returns Interpolated Size value
  29796. */
  29797. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29798. /**
  29799. * Interpolates a Color3 linearly
  29800. * @param startValue Start value of the animation curve
  29801. * @param endValue End value of the animation curve
  29802. * @param gradient Scalar amount to interpolate
  29803. * @returns Interpolated Color3 value
  29804. */
  29805. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29806. /**
  29807. * Interpolates a Color4 linearly
  29808. * @param startValue Start value of the animation curve
  29809. * @param endValue End value of the animation curve
  29810. * @param gradient Scalar amount to interpolate
  29811. * @returns Interpolated Color3 value
  29812. */
  29813. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29814. /**
  29815. * @hidden Internal use only
  29816. */
  29817. _getKeyValue(value: any): any;
  29818. /**
  29819. * @hidden Internal use only
  29820. */
  29821. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29822. /**
  29823. * Defines the function to use to interpolate matrices
  29824. * @param startValue defines the start matrix
  29825. * @param endValue defines the end matrix
  29826. * @param gradient defines the gradient between both matrices
  29827. * @param result defines an optional target matrix where to store the interpolation
  29828. * @returns the interpolated matrix
  29829. */
  29830. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29831. /**
  29832. * Makes a copy of the animation
  29833. * @returns Cloned animation
  29834. */
  29835. clone(): Animation;
  29836. /**
  29837. * Sets the key frames of the animation
  29838. * @param values The animation key frames to set
  29839. */
  29840. setKeys(values: Array<IAnimationKey>): void;
  29841. /**
  29842. * Serializes the animation to an object
  29843. * @returns Serialized object
  29844. */
  29845. serialize(): any;
  29846. /**
  29847. * Float animation type
  29848. */
  29849. static readonly ANIMATIONTYPE_FLOAT: number;
  29850. /**
  29851. * Vector3 animation type
  29852. */
  29853. static readonly ANIMATIONTYPE_VECTOR3: number;
  29854. /**
  29855. * Quaternion animation type
  29856. */
  29857. static readonly ANIMATIONTYPE_QUATERNION: number;
  29858. /**
  29859. * Matrix animation type
  29860. */
  29861. static readonly ANIMATIONTYPE_MATRIX: number;
  29862. /**
  29863. * Color3 animation type
  29864. */
  29865. static readonly ANIMATIONTYPE_COLOR3: number;
  29866. /**
  29867. * Color3 animation type
  29868. */
  29869. static readonly ANIMATIONTYPE_COLOR4: number;
  29870. /**
  29871. * Vector2 animation type
  29872. */
  29873. static readonly ANIMATIONTYPE_VECTOR2: number;
  29874. /**
  29875. * Size animation type
  29876. */
  29877. static readonly ANIMATIONTYPE_SIZE: number;
  29878. /**
  29879. * Relative Loop Mode
  29880. */
  29881. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29882. /**
  29883. * Cycle Loop Mode
  29884. */
  29885. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29886. /**
  29887. * Constant Loop Mode
  29888. */
  29889. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29890. /** @hidden */
  29891. static _UniversalLerp(left: any, right: any, amount: number): any;
  29892. /**
  29893. * Parses an animation object and creates an animation
  29894. * @param parsedAnimation Parsed animation object
  29895. * @returns Animation object
  29896. */
  29897. static Parse(parsedAnimation: any): Animation;
  29898. /**
  29899. * Appends the serialized animations from the source animations
  29900. * @param source Source containing the animations
  29901. * @param destination Target to store the animations
  29902. */
  29903. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29904. }
  29905. }
  29906. declare module "babylonjs/Animations/animatable.interface" {
  29907. import { Nullable } from "babylonjs/types";
  29908. import { Animation } from "babylonjs/Animations/animation";
  29909. /**
  29910. * Interface containing an array of animations
  29911. */
  29912. export interface IAnimatable {
  29913. /**
  29914. * Array of animations
  29915. */
  29916. animations: Nullable<Array<Animation>>;
  29917. }
  29918. }
  29919. declare module "babylonjs/Misc/decorators" {
  29920. import { Nullable } from "babylonjs/types";
  29921. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29922. import { Scene } from "babylonjs/scene";
  29923. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29924. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29925. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29926. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29927. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29928. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29929. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29930. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29931. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29932. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29933. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29934. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29935. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29936. /**
  29937. * Decorator used to define property that can be serialized as reference to a camera
  29938. * @param sourceName defines the name of the property to decorate
  29939. */
  29940. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29941. /**
  29942. * Class used to help serialization objects
  29943. */
  29944. export class SerializationHelper {
  29945. /** @hidden */
  29946. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  29947. /** @hidden */
  29948. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  29949. /** @hidden */
  29950. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  29951. /** @hidden */
  29952. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  29953. /**
  29954. * Appends the serialized animations from the source animations
  29955. * @param source Source containing the animations
  29956. * @param destination Target to store the animations
  29957. */
  29958. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29959. /**
  29960. * Static function used to serialized a specific entity
  29961. * @param entity defines the entity to serialize
  29962. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29963. * @returns a JSON compatible object representing the serialization of the entity
  29964. */
  29965. static Serialize<T>(entity: T, serializationObject?: any): any;
  29966. /**
  29967. * Creates a new entity from a serialization data object
  29968. * @param creationFunction defines a function used to instanciated the new entity
  29969. * @param source defines the source serialization data
  29970. * @param scene defines the hosting scene
  29971. * @param rootUrl defines the root url for resources
  29972. * @returns a new entity
  29973. */
  29974. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29975. /**
  29976. * Clones an object
  29977. * @param creationFunction defines the function used to instanciate the new object
  29978. * @param source defines the source object
  29979. * @returns the cloned object
  29980. */
  29981. static Clone<T>(creationFunction: () => T, source: T): T;
  29982. /**
  29983. * Instanciates a new object based on a source one (some data will be shared between both object)
  29984. * @param creationFunction defines the function used to instanciate the new object
  29985. * @param source defines the source object
  29986. * @returns the new object
  29987. */
  29988. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29989. }
  29990. }
  29991. declare module "babylonjs/Misc/guid" {
  29992. /**
  29993. * Class used to manipulate GUIDs
  29994. */
  29995. export class GUID {
  29996. /**
  29997. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29998. * Be aware Math.random() could cause collisions, but:
  29999. * "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"
  30000. * @returns a pseudo random id
  30001. */
  30002. static RandomId(): string;
  30003. }
  30004. }
  30005. declare module "babylonjs/Materials/Textures/baseTexture" {
  30006. import { Observable } from "babylonjs/Misc/observable";
  30007. import { Nullable } from "babylonjs/types";
  30008. import { Scene } from "babylonjs/scene";
  30009. import { Matrix } from "babylonjs/Maths/math.vector";
  30010. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30011. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30012. import { ISize } from "babylonjs/Maths/math.size";
  30013. /**
  30014. * Base class of all the textures in babylon.
  30015. * It groups all the common properties the materials, post process, lights... might need
  30016. * in order to make a correct use of the texture.
  30017. */
  30018. export class BaseTexture implements IAnimatable {
  30019. /**
  30020. * Default anisotropic filtering level for the application.
  30021. * It is set to 4 as a good tradeoff between perf and quality.
  30022. */
  30023. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30024. /**
  30025. * Gets or sets the unique id of the texture
  30026. */
  30027. uniqueId: number;
  30028. /**
  30029. * Define the name of the texture.
  30030. */
  30031. name: string;
  30032. /**
  30033. * Gets or sets an object used to store user defined information.
  30034. */
  30035. metadata: any;
  30036. /**
  30037. * For internal use only. Please do not use.
  30038. */
  30039. reservedDataStore: any;
  30040. private _hasAlpha;
  30041. /**
  30042. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30043. */
  30044. hasAlpha: boolean;
  30045. /**
  30046. * Defines if the alpha value should be determined via the rgb values.
  30047. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30048. */
  30049. getAlphaFromRGB: boolean;
  30050. /**
  30051. * Intensity or strength of the texture.
  30052. * It is commonly used by materials to fine tune the intensity of the texture
  30053. */
  30054. level: number;
  30055. /**
  30056. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30057. * This is part of the texture as textures usually maps to one uv set.
  30058. */
  30059. coordinatesIndex: number;
  30060. private _coordinatesMode;
  30061. /**
  30062. * How a texture is mapped.
  30063. *
  30064. * | Value | Type | Description |
  30065. * | ----- | ----------------------------------- | ----------- |
  30066. * | 0 | EXPLICIT_MODE | |
  30067. * | 1 | SPHERICAL_MODE | |
  30068. * | 2 | PLANAR_MODE | |
  30069. * | 3 | CUBIC_MODE | |
  30070. * | 4 | PROJECTION_MODE | |
  30071. * | 5 | SKYBOX_MODE | |
  30072. * | 6 | INVCUBIC_MODE | |
  30073. * | 7 | EQUIRECTANGULAR_MODE | |
  30074. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30075. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30076. */
  30077. coordinatesMode: number;
  30078. /**
  30079. * | Value | Type | Description |
  30080. * | ----- | ------------------ | ----------- |
  30081. * | 0 | CLAMP_ADDRESSMODE | |
  30082. * | 1 | WRAP_ADDRESSMODE | |
  30083. * | 2 | MIRROR_ADDRESSMODE | |
  30084. */
  30085. wrapU: number;
  30086. /**
  30087. * | Value | Type | Description |
  30088. * | ----- | ------------------ | ----------- |
  30089. * | 0 | CLAMP_ADDRESSMODE | |
  30090. * | 1 | WRAP_ADDRESSMODE | |
  30091. * | 2 | MIRROR_ADDRESSMODE | |
  30092. */
  30093. wrapV: number;
  30094. /**
  30095. * | Value | Type | Description |
  30096. * | ----- | ------------------ | ----------- |
  30097. * | 0 | CLAMP_ADDRESSMODE | |
  30098. * | 1 | WRAP_ADDRESSMODE | |
  30099. * | 2 | MIRROR_ADDRESSMODE | |
  30100. */
  30101. wrapR: number;
  30102. /**
  30103. * With compliant hardware and browser (supporting anisotropic filtering)
  30104. * this defines the level of anisotropic filtering in the texture.
  30105. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30106. */
  30107. anisotropicFilteringLevel: number;
  30108. /**
  30109. * Define if the texture is a cube texture or if false a 2d texture.
  30110. */
  30111. isCube: boolean;
  30112. /**
  30113. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30114. */
  30115. is3D: boolean;
  30116. /**
  30117. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30118. */
  30119. is2DArray: boolean;
  30120. /**
  30121. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30122. * HDR texture are usually stored in linear space.
  30123. * This only impacts the PBR and Background materials
  30124. */
  30125. gammaSpace: boolean;
  30126. /**
  30127. * Gets or sets whether or not the texture contains RGBD data.
  30128. */
  30129. isRGBD: boolean;
  30130. /**
  30131. * Is Z inverted in the texture (useful in a cube texture).
  30132. */
  30133. invertZ: boolean;
  30134. /**
  30135. * Are mip maps generated for this texture or not.
  30136. */
  30137. readonly noMipmap: boolean;
  30138. /**
  30139. * @hidden
  30140. */
  30141. lodLevelInAlpha: boolean;
  30142. /**
  30143. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30144. */
  30145. lodGenerationOffset: number;
  30146. /**
  30147. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30148. */
  30149. lodGenerationScale: number;
  30150. /**
  30151. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30152. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30153. * average roughness values.
  30154. */
  30155. linearSpecularLOD: boolean;
  30156. /**
  30157. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30158. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30159. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30160. */
  30161. irradianceTexture: Nullable<BaseTexture>;
  30162. /**
  30163. * Define if the texture is a render target.
  30164. */
  30165. isRenderTarget: boolean;
  30166. /**
  30167. * Define the unique id of the texture in the scene.
  30168. */
  30169. readonly uid: string;
  30170. /**
  30171. * Return a string representation of the texture.
  30172. * @returns the texture as a string
  30173. */
  30174. toString(): string;
  30175. /**
  30176. * Get the class name of the texture.
  30177. * @returns "BaseTexture"
  30178. */
  30179. getClassName(): string;
  30180. /**
  30181. * Define the list of animation attached to the texture.
  30182. */
  30183. animations: import("babylonjs/Animations/animation").Animation[];
  30184. /**
  30185. * An event triggered when the texture is disposed.
  30186. */
  30187. onDisposeObservable: Observable<BaseTexture>;
  30188. private _onDisposeObserver;
  30189. /**
  30190. * Callback triggered when the texture has been disposed.
  30191. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30192. */
  30193. onDispose: () => void;
  30194. /**
  30195. * Define the current state of the loading sequence when in delayed load mode.
  30196. */
  30197. delayLoadState: number;
  30198. private _scene;
  30199. /** @hidden */
  30200. _texture: Nullable<InternalTexture>;
  30201. private _uid;
  30202. /**
  30203. * Define if the texture is preventinga material to render or not.
  30204. * If not and the texture is not ready, the engine will use a default black texture instead.
  30205. */
  30206. readonly isBlocking: boolean;
  30207. /**
  30208. * Instantiates a new BaseTexture.
  30209. * Base class of all the textures in babylon.
  30210. * It groups all the common properties the materials, post process, lights... might need
  30211. * in order to make a correct use of the texture.
  30212. * @param scene Define the scene the texture blongs to
  30213. */
  30214. constructor(scene: Nullable<Scene>);
  30215. /**
  30216. * Get the scene the texture belongs to.
  30217. * @returns the scene or null if undefined
  30218. */
  30219. getScene(): Nullable<Scene>;
  30220. /**
  30221. * Get the texture transform matrix used to offset tile the texture for istance.
  30222. * @returns the transformation matrix
  30223. */
  30224. getTextureMatrix(): Matrix;
  30225. /**
  30226. * Get the texture reflection matrix used to rotate/transform the reflection.
  30227. * @returns the reflection matrix
  30228. */
  30229. getReflectionTextureMatrix(): Matrix;
  30230. /**
  30231. * Get the underlying lower level texture from Babylon.
  30232. * @returns the insternal texture
  30233. */
  30234. getInternalTexture(): Nullable<InternalTexture>;
  30235. /**
  30236. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30237. * @returns true if ready or not blocking
  30238. */
  30239. isReadyOrNotBlocking(): boolean;
  30240. /**
  30241. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30242. * @returns true if fully ready
  30243. */
  30244. isReady(): boolean;
  30245. private _cachedSize;
  30246. /**
  30247. * Get the size of the texture.
  30248. * @returns the texture size.
  30249. */
  30250. getSize(): ISize;
  30251. /**
  30252. * Get the base size of the texture.
  30253. * It can be different from the size if the texture has been resized for POT for instance
  30254. * @returns the base size
  30255. */
  30256. getBaseSize(): ISize;
  30257. /**
  30258. * Update the sampling mode of the texture.
  30259. * Default is Trilinear mode.
  30260. *
  30261. * | Value | Type | Description |
  30262. * | ----- | ------------------ | ----------- |
  30263. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30264. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30265. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30266. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30267. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30268. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30269. * | 7 | NEAREST_LINEAR | |
  30270. * | 8 | NEAREST_NEAREST | |
  30271. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30272. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30273. * | 11 | LINEAR_LINEAR | |
  30274. * | 12 | LINEAR_NEAREST | |
  30275. *
  30276. * > _mag_: magnification filter (close to the viewer)
  30277. * > _min_: minification filter (far from the viewer)
  30278. * > _mip_: filter used between mip map levels
  30279. *@param samplingMode Define the new sampling mode of the texture
  30280. */
  30281. updateSamplingMode(samplingMode: number): void;
  30282. /**
  30283. * Scales the texture if is `canRescale()`
  30284. * @param ratio the resize factor we want to use to rescale
  30285. */
  30286. scale(ratio: number): void;
  30287. /**
  30288. * Get if the texture can rescale.
  30289. */
  30290. readonly canRescale: boolean;
  30291. /** @hidden */
  30292. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30293. /** @hidden */
  30294. _rebuild(): void;
  30295. /**
  30296. * Triggers the load sequence in delayed load mode.
  30297. */
  30298. delayLoad(): void;
  30299. /**
  30300. * Clones the texture.
  30301. * @returns the cloned texture
  30302. */
  30303. clone(): Nullable<BaseTexture>;
  30304. /**
  30305. * Get the texture underlying type (INT, FLOAT...)
  30306. */
  30307. readonly textureType: number;
  30308. /**
  30309. * Get the texture underlying format (RGB, RGBA...)
  30310. */
  30311. readonly textureFormat: number;
  30312. /**
  30313. * Indicates that textures need to be re-calculated for all materials
  30314. */
  30315. protected _markAllSubMeshesAsTexturesDirty(): void;
  30316. /**
  30317. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30318. * This will returns an RGBA array buffer containing either in values (0-255) or
  30319. * float values (0-1) depending of the underlying buffer type.
  30320. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30321. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30322. * @param buffer defines a user defined buffer to fill with data (can be null)
  30323. * @returns The Array buffer containing the pixels data.
  30324. */
  30325. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30326. /**
  30327. * Release and destroy the underlying lower level texture aka internalTexture.
  30328. */
  30329. releaseInternalTexture(): void;
  30330. /** @hidden */
  30331. readonly _lodTextureHigh: Nullable<BaseTexture>;
  30332. /** @hidden */
  30333. readonly _lodTextureMid: Nullable<BaseTexture>;
  30334. /** @hidden */
  30335. readonly _lodTextureLow: Nullable<BaseTexture>;
  30336. /**
  30337. * Dispose the texture and release its associated resources.
  30338. */
  30339. dispose(): void;
  30340. /**
  30341. * Serialize the texture into a JSON representation that can be parsed later on.
  30342. * @returns the JSON representation of the texture
  30343. */
  30344. serialize(): any;
  30345. /**
  30346. * Helper function to be called back once a list of texture contains only ready textures.
  30347. * @param textures Define the list of textures to wait for
  30348. * @param callback Define the callback triggered once the entire list will be ready
  30349. */
  30350. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30351. }
  30352. }
  30353. declare module "babylonjs/Materials/effect" {
  30354. import { Observable } from "babylonjs/Misc/observable";
  30355. import { Nullable } from "babylonjs/types";
  30356. import { IDisposable } from "babylonjs/scene";
  30357. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30358. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30359. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  30360. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  30361. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30362. import { Engine } from "babylonjs/Engines/engine";
  30363. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30364. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30365. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30366. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30367. /**
  30368. * Options to be used when creating an effect.
  30369. */
  30370. export interface IEffectCreationOptions {
  30371. /**
  30372. * Atrributes that will be used in the shader.
  30373. */
  30374. attributes: string[];
  30375. /**
  30376. * Uniform varible names that will be set in the shader.
  30377. */
  30378. uniformsNames: string[];
  30379. /**
  30380. * Uniform buffer variable names that will be set in the shader.
  30381. */
  30382. uniformBuffersNames: string[];
  30383. /**
  30384. * Sampler texture variable names that will be set in the shader.
  30385. */
  30386. samplers: string[];
  30387. /**
  30388. * Define statements that will be set in the shader.
  30389. */
  30390. defines: any;
  30391. /**
  30392. * Possible fallbacks for this effect to improve performance when needed.
  30393. */
  30394. fallbacks: Nullable<IEffectFallbacks>;
  30395. /**
  30396. * Callback that will be called when the shader is compiled.
  30397. */
  30398. onCompiled: Nullable<(effect: Effect) => void>;
  30399. /**
  30400. * Callback that will be called if an error occurs during shader compilation.
  30401. */
  30402. onError: Nullable<(effect: Effect, errors: string) => void>;
  30403. /**
  30404. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30405. */
  30406. indexParameters?: any;
  30407. /**
  30408. * Max number of lights that can be used in the shader.
  30409. */
  30410. maxSimultaneousLights?: number;
  30411. /**
  30412. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30413. */
  30414. transformFeedbackVaryings?: Nullable<string[]>;
  30415. }
  30416. /**
  30417. * Effect containing vertex and fragment shader that can be executed on an object.
  30418. */
  30419. export class Effect implements IDisposable {
  30420. /**
  30421. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30422. */
  30423. static ShadersRepository: string;
  30424. /**
  30425. * Name of the effect.
  30426. */
  30427. name: any;
  30428. /**
  30429. * String container all the define statements that should be set on the shader.
  30430. */
  30431. defines: string;
  30432. /**
  30433. * Callback that will be called when the shader is compiled.
  30434. */
  30435. onCompiled: Nullable<(effect: Effect) => void>;
  30436. /**
  30437. * Callback that will be called if an error occurs during shader compilation.
  30438. */
  30439. onError: Nullable<(effect: Effect, errors: string) => void>;
  30440. /**
  30441. * Callback that will be called when effect is bound.
  30442. */
  30443. onBind: Nullable<(effect: Effect) => void>;
  30444. /**
  30445. * Unique ID of the effect.
  30446. */
  30447. uniqueId: number;
  30448. /**
  30449. * Observable that will be called when the shader is compiled.
  30450. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30451. */
  30452. onCompileObservable: Observable<Effect>;
  30453. /**
  30454. * Observable that will be called if an error occurs during shader compilation.
  30455. */
  30456. onErrorObservable: Observable<Effect>;
  30457. /** @hidden */
  30458. _onBindObservable: Nullable<Observable<Effect>>;
  30459. /**
  30460. * Observable that will be called when effect is bound.
  30461. */
  30462. readonly onBindObservable: Observable<Effect>;
  30463. /** @hidden */
  30464. _bonesComputationForcedToCPU: boolean;
  30465. private static _uniqueIdSeed;
  30466. private _engine;
  30467. private _uniformBuffersNames;
  30468. private _uniformsNames;
  30469. private _samplerList;
  30470. private _samplers;
  30471. private _isReady;
  30472. private _compilationError;
  30473. private _allFallbacksProcessed;
  30474. private _attributesNames;
  30475. private _attributes;
  30476. private _uniforms;
  30477. /**
  30478. * Key for the effect.
  30479. * @hidden
  30480. */
  30481. _key: string;
  30482. private _indexParameters;
  30483. private _fallbacks;
  30484. private _vertexSourceCode;
  30485. private _fragmentSourceCode;
  30486. private _vertexSourceCodeOverride;
  30487. private _fragmentSourceCodeOverride;
  30488. private _transformFeedbackVaryings;
  30489. /**
  30490. * Compiled shader to webGL program.
  30491. * @hidden
  30492. */
  30493. _pipelineContext: Nullable<IPipelineContext>;
  30494. private _valueCache;
  30495. private static _baseCache;
  30496. /**
  30497. * Instantiates an effect.
  30498. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30499. * @param baseName Name of the effect.
  30500. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30501. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30502. * @param samplers List of sampler variables that will be passed to the shader.
  30503. * @param engine Engine to be used to render the effect
  30504. * @param defines Define statements to be added to the shader.
  30505. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30506. * @param onCompiled Callback that will be called when the shader is compiled.
  30507. * @param onError Callback that will be called if an error occurs during shader compilation.
  30508. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30509. */
  30510. 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);
  30511. private _useFinalCode;
  30512. /**
  30513. * Unique key for this effect
  30514. */
  30515. readonly key: string;
  30516. /**
  30517. * If the effect has been compiled and prepared.
  30518. * @returns if the effect is compiled and prepared.
  30519. */
  30520. isReady(): boolean;
  30521. private _isReadyInternal;
  30522. /**
  30523. * The engine the effect was initialized with.
  30524. * @returns the engine.
  30525. */
  30526. getEngine(): Engine;
  30527. /**
  30528. * The pipeline context for this effect
  30529. * @returns the associated pipeline context
  30530. */
  30531. getPipelineContext(): Nullable<IPipelineContext>;
  30532. /**
  30533. * The set of names of attribute variables for the shader.
  30534. * @returns An array of attribute names.
  30535. */
  30536. getAttributesNames(): string[];
  30537. /**
  30538. * Returns the attribute at the given index.
  30539. * @param index The index of the attribute.
  30540. * @returns The location of the attribute.
  30541. */
  30542. getAttributeLocation(index: number): number;
  30543. /**
  30544. * Returns the attribute based on the name of the variable.
  30545. * @param name of the attribute to look up.
  30546. * @returns the attribute location.
  30547. */
  30548. getAttributeLocationByName(name: string): number;
  30549. /**
  30550. * The number of attributes.
  30551. * @returns the numnber of attributes.
  30552. */
  30553. getAttributesCount(): number;
  30554. /**
  30555. * Gets the index of a uniform variable.
  30556. * @param uniformName of the uniform to look up.
  30557. * @returns the index.
  30558. */
  30559. getUniformIndex(uniformName: string): number;
  30560. /**
  30561. * Returns the attribute based on the name of the variable.
  30562. * @param uniformName of the uniform to look up.
  30563. * @returns the location of the uniform.
  30564. */
  30565. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30566. /**
  30567. * Returns an array of sampler variable names
  30568. * @returns The array of sampler variable neames.
  30569. */
  30570. getSamplers(): string[];
  30571. /**
  30572. * The error from the last compilation.
  30573. * @returns the error string.
  30574. */
  30575. getCompilationError(): string;
  30576. /**
  30577. * Gets a boolean indicating that all fallbacks were used during compilation
  30578. * @returns true if all fallbacks were used
  30579. */
  30580. allFallbacksProcessed(): boolean;
  30581. /**
  30582. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30583. * @param func The callback to be used.
  30584. */
  30585. executeWhenCompiled(func: (effect: Effect) => void): void;
  30586. private _checkIsReady;
  30587. private _loadShader;
  30588. /**
  30589. * Recompiles the webGL program
  30590. * @param vertexSourceCode The source code for the vertex shader.
  30591. * @param fragmentSourceCode The source code for the fragment shader.
  30592. * @param onCompiled Callback called when completed.
  30593. * @param onError Callback called on error.
  30594. * @hidden
  30595. */
  30596. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30597. /**
  30598. * Prepares the effect
  30599. * @hidden
  30600. */
  30601. _prepareEffect(): void;
  30602. private _processCompilationErrors;
  30603. /**
  30604. * Checks if the effect is supported. (Must be called after compilation)
  30605. */
  30606. readonly isSupported: boolean;
  30607. /**
  30608. * Binds a texture to the engine to be used as output of the shader.
  30609. * @param channel Name of the output variable.
  30610. * @param texture Texture to bind.
  30611. * @hidden
  30612. */
  30613. _bindTexture(channel: string, texture: InternalTexture): void;
  30614. /**
  30615. * Sets a texture on the engine to be used in the shader.
  30616. * @param channel Name of the sampler variable.
  30617. * @param texture Texture to set.
  30618. */
  30619. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30620. /**
  30621. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30622. * @param channel Name of the sampler variable.
  30623. * @param texture Texture to set.
  30624. */
  30625. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30626. /**
  30627. * Sets an array of textures on the engine to be used in the shader.
  30628. * @param channel Name of the variable.
  30629. * @param textures Textures to set.
  30630. */
  30631. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30632. /**
  30633. * 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)
  30634. * @param channel Name of the sampler variable.
  30635. * @param postProcess Post process to get the input texture from.
  30636. */
  30637. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30638. /**
  30639. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30640. * 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)
  30641. * @param channel Name of the sampler variable.
  30642. * @param postProcess Post process to get the output texture from.
  30643. */
  30644. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30645. /** @hidden */
  30646. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30647. /** @hidden */
  30648. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30649. /** @hidden */
  30650. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30651. /** @hidden */
  30652. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30653. /**
  30654. * Binds a buffer to a uniform.
  30655. * @param buffer Buffer to bind.
  30656. * @param name Name of the uniform variable to bind to.
  30657. */
  30658. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30659. /**
  30660. * Binds block to a uniform.
  30661. * @param blockName Name of the block to bind.
  30662. * @param index Index to bind.
  30663. */
  30664. bindUniformBlock(blockName: string, index: number): void;
  30665. /**
  30666. * Sets an interger value on a uniform variable.
  30667. * @param uniformName Name of the variable.
  30668. * @param value Value to be set.
  30669. * @returns this effect.
  30670. */
  30671. setInt(uniformName: string, value: number): Effect;
  30672. /**
  30673. * Sets an int array on a uniform variable.
  30674. * @param uniformName Name of the variable.
  30675. * @param array array to be set.
  30676. * @returns this effect.
  30677. */
  30678. setIntArray(uniformName: string, array: Int32Array): Effect;
  30679. /**
  30680. * 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)
  30681. * @param uniformName Name of the variable.
  30682. * @param array array to be set.
  30683. * @returns this effect.
  30684. */
  30685. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30686. /**
  30687. * 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)
  30688. * @param uniformName Name of the variable.
  30689. * @param array array to be set.
  30690. * @returns this effect.
  30691. */
  30692. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30693. /**
  30694. * 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)
  30695. * @param uniformName Name of the variable.
  30696. * @param array array to be set.
  30697. * @returns this effect.
  30698. */
  30699. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30700. /**
  30701. * Sets an float array on a uniform variable.
  30702. * @param uniformName Name of the variable.
  30703. * @param array array to be set.
  30704. * @returns this effect.
  30705. */
  30706. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30707. /**
  30708. * 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)
  30709. * @param uniformName Name of the variable.
  30710. * @param array array to be set.
  30711. * @returns this effect.
  30712. */
  30713. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30714. /**
  30715. * 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)
  30716. * @param uniformName Name of the variable.
  30717. * @param array array to be set.
  30718. * @returns this effect.
  30719. */
  30720. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30721. /**
  30722. * 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)
  30723. * @param uniformName Name of the variable.
  30724. * @param array array to be set.
  30725. * @returns this effect.
  30726. */
  30727. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30728. /**
  30729. * Sets an array on a uniform variable.
  30730. * @param uniformName Name of the variable.
  30731. * @param array array to be set.
  30732. * @returns this effect.
  30733. */
  30734. setArray(uniformName: string, array: number[]): Effect;
  30735. /**
  30736. * 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)
  30737. * @param uniformName Name of the variable.
  30738. * @param array array to be set.
  30739. * @returns this effect.
  30740. */
  30741. setArray2(uniformName: string, array: number[]): Effect;
  30742. /**
  30743. * 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)
  30744. * @param uniformName Name of the variable.
  30745. * @param array array to be set.
  30746. * @returns this effect.
  30747. */
  30748. setArray3(uniformName: string, array: number[]): Effect;
  30749. /**
  30750. * 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)
  30751. * @param uniformName Name of the variable.
  30752. * @param array array to be set.
  30753. * @returns this effect.
  30754. */
  30755. setArray4(uniformName: string, array: number[]): Effect;
  30756. /**
  30757. * Sets matrices on a uniform variable.
  30758. * @param uniformName Name of the variable.
  30759. * @param matrices matrices to be set.
  30760. * @returns this effect.
  30761. */
  30762. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30763. /**
  30764. * Sets matrix on a uniform variable.
  30765. * @param uniformName Name of the variable.
  30766. * @param matrix matrix to be set.
  30767. * @returns this effect.
  30768. */
  30769. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30770. /**
  30771. * 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)
  30772. * @param uniformName Name of the variable.
  30773. * @param matrix matrix to be set.
  30774. * @returns this effect.
  30775. */
  30776. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30777. /**
  30778. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30779. * @param uniformName Name of the variable.
  30780. * @param matrix matrix to be set.
  30781. * @returns this effect.
  30782. */
  30783. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30784. /**
  30785. * Sets a float on a uniform variable.
  30786. * @param uniformName Name of the variable.
  30787. * @param value value to be set.
  30788. * @returns this effect.
  30789. */
  30790. setFloat(uniformName: string, value: number): Effect;
  30791. /**
  30792. * Sets a boolean on a uniform variable.
  30793. * @param uniformName Name of the variable.
  30794. * @param bool value to be set.
  30795. * @returns this effect.
  30796. */
  30797. setBool(uniformName: string, bool: boolean): Effect;
  30798. /**
  30799. * Sets a Vector2 on a uniform variable.
  30800. * @param uniformName Name of the variable.
  30801. * @param vector2 vector2 to be set.
  30802. * @returns this effect.
  30803. */
  30804. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30805. /**
  30806. * Sets a float2 on a uniform variable.
  30807. * @param uniformName Name of the variable.
  30808. * @param x First float in float2.
  30809. * @param y Second float in float2.
  30810. * @returns this effect.
  30811. */
  30812. setFloat2(uniformName: string, x: number, y: number): Effect;
  30813. /**
  30814. * Sets a Vector3 on a uniform variable.
  30815. * @param uniformName Name of the variable.
  30816. * @param vector3 Value to be set.
  30817. * @returns this effect.
  30818. */
  30819. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30820. /**
  30821. * Sets a float3 on a uniform variable.
  30822. * @param uniformName Name of the variable.
  30823. * @param x First float in float3.
  30824. * @param y Second float in float3.
  30825. * @param z Third float in float3.
  30826. * @returns this effect.
  30827. */
  30828. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30829. /**
  30830. * Sets a Vector4 on a uniform variable.
  30831. * @param uniformName Name of the variable.
  30832. * @param vector4 Value to be set.
  30833. * @returns this effect.
  30834. */
  30835. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30836. /**
  30837. * Sets a float4 on a uniform variable.
  30838. * @param uniformName Name of the variable.
  30839. * @param x First float in float4.
  30840. * @param y Second float in float4.
  30841. * @param z Third float in float4.
  30842. * @param w Fourth float in float4.
  30843. * @returns this effect.
  30844. */
  30845. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30846. /**
  30847. * Sets a Color3 on a uniform variable.
  30848. * @param uniformName Name of the variable.
  30849. * @param color3 Value to be set.
  30850. * @returns this effect.
  30851. */
  30852. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30853. /**
  30854. * Sets a Color4 on a uniform variable.
  30855. * @param uniformName Name of the variable.
  30856. * @param color3 Value to be set.
  30857. * @param alpha Alpha value to be set.
  30858. * @returns this effect.
  30859. */
  30860. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30861. /**
  30862. * Sets a Color4 on a uniform variable
  30863. * @param uniformName defines the name of the variable
  30864. * @param color4 defines the value to be set
  30865. * @returns this effect.
  30866. */
  30867. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30868. /** Release all associated resources */
  30869. dispose(): void;
  30870. /**
  30871. * This function will add a new shader to the shader store
  30872. * @param name the name of the shader
  30873. * @param pixelShader optional pixel shader content
  30874. * @param vertexShader optional vertex shader content
  30875. */
  30876. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30877. /**
  30878. * Store of each shader (The can be looked up using effect.key)
  30879. */
  30880. static ShadersStore: {
  30881. [key: string]: string;
  30882. };
  30883. /**
  30884. * Store of each included file for a shader (The can be looked up using effect.key)
  30885. */
  30886. static IncludesShadersStore: {
  30887. [key: string]: string;
  30888. };
  30889. /**
  30890. * Resets the cache of effects.
  30891. */
  30892. static ResetCache(): void;
  30893. }
  30894. }
  30895. declare module "babylonjs/Engines/engineCapabilities" {
  30896. /**
  30897. * Interface used to describe the capabilities of the engine relatively to the current browser
  30898. */
  30899. export interface EngineCapabilities {
  30900. /** Maximum textures units per fragment shader */
  30901. maxTexturesImageUnits: number;
  30902. /** Maximum texture units per vertex shader */
  30903. maxVertexTextureImageUnits: number;
  30904. /** Maximum textures units in the entire pipeline */
  30905. maxCombinedTexturesImageUnits: number;
  30906. /** Maximum texture size */
  30907. maxTextureSize: number;
  30908. /** Maximum texture samples */
  30909. maxSamples?: number;
  30910. /** Maximum cube texture size */
  30911. maxCubemapTextureSize: number;
  30912. /** Maximum render texture size */
  30913. maxRenderTextureSize: number;
  30914. /** Maximum number of vertex attributes */
  30915. maxVertexAttribs: number;
  30916. /** Maximum number of varyings */
  30917. maxVaryingVectors: number;
  30918. /** Maximum number of uniforms per vertex shader */
  30919. maxVertexUniformVectors: number;
  30920. /** Maximum number of uniforms per fragment shader */
  30921. maxFragmentUniformVectors: number;
  30922. /** Defines if standard derivates (dx/dy) are supported */
  30923. standardDerivatives: boolean;
  30924. /** Defines if s3tc texture compression is supported */
  30925. s3tc?: WEBGL_compressed_texture_s3tc;
  30926. /** Defines if pvrtc texture compression is supported */
  30927. pvrtc: any;
  30928. /** Defines if etc1 texture compression is supported */
  30929. etc1: any;
  30930. /** Defines if etc2 texture compression is supported */
  30931. etc2: any;
  30932. /** Defines if astc texture compression is supported */
  30933. astc: any;
  30934. /** Defines if float textures are supported */
  30935. textureFloat: boolean;
  30936. /** Defines if vertex array objects are supported */
  30937. vertexArrayObject: boolean;
  30938. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30939. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30940. /** Gets the maximum level of anisotropy supported */
  30941. maxAnisotropy: number;
  30942. /** Defines if instancing is supported */
  30943. instancedArrays: boolean;
  30944. /** Defines if 32 bits indices are supported */
  30945. uintIndices: boolean;
  30946. /** Defines if high precision shaders are supported */
  30947. highPrecisionShaderSupported: boolean;
  30948. /** Defines if depth reading in the fragment shader is supported */
  30949. fragmentDepthSupported: boolean;
  30950. /** Defines if float texture linear filtering is supported*/
  30951. textureFloatLinearFiltering: boolean;
  30952. /** Defines if rendering to float textures is supported */
  30953. textureFloatRender: boolean;
  30954. /** Defines if half float textures are supported*/
  30955. textureHalfFloat: boolean;
  30956. /** Defines if half float texture linear filtering is supported*/
  30957. textureHalfFloatLinearFiltering: boolean;
  30958. /** Defines if rendering to half float textures is supported */
  30959. textureHalfFloatRender: boolean;
  30960. /** Defines if textureLOD shader command is supported */
  30961. textureLOD: boolean;
  30962. /** Defines if draw buffers extension is supported */
  30963. drawBuffersExtension: boolean;
  30964. /** Defines if depth textures are supported */
  30965. depthTextureExtension: boolean;
  30966. /** Defines if float color buffer are supported */
  30967. colorBufferFloat: boolean;
  30968. /** Gets disjoint timer query extension (null if not supported) */
  30969. timerQuery?: EXT_disjoint_timer_query;
  30970. /** Defines if timestamp can be used with timer query */
  30971. canUseTimestampForTimerQuery: boolean;
  30972. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30973. multiview?: any;
  30974. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30975. oculusMultiview?: any;
  30976. /** Function used to let the system compiles shaders in background */
  30977. parallelShaderCompile?: {
  30978. COMPLETION_STATUS_KHR: number;
  30979. };
  30980. /** Max number of texture samples for MSAA */
  30981. maxMSAASamples: number;
  30982. /** Defines if the blend min max extension is supported */
  30983. blendMinMax: boolean;
  30984. }
  30985. }
  30986. declare module "babylonjs/States/depthCullingState" {
  30987. import { Nullable } from "babylonjs/types";
  30988. /**
  30989. * @hidden
  30990. **/
  30991. export class DepthCullingState {
  30992. private _isDepthTestDirty;
  30993. private _isDepthMaskDirty;
  30994. private _isDepthFuncDirty;
  30995. private _isCullFaceDirty;
  30996. private _isCullDirty;
  30997. private _isZOffsetDirty;
  30998. private _isFrontFaceDirty;
  30999. private _depthTest;
  31000. private _depthMask;
  31001. private _depthFunc;
  31002. private _cull;
  31003. private _cullFace;
  31004. private _zOffset;
  31005. private _frontFace;
  31006. /**
  31007. * Initializes the state.
  31008. */
  31009. constructor();
  31010. readonly isDirty: boolean;
  31011. zOffset: number;
  31012. cullFace: Nullable<number>;
  31013. cull: Nullable<boolean>;
  31014. depthFunc: Nullable<number>;
  31015. depthMask: boolean;
  31016. depthTest: boolean;
  31017. frontFace: Nullable<number>;
  31018. reset(): void;
  31019. apply(gl: WebGLRenderingContext): void;
  31020. }
  31021. }
  31022. declare module "babylonjs/States/stencilState" {
  31023. /**
  31024. * @hidden
  31025. **/
  31026. export class StencilState {
  31027. /** 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 */
  31028. static readonly ALWAYS: number;
  31029. /** Passed to stencilOperation to specify that stencil value must be kept */
  31030. static readonly KEEP: number;
  31031. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31032. static readonly REPLACE: number;
  31033. private _isStencilTestDirty;
  31034. private _isStencilMaskDirty;
  31035. private _isStencilFuncDirty;
  31036. private _isStencilOpDirty;
  31037. private _stencilTest;
  31038. private _stencilMask;
  31039. private _stencilFunc;
  31040. private _stencilFuncRef;
  31041. private _stencilFuncMask;
  31042. private _stencilOpStencilFail;
  31043. private _stencilOpDepthFail;
  31044. private _stencilOpStencilDepthPass;
  31045. readonly isDirty: boolean;
  31046. stencilFunc: number;
  31047. stencilFuncRef: number;
  31048. stencilFuncMask: number;
  31049. stencilOpStencilFail: number;
  31050. stencilOpDepthFail: number;
  31051. stencilOpStencilDepthPass: number;
  31052. stencilMask: number;
  31053. stencilTest: boolean;
  31054. constructor();
  31055. reset(): void;
  31056. apply(gl: WebGLRenderingContext): void;
  31057. }
  31058. }
  31059. declare module "babylonjs/States/alphaCullingState" {
  31060. /**
  31061. * @hidden
  31062. **/
  31063. export class AlphaState {
  31064. private _isAlphaBlendDirty;
  31065. private _isBlendFunctionParametersDirty;
  31066. private _isBlendEquationParametersDirty;
  31067. private _isBlendConstantsDirty;
  31068. private _alphaBlend;
  31069. private _blendFunctionParameters;
  31070. private _blendEquationParameters;
  31071. private _blendConstants;
  31072. /**
  31073. * Initializes the state.
  31074. */
  31075. constructor();
  31076. readonly isDirty: boolean;
  31077. alphaBlend: boolean;
  31078. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31079. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31080. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31081. reset(): void;
  31082. apply(gl: WebGLRenderingContext): void;
  31083. }
  31084. }
  31085. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  31086. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31087. /** @hidden */
  31088. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31089. attributeProcessor(attribute: string): string;
  31090. varyingProcessor(varying: string, isFragment: boolean): string;
  31091. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31092. }
  31093. }
  31094. declare module "babylonjs/Engines/instancingAttributeInfo" {
  31095. /**
  31096. * Interface for attribute information associated with buffer instanciation
  31097. */
  31098. export interface InstancingAttributeInfo {
  31099. /**
  31100. * Index/offset of the attribute in the vertex shader
  31101. */
  31102. index: number;
  31103. /**
  31104. * size of the attribute, 1, 2, 3 or 4
  31105. */
  31106. attributeSize: number;
  31107. /**
  31108. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31109. * default is FLOAT
  31110. */
  31111. attributeType: number;
  31112. /**
  31113. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31114. */
  31115. normalized: boolean;
  31116. /**
  31117. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31118. */
  31119. offset: number;
  31120. /**
  31121. * Name of the GLSL attribute, for debugging purpose only
  31122. */
  31123. attributeName: string;
  31124. }
  31125. }
  31126. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  31127. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31128. import { Nullable } from "babylonjs/types";
  31129. module "babylonjs/Engines/thinEngine" {
  31130. interface ThinEngine {
  31131. /**
  31132. * Update a video texture
  31133. * @param texture defines the texture to update
  31134. * @param video defines the video element to use
  31135. * @param invertY defines if data must be stored with Y axis inverted
  31136. */
  31137. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31138. }
  31139. }
  31140. }
  31141. declare module "babylonjs/Materials/Textures/videoTexture" {
  31142. import { Observable } from "babylonjs/Misc/observable";
  31143. import { Nullable } from "babylonjs/types";
  31144. import { Scene } from "babylonjs/scene";
  31145. import { Texture } from "babylonjs/Materials/Textures/texture";
  31146. import "babylonjs/Engines/Extensions/engine.videoTexture";
  31147. /**
  31148. * Settings for finer control over video usage
  31149. */
  31150. export interface VideoTextureSettings {
  31151. /**
  31152. * Applies `autoplay` to video, if specified
  31153. */
  31154. autoPlay?: boolean;
  31155. /**
  31156. * Applies `loop` to video, if specified
  31157. */
  31158. loop?: boolean;
  31159. /**
  31160. * Automatically updates internal texture from video at every frame in the render loop
  31161. */
  31162. autoUpdateTexture: boolean;
  31163. /**
  31164. * Image src displayed during the video loading or until the user interacts with the video.
  31165. */
  31166. poster?: string;
  31167. }
  31168. /**
  31169. * If you want to display a video in your scene, this is the special texture for that.
  31170. * This special texture works similar to other textures, with the exception of a few parameters.
  31171. * @see https://doc.babylonjs.com/how_to/video_texture
  31172. */
  31173. export class VideoTexture extends Texture {
  31174. /**
  31175. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31176. */
  31177. readonly autoUpdateTexture: boolean;
  31178. /**
  31179. * The video instance used by the texture internally
  31180. */
  31181. readonly video: HTMLVideoElement;
  31182. private _onUserActionRequestedObservable;
  31183. /**
  31184. * Event triggerd when a dom action is required by the user to play the video.
  31185. * This happens due to recent changes in browser policies preventing video to auto start.
  31186. */
  31187. readonly onUserActionRequestedObservable: Observable<Texture>;
  31188. private _generateMipMaps;
  31189. private _engine;
  31190. private _stillImageCaptured;
  31191. private _displayingPosterTexture;
  31192. private _settings;
  31193. private _createInternalTextureOnEvent;
  31194. private _frameId;
  31195. /**
  31196. * Creates a video texture.
  31197. * If you want to display a video in your scene, this is the special texture for that.
  31198. * This special texture works similar to other textures, with the exception of a few parameters.
  31199. * @see https://doc.babylonjs.com/how_to/video_texture
  31200. * @param name optional name, will detect from video source, if not defined
  31201. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31202. * @param scene is obviously the current scene.
  31203. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31204. * @param invertY is false by default but can be used to invert video on Y axis
  31205. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31206. * @param settings allows finer control over video usage
  31207. */
  31208. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31209. private _getName;
  31210. private _getVideo;
  31211. private _createInternalTexture;
  31212. private reset;
  31213. /**
  31214. * @hidden Internal method to initiate `update`.
  31215. */
  31216. _rebuild(): void;
  31217. /**
  31218. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31219. */
  31220. update(): void;
  31221. /**
  31222. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31223. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31224. */
  31225. updateTexture(isVisible: boolean): void;
  31226. protected _updateInternalTexture: () => void;
  31227. /**
  31228. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31229. * @param url New url.
  31230. */
  31231. updateURL(url: string): void;
  31232. /**
  31233. * Dispose the texture and release its associated resources.
  31234. */
  31235. dispose(): void;
  31236. /**
  31237. * Creates a video texture straight from a stream.
  31238. * @param scene Define the scene the texture should be created in
  31239. * @param stream Define the stream the texture should be created from
  31240. * @returns The created video texture as a promise
  31241. */
  31242. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31243. /**
  31244. * Creates a video texture straight from your WebCam video feed.
  31245. * @param scene Define the scene the texture should be created in
  31246. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31247. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31248. * @returns The created video texture as a promise
  31249. */
  31250. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31251. minWidth: number;
  31252. maxWidth: number;
  31253. minHeight: number;
  31254. maxHeight: number;
  31255. deviceId: string;
  31256. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31257. /**
  31258. * Creates a video texture straight from your WebCam video feed.
  31259. * @param scene Define the scene the texture should be created in
  31260. * @param onReady Define a callback to triggered once the texture will be ready
  31261. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31262. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31263. */
  31264. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31265. minWidth: number;
  31266. maxWidth: number;
  31267. minHeight: number;
  31268. maxHeight: number;
  31269. deviceId: string;
  31270. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31271. }
  31272. }
  31273. declare module "babylonjs/Engines/thinEngine" {
  31274. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  31275. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  31276. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31277. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31278. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  31279. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  31280. import { Observable } from "babylonjs/Misc/observable";
  31281. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  31282. import { StencilState } from "babylonjs/States/stencilState";
  31283. import { AlphaState } from "babylonjs/States/alphaCullingState";
  31284. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31285. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31286. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31287. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  31288. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31289. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31290. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31291. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  31292. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31293. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31294. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31295. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  31296. /**
  31297. * Defines the interface used by objects working like Scene
  31298. * @hidden
  31299. */
  31300. interface ISceneLike {
  31301. _addPendingData(data: any): void;
  31302. _removePendingData(data: any): void;
  31303. offlineProvider: IOfflineProvider;
  31304. }
  31305. /** Interface defining initialization parameters for Engine class */
  31306. export interface EngineOptions extends WebGLContextAttributes {
  31307. /**
  31308. * Defines if the engine should no exceed a specified device ratio
  31309. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31310. */
  31311. limitDeviceRatio?: number;
  31312. /**
  31313. * Defines if webvr should be enabled automatically
  31314. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31315. */
  31316. autoEnableWebVR?: boolean;
  31317. /**
  31318. * Defines if webgl2 should be turned off even if supported
  31319. * @see http://doc.babylonjs.com/features/webgl2
  31320. */
  31321. disableWebGL2Support?: boolean;
  31322. /**
  31323. * Defines if webaudio should be initialized as well
  31324. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31325. */
  31326. audioEngine?: boolean;
  31327. /**
  31328. * Defines if animations should run using a deterministic lock step
  31329. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31330. */
  31331. deterministicLockstep?: boolean;
  31332. /** Defines the maximum steps to use with deterministic lock step mode */
  31333. lockstepMaxSteps?: number;
  31334. /** Defines the seconds between each deterministic lock step */
  31335. timeStep?: number;
  31336. /**
  31337. * Defines that engine should ignore context lost events
  31338. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31339. */
  31340. doNotHandleContextLost?: boolean;
  31341. /**
  31342. * Defines that engine should ignore modifying touch action attribute and style
  31343. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31344. */
  31345. doNotHandleTouchAction?: boolean;
  31346. /**
  31347. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31348. */
  31349. useHighPrecisionFloats?: boolean;
  31350. }
  31351. /**
  31352. * The base engine class (root of all engines)
  31353. */
  31354. export class ThinEngine {
  31355. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31356. static ExceptionList: ({
  31357. key: string;
  31358. capture: string;
  31359. captureConstraint: number;
  31360. targets: string[];
  31361. } | {
  31362. key: string;
  31363. capture: null;
  31364. captureConstraint: null;
  31365. targets: string[];
  31366. })[];
  31367. /** @hidden */
  31368. static _TextureLoaders: IInternalTextureLoader[];
  31369. /**
  31370. * Returns the current npm package of the sdk
  31371. */
  31372. static readonly NpmPackage: string;
  31373. /**
  31374. * Returns the current version of the framework
  31375. */
  31376. static readonly Version: string;
  31377. /**
  31378. * Returns a string describing the current engine
  31379. */
  31380. readonly description: string;
  31381. /**
  31382. * Gets or sets the epsilon value used by collision engine
  31383. */
  31384. static CollisionsEpsilon: number;
  31385. /**
  31386. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31387. */
  31388. static ShadersRepository: string;
  31389. /**
  31390. * Gets or sets the textures that the engine should not attempt to load as compressed
  31391. */
  31392. protected _excludedCompressedTextures: string[];
  31393. /**
  31394. * Filters the compressed texture formats to only include
  31395. * files that are not included in the skippable list
  31396. *
  31397. * @param url the current extension
  31398. * @param textureFormatInUse the current compressed texture format
  31399. * @returns "format" string
  31400. */
  31401. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  31402. /** @hidden */
  31403. _shaderProcessor: IShaderProcessor;
  31404. /**
  31405. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31406. */
  31407. forcePOTTextures: boolean;
  31408. /**
  31409. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31410. */
  31411. isFullscreen: boolean;
  31412. /**
  31413. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31414. */
  31415. cullBackFaces: boolean;
  31416. /**
  31417. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31418. */
  31419. renderEvenInBackground: boolean;
  31420. /**
  31421. * Gets or sets a boolean indicating that cache can be kept between frames
  31422. */
  31423. preventCacheWipeBetweenFrames: boolean;
  31424. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31425. validateShaderPrograms: boolean;
  31426. /**
  31427. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31428. * This can provide greater z depth for distant objects.
  31429. */
  31430. useReverseDepthBuffer: boolean;
  31431. /**
  31432. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31433. */
  31434. disableUniformBuffers: boolean;
  31435. /** @hidden */
  31436. _uniformBuffers: UniformBuffer[];
  31437. /**
  31438. * Gets a boolean indicating that the engine supports uniform buffers
  31439. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31440. */
  31441. readonly supportsUniformBuffers: boolean;
  31442. /** @hidden */
  31443. _gl: WebGLRenderingContext;
  31444. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31445. protected _windowIsBackground: boolean;
  31446. protected _webGLVersion: number;
  31447. protected _creationOptions: EngineOptions;
  31448. protected _highPrecisionShadersAllowed: boolean;
  31449. /** @hidden */
  31450. readonly _shouldUseHighPrecisionShader: boolean;
  31451. /**
  31452. * Gets a boolean indicating that only power of 2 textures are supported
  31453. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31454. */
  31455. readonly needPOTTextures: boolean;
  31456. /** @hidden */
  31457. _badOS: boolean;
  31458. /** @hidden */
  31459. _badDesktopOS: boolean;
  31460. private _hardwareScalingLevel;
  31461. /** @hidden */
  31462. _caps: EngineCapabilities;
  31463. private _isStencilEnable;
  31464. protected _colorWrite: boolean;
  31465. private _glVersion;
  31466. private _glRenderer;
  31467. private _glVendor;
  31468. /** @hidden */
  31469. _videoTextureSupported: boolean;
  31470. protected _renderingQueueLaunched: boolean;
  31471. protected _activeRenderLoops: (() => void)[];
  31472. /**
  31473. * Observable signaled when a context lost event is raised
  31474. */
  31475. onContextLostObservable: Observable<ThinEngine>;
  31476. /**
  31477. * Observable signaled when a context restored event is raised
  31478. */
  31479. onContextRestoredObservable: Observable<ThinEngine>;
  31480. private _onContextLost;
  31481. private _onContextRestored;
  31482. protected _contextWasLost: boolean;
  31483. /** @hidden */
  31484. _doNotHandleContextLost: boolean;
  31485. /**
  31486. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31487. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31488. */
  31489. doNotHandleContextLost: boolean;
  31490. /**
  31491. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31492. */
  31493. disableVertexArrayObjects: boolean;
  31494. /** @hidden */
  31495. protected _depthCullingState: DepthCullingState;
  31496. /** @hidden */
  31497. protected _stencilState: StencilState;
  31498. /** @hidden */
  31499. protected _alphaState: AlphaState;
  31500. /** @hidden */
  31501. _internalTexturesCache: InternalTexture[];
  31502. /** @hidden */
  31503. protected _activeChannel: number;
  31504. private _currentTextureChannel;
  31505. /** @hidden */
  31506. protected _boundTexturesCache: {
  31507. [key: string]: Nullable<InternalTexture>;
  31508. };
  31509. /** @hidden */
  31510. protected _currentEffect: Nullable<Effect>;
  31511. /** @hidden */
  31512. protected _currentProgram: Nullable<WebGLProgram>;
  31513. private _compiledEffects;
  31514. private _vertexAttribArraysEnabled;
  31515. /** @hidden */
  31516. protected _cachedViewport: Nullable<IViewportLike>;
  31517. private _cachedVertexArrayObject;
  31518. /** @hidden */
  31519. protected _cachedVertexBuffers: any;
  31520. /** @hidden */
  31521. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31522. /** @hidden */
  31523. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31524. /** @hidden */
  31525. _currentRenderTarget: Nullable<InternalTexture>;
  31526. private _uintIndicesCurrentlySet;
  31527. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31528. /** @hidden */
  31529. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31530. private _currentBufferPointers;
  31531. private _currentInstanceLocations;
  31532. private _currentInstanceBuffers;
  31533. private _textureUnits;
  31534. /** @hidden */
  31535. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31536. /** @hidden */
  31537. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31538. /** @hidden */
  31539. _boundRenderFunction: any;
  31540. private _vaoRecordInProgress;
  31541. private _mustWipeVertexAttributes;
  31542. private _emptyTexture;
  31543. private _emptyCubeTexture;
  31544. private _emptyTexture3D;
  31545. private _emptyTexture2DArray;
  31546. /** @hidden */
  31547. _frameHandler: number;
  31548. private _nextFreeTextureSlots;
  31549. private _maxSimultaneousTextures;
  31550. private _activeRequests;
  31551. protected _texturesSupported: string[];
  31552. /** @hidden */
  31553. _textureFormatInUse: Nullable<string>;
  31554. protected readonly _supportsHardwareTextureRescaling: boolean;
  31555. /**
  31556. * Gets the list of texture formats supported
  31557. */
  31558. readonly texturesSupported: Array<string>;
  31559. /**
  31560. * Gets the list of texture formats in use
  31561. */
  31562. readonly textureFormatInUse: Nullable<string>;
  31563. /**
  31564. * Gets the current viewport
  31565. */
  31566. readonly currentViewport: Nullable<IViewportLike>;
  31567. /**
  31568. * Gets the default empty texture
  31569. */
  31570. readonly emptyTexture: InternalTexture;
  31571. /**
  31572. * Gets the default empty 3D texture
  31573. */
  31574. readonly emptyTexture3D: InternalTexture;
  31575. /**
  31576. * Gets the default empty 2D array texture
  31577. */
  31578. readonly emptyTexture2DArray: InternalTexture;
  31579. /**
  31580. * Gets the default empty cube texture
  31581. */
  31582. readonly emptyCubeTexture: InternalTexture;
  31583. /**
  31584. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31585. */
  31586. readonly premultipliedAlpha: boolean;
  31587. /**
  31588. * Observable event triggered before each texture is initialized
  31589. */
  31590. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  31591. /**
  31592. * Creates a new engine
  31593. * @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
  31594. * @param antialias defines enable antialiasing (default: false)
  31595. * @param options defines further options to be sent to the getContext() function
  31596. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31597. */
  31598. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31599. private _rebuildInternalTextures;
  31600. private _rebuildEffects;
  31601. /**
  31602. * Gets a boolean indicating if all created effects are ready
  31603. * @returns true if all effects are ready
  31604. */
  31605. areAllEffectsReady(): boolean;
  31606. protected _rebuildBuffers(): void;
  31607. private _initGLContext;
  31608. /**
  31609. * Gets version of the current webGL context
  31610. */
  31611. readonly webGLVersion: number;
  31612. /**
  31613. * Gets a string idenfifying the name of the class
  31614. * @returns "Engine" string
  31615. */
  31616. getClassName(): string;
  31617. /**
  31618. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31619. */
  31620. readonly isStencilEnable: boolean;
  31621. /** @hidden */
  31622. _prepareWorkingCanvas(): void;
  31623. /**
  31624. * Reset the texture cache to empty state
  31625. */
  31626. resetTextureCache(): void;
  31627. /**
  31628. * Gets an object containing information about the current webGL context
  31629. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31630. */
  31631. getGlInfo(): {
  31632. vendor: string;
  31633. renderer: string;
  31634. version: string;
  31635. };
  31636. /**
  31637. * Defines the hardware scaling level.
  31638. * By default the hardware scaling level is computed from the window device ratio.
  31639. * 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.
  31640. * @param level defines the level to use
  31641. */
  31642. setHardwareScalingLevel(level: number): void;
  31643. /**
  31644. * Gets the current hardware scaling level.
  31645. * By default the hardware scaling level is computed from the window device ratio.
  31646. * 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.
  31647. * @returns a number indicating the current hardware scaling level
  31648. */
  31649. getHardwareScalingLevel(): number;
  31650. /**
  31651. * Gets the list of loaded textures
  31652. * @returns an array containing all loaded textures
  31653. */
  31654. getLoadedTexturesCache(): InternalTexture[];
  31655. /**
  31656. * Gets the object containing all engine capabilities
  31657. * @returns the EngineCapabilities object
  31658. */
  31659. getCaps(): EngineCapabilities;
  31660. /**
  31661. * stop executing a render loop function and remove it from the execution array
  31662. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31663. */
  31664. stopRenderLoop(renderFunction?: () => void): void;
  31665. /** @hidden */
  31666. _renderLoop(): void;
  31667. /**
  31668. * Gets the HTML canvas attached with the current webGL context
  31669. * @returns a HTML canvas
  31670. */
  31671. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31672. /**
  31673. * Gets host window
  31674. * @returns the host window object
  31675. */
  31676. getHostWindow(): Nullable<Window>;
  31677. /**
  31678. * Gets the current render width
  31679. * @param useScreen defines if screen size must be used (or the current render target if any)
  31680. * @returns a number defining the current render width
  31681. */
  31682. getRenderWidth(useScreen?: boolean): number;
  31683. /**
  31684. * Gets the current render height
  31685. * @param useScreen defines if screen size must be used (or the current render target if any)
  31686. * @returns a number defining the current render height
  31687. */
  31688. getRenderHeight(useScreen?: boolean): number;
  31689. /**
  31690. * Can be used to override the current requestAnimationFrame requester.
  31691. * @hidden
  31692. */
  31693. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31694. /**
  31695. * Register and execute a render loop. The engine can have more than one render function
  31696. * @param renderFunction defines the function to continuously execute
  31697. */
  31698. runRenderLoop(renderFunction: () => void): void;
  31699. /**
  31700. * Clear the current render buffer or the current render target (if any is set up)
  31701. * @param color defines the color to use
  31702. * @param backBuffer defines if the back buffer must be cleared
  31703. * @param depth defines if the depth buffer must be cleared
  31704. * @param stencil defines if the stencil buffer must be cleared
  31705. */
  31706. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31707. private _viewportCached;
  31708. /** @hidden */
  31709. _viewport(x: number, y: number, width: number, height: number): void;
  31710. /**
  31711. * Set the WebGL's viewport
  31712. * @param viewport defines the viewport element to be used
  31713. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31714. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31715. */
  31716. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31717. /**
  31718. * Begin a new frame
  31719. */
  31720. beginFrame(): void;
  31721. /**
  31722. * Enf the current frame
  31723. */
  31724. endFrame(): void;
  31725. /**
  31726. * Resize the view according to the canvas' size
  31727. */
  31728. resize(): void;
  31729. /**
  31730. * Force a specific size of the canvas
  31731. * @param width defines the new canvas' width
  31732. * @param height defines the new canvas' height
  31733. */
  31734. setSize(width: number, height: number): void;
  31735. /**
  31736. * Binds the frame buffer to the specified texture.
  31737. * @param texture The texture to render to or null for the default canvas
  31738. * @param faceIndex The face of the texture to render to in case of cube texture
  31739. * @param requiredWidth The width of the target to render to
  31740. * @param requiredHeight The height of the target to render to
  31741. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31742. * @param depthStencilTexture The depth stencil texture to use to render
  31743. * @param lodLevel defines le lod level to bind to the frame buffer
  31744. */
  31745. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  31746. /** @hidden */
  31747. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31748. /**
  31749. * Unbind the current render target texture from the webGL context
  31750. * @param texture defines the render target texture to unbind
  31751. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31752. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31753. */
  31754. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31755. /**
  31756. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31757. */
  31758. flushFramebuffer(): void;
  31759. /**
  31760. * Unbind the current render target and bind the default framebuffer
  31761. */
  31762. restoreDefaultFramebuffer(): void;
  31763. /** @hidden */
  31764. protected _resetVertexBufferBinding(): void;
  31765. /**
  31766. * Creates a vertex buffer
  31767. * @param data the data for the vertex buffer
  31768. * @returns the new WebGL static buffer
  31769. */
  31770. createVertexBuffer(data: DataArray): DataBuffer;
  31771. private _createVertexBuffer;
  31772. /**
  31773. * Creates a dynamic vertex buffer
  31774. * @param data the data for the dynamic vertex buffer
  31775. * @returns the new WebGL dynamic buffer
  31776. */
  31777. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31778. protected _resetIndexBufferBinding(): void;
  31779. /**
  31780. * Creates a new index buffer
  31781. * @param indices defines the content of the index buffer
  31782. * @param updatable defines if the index buffer must be updatable
  31783. * @returns a new webGL buffer
  31784. */
  31785. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31786. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31787. /**
  31788. * Bind a webGL buffer to the webGL context
  31789. * @param buffer defines the buffer to bind
  31790. */
  31791. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31792. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31793. private bindBuffer;
  31794. /**
  31795. * update the bound buffer with the given data
  31796. * @param data defines the data to update
  31797. */
  31798. updateArrayBuffer(data: Float32Array): void;
  31799. private _vertexAttribPointer;
  31800. private _bindIndexBufferWithCache;
  31801. private _bindVertexBuffersAttributes;
  31802. /**
  31803. * Records a vertex array object
  31804. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31805. * @param vertexBuffers defines the list of vertex buffers to store
  31806. * @param indexBuffer defines the index buffer to store
  31807. * @param effect defines the effect to store
  31808. * @returns the new vertex array object
  31809. */
  31810. recordVertexArrayObject(vertexBuffers: {
  31811. [key: string]: VertexBuffer;
  31812. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31813. /**
  31814. * Bind a specific vertex array object
  31815. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31816. * @param vertexArrayObject defines the vertex array object to bind
  31817. * @param indexBuffer defines the index buffer to bind
  31818. */
  31819. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31820. /**
  31821. * Bind webGl buffers directly to the webGL context
  31822. * @param vertexBuffer defines the vertex buffer to bind
  31823. * @param indexBuffer defines the index buffer to bind
  31824. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31825. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31826. * @param effect defines the effect associated with the vertex buffer
  31827. */
  31828. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31829. private _unbindVertexArrayObject;
  31830. /**
  31831. * Bind a list of vertex buffers to the webGL context
  31832. * @param vertexBuffers defines the list of vertex buffers to bind
  31833. * @param indexBuffer defines the index buffer to bind
  31834. * @param effect defines the effect associated with the vertex buffers
  31835. */
  31836. bindBuffers(vertexBuffers: {
  31837. [key: string]: Nullable<VertexBuffer>;
  31838. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31839. /**
  31840. * Unbind all instance attributes
  31841. */
  31842. unbindInstanceAttributes(): void;
  31843. /**
  31844. * Release and free the memory of a vertex array object
  31845. * @param vao defines the vertex array object to delete
  31846. */
  31847. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31848. /** @hidden */
  31849. _releaseBuffer(buffer: DataBuffer): boolean;
  31850. protected _deleteBuffer(buffer: DataBuffer): void;
  31851. /**
  31852. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31853. * @param instancesBuffer defines the webGL buffer to update and bind
  31854. * @param data defines the data to store in the buffer
  31855. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31856. */
  31857. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31858. /**
  31859. * Apply all cached states (depth, culling, stencil and alpha)
  31860. */
  31861. applyStates(): void;
  31862. /**
  31863. * Send a draw order
  31864. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31865. * @param indexStart defines the starting index
  31866. * @param indexCount defines the number of index to draw
  31867. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31868. */
  31869. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31870. /**
  31871. * Draw a list of points
  31872. * @param verticesStart defines the index of first vertex to draw
  31873. * @param verticesCount defines the count of vertices to draw
  31874. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31875. */
  31876. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31877. /**
  31878. * Draw a list of unindexed primitives
  31879. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31880. * @param verticesStart defines the index of first vertex to draw
  31881. * @param verticesCount defines the count of vertices to draw
  31882. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31883. */
  31884. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31885. /**
  31886. * Draw a list of indexed primitives
  31887. * @param fillMode defines the primitive to use
  31888. * @param indexStart defines the starting index
  31889. * @param indexCount defines the number of index to draw
  31890. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31891. */
  31892. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31893. /**
  31894. * Draw a list of unindexed primitives
  31895. * @param fillMode defines the primitive to use
  31896. * @param verticesStart defines the index of first vertex to draw
  31897. * @param verticesCount defines the count of vertices to draw
  31898. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31899. */
  31900. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31901. private _drawMode;
  31902. /** @hidden */
  31903. protected _reportDrawCall(): void;
  31904. /** @hidden */
  31905. _releaseEffect(effect: Effect): void;
  31906. /** @hidden */
  31907. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31908. /**
  31909. * Create a new effect (used to store vertex/fragment shaders)
  31910. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31911. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31912. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31913. * @param samplers defines an array of string used to represent textures
  31914. * @param defines defines the string containing the defines to use to compile the shaders
  31915. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31916. * @param onCompiled defines a function to call when the effect creation is successful
  31917. * @param onError defines a function to call when the effect creation has failed
  31918. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31919. * @returns the new Effect
  31920. */
  31921. 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;
  31922. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31923. private _compileShader;
  31924. private _compileRawShader;
  31925. /**
  31926. * Directly creates a webGL program
  31927. * @param pipelineContext defines the pipeline context to attach to
  31928. * @param vertexCode defines the vertex shader code to use
  31929. * @param fragmentCode defines the fragment shader code to use
  31930. * @param context defines the webGL context to use (if not set, the current one will be used)
  31931. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31932. * @returns the new webGL program
  31933. */
  31934. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31935. /**
  31936. * Creates a webGL program
  31937. * @param pipelineContext defines the pipeline context to attach to
  31938. * @param vertexCode defines the vertex shader code to use
  31939. * @param fragmentCode defines the fragment shader code to use
  31940. * @param defines defines the string containing the defines to use to compile the shaders
  31941. * @param context defines the webGL context to use (if not set, the current one will be used)
  31942. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31943. * @returns the new webGL program
  31944. */
  31945. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31946. /**
  31947. * Creates a new pipeline context
  31948. * @returns the new pipeline
  31949. */
  31950. createPipelineContext(): IPipelineContext;
  31951. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31952. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31953. /** @hidden */
  31954. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31955. /** @hidden */
  31956. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31957. /** @hidden */
  31958. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31959. /**
  31960. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31961. * @param pipelineContext defines the pipeline context to use
  31962. * @param uniformsNames defines the list of uniform names
  31963. * @returns an array of webGL uniform locations
  31964. */
  31965. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31966. /**
  31967. * Gets the lsit of active attributes for a given webGL program
  31968. * @param pipelineContext defines the pipeline context to use
  31969. * @param attributesNames defines the list of attribute names to get
  31970. * @returns an array of indices indicating the offset of each attribute
  31971. */
  31972. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31973. /**
  31974. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31975. * @param effect defines the effect to activate
  31976. */
  31977. enableEffect(effect: Nullable<Effect>): void;
  31978. /**
  31979. * Set the value of an uniform to a number (int)
  31980. * @param uniform defines the webGL uniform location where to store the value
  31981. * @param value defines the int number to store
  31982. */
  31983. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31984. /**
  31985. * Set the value of an uniform to an array of int32
  31986. * @param uniform defines the webGL uniform location where to store the value
  31987. * @param array defines the array of int32 to store
  31988. */
  31989. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31990. /**
  31991. * Set the value of an uniform to an array of int32 (stored as vec2)
  31992. * @param uniform defines the webGL uniform location where to store the value
  31993. * @param array defines the array of int32 to store
  31994. */
  31995. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31996. /**
  31997. * Set the value of an uniform to an array of int32 (stored as vec3)
  31998. * @param uniform defines the webGL uniform location where to store the value
  31999. * @param array defines the array of int32 to store
  32000. */
  32001. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32002. /**
  32003. * Set the value of an uniform to an array of int32 (stored as vec4)
  32004. * @param uniform defines the webGL uniform location where to store the value
  32005. * @param array defines the array of int32 to store
  32006. */
  32007. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32008. /**
  32009. * Set the value of an uniform to an array of number
  32010. * @param uniform defines the webGL uniform location where to store the value
  32011. * @param array defines the array of number to store
  32012. */
  32013. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32014. /**
  32015. * Set the value of an uniform to an array of number (stored as vec2)
  32016. * @param uniform defines the webGL uniform location where to store the value
  32017. * @param array defines the array of number to store
  32018. */
  32019. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32020. /**
  32021. * Set the value of an uniform to an array of number (stored as vec3)
  32022. * @param uniform defines the webGL uniform location where to store the value
  32023. * @param array defines the array of number to store
  32024. */
  32025. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32026. /**
  32027. * Set the value of an uniform to an array of number (stored as vec4)
  32028. * @param uniform defines the webGL uniform location where to store the value
  32029. * @param array defines the array of number to store
  32030. */
  32031. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32032. /**
  32033. * Set the value of an uniform to an array of float32 (stored as matrices)
  32034. * @param uniform defines the webGL uniform location where to store the value
  32035. * @param matrices defines the array of float32 to store
  32036. */
  32037. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32038. /**
  32039. * Set the value of an uniform to a matrix (3x3)
  32040. * @param uniform defines the webGL uniform location where to store the value
  32041. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32042. */
  32043. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32044. /**
  32045. * Set the value of an uniform to a matrix (2x2)
  32046. * @param uniform defines the webGL uniform location where to store the value
  32047. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32048. */
  32049. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32050. /**
  32051. * Set the value of an uniform to a number (float)
  32052. * @param uniform defines the webGL uniform location where to store the value
  32053. * @param value defines the float number to store
  32054. */
  32055. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32056. /**
  32057. * Set the value of an uniform to a vec2
  32058. * @param uniform defines the webGL uniform location where to store the value
  32059. * @param x defines the 1st component of the value
  32060. * @param y defines the 2nd component of the value
  32061. */
  32062. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32063. /**
  32064. * Set the value of an uniform to a vec3
  32065. * @param uniform defines the webGL uniform location where to store the value
  32066. * @param x defines the 1st component of the value
  32067. * @param y defines the 2nd component of the value
  32068. * @param z defines the 3rd component of the value
  32069. */
  32070. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32071. /**
  32072. * Set the value of an uniform to a vec4
  32073. * @param uniform defines the webGL uniform location where to store the value
  32074. * @param x defines the 1st component of the value
  32075. * @param y defines the 2nd component of the value
  32076. * @param z defines the 3rd component of the value
  32077. * @param w defines the 4th component of the value
  32078. */
  32079. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32080. /**
  32081. * Gets the depth culling state manager
  32082. */
  32083. readonly depthCullingState: DepthCullingState;
  32084. /**
  32085. * Gets the alpha state manager
  32086. */
  32087. readonly alphaState: AlphaState;
  32088. /**
  32089. * Gets the stencil state manager
  32090. */
  32091. readonly stencilState: StencilState;
  32092. /**
  32093. * Clears the list of texture accessible through engine.
  32094. * This can help preventing texture load conflict due to name collision.
  32095. */
  32096. clearInternalTexturesCache(): void;
  32097. /**
  32098. * Force the entire cache to be cleared
  32099. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32100. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32101. */
  32102. wipeCaches(bruteForce?: boolean): void;
  32103. /** @hidden */
  32104. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32105. min: number;
  32106. mag: number;
  32107. };
  32108. /** @hidden */
  32109. _createTexture(): WebGLTexture;
  32110. /**
  32111. * Usually called from Texture.ts.
  32112. * Passed information to create a WebGLTexture
  32113. * @param urlArg defines a value which contains one of the following:
  32114. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32115. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32116. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32117. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32118. * @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)
  32119. * @param scene needed for loading to the correct scene
  32120. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32121. * @param onLoad optional callback to be called upon successful completion
  32122. * @param onError optional callback to be called upon failure
  32123. * @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
  32124. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32125. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32126. * @param forcedExtension defines the extension to use to pick the right loader
  32127. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32128. * @param mimeType defines an optional mime type
  32129. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32130. */
  32131. 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;
  32132. /**
  32133. * @hidden
  32134. */
  32135. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32136. /**
  32137. * Creates a raw texture
  32138. * @param data defines the data to store in the texture
  32139. * @param width defines the width of the texture
  32140. * @param height defines the height of the texture
  32141. * @param format defines the format of the data
  32142. * @param generateMipMaps defines if the engine should generate the mip levels
  32143. * @param invertY defines if data must be stored with Y axis inverted
  32144. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32145. * @param compression defines the compression used (null by default)
  32146. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32147. * @returns the raw texture inside an InternalTexture
  32148. */
  32149. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32150. /**
  32151. * Creates a new raw cube texture
  32152. * @param data defines the array of data to use to create each face
  32153. * @param size defines the size of the textures
  32154. * @param format defines the format of the data
  32155. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32156. * @param generateMipMaps defines if the engine should generate the mip levels
  32157. * @param invertY defines if data must be stored with Y axis inverted
  32158. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32159. * @param compression defines the compression used (null by default)
  32160. * @returns the cube texture as an InternalTexture
  32161. */
  32162. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32163. /**
  32164. * Creates a new raw 3D texture
  32165. * @param data defines the data used to create the texture
  32166. * @param width defines the width of the texture
  32167. * @param height defines the height of the texture
  32168. * @param depth defines the depth of the texture
  32169. * @param format defines the format of the texture
  32170. * @param generateMipMaps defines if the engine must generate mip levels
  32171. * @param invertY defines if data must be stored with Y axis inverted
  32172. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32173. * @param compression defines the compressed used (can be null)
  32174. * @param textureType defines the compressed used (can be null)
  32175. * @returns a new raw 3D texture (stored in an InternalTexture)
  32176. */
  32177. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32178. /**
  32179. * Creates a new raw 2D array texture
  32180. * @param data defines the data used to create the texture
  32181. * @param width defines the width of the texture
  32182. * @param height defines the height of the texture
  32183. * @param depth defines the number of layers of the texture
  32184. * @param format defines the format of the texture
  32185. * @param generateMipMaps defines if the engine must generate mip levels
  32186. * @param invertY defines if data must be stored with Y axis inverted
  32187. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32188. * @param compression defines the compressed used (can be null)
  32189. * @param textureType defines the compressed used (can be null)
  32190. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32191. */
  32192. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32193. private _unpackFlipYCached;
  32194. /**
  32195. * In case you are sharing the context with other applications, it might
  32196. * be interested to not cache the unpack flip y state to ensure a consistent
  32197. * value would be set.
  32198. */
  32199. enableUnpackFlipYCached: boolean;
  32200. /** @hidden */
  32201. _unpackFlipY(value: boolean): void;
  32202. /** @hidden */
  32203. _getUnpackAlignement(): number;
  32204. /**
  32205. * Update the sampling mode of a given texture
  32206. * @param samplingMode defines the required sampling mode
  32207. * @param texture defines the texture to update
  32208. */
  32209. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  32210. /** @hidden */
  32211. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32212. width: number;
  32213. height: number;
  32214. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32215. /** @hidden */
  32216. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32217. /** @hidden */
  32218. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32219. /** @hidden */
  32220. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32221. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32222. private _prepareWebGLTexture;
  32223. /** @hidden */
  32224. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32225. /** @hidden */
  32226. _releaseFramebufferObjects(texture: InternalTexture): void;
  32227. /** @hidden */
  32228. _releaseTexture(texture: InternalTexture): void;
  32229. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32230. protected _setProgram(program: WebGLProgram): void;
  32231. protected _boundUniforms: {
  32232. [key: number]: WebGLUniformLocation;
  32233. };
  32234. /**
  32235. * Binds an effect to the webGL context
  32236. * @param effect defines the effect to bind
  32237. */
  32238. bindSamplers(effect: Effect): void;
  32239. private _activateCurrentTexture;
  32240. /** @hidden */
  32241. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32242. /** @hidden */
  32243. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32244. /**
  32245. * Unbind all textures from the webGL context
  32246. */
  32247. unbindAllTextures(): void;
  32248. /**
  32249. * Sets a texture to the according uniform.
  32250. * @param channel The texture channel
  32251. * @param uniform The uniform to set
  32252. * @param texture The texture to apply
  32253. */
  32254. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32255. private _bindSamplerUniformToChannel;
  32256. private _getTextureWrapMode;
  32257. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32258. /**
  32259. * Sets an array of texture to the webGL context
  32260. * @param channel defines the channel where the texture array must be set
  32261. * @param uniform defines the associated uniform location
  32262. * @param textures defines the array of textures to bind
  32263. */
  32264. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32265. /** @hidden */
  32266. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  32267. private _setTextureParameterFloat;
  32268. private _setTextureParameterInteger;
  32269. /**
  32270. * Unbind all vertex attributes from the webGL context
  32271. */
  32272. unbindAllAttributes(): void;
  32273. /**
  32274. * 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
  32275. */
  32276. releaseEffects(): void;
  32277. /**
  32278. * Dispose and release all associated resources
  32279. */
  32280. dispose(): void;
  32281. /**
  32282. * Attach a new callback raised when context lost event is fired
  32283. * @param callback defines the callback to call
  32284. */
  32285. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32286. /**
  32287. * Attach a new callback raised when context restored event is fired
  32288. * @param callback defines the callback to call
  32289. */
  32290. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32291. /**
  32292. * Get the current error code of the webGL context
  32293. * @returns the error code
  32294. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32295. */
  32296. getError(): number;
  32297. private _canRenderToFloatFramebuffer;
  32298. private _canRenderToHalfFloatFramebuffer;
  32299. private _canRenderToFramebuffer;
  32300. /** @hidden */
  32301. _getWebGLTextureType(type: number): number;
  32302. /** @hidden */
  32303. _getInternalFormat(format: number): number;
  32304. /** @hidden */
  32305. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32306. /** @hidden */
  32307. _getRGBAMultiSampleBufferFormat(type: number): number;
  32308. /** @hidden */
  32309. _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;
  32310. /**
  32311. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32312. * @returns true if the engine can be created
  32313. * @ignorenaming
  32314. */
  32315. static isSupported(): boolean;
  32316. /**
  32317. * Find the next highest power of two.
  32318. * @param x Number to start search from.
  32319. * @return Next highest power of two.
  32320. */
  32321. static CeilingPOT(x: number): number;
  32322. /**
  32323. * Find the next lowest power of two.
  32324. * @param x Number to start search from.
  32325. * @return Next lowest power of two.
  32326. */
  32327. static FloorPOT(x: number): number;
  32328. /**
  32329. * Find the nearest power of two.
  32330. * @param x Number to start search from.
  32331. * @return Next nearest power of two.
  32332. */
  32333. static NearestPOT(x: number): number;
  32334. /**
  32335. * Get the closest exponent of two
  32336. * @param value defines the value to approximate
  32337. * @param max defines the maximum value to return
  32338. * @param mode defines how to define the closest value
  32339. * @returns closest exponent of two of the given value
  32340. */
  32341. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32342. /**
  32343. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32344. * @param func - the function to be called
  32345. * @param requester - the object that will request the next frame. Falls back to window.
  32346. * @returns frame number
  32347. */
  32348. static QueueNewFrame(func: () => void, requester?: any): number;
  32349. /**
  32350. * Gets host document
  32351. * @returns the host document object
  32352. */
  32353. getHostDocument(): Document;
  32354. }
  32355. }
  32356. declare module "babylonjs/Maths/sphericalPolynomial" {
  32357. import { Vector3 } from "babylonjs/Maths/math.vector";
  32358. import { Color3 } from "babylonjs/Maths/math.color";
  32359. /**
  32360. * Class representing spherical harmonics coefficients to the 3rd degree
  32361. */
  32362. export class SphericalHarmonics {
  32363. /**
  32364. * Defines whether or not the harmonics have been prescaled for rendering.
  32365. */
  32366. preScaled: boolean;
  32367. /**
  32368. * The l0,0 coefficients of the spherical harmonics
  32369. */
  32370. l00: Vector3;
  32371. /**
  32372. * The l1,-1 coefficients of the spherical harmonics
  32373. */
  32374. l1_1: Vector3;
  32375. /**
  32376. * The l1,0 coefficients of the spherical harmonics
  32377. */
  32378. l10: Vector3;
  32379. /**
  32380. * The l1,1 coefficients of the spherical harmonics
  32381. */
  32382. l11: Vector3;
  32383. /**
  32384. * The l2,-2 coefficients of the spherical harmonics
  32385. */
  32386. l2_2: Vector3;
  32387. /**
  32388. * The l2,-1 coefficients of the spherical harmonics
  32389. */
  32390. l2_1: Vector3;
  32391. /**
  32392. * The l2,0 coefficients of the spherical harmonics
  32393. */
  32394. l20: Vector3;
  32395. /**
  32396. * The l2,1 coefficients of the spherical harmonics
  32397. */
  32398. l21: Vector3;
  32399. /**
  32400. * The l2,2 coefficients of the spherical harmonics
  32401. */
  32402. l22: Vector3;
  32403. /**
  32404. * Adds a light to the spherical harmonics
  32405. * @param direction the direction of the light
  32406. * @param color the color of the light
  32407. * @param deltaSolidAngle the delta solid angle of the light
  32408. */
  32409. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32410. /**
  32411. * Scales the spherical harmonics by the given amount
  32412. * @param scale the amount to scale
  32413. */
  32414. scaleInPlace(scale: number): void;
  32415. /**
  32416. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32417. *
  32418. * ```
  32419. * E_lm = A_l * L_lm
  32420. * ```
  32421. *
  32422. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32423. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32424. * the scaling factors are given in equation 9.
  32425. */
  32426. convertIncidentRadianceToIrradiance(): void;
  32427. /**
  32428. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32429. *
  32430. * ```
  32431. * L = (1/pi) * E * rho
  32432. * ```
  32433. *
  32434. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32435. */
  32436. convertIrradianceToLambertianRadiance(): void;
  32437. /**
  32438. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32439. * required operations at run time.
  32440. *
  32441. * This is simply done by scaling back the SH with Ylm constants parameter.
  32442. * The trigonometric part being applied by the shader at run time.
  32443. */
  32444. preScaleForRendering(): void;
  32445. /**
  32446. * Constructs a spherical harmonics from an array.
  32447. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32448. * @returns the spherical harmonics
  32449. */
  32450. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32451. /**
  32452. * Gets the spherical harmonics from polynomial
  32453. * @param polynomial the spherical polynomial
  32454. * @returns the spherical harmonics
  32455. */
  32456. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32457. }
  32458. /**
  32459. * Class representing spherical polynomial coefficients to the 3rd degree
  32460. */
  32461. export class SphericalPolynomial {
  32462. private _harmonics;
  32463. /**
  32464. * The spherical harmonics used to create the polynomials.
  32465. */
  32466. readonly preScaledHarmonics: SphericalHarmonics;
  32467. /**
  32468. * The x coefficients of the spherical polynomial
  32469. */
  32470. x: Vector3;
  32471. /**
  32472. * The y coefficients of the spherical polynomial
  32473. */
  32474. y: Vector3;
  32475. /**
  32476. * The z coefficients of the spherical polynomial
  32477. */
  32478. z: Vector3;
  32479. /**
  32480. * The xx coefficients of the spherical polynomial
  32481. */
  32482. xx: Vector3;
  32483. /**
  32484. * The yy coefficients of the spherical polynomial
  32485. */
  32486. yy: Vector3;
  32487. /**
  32488. * The zz coefficients of the spherical polynomial
  32489. */
  32490. zz: Vector3;
  32491. /**
  32492. * The xy coefficients of the spherical polynomial
  32493. */
  32494. xy: Vector3;
  32495. /**
  32496. * The yz coefficients of the spherical polynomial
  32497. */
  32498. yz: Vector3;
  32499. /**
  32500. * The zx coefficients of the spherical polynomial
  32501. */
  32502. zx: Vector3;
  32503. /**
  32504. * Adds an ambient color to the spherical polynomial
  32505. * @param color the color to add
  32506. */
  32507. addAmbient(color: Color3): void;
  32508. /**
  32509. * Scales the spherical polynomial by the given amount
  32510. * @param scale the amount to scale
  32511. */
  32512. scaleInPlace(scale: number): void;
  32513. /**
  32514. * Gets the spherical polynomial from harmonics
  32515. * @param harmonics the spherical harmonics
  32516. * @returns the spherical polynomial
  32517. */
  32518. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32519. /**
  32520. * Constructs a spherical polynomial from an array.
  32521. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32522. * @returns the spherical polynomial
  32523. */
  32524. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32525. }
  32526. }
  32527. declare module "babylonjs/Materials/Textures/internalTexture" {
  32528. import { Observable } from "babylonjs/Misc/observable";
  32529. import { Nullable, int } from "babylonjs/types";
  32530. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  32531. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32532. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  32533. /**
  32534. * Defines the source of the internal texture
  32535. */
  32536. export enum InternalTextureSource {
  32537. /**
  32538. * The source of the texture data is unknown
  32539. */
  32540. Unknown = 0,
  32541. /**
  32542. * Texture data comes from an URL
  32543. */
  32544. Url = 1,
  32545. /**
  32546. * Texture data is only used for temporary storage
  32547. */
  32548. Temp = 2,
  32549. /**
  32550. * Texture data comes from raw data (ArrayBuffer)
  32551. */
  32552. Raw = 3,
  32553. /**
  32554. * Texture content is dynamic (video or dynamic texture)
  32555. */
  32556. Dynamic = 4,
  32557. /**
  32558. * Texture content is generated by rendering to it
  32559. */
  32560. RenderTarget = 5,
  32561. /**
  32562. * Texture content is part of a multi render target process
  32563. */
  32564. MultiRenderTarget = 6,
  32565. /**
  32566. * Texture data comes from a cube data file
  32567. */
  32568. Cube = 7,
  32569. /**
  32570. * Texture data comes from a raw cube data
  32571. */
  32572. CubeRaw = 8,
  32573. /**
  32574. * Texture data come from a prefiltered cube data file
  32575. */
  32576. CubePrefiltered = 9,
  32577. /**
  32578. * Texture content is raw 3D data
  32579. */
  32580. Raw3D = 10,
  32581. /**
  32582. * Texture content is raw 2D array data
  32583. */
  32584. Raw2DArray = 11,
  32585. /**
  32586. * Texture content is a depth texture
  32587. */
  32588. Depth = 12,
  32589. /**
  32590. * Texture data comes from a raw cube data encoded with RGBD
  32591. */
  32592. CubeRawRGBD = 13
  32593. }
  32594. /**
  32595. * Class used to store data associated with WebGL texture data for the engine
  32596. * This class should not be used directly
  32597. */
  32598. export class InternalTexture {
  32599. /** @hidden */
  32600. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32601. /**
  32602. * Defines if the texture is ready
  32603. */
  32604. isReady: boolean;
  32605. /**
  32606. * Defines if the texture is a cube texture
  32607. */
  32608. isCube: boolean;
  32609. /**
  32610. * Defines if the texture contains 3D data
  32611. */
  32612. is3D: boolean;
  32613. /**
  32614. * Defines if the texture contains 2D array data
  32615. */
  32616. is2DArray: boolean;
  32617. /**
  32618. * Defines if the texture contains multiview data
  32619. */
  32620. isMultiview: boolean;
  32621. /**
  32622. * Gets the URL used to load this texture
  32623. */
  32624. url: string;
  32625. /**
  32626. * Gets the sampling mode of the texture
  32627. */
  32628. samplingMode: number;
  32629. /**
  32630. * Gets a boolean indicating if the texture needs mipmaps generation
  32631. */
  32632. generateMipMaps: boolean;
  32633. /**
  32634. * Gets the number of samples used by the texture (WebGL2+ only)
  32635. */
  32636. samples: number;
  32637. /**
  32638. * Gets the type of the texture (int, float...)
  32639. */
  32640. type: number;
  32641. /**
  32642. * Gets the format of the texture (RGB, RGBA...)
  32643. */
  32644. format: number;
  32645. /**
  32646. * Observable called when the texture is loaded
  32647. */
  32648. onLoadedObservable: Observable<InternalTexture>;
  32649. /**
  32650. * Gets the width of the texture
  32651. */
  32652. width: number;
  32653. /**
  32654. * Gets the height of the texture
  32655. */
  32656. height: number;
  32657. /**
  32658. * Gets the depth of the texture
  32659. */
  32660. depth: number;
  32661. /**
  32662. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32663. */
  32664. baseWidth: number;
  32665. /**
  32666. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32667. */
  32668. baseHeight: number;
  32669. /**
  32670. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32671. */
  32672. baseDepth: number;
  32673. /**
  32674. * Gets a boolean indicating if the texture is inverted on Y axis
  32675. */
  32676. invertY: boolean;
  32677. /** @hidden */
  32678. _invertVScale: boolean;
  32679. /** @hidden */
  32680. _associatedChannel: number;
  32681. /** @hidden */
  32682. _source: InternalTextureSource;
  32683. /** @hidden */
  32684. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32685. /** @hidden */
  32686. _bufferView: Nullable<ArrayBufferView>;
  32687. /** @hidden */
  32688. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32689. /** @hidden */
  32690. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32691. /** @hidden */
  32692. _size: number;
  32693. /** @hidden */
  32694. _extension: string;
  32695. /** @hidden */
  32696. _files: Nullable<string[]>;
  32697. /** @hidden */
  32698. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32699. /** @hidden */
  32700. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32701. /** @hidden */
  32702. _framebuffer: Nullable<WebGLFramebuffer>;
  32703. /** @hidden */
  32704. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32705. /** @hidden */
  32706. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32707. /** @hidden */
  32708. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32709. /** @hidden */
  32710. _attachments: Nullable<number[]>;
  32711. /** @hidden */
  32712. _cachedCoordinatesMode: Nullable<number>;
  32713. /** @hidden */
  32714. _cachedWrapU: Nullable<number>;
  32715. /** @hidden */
  32716. _cachedWrapV: Nullable<number>;
  32717. /** @hidden */
  32718. _cachedWrapR: Nullable<number>;
  32719. /** @hidden */
  32720. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32721. /** @hidden */
  32722. _isDisabled: boolean;
  32723. /** @hidden */
  32724. _compression: Nullable<string>;
  32725. /** @hidden */
  32726. _generateStencilBuffer: boolean;
  32727. /** @hidden */
  32728. _generateDepthBuffer: boolean;
  32729. /** @hidden */
  32730. _comparisonFunction: number;
  32731. /** @hidden */
  32732. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32733. /** @hidden */
  32734. _lodGenerationScale: number;
  32735. /** @hidden */
  32736. _lodGenerationOffset: number;
  32737. /** @hidden */
  32738. _colorTextureArray: Nullable<WebGLTexture>;
  32739. /** @hidden */
  32740. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32741. /** @hidden */
  32742. _lodTextureHigh: Nullable<BaseTexture>;
  32743. /** @hidden */
  32744. _lodTextureMid: Nullable<BaseTexture>;
  32745. /** @hidden */
  32746. _lodTextureLow: Nullable<BaseTexture>;
  32747. /** @hidden */
  32748. _isRGBD: boolean;
  32749. /** @hidden */
  32750. _linearSpecularLOD: boolean;
  32751. /** @hidden */
  32752. _irradianceTexture: Nullable<BaseTexture>;
  32753. /** @hidden */
  32754. _webGLTexture: Nullable<WebGLTexture>;
  32755. /** @hidden */
  32756. _references: number;
  32757. private _engine;
  32758. /**
  32759. * Gets the Engine the texture belongs to.
  32760. * @returns The babylon engine
  32761. */
  32762. getEngine(): ThinEngine;
  32763. /**
  32764. * Gets the data source type of the texture
  32765. */
  32766. readonly source: InternalTextureSource;
  32767. /**
  32768. * Creates a new InternalTexture
  32769. * @param engine defines the engine to use
  32770. * @param source defines the type of data that will be used
  32771. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32772. */
  32773. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32774. /**
  32775. * Increments the number of references (ie. the number of Texture that point to it)
  32776. */
  32777. incrementReferences(): void;
  32778. /**
  32779. * Change the size of the texture (not the size of the content)
  32780. * @param width defines the new width
  32781. * @param height defines the new height
  32782. * @param depth defines the new depth (1 by default)
  32783. */
  32784. updateSize(width: int, height: int, depth?: int): void;
  32785. /** @hidden */
  32786. _rebuild(): void;
  32787. /** @hidden */
  32788. _swapAndDie(target: InternalTexture): void;
  32789. /**
  32790. * Dispose the current allocated resources
  32791. */
  32792. dispose(): void;
  32793. }
  32794. }
  32795. declare module "babylonjs/Audio/analyser" {
  32796. import { Scene } from "babylonjs/scene";
  32797. /**
  32798. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32799. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32800. */
  32801. export class Analyser {
  32802. /**
  32803. * Gets or sets the smoothing
  32804. * @ignorenaming
  32805. */
  32806. SMOOTHING: number;
  32807. /**
  32808. * Gets or sets the FFT table size
  32809. * @ignorenaming
  32810. */
  32811. FFT_SIZE: number;
  32812. /**
  32813. * Gets or sets the bar graph amplitude
  32814. * @ignorenaming
  32815. */
  32816. BARGRAPHAMPLITUDE: number;
  32817. /**
  32818. * Gets or sets the position of the debug canvas
  32819. * @ignorenaming
  32820. */
  32821. DEBUGCANVASPOS: {
  32822. x: number;
  32823. y: number;
  32824. };
  32825. /**
  32826. * Gets or sets the debug canvas size
  32827. * @ignorenaming
  32828. */
  32829. DEBUGCANVASSIZE: {
  32830. width: number;
  32831. height: number;
  32832. };
  32833. private _byteFreqs;
  32834. private _byteTime;
  32835. private _floatFreqs;
  32836. private _webAudioAnalyser;
  32837. private _debugCanvas;
  32838. private _debugCanvasContext;
  32839. private _scene;
  32840. private _registerFunc;
  32841. private _audioEngine;
  32842. /**
  32843. * Creates a new analyser
  32844. * @param scene defines hosting scene
  32845. */
  32846. constructor(scene: Scene);
  32847. /**
  32848. * Get the number of data values you will have to play with for the visualization
  32849. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32850. * @returns a number
  32851. */
  32852. getFrequencyBinCount(): number;
  32853. /**
  32854. * Gets the current frequency data as a byte array
  32855. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32856. * @returns a Uint8Array
  32857. */
  32858. getByteFrequencyData(): Uint8Array;
  32859. /**
  32860. * Gets the current waveform as a byte array
  32861. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  32862. * @returns a Uint8Array
  32863. */
  32864. getByteTimeDomainData(): Uint8Array;
  32865. /**
  32866. * Gets the current frequency data as a float array
  32867. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32868. * @returns a Float32Array
  32869. */
  32870. getFloatFrequencyData(): Float32Array;
  32871. /**
  32872. * Renders the debug canvas
  32873. */
  32874. drawDebugCanvas(): void;
  32875. /**
  32876. * Stops rendering the debug canvas and removes it
  32877. */
  32878. stopDebugCanvas(): void;
  32879. /**
  32880. * Connects two audio nodes
  32881. * @param inputAudioNode defines first node to connect
  32882. * @param outputAudioNode defines second node to connect
  32883. */
  32884. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32885. /**
  32886. * Releases all associated resources
  32887. */
  32888. dispose(): void;
  32889. }
  32890. }
  32891. declare module "babylonjs/Audio/audioEngine" {
  32892. import { IDisposable } from "babylonjs/scene";
  32893. import { Analyser } from "babylonjs/Audio/analyser";
  32894. import { Nullable } from "babylonjs/types";
  32895. import { Observable } from "babylonjs/Misc/observable";
  32896. /**
  32897. * This represents an audio engine and it is responsible
  32898. * to play, synchronize and analyse sounds throughout the application.
  32899. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32900. */
  32901. export interface IAudioEngine extends IDisposable {
  32902. /**
  32903. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32904. */
  32905. readonly canUseWebAudio: boolean;
  32906. /**
  32907. * Gets the current AudioContext if available.
  32908. */
  32909. readonly audioContext: Nullable<AudioContext>;
  32910. /**
  32911. * The master gain node defines the global audio volume of your audio engine.
  32912. */
  32913. readonly masterGain: GainNode;
  32914. /**
  32915. * Gets whether or not mp3 are supported by your browser.
  32916. */
  32917. readonly isMP3supported: boolean;
  32918. /**
  32919. * Gets whether or not ogg are supported by your browser.
  32920. */
  32921. readonly isOGGsupported: boolean;
  32922. /**
  32923. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32924. * @ignoreNaming
  32925. */
  32926. WarnedWebAudioUnsupported: boolean;
  32927. /**
  32928. * Defines if the audio engine relies on a custom unlocked button.
  32929. * In this case, the embedded button will not be displayed.
  32930. */
  32931. useCustomUnlockedButton: boolean;
  32932. /**
  32933. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32934. */
  32935. readonly unlocked: boolean;
  32936. /**
  32937. * Event raised when audio has been unlocked on the browser.
  32938. */
  32939. onAudioUnlockedObservable: Observable<AudioEngine>;
  32940. /**
  32941. * Event raised when audio has been locked on the browser.
  32942. */
  32943. onAudioLockedObservable: Observable<AudioEngine>;
  32944. /**
  32945. * Flags the audio engine in Locked state.
  32946. * This happens due to new browser policies preventing audio to autoplay.
  32947. */
  32948. lock(): void;
  32949. /**
  32950. * Unlocks the audio engine once a user action has been done on the dom.
  32951. * This is helpful to resume play once browser policies have been satisfied.
  32952. */
  32953. unlock(): void;
  32954. }
  32955. /**
  32956. * This represents the default audio engine used in babylon.
  32957. * It is responsible to play, synchronize and analyse sounds throughout the application.
  32958. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32959. */
  32960. export class AudioEngine implements IAudioEngine {
  32961. private _audioContext;
  32962. private _audioContextInitialized;
  32963. private _muteButton;
  32964. private _hostElement;
  32965. /**
  32966. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32967. */
  32968. canUseWebAudio: boolean;
  32969. /**
  32970. * The master gain node defines the global audio volume of your audio engine.
  32971. */
  32972. masterGain: GainNode;
  32973. /**
  32974. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32975. * @ignoreNaming
  32976. */
  32977. WarnedWebAudioUnsupported: boolean;
  32978. /**
  32979. * Gets whether or not mp3 are supported by your browser.
  32980. */
  32981. isMP3supported: boolean;
  32982. /**
  32983. * Gets whether or not ogg are supported by your browser.
  32984. */
  32985. isOGGsupported: boolean;
  32986. /**
  32987. * Gets whether audio has been unlocked on the device.
  32988. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  32989. * a user interaction has happened.
  32990. */
  32991. unlocked: boolean;
  32992. /**
  32993. * Defines if the audio engine relies on a custom unlocked button.
  32994. * In this case, the embedded button will not be displayed.
  32995. */
  32996. useCustomUnlockedButton: boolean;
  32997. /**
  32998. * Event raised when audio has been unlocked on the browser.
  32999. */
  33000. onAudioUnlockedObservable: Observable<AudioEngine>;
  33001. /**
  33002. * Event raised when audio has been locked on the browser.
  33003. */
  33004. onAudioLockedObservable: Observable<AudioEngine>;
  33005. /**
  33006. * Gets the current AudioContext if available.
  33007. */
  33008. readonly audioContext: Nullable<AudioContext>;
  33009. private _connectedAnalyser;
  33010. /**
  33011. * Instantiates a new audio engine.
  33012. *
  33013. * There should be only one per page as some browsers restrict the number
  33014. * of audio contexts you can create.
  33015. * @param hostElement defines the host element where to display the mute icon if necessary
  33016. */
  33017. constructor(hostElement?: Nullable<HTMLElement>);
  33018. /**
  33019. * Flags the audio engine in Locked state.
  33020. * This happens due to new browser policies preventing audio to autoplay.
  33021. */
  33022. lock(): void;
  33023. /**
  33024. * Unlocks the audio engine once a user action has been done on the dom.
  33025. * This is helpful to resume play once browser policies have been satisfied.
  33026. */
  33027. unlock(): void;
  33028. private _resumeAudioContext;
  33029. private _initializeAudioContext;
  33030. private _tryToRun;
  33031. private _triggerRunningState;
  33032. private _triggerSuspendedState;
  33033. private _displayMuteButton;
  33034. private _moveButtonToTopLeft;
  33035. private _onResize;
  33036. private _hideMuteButton;
  33037. /**
  33038. * Destroy and release the resources associated with the audio ccontext.
  33039. */
  33040. dispose(): void;
  33041. /**
  33042. * Gets the global volume sets on the master gain.
  33043. * @returns the global volume if set or -1 otherwise
  33044. */
  33045. getGlobalVolume(): number;
  33046. /**
  33047. * Sets the global volume of your experience (sets on the master gain).
  33048. * @param newVolume Defines the new global volume of the application
  33049. */
  33050. setGlobalVolume(newVolume: number): void;
  33051. /**
  33052. * Connect the audio engine to an audio analyser allowing some amazing
  33053. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33054. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33055. * @param analyser The analyser to connect to the engine
  33056. */
  33057. connectToAnalyser(analyser: Analyser): void;
  33058. }
  33059. }
  33060. declare module "babylonjs/Loading/loadingScreen" {
  33061. /**
  33062. * Interface used to present a loading screen while loading a scene
  33063. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33064. */
  33065. export interface ILoadingScreen {
  33066. /**
  33067. * Function called to display the loading screen
  33068. */
  33069. displayLoadingUI: () => void;
  33070. /**
  33071. * Function called to hide the loading screen
  33072. */
  33073. hideLoadingUI: () => void;
  33074. /**
  33075. * Gets or sets the color to use for the background
  33076. */
  33077. loadingUIBackgroundColor: string;
  33078. /**
  33079. * Gets or sets the text to display while loading
  33080. */
  33081. loadingUIText: string;
  33082. }
  33083. /**
  33084. * Class used for the default loading screen
  33085. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33086. */
  33087. export class DefaultLoadingScreen implements ILoadingScreen {
  33088. private _renderingCanvas;
  33089. private _loadingText;
  33090. private _loadingDivBackgroundColor;
  33091. private _loadingDiv;
  33092. private _loadingTextDiv;
  33093. /** Gets or sets the logo url to use for the default loading screen */
  33094. static DefaultLogoUrl: string;
  33095. /** Gets or sets the spinner url to use for the default loading screen */
  33096. static DefaultSpinnerUrl: string;
  33097. /**
  33098. * Creates a new default loading screen
  33099. * @param _renderingCanvas defines the canvas used to render the scene
  33100. * @param _loadingText defines the default text to display
  33101. * @param _loadingDivBackgroundColor defines the default background color
  33102. */
  33103. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33104. /**
  33105. * Function called to display the loading screen
  33106. */
  33107. displayLoadingUI(): void;
  33108. /**
  33109. * Function called to hide the loading screen
  33110. */
  33111. hideLoadingUI(): void;
  33112. /**
  33113. * Gets or sets the text to display while loading
  33114. */
  33115. loadingUIText: string;
  33116. /**
  33117. * Gets or sets the color to use for the background
  33118. */
  33119. loadingUIBackgroundColor: string;
  33120. private _resizeLoadingUI;
  33121. }
  33122. }
  33123. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  33124. /**
  33125. * Interface for any object that can request an animation frame
  33126. */
  33127. export interface ICustomAnimationFrameRequester {
  33128. /**
  33129. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33130. */
  33131. renderFunction?: Function;
  33132. /**
  33133. * Called to request the next frame to render to
  33134. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33135. */
  33136. requestAnimationFrame: Function;
  33137. /**
  33138. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33139. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33140. */
  33141. requestID?: number;
  33142. }
  33143. }
  33144. declare module "babylonjs/Misc/performanceMonitor" {
  33145. /**
  33146. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33147. */
  33148. export class PerformanceMonitor {
  33149. private _enabled;
  33150. private _rollingFrameTime;
  33151. private _lastFrameTimeMs;
  33152. /**
  33153. * constructor
  33154. * @param frameSampleSize The number of samples required to saturate the sliding window
  33155. */
  33156. constructor(frameSampleSize?: number);
  33157. /**
  33158. * Samples current frame
  33159. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33160. */
  33161. sampleFrame(timeMs?: number): void;
  33162. /**
  33163. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33164. */
  33165. readonly averageFrameTime: number;
  33166. /**
  33167. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33168. */
  33169. readonly averageFrameTimeVariance: number;
  33170. /**
  33171. * Returns the frame time of the most recent frame
  33172. */
  33173. readonly instantaneousFrameTime: number;
  33174. /**
  33175. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33176. */
  33177. readonly averageFPS: number;
  33178. /**
  33179. * Returns the average framerate in frames per second using the most recent frame time
  33180. */
  33181. readonly instantaneousFPS: number;
  33182. /**
  33183. * Returns true if enough samples have been taken to completely fill the sliding window
  33184. */
  33185. readonly isSaturated: boolean;
  33186. /**
  33187. * Enables contributions to the sliding window sample set
  33188. */
  33189. enable(): void;
  33190. /**
  33191. * Disables contributions to the sliding window sample set
  33192. * Samples will not be interpolated over the disabled period
  33193. */
  33194. disable(): void;
  33195. /**
  33196. * Returns true if sampling is enabled
  33197. */
  33198. readonly isEnabled: boolean;
  33199. /**
  33200. * Resets performance monitor
  33201. */
  33202. reset(): void;
  33203. }
  33204. /**
  33205. * RollingAverage
  33206. *
  33207. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33208. */
  33209. export class RollingAverage {
  33210. /**
  33211. * Current average
  33212. */
  33213. average: number;
  33214. /**
  33215. * Current variance
  33216. */
  33217. variance: number;
  33218. protected _samples: Array<number>;
  33219. protected _sampleCount: number;
  33220. protected _pos: number;
  33221. protected _m2: number;
  33222. /**
  33223. * constructor
  33224. * @param length The number of samples required to saturate the sliding window
  33225. */
  33226. constructor(length: number);
  33227. /**
  33228. * Adds a sample to the sample set
  33229. * @param v The sample value
  33230. */
  33231. add(v: number): void;
  33232. /**
  33233. * Returns previously added values or null if outside of history or outside the sliding window domain
  33234. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33235. * @return Value previously recorded with add() or null if outside of range
  33236. */
  33237. history(i: number): number;
  33238. /**
  33239. * Returns true if enough samples have been taken to completely fill the sliding window
  33240. * @return true if sample-set saturated
  33241. */
  33242. isSaturated(): boolean;
  33243. /**
  33244. * Resets the rolling average (equivalent to 0 samples taken so far)
  33245. */
  33246. reset(): void;
  33247. /**
  33248. * Wraps a value around the sample range boundaries
  33249. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33250. * @return Wrapped position in sample range
  33251. */
  33252. protected _wrapPosition(i: number): number;
  33253. }
  33254. }
  33255. declare module "babylonjs/Misc/perfCounter" {
  33256. /**
  33257. * This class is used to track a performance counter which is number based.
  33258. * The user has access to many properties which give statistics of different nature.
  33259. *
  33260. * The implementer can track two kinds of Performance Counter: time and count.
  33261. * 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.
  33262. * 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.
  33263. */
  33264. export class PerfCounter {
  33265. /**
  33266. * Gets or sets a global boolean to turn on and off all the counters
  33267. */
  33268. static Enabled: boolean;
  33269. /**
  33270. * Returns the smallest value ever
  33271. */
  33272. readonly min: number;
  33273. /**
  33274. * Returns the biggest value ever
  33275. */
  33276. readonly max: number;
  33277. /**
  33278. * Returns the average value since the performance counter is running
  33279. */
  33280. readonly average: number;
  33281. /**
  33282. * Returns the average value of the last second the counter was monitored
  33283. */
  33284. readonly lastSecAverage: number;
  33285. /**
  33286. * Returns the current value
  33287. */
  33288. readonly current: number;
  33289. /**
  33290. * Gets the accumulated total
  33291. */
  33292. readonly total: number;
  33293. /**
  33294. * Gets the total value count
  33295. */
  33296. readonly count: number;
  33297. /**
  33298. * Creates a new counter
  33299. */
  33300. constructor();
  33301. /**
  33302. * Call this method to start monitoring a new frame.
  33303. * 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.
  33304. */
  33305. fetchNewFrame(): void;
  33306. /**
  33307. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33308. * @param newCount the count value to add to the monitored count
  33309. * @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.
  33310. */
  33311. addCount(newCount: number, fetchResult: boolean): void;
  33312. /**
  33313. * Start monitoring this performance counter
  33314. */
  33315. beginMonitoring(): void;
  33316. /**
  33317. * Compute the time lapsed since the previous beginMonitoring() call.
  33318. * @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
  33319. */
  33320. endMonitoring(newFrame?: boolean): void;
  33321. private _fetchResult;
  33322. private _startMonitoringTime;
  33323. private _min;
  33324. private _max;
  33325. private _average;
  33326. private _current;
  33327. private _totalValueCount;
  33328. private _totalAccumulated;
  33329. private _lastSecAverage;
  33330. private _lastSecAccumulated;
  33331. private _lastSecTime;
  33332. private _lastSecValueCount;
  33333. }
  33334. }
  33335. declare module "babylonjs/Engines/engine" {
  33336. import { Observable } from "babylonjs/Misc/observable";
  33337. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  33338. import { Scene } from "babylonjs/scene";
  33339. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  33340. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  33341. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33342. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  33343. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  33344. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  33345. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  33346. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  33347. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  33348. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33349. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  33350. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  33351. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33352. import { Material } from "babylonjs/Materials/material";
  33353. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33354. /**
  33355. * Defines the interface used by display changed events
  33356. */
  33357. export interface IDisplayChangedEventArgs {
  33358. /** Gets the vrDisplay object (if any) */
  33359. vrDisplay: Nullable<any>;
  33360. /** Gets a boolean indicating if webVR is supported */
  33361. vrSupported: boolean;
  33362. }
  33363. /**
  33364. * Defines the interface used by objects containing a viewport (like a camera)
  33365. */
  33366. interface IViewportOwnerLike {
  33367. /**
  33368. * Gets or sets the viewport
  33369. */
  33370. viewport: IViewportLike;
  33371. }
  33372. /**
  33373. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33374. */
  33375. export class Engine extends ThinEngine {
  33376. /** Defines that alpha blending is disabled */
  33377. static readonly ALPHA_DISABLE: number;
  33378. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33379. static readonly ALPHA_ADD: number;
  33380. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33381. static readonly ALPHA_COMBINE: number;
  33382. /** Defines that alpha blending to DEST - SRC * DEST */
  33383. static readonly ALPHA_SUBTRACT: number;
  33384. /** Defines that alpha blending to SRC * DEST */
  33385. static readonly ALPHA_MULTIPLY: number;
  33386. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33387. static readonly ALPHA_MAXIMIZED: number;
  33388. /** Defines that alpha blending to SRC + DEST */
  33389. static readonly ALPHA_ONEONE: number;
  33390. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33391. static readonly ALPHA_PREMULTIPLIED: number;
  33392. /**
  33393. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33394. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33395. */
  33396. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33397. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33398. static readonly ALPHA_INTERPOLATE: number;
  33399. /**
  33400. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33401. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33402. */
  33403. static readonly ALPHA_SCREENMODE: number;
  33404. /** Defines that the ressource is not delayed*/
  33405. static readonly DELAYLOADSTATE_NONE: number;
  33406. /** Defines that the ressource was successfully delay loaded */
  33407. static readonly DELAYLOADSTATE_LOADED: number;
  33408. /** Defines that the ressource is currently delay loading */
  33409. static readonly DELAYLOADSTATE_LOADING: number;
  33410. /** Defines that the ressource is delayed and has not started loading */
  33411. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33412. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33413. static readonly NEVER: number;
  33414. /** 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 */
  33415. static readonly ALWAYS: number;
  33416. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33417. static readonly LESS: number;
  33418. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33419. static readonly EQUAL: number;
  33420. /** 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 */
  33421. static readonly LEQUAL: number;
  33422. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33423. static readonly GREATER: number;
  33424. /** 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 */
  33425. static readonly GEQUAL: number;
  33426. /** 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 */
  33427. static readonly NOTEQUAL: number;
  33428. /** Passed to stencilOperation to specify that stencil value must be kept */
  33429. static readonly KEEP: number;
  33430. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33431. static readonly REPLACE: number;
  33432. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33433. static readonly INCR: number;
  33434. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33435. static readonly DECR: number;
  33436. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33437. static readonly INVERT: number;
  33438. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33439. static readonly INCR_WRAP: number;
  33440. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33441. static readonly DECR_WRAP: number;
  33442. /** Texture is not repeating outside of 0..1 UVs */
  33443. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33444. /** Texture is repeating outside of 0..1 UVs */
  33445. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33446. /** Texture is repeating and mirrored */
  33447. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33448. /** ALPHA */
  33449. static readonly TEXTUREFORMAT_ALPHA: number;
  33450. /** LUMINANCE */
  33451. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33452. /** LUMINANCE_ALPHA */
  33453. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33454. /** RGB */
  33455. static readonly TEXTUREFORMAT_RGB: number;
  33456. /** RGBA */
  33457. static readonly TEXTUREFORMAT_RGBA: number;
  33458. /** RED */
  33459. static readonly TEXTUREFORMAT_RED: number;
  33460. /** RED (2nd reference) */
  33461. static readonly TEXTUREFORMAT_R: number;
  33462. /** RG */
  33463. static readonly TEXTUREFORMAT_RG: number;
  33464. /** RED_INTEGER */
  33465. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33466. /** RED_INTEGER (2nd reference) */
  33467. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33468. /** RG_INTEGER */
  33469. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33470. /** RGB_INTEGER */
  33471. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33472. /** RGBA_INTEGER */
  33473. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33474. /** UNSIGNED_BYTE */
  33475. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33476. /** UNSIGNED_BYTE (2nd reference) */
  33477. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33478. /** FLOAT */
  33479. static readonly TEXTURETYPE_FLOAT: number;
  33480. /** HALF_FLOAT */
  33481. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33482. /** BYTE */
  33483. static readonly TEXTURETYPE_BYTE: number;
  33484. /** SHORT */
  33485. static readonly TEXTURETYPE_SHORT: number;
  33486. /** UNSIGNED_SHORT */
  33487. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33488. /** INT */
  33489. static readonly TEXTURETYPE_INT: number;
  33490. /** UNSIGNED_INT */
  33491. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33492. /** UNSIGNED_SHORT_4_4_4_4 */
  33493. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33494. /** UNSIGNED_SHORT_5_5_5_1 */
  33495. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33496. /** UNSIGNED_SHORT_5_6_5 */
  33497. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33498. /** UNSIGNED_INT_2_10_10_10_REV */
  33499. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33500. /** UNSIGNED_INT_24_8 */
  33501. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33502. /** UNSIGNED_INT_10F_11F_11F_REV */
  33503. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33504. /** UNSIGNED_INT_5_9_9_9_REV */
  33505. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33506. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33507. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33508. /** nearest is mag = nearest and min = nearest and mip = linear */
  33509. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33510. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33511. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33512. /** Trilinear is mag = linear and min = linear and mip = linear */
  33513. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33514. /** nearest is mag = nearest and min = nearest and mip = linear */
  33515. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33516. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33517. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33518. /** Trilinear is mag = linear and min = linear and mip = linear */
  33519. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33520. /** mag = nearest and min = nearest and mip = nearest */
  33521. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33522. /** mag = nearest and min = linear and mip = nearest */
  33523. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33524. /** mag = nearest and min = linear and mip = linear */
  33525. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33526. /** mag = nearest and min = linear and mip = none */
  33527. static readonly TEXTURE_NEAREST_LINEAR: number;
  33528. /** mag = nearest and min = nearest and mip = none */
  33529. static readonly TEXTURE_NEAREST_NEAREST: number;
  33530. /** mag = linear and min = nearest and mip = nearest */
  33531. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33532. /** mag = linear and min = nearest and mip = linear */
  33533. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33534. /** mag = linear and min = linear and mip = none */
  33535. static readonly TEXTURE_LINEAR_LINEAR: number;
  33536. /** mag = linear and min = nearest and mip = none */
  33537. static readonly TEXTURE_LINEAR_NEAREST: number;
  33538. /** Explicit coordinates mode */
  33539. static readonly TEXTURE_EXPLICIT_MODE: number;
  33540. /** Spherical coordinates mode */
  33541. static readonly TEXTURE_SPHERICAL_MODE: number;
  33542. /** Planar coordinates mode */
  33543. static readonly TEXTURE_PLANAR_MODE: number;
  33544. /** Cubic coordinates mode */
  33545. static readonly TEXTURE_CUBIC_MODE: number;
  33546. /** Projection coordinates mode */
  33547. static readonly TEXTURE_PROJECTION_MODE: number;
  33548. /** Skybox coordinates mode */
  33549. static readonly TEXTURE_SKYBOX_MODE: number;
  33550. /** Inverse Cubic coordinates mode */
  33551. static readonly TEXTURE_INVCUBIC_MODE: number;
  33552. /** Equirectangular coordinates mode */
  33553. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33554. /** Equirectangular Fixed coordinates mode */
  33555. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33556. /** Equirectangular Fixed Mirrored coordinates mode */
  33557. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33558. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33559. static readonly SCALEMODE_FLOOR: number;
  33560. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33561. static readonly SCALEMODE_NEAREST: number;
  33562. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33563. static readonly SCALEMODE_CEILING: number;
  33564. /**
  33565. * Returns the current npm package of the sdk
  33566. */
  33567. static readonly NpmPackage: string;
  33568. /**
  33569. * Returns the current version of the framework
  33570. */
  33571. static readonly Version: string;
  33572. /** Gets the list of created engines */
  33573. static readonly Instances: Engine[];
  33574. /**
  33575. * Gets the latest created engine
  33576. */
  33577. static readonly LastCreatedEngine: Nullable<Engine>;
  33578. /**
  33579. * Gets the latest created scene
  33580. */
  33581. static readonly LastCreatedScene: Nullable<Scene>;
  33582. /**
  33583. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33584. * @param flag defines which part of the materials must be marked as dirty
  33585. * @param predicate defines a predicate used to filter which materials should be affected
  33586. */
  33587. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33588. /**
  33589. * Method called to create the default loading screen.
  33590. * This can be overriden in your own app.
  33591. * @param canvas The rendering canvas element
  33592. * @returns The loading screen
  33593. */
  33594. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33595. /**
  33596. * Method called to create the default rescale post process on each engine.
  33597. */
  33598. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33599. /**
  33600. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33601. **/
  33602. enableOfflineSupport: boolean;
  33603. /**
  33604. * 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)
  33605. **/
  33606. disableManifestCheck: boolean;
  33607. /**
  33608. * Gets the list of created scenes
  33609. */
  33610. scenes: Scene[];
  33611. /**
  33612. * Event raised when a new scene is created
  33613. */
  33614. onNewSceneAddedObservable: Observable<Scene>;
  33615. /**
  33616. * Gets the list of created postprocesses
  33617. */
  33618. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  33619. /**
  33620. * Gets a boolean indicating if the pointer is currently locked
  33621. */
  33622. isPointerLock: boolean;
  33623. /**
  33624. * Observable event triggered each time the rendering canvas is resized
  33625. */
  33626. onResizeObservable: Observable<Engine>;
  33627. /**
  33628. * Observable event triggered each time the canvas loses focus
  33629. */
  33630. onCanvasBlurObservable: Observable<Engine>;
  33631. /**
  33632. * Observable event triggered each time the canvas gains focus
  33633. */
  33634. onCanvasFocusObservable: Observable<Engine>;
  33635. /**
  33636. * Observable event triggered each time the canvas receives pointerout event
  33637. */
  33638. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33639. /**
  33640. * Observable raised when the engine begins a new frame
  33641. */
  33642. onBeginFrameObservable: Observable<Engine>;
  33643. /**
  33644. * If set, will be used to request the next animation frame for the render loop
  33645. */
  33646. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33647. /**
  33648. * Observable raised when the engine ends the current frame
  33649. */
  33650. onEndFrameObservable: Observable<Engine>;
  33651. /**
  33652. * Observable raised when the engine is about to compile a shader
  33653. */
  33654. onBeforeShaderCompilationObservable: Observable<Engine>;
  33655. /**
  33656. * Observable raised when the engine has jsut compiled a shader
  33657. */
  33658. onAfterShaderCompilationObservable: Observable<Engine>;
  33659. /**
  33660. * Gets the audio engine
  33661. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33662. * @ignorenaming
  33663. */
  33664. static audioEngine: IAudioEngine;
  33665. /**
  33666. * Default AudioEngine factory responsible of creating the Audio Engine.
  33667. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33668. */
  33669. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33670. /**
  33671. * Default offline support factory responsible of creating a tool used to store data locally.
  33672. * By default, this will create a Database object if the workload has been embedded.
  33673. */
  33674. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33675. private _loadingScreen;
  33676. private _pointerLockRequested;
  33677. private _dummyFramebuffer;
  33678. private _rescalePostProcess;
  33679. /** @hidden */
  33680. protected _alphaMode: number;
  33681. /** @hidden */
  33682. protected _alphaEquation: number;
  33683. private _deterministicLockstep;
  33684. private _lockstepMaxSteps;
  33685. private _timeStep;
  33686. protected readonly _supportsHardwareTextureRescaling: boolean;
  33687. private _fps;
  33688. private _deltaTime;
  33689. /** @hidden */
  33690. _drawCalls: PerfCounter;
  33691. /**
  33692. * Turn this value on if you want to pause FPS computation when in background
  33693. */
  33694. disablePerformanceMonitorInBackground: boolean;
  33695. private _performanceMonitor;
  33696. /**
  33697. * Gets the performance monitor attached to this engine
  33698. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33699. */
  33700. readonly performanceMonitor: PerformanceMonitor;
  33701. private _onFocus;
  33702. private _onBlur;
  33703. private _onCanvasPointerOut;
  33704. private _onCanvasBlur;
  33705. private _onCanvasFocus;
  33706. private _onFullscreenChange;
  33707. private _onPointerLockChange;
  33708. /**
  33709. * Gets the HTML element used to attach event listeners
  33710. * @returns a HTML element
  33711. */
  33712. getInputElement(): Nullable<HTMLElement>;
  33713. /**
  33714. * Creates a new engine
  33715. * @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
  33716. * @param antialias defines enable antialiasing (default: false)
  33717. * @param options defines further options to be sent to the getContext() function
  33718. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33719. */
  33720. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33721. /**
  33722. * Gets current aspect ratio
  33723. * @param viewportOwner defines the camera to use to get the aspect ratio
  33724. * @param useScreen defines if screen size must be used (or the current render target if any)
  33725. * @returns a number defining the aspect ratio
  33726. */
  33727. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33728. /**
  33729. * Gets current screen aspect ratio
  33730. * @returns a number defining the aspect ratio
  33731. */
  33732. getScreenAspectRatio(): number;
  33733. /**
  33734. * Gets the client rect of the HTML canvas attached with the current webGL context
  33735. * @returns a client rectanglee
  33736. */
  33737. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33738. /**
  33739. * Gets the client rect of the HTML element used for events
  33740. * @returns a client rectanglee
  33741. */
  33742. getInputElementClientRect(): Nullable<ClientRect>;
  33743. /**
  33744. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33745. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33746. * @returns true if engine is in deterministic lock step mode
  33747. */
  33748. isDeterministicLockStep(): boolean;
  33749. /**
  33750. * Gets the max steps when engine is running in deterministic lock step
  33751. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33752. * @returns the max steps
  33753. */
  33754. getLockstepMaxSteps(): number;
  33755. /**
  33756. * Returns the time in ms between steps when using deterministic lock step.
  33757. * @returns time step in (ms)
  33758. */
  33759. getTimeStep(): number;
  33760. /**
  33761. * Force the mipmap generation for the given render target texture
  33762. * @param texture defines the render target texture to use
  33763. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33764. */
  33765. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33766. /** States */
  33767. /**
  33768. * Set various states to the webGL context
  33769. * @param culling defines backface culling state
  33770. * @param zOffset defines the value to apply to zOffset (0 by default)
  33771. * @param force defines if states must be applied even if cache is up to date
  33772. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33773. */
  33774. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33775. /**
  33776. * Set the z offset to apply to current rendering
  33777. * @param value defines the offset to apply
  33778. */
  33779. setZOffset(value: number): void;
  33780. /**
  33781. * Gets the current value of the zOffset
  33782. * @returns the current zOffset state
  33783. */
  33784. getZOffset(): number;
  33785. /**
  33786. * Enable or disable depth buffering
  33787. * @param enable defines the state to set
  33788. */
  33789. setDepthBuffer(enable: boolean): void;
  33790. /**
  33791. * Gets a boolean indicating if depth writing is enabled
  33792. * @returns the current depth writing state
  33793. */
  33794. getDepthWrite(): boolean;
  33795. /**
  33796. * Enable or disable depth writing
  33797. * @param enable defines the state to set
  33798. */
  33799. setDepthWrite(enable: boolean): void;
  33800. /**
  33801. * Enable or disable color writing
  33802. * @param enable defines the state to set
  33803. */
  33804. setColorWrite(enable: boolean): void;
  33805. /**
  33806. * Gets a boolean indicating if color writing is enabled
  33807. * @returns the current color writing state
  33808. */
  33809. getColorWrite(): boolean;
  33810. /**
  33811. * Sets alpha constants used by some alpha blending modes
  33812. * @param r defines the red component
  33813. * @param g defines the green component
  33814. * @param b defines the blue component
  33815. * @param a defines the alpha component
  33816. */
  33817. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33818. /**
  33819. * Sets the current alpha mode
  33820. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33821. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33822. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33823. */
  33824. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33825. /**
  33826. * Gets the current alpha mode
  33827. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33828. * @returns the current alpha mode
  33829. */
  33830. getAlphaMode(): number;
  33831. /**
  33832. * Sets the current alpha equation
  33833. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33834. */
  33835. setAlphaEquation(equation: number): void;
  33836. /**
  33837. * Gets the current alpha equation.
  33838. * @returns the current alpha equation
  33839. */
  33840. getAlphaEquation(): number;
  33841. /**
  33842. * Gets a boolean indicating if stencil buffer is enabled
  33843. * @returns the current stencil buffer state
  33844. */
  33845. getStencilBuffer(): boolean;
  33846. /**
  33847. * Enable or disable the stencil buffer
  33848. * @param enable defines if the stencil buffer must be enabled or disabled
  33849. */
  33850. setStencilBuffer(enable: boolean): void;
  33851. /**
  33852. * Gets the current stencil mask
  33853. * @returns a number defining the new stencil mask to use
  33854. */
  33855. getStencilMask(): number;
  33856. /**
  33857. * Sets the current stencil mask
  33858. * @param mask defines the new stencil mask to use
  33859. */
  33860. setStencilMask(mask: number): void;
  33861. /**
  33862. * Gets the current stencil function
  33863. * @returns a number defining the stencil function to use
  33864. */
  33865. getStencilFunction(): number;
  33866. /**
  33867. * Gets the current stencil reference value
  33868. * @returns a number defining the stencil reference value to use
  33869. */
  33870. getStencilFunctionReference(): number;
  33871. /**
  33872. * Gets the current stencil mask
  33873. * @returns a number defining the stencil mask to use
  33874. */
  33875. getStencilFunctionMask(): number;
  33876. /**
  33877. * Sets the current stencil function
  33878. * @param stencilFunc defines the new stencil function to use
  33879. */
  33880. setStencilFunction(stencilFunc: number): void;
  33881. /**
  33882. * Sets the current stencil reference
  33883. * @param reference defines the new stencil reference to use
  33884. */
  33885. setStencilFunctionReference(reference: number): void;
  33886. /**
  33887. * Sets the current stencil mask
  33888. * @param mask defines the new stencil mask to use
  33889. */
  33890. setStencilFunctionMask(mask: number): void;
  33891. /**
  33892. * Gets the current stencil operation when stencil fails
  33893. * @returns a number defining stencil operation to use when stencil fails
  33894. */
  33895. getStencilOperationFail(): number;
  33896. /**
  33897. * Gets the current stencil operation when depth fails
  33898. * @returns a number defining stencil operation to use when depth fails
  33899. */
  33900. getStencilOperationDepthFail(): number;
  33901. /**
  33902. * Gets the current stencil operation when stencil passes
  33903. * @returns a number defining stencil operation to use when stencil passes
  33904. */
  33905. getStencilOperationPass(): number;
  33906. /**
  33907. * Sets the stencil operation to use when stencil fails
  33908. * @param operation defines the stencil operation to use when stencil fails
  33909. */
  33910. setStencilOperationFail(operation: number): void;
  33911. /**
  33912. * Sets the stencil operation to use when depth fails
  33913. * @param operation defines the stencil operation to use when depth fails
  33914. */
  33915. setStencilOperationDepthFail(operation: number): void;
  33916. /**
  33917. * Sets the stencil operation to use when stencil passes
  33918. * @param operation defines the stencil operation to use when stencil passes
  33919. */
  33920. setStencilOperationPass(operation: number): void;
  33921. /**
  33922. * Sets a boolean indicating if the dithering state is enabled or disabled
  33923. * @param value defines the dithering state
  33924. */
  33925. setDitheringState(value: boolean): void;
  33926. /**
  33927. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33928. * @param value defines the rasterizer state
  33929. */
  33930. setRasterizerState(value: boolean): void;
  33931. /**
  33932. * Gets the current depth function
  33933. * @returns a number defining the depth function
  33934. */
  33935. getDepthFunction(): Nullable<number>;
  33936. /**
  33937. * Sets the current depth function
  33938. * @param depthFunc defines the function to use
  33939. */
  33940. setDepthFunction(depthFunc: number): void;
  33941. /**
  33942. * Sets the current depth function to GREATER
  33943. */
  33944. setDepthFunctionToGreater(): void;
  33945. /**
  33946. * Sets the current depth function to GEQUAL
  33947. */
  33948. setDepthFunctionToGreaterOrEqual(): void;
  33949. /**
  33950. * Sets the current depth function to LESS
  33951. */
  33952. setDepthFunctionToLess(): void;
  33953. /**
  33954. * Sets the current depth function to LEQUAL
  33955. */
  33956. setDepthFunctionToLessOrEqual(): void;
  33957. private _cachedStencilBuffer;
  33958. private _cachedStencilFunction;
  33959. private _cachedStencilMask;
  33960. private _cachedStencilOperationPass;
  33961. private _cachedStencilOperationFail;
  33962. private _cachedStencilOperationDepthFail;
  33963. private _cachedStencilReference;
  33964. /**
  33965. * Caches the the state of the stencil buffer
  33966. */
  33967. cacheStencilState(): void;
  33968. /**
  33969. * Restores the state of the stencil buffer
  33970. */
  33971. restoreStencilState(): void;
  33972. /**
  33973. * Directly set the WebGL Viewport
  33974. * @param x defines the x coordinate of the viewport (in screen space)
  33975. * @param y defines the y coordinate of the viewport (in screen space)
  33976. * @param width defines the width of the viewport (in screen space)
  33977. * @param height defines the height of the viewport (in screen space)
  33978. * @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
  33979. */
  33980. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  33981. /**
  33982. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  33983. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33984. * @param y defines the y-coordinate of the corner of the clear rectangle
  33985. * @param width defines the width of the clear rectangle
  33986. * @param height defines the height of the clear rectangle
  33987. * @param clearColor defines the clear color
  33988. */
  33989. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  33990. /**
  33991. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  33992. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33993. * @param y defines the y-coordinate of the corner of the clear rectangle
  33994. * @param width defines the width of the clear rectangle
  33995. * @param height defines the height of the clear rectangle
  33996. */
  33997. enableScissor(x: number, y: number, width: number, height: number): void;
  33998. /**
  33999. * Disable previously set scissor test rectangle
  34000. */
  34001. disableScissor(): void;
  34002. protected _reportDrawCall(): void;
  34003. /**
  34004. * Initializes a webVR display and starts listening to display change events
  34005. * The onVRDisplayChangedObservable will be notified upon these changes
  34006. * @returns The onVRDisplayChangedObservable
  34007. */
  34008. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34009. /** @hidden */
  34010. _prepareVRComponent(): void;
  34011. /** @hidden */
  34012. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34013. /** @hidden */
  34014. _submitVRFrame(): void;
  34015. /**
  34016. * Call this function to leave webVR mode
  34017. * Will do nothing if webVR is not supported or if there is no webVR device
  34018. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34019. */
  34020. disableVR(): void;
  34021. /**
  34022. * Gets a boolean indicating that the system is in VR mode and is presenting
  34023. * @returns true if VR mode is engaged
  34024. */
  34025. isVRPresenting(): boolean;
  34026. /** @hidden */
  34027. _requestVRFrame(): void;
  34028. /** @hidden */
  34029. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34030. /**
  34031. * Gets the source code of the vertex shader associated with a specific webGL program
  34032. * @param program defines the program to use
  34033. * @returns a string containing the source code of the vertex shader associated with the program
  34034. */
  34035. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34036. /**
  34037. * Gets the source code of the fragment shader associated with a specific webGL program
  34038. * @param program defines the program to use
  34039. * @returns a string containing the source code of the fragment shader associated with the program
  34040. */
  34041. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34042. /**
  34043. * Reads pixels from the current frame buffer. Please note that this function can be slow
  34044. * @param x defines the x coordinate of the rectangle where pixels must be read
  34045. * @param y defines the y coordinate of the rectangle where pixels must be read
  34046. * @param width defines the width of the rectangle where pixels must be read
  34047. * @param height defines the height of the rectangle where pixels must be read
  34048. * @returns a Uint8Array containing RGBA colors
  34049. */
  34050. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  34051. /**
  34052. * Sets a depth stencil texture from a render target to the according uniform.
  34053. * @param channel The texture channel
  34054. * @param uniform The uniform to set
  34055. * @param texture The render target texture containing the depth stencil texture to apply
  34056. */
  34057. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34058. /**
  34059. * Sets a texture to the webGL context from a postprocess
  34060. * @param channel defines the channel to use
  34061. * @param postProcess defines the source postprocess
  34062. */
  34063. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34064. /**
  34065. * Binds the output of the passed in post process to the texture channel specified
  34066. * @param channel The channel the texture should be bound to
  34067. * @param postProcess The post process which's output should be bound
  34068. */
  34069. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34070. /** @hidden */
  34071. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34072. protected _rebuildBuffers(): void;
  34073. /** @hidden */
  34074. _renderFrame(): void;
  34075. _renderLoop(): void;
  34076. /** @hidden */
  34077. _renderViews(): boolean;
  34078. /**
  34079. * Toggle full screen mode
  34080. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34081. */
  34082. switchFullscreen(requestPointerLock: boolean): void;
  34083. /**
  34084. * Enters full screen mode
  34085. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34086. */
  34087. enterFullscreen(requestPointerLock: boolean): void;
  34088. /**
  34089. * Exits full screen mode
  34090. */
  34091. exitFullscreen(): void;
  34092. /**
  34093. * Enters Pointerlock mode
  34094. */
  34095. enterPointerlock(): void;
  34096. /**
  34097. * Exits Pointerlock mode
  34098. */
  34099. exitPointerlock(): void;
  34100. /**
  34101. * Begin a new frame
  34102. */
  34103. beginFrame(): void;
  34104. /**
  34105. * Enf the current frame
  34106. */
  34107. endFrame(): void;
  34108. resize(): void;
  34109. /**
  34110. * Set the compressed texture format to use, based on the formats you have, and the formats
  34111. * supported by the hardware / browser.
  34112. *
  34113. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  34114. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  34115. * to API arguments needed to compressed textures. This puts the burden on the container
  34116. * generator to house the arcane code for determining these for current & future formats.
  34117. *
  34118. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  34119. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  34120. *
  34121. * Note: The result of this call is not taken into account when a texture is base64.
  34122. *
  34123. * @param formatsAvailable defines the list of those format families you have created
  34124. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  34125. *
  34126. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  34127. * @returns The extension selected.
  34128. */
  34129. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  34130. /**
  34131. * Set the compressed texture extensions or file names to skip.
  34132. *
  34133. * @param skippedFiles defines the list of those texture files you want to skip
  34134. * Example: [".dds", ".env", "myfile.png"]
  34135. */
  34136. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  34137. /**
  34138. * Force a specific size of the canvas
  34139. * @param width defines the new canvas' width
  34140. * @param height defines the new canvas' height
  34141. */
  34142. setSize(width: number, height: number): void;
  34143. /**
  34144. * Updates a dynamic vertex buffer.
  34145. * @param vertexBuffer the vertex buffer to update
  34146. * @param data the data used to update the vertex buffer
  34147. * @param byteOffset the byte offset of the data
  34148. * @param byteLength the byte length of the data
  34149. */
  34150. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34151. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34152. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34153. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34154. _releaseTexture(texture: InternalTexture): void;
  34155. /**
  34156. * @hidden
  34157. * Rescales a texture
  34158. * @param source input texutre
  34159. * @param destination destination texture
  34160. * @param scene scene to use to render the resize
  34161. * @param internalFormat format to use when resizing
  34162. * @param onComplete callback to be called when resize has completed
  34163. */
  34164. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34165. /**
  34166. * Gets the current framerate
  34167. * @returns a number representing the framerate
  34168. */
  34169. getFps(): number;
  34170. /**
  34171. * Gets the time spent between current and previous frame
  34172. * @returns a number representing the delta time in ms
  34173. */
  34174. getDeltaTime(): number;
  34175. private _measureFps;
  34176. /** @hidden */
  34177. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34178. /**
  34179. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  34180. * @param renderTarget The render target to set the frame buffer for
  34181. */
  34182. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  34183. /**
  34184. * Update a dynamic index buffer
  34185. * @param indexBuffer defines the target index buffer
  34186. * @param indices defines the data to update
  34187. * @param offset defines the offset in the target index buffer where update should start
  34188. */
  34189. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34190. /**
  34191. * Updates the sample count of a render target texture
  34192. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34193. * @param texture defines the texture to update
  34194. * @param samples defines the sample count to set
  34195. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34196. */
  34197. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34198. /**
  34199. * Updates a depth texture Comparison Mode and Function.
  34200. * If the comparison Function is equal to 0, the mode will be set to none.
  34201. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34202. * @param texture The texture to set the comparison function for
  34203. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34204. */
  34205. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34206. /**
  34207. * Creates a webGL buffer to use with instanciation
  34208. * @param capacity defines the size of the buffer
  34209. * @returns the webGL buffer
  34210. */
  34211. createInstancesBuffer(capacity: number): DataBuffer;
  34212. /**
  34213. * Delete a webGL buffer used with instanciation
  34214. * @param buffer defines the webGL buffer to delete
  34215. */
  34216. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34217. /** @hidden */
  34218. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34219. dispose(): void;
  34220. private _disableTouchAction;
  34221. /**
  34222. * Display the loading screen
  34223. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34224. */
  34225. displayLoadingUI(): void;
  34226. /**
  34227. * Hide the loading screen
  34228. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34229. */
  34230. hideLoadingUI(): void;
  34231. /**
  34232. * Gets the current loading screen object
  34233. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34234. */
  34235. /**
  34236. * Sets the current loading screen object
  34237. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34238. */
  34239. loadingScreen: ILoadingScreen;
  34240. /**
  34241. * Sets the current loading screen text
  34242. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34243. */
  34244. loadingUIText: string;
  34245. /**
  34246. * Sets the current loading screen background color
  34247. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34248. */
  34249. loadingUIBackgroundColor: string;
  34250. /** Pointerlock and fullscreen */
  34251. /**
  34252. * Ask the browser to promote the current element to pointerlock mode
  34253. * @param element defines the DOM element to promote
  34254. */
  34255. static _RequestPointerlock(element: HTMLElement): void;
  34256. /**
  34257. * Asks the browser to exit pointerlock mode
  34258. */
  34259. static _ExitPointerlock(): void;
  34260. /**
  34261. * Ask the browser to promote the current element to fullscreen rendering mode
  34262. * @param element defines the DOM element to promote
  34263. */
  34264. static _RequestFullscreen(element: HTMLElement): void;
  34265. /**
  34266. * Asks the browser to exit fullscreen mode
  34267. */
  34268. static _ExitFullscreen(): void;
  34269. }
  34270. }
  34271. declare module "babylonjs/Engines/engineStore" {
  34272. import { Nullable } from "babylonjs/types";
  34273. import { Engine } from "babylonjs/Engines/engine";
  34274. import { Scene } from "babylonjs/scene";
  34275. /**
  34276. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34277. * during the life time of the application.
  34278. */
  34279. export class EngineStore {
  34280. /** Gets the list of created engines */
  34281. static Instances: import("babylonjs/Engines/engine").Engine[];
  34282. /** @hidden */
  34283. static _LastCreatedScene: Nullable<Scene>;
  34284. /**
  34285. * Gets the latest created engine
  34286. */
  34287. static readonly LastCreatedEngine: Nullable<Engine>;
  34288. /**
  34289. * Gets the latest created scene
  34290. */
  34291. static readonly LastCreatedScene: Nullable<Scene>;
  34292. /**
  34293. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34294. * @ignorenaming
  34295. */
  34296. static UseFallbackTexture: boolean;
  34297. /**
  34298. * Texture content used if a texture cannot loaded
  34299. * @ignorenaming
  34300. */
  34301. static FallbackTexture: string;
  34302. }
  34303. }
  34304. declare module "babylonjs/Misc/promise" {
  34305. /**
  34306. * Helper class that provides a small promise polyfill
  34307. */
  34308. export class PromisePolyfill {
  34309. /**
  34310. * Static function used to check if the polyfill is required
  34311. * If this is the case then the function will inject the polyfill to window.Promise
  34312. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34313. */
  34314. static Apply(force?: boolean): void;
  34315. }
  34316. }
  34317. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  34318. /**
  34319. * Interface for screenshot methods with describe argument called `size` as object with options
  34320. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34321. */
  34322. export interface IScreenshotSize {
  34323. /**
  34324. * number in pixels for canvas height
  34325. */
  34326. height?: number;
  34327. /**
  34328. * multiplier allowing render at a higher or lower resolution
  34329. * If value is defined then height and width will be ignored and taken from camera
  34330. */
  34331. precision?: number;
  34332. /**
  34333. * number in pixels for canvas width
  34334. */
  34335. width?: number;
  34336. }
  34337. }
  34338. declare module "babylonjs/Misc/tools" {
  34339. import { Nullable, float } from "babylonjs/types";
  34340. import { DomManagement } from "babylonjs/Misc/domManagement";
  34341. import { WebRequest } from "babylonjs/Misc/webRequest";
  34342. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34343. import { ReadFileError } from "babylonjs/Misc/fileTools";
  34344. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34345. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  34346. import { Camera } from "babylonjs/Cameras/camera";
  34347. import { Engine } from "babylonjs/Engines/engine";
  34348. interface IColor4Like {
  34349. r: float;
  34350. g: float;
  34351. b: float;
  34352. a: float;
  34353. }
  34354. /**
  34355. * Class containing a set of static utilities functions
  34356. */
  34357. export class Tools {
  34358. /**
  34359. * Gets or sets the base URL to use to load assets
  34360. */
  34361. static BaseUrl: string;
  34362. /**
  34363. * Enable/Disable Custom HTTP Request Headers globally.
  34364. * default = false
  34365. * @see CustomRequestHeaders
  34366. */
  34367. static UseCustomRequestHeaders: boolean;
  34368. /**
  34369. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34370. * i.e. when loading files, where the server/service expects an Authorization header
  34371. */
  34372. static CustomRequestHeaders: {
  34373. [key: string]: string;
  34374. };
  34375. /**
  34376. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34377. */
  34378. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  34379. /**
  34380. * Default behaviour for cors in the application.
  34381. * It can be a string if the expected behavior is identical in the entire app.
  34382. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34383. */
  34384. static CorsBehavior: string | ((url: string | string[]) => string);
  34385. /**
  34386. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34387. * @ignorenaming
  34388. */
  34389. static UseFallbackTexture: boolean;
  34390. /**
  34391. * Use this object to register external classes like custom textures or material
  34392. * to allow the laoders to instantiate them
  34393. */
  34394. static RegisteredExternalClasses: {
  34395. [key: string]: Object;
  34396. };
  34397. /**
  34398. * Texture content used if a texture cannot loaded
  34399. * @ignorenaming
  34400. */
  34401. static fallbackTexture: string;
  34402. /**
  34403. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34404. * @param u defines the coordinate on X axis
  34405. * @param v defines the coordinate on Y axis
  34406. * @param width defines the width of the source data
  34407. * @param height defines the height of the source data
  34408. * @param pixels defines the source byte array
  34409. * @param color defines the output color
  34410. */
  34411. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34412. /**
  34413. * Interpolates between a and b via alpha
  34414. * @param a The lower value (returned when alpha = 0)
  34415. * @param b The upper value (returned when alpha = 1)
  34416. * @param alpha The interpolation-factor
  34417. * @return The mixed value
  34418. */
  34419. static Mix(a: number, b: number, alpha: number): number;
  34420. /**
  34421. * Tries to instantiate a new object from a given class name
  34422. * @param className defines the class name to instantiate
  34423. * @returns the new object or null if the system was not able to do the instantiation
  34424. */
  34425. static Instantiate(className: string): any;
  34426. /**
  34427. * Provides a slice function that will work even on IE
  34428. * @param data defines the array to slice
  34429. * @param start defines the start of the data (optional)
  34430. * @param end defines the end of the data (optional)
  34431. * @returns the new sliced array
  34432. */
  34433. static Slice<T>(data: T, start?: number, end?: number): T;
  34434. /**
  34435. * Polyfill for setImmediate
  34436. * @param action defines the action to execute after the current execution block
  34437. */
  34438. static SetImmediate(action: () => void): void;
  34439. /**
  34440. * Function indicating if a number is an exponent of 2
  34441. * @param value defines the value to test
  34442. * @returns true if the value is an exponent of 2
  34443. */
  34444. static IsExponentOfTwo(value: number): boolean;
  34445. private static _tmpFloatArray;
  34446. /**
  34447. * Returns the nearest 32-bit single precision float representation of a Number
  34448. * @param value A Number. If the parameter is of a different type, it will get converted
  34449. * to a number or to NaN if it cannot be converted
  34450. * @returns number
  34451. */
  34452. static FloatRound(value: number): number;
  34453. /**
  34454. * Extracts the filename from a path
  34455. * @param path defines the path to use
  34456. * @returns the filename
  34457. */
  34458. static GetFilename(path: string): string;
  34459. /**
  34460. * Extracts the "folder" part of a path (everything before the filename).
  34461. * @param uri The URI to extract the info from
  34462. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34463. * @returns The "folder" part of the path
  34464. */
  34465. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34466. /**
  34467. * Extracts text content from a DOM element hierarchy
  34468. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34469. */
  34470. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34471. /**
  34472. * Convert an angle in radians to degrees
  34473. * @param angle defines the angle to convert
  34474. * @returns the angle in degrees
  34475. */
  34476. static ToDegrees(angle: number): number;
  34477. /**
  34478. * Convert an angle in degrees to radians
  34479. * @param angle defines the angle to convert
  34480. * @returns the angle in radians
  34481. */
  34482. static ToRadians(angle: number): number;
  34483. /**
  34484. * Returns an array if obj is not an array
  34485. * @param obj defines the object to evaluate as an array
  34486. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34487. * @returns either obj directly if obj is an array or a new array containing obj
  34488. */
  34489. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34490. /**
  34491. * Gets the pointer prefix to use
  34492. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34493. */
  34494. static GetPointerPrefix(): string;
  34495. /**
  34496. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34497. * @param url define the url we are trying
  34498. * @param element define the dom element where to configure the cors policy
  34499. */
  34500. static SetCorsBehavior(url: string | string[], element: {
  34501. crossOrigin: string | null;
  34502. }): void;
  34503. /**
  34504. * Removes unwanted characters from an url
  34505. * @param url defines the url to clean
  34506. * @returns the cleaned url
  34507. */
  34508. static CleanUrl(url: string): string;
  34509. /**
  34510. * Gets or sets a function used to pre-process url before using them to load assets
  34511. */
  34512. static PreprocessUrl: (url: string) => string;
  34513. /**
  34514. * Loads an image as an HTMLImageElement.
  34515. * @param input url string, ArrayBuffer, or Blob to load
  34516. * @param onLoad callback called when the image successfully loads
  34517. * @param onError callback called when the image fails to load
  34518. * @param offlineProvider offline provider for caching
  34519. * @param mimeType optional mime type
  34520. * @returns the HTMLImageElement of the loaded image
  34521. */
  34522. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34523. /**
  34524. * Loads a file from a url
  34525. * @param url url string, ArrayBuffer, or Blob to load
  34526. * @param onSuccess callback called when the file successfully loads
  34527. * @param onProgress callback called while file is loading (if the server supports this mode)
  34528. * @param offlineProvider defines the offline provider for caching
  34529. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34530. * @param onError callback called when the file fails to load
  34531. * @returns a file request object
  34532. */
  34533. 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;
  34534. /**
  34535. * Loads a file from a url
  34536. * @param url the file url to load
  34537. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  34538. */
  34539. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  34540. /**
  34541. * Load a script (identified by an url). When the url returns, the
  34542. * content of this file is added into a new script element, attached to the DOM (body element)
  34543. * @param scriptUrl defines the url of the script to laod
  34544. * @param onSuccess defines the callback called when the script is loaded
  34545. * @param onError defines the callback to call if an error occurs
  34546. * @param scriptId defines the id of the script element
  34547. */
  34548. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34549. /**
  34550. * Load an asynchronous script (identified by an url). When the url returns, the
  34551. * content of this file is added into a new script element, attached to the DOM (body element)
  34552. * @param scriptUrl defines the url of the script to laod
  34553. * @param scriptId defines the id of the script element
  34554. * @returns a promise request object
  34555. */
  34556. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  34557. /**
  34558. * Loads a file from a blob
  34559. * @param fileToLoad defines the blob to use
  34560. * @param callback defines the callback to call when data is loaded
  34561. * @param progressCallback defines the callback to call during loading process
  34562. * @returns a file request object
  34563. */
  34564. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34565. /**
  34566. * Reads a file from a File object
  34567. * @param file defines the file to load
  34568. * @param onSuccess defines the callback to call when data is loaded
  34569. * @param onProgress defines the callback to call during loading process
  34570. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34571. * @param onError defines the callback to call when an error occurs
  34572. * @returns a file request object
  34573. */
  34574. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34575. /**
  34576. * Creates a data url from a given string content
  34577. * @param content defines the content to convert
  34578. * @returns the new data url link
  34579. */
  34580. static FileAsURL(content: string): string;
  34581. /**
  34582. * Format the given number to a specific decimal format
  34583. * @param value defines the number to format
  34584. * @param decimals defines the number of decimals to use
  34585. * @returns the formatted string
  34586. */
  34587. static Format(value: number, decimals?: number): string;
  34588. /**
  34589. * Tries to copy an object by duplicating every property
  34590. * @param source defines the source object
  34591. * @param destination defines the target object
  34592. * @param doNotCopyList defines a list of properties to avoid
  34593. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34594. */
  34595. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34596. /**
  34597. * Gets a boolean indicating if the given object has no own property
  34598. * @param obj defines the object to test
  34599. * @returns true if object has no own property
  34600. */
  34601. static IsEmpty(obj: any): boolean;
  34602. /**
  34603. * Function used to register events at window level
  34604. * @param windowElement defines the Window object to use
  34605. * @param events defines the events to register
  34606. */
  34607. static RegisterTopRootEvents(windowElement: Window, events: {
  34608. name: string;
  34609. handler: Nullable<(e: FocusEvent) => any>;
  34610. }[]): void;
  34611. /**
  34612. * Function used to unregister events from window level
  34613. * @param windowElement defines the Window object to use
  34614. * @param events defines the events to unregister
  34615. */
  34616. static UnregisterTopRootEvents(windowElement: Window, events: {
  34617. name: string;
  34618. handler: Nullable<(e: FocusEvent) => any>;
  34619. }[]): void;
  34620. /**
  34621. * @ignore
  34622. */
  34623. static _ScreenshotCanvas: HTMLCanvasElement;
  34624. /**
  34625. * Dumps the current bound framebuffer
  34626. * @param width defines the rendering width
  34627. * @param height defines the rendering height
  34628. * @param engine defines the hosting engine
  34629. * @param successCallback defines the callback triggered once the data are available
  34630. * @param mimeType defines the mime type of the result
  34631. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34632. */
  34633. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34634. /**
  34635. * Converts the canvas data to blob.
  34636. * This acts as a polyfill for browsers not supporting the to blob function.
  34637. * @param canvas Defines the canvas to extract the data from
  34638. * @param successCallback Defines the callback triggered once the data are available
  34639. * @param mimeType Defines the mime type of the result
  34640. */
  34641. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34642. /**
  34643. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34644. * @param successCallback defines the callback triggered once the data are available
  34645. * @param mimeType defines the mime type of the result
  34646. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34647. */
  34648. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34649. /**
  34650. * Downloads a blob in the browser
  34651. * @param blob defines the blob to download
  34652. * @param fileName defines the name of the downloaded file
  34653. */
  34654. static Download(blob: Blob, fileName: string): void;
  34655. /**
  34656. * Captures a screenshot of the current rendering
  34657. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34658. * @param engine defines the rendering engine
  34659. * @param camera defines the source camera
  34660. * @param size This parameter can be set to a single number or to an object with the
  34661. * following (optional) properties: precision, width, height. If a single number is passed,
  34662. * it will be used for both width and height. If an object is passed, the screenshot size
  34663. * will be derived from the parameters. The precision property is a multiplier allowing
  34664. * rendering at a higher or lower resolution
  34665. * @param successCallback defines the callback receives a single parameter which contains the
  34666. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34667. * src parameter of an <img> to display it
  34668. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34669. * Check your browser for supported MIME types
  34670. */
  34671. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34672. /**
  34673. * Captures a screenshot of the current rendering
  34674. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34675. * @param engine defines the rendering engine
  34676. * @param camera defines the source camera
  34677. * @param size This parameter can be set to a single number or to an object with the
  34678. * following (optional) properties: precision, width, height. If a single number is passed,
  34679. * it will be used for both width and height. If an object is passed, the screenshot size
  34680. * will be derived from the parameters. The precision property is a multiplier allowing
  34681. * rendering at a higher or lower resolution
  34682. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34683. * Check your browser for supported MIME types
  34684. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34685. * to the src parameter of an <img> to display it
  34686. */
  34687. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34688. /**
  34689. * Generates an image screenshot from the specified camera.
  34690. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34691. * @param engine The engine to use for rendering
  34692. * @param camera The camera to use for rendering
  34693. * @param size This parameter can be set to a single number or to an object with the
  34694. * following (optional) properties: precision, width, height. If a single number is passed,
  34695. * it will be used for both width and height. If an object is passed, the screenshot size
  34696. * will be derived from the parameters. The precision property is a multiplier allowing
  34697. * rendering at a higher or lower resolution
  34698. * @param successCallback The callback receives a single parameter which contains the
  34699. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34700. * src parameter of an <img> to display it
  34701. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34702. * Check your browser for supported MIME types
  34703. * @param samples Texture samples (default: 1)
  34704. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34705. * @param fileName A name for for the downloaded file.
  34706. */
  34707. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34708. /**
  34709. * Generates an image screenshot from the specified camera.
  34710. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34711. * @param engine The engine to use for rendering
  34712. * @param camera The camera to use for rendering
  34713. * @param size This parameter can be set to a single number or to an object with the
  34714. * following (optional) properties: precision, width, height. If a single number is passed,
  34715. * it will be used for both width and height. If an object is passed, the screenshot size
  34716. * will be derived from the parameters. The precision property is a multiplier allowing
  34717. * rendering at a higher or lower resolution
  34718. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34719. * Check your browser for supported MIME types
  34720. * @param samples Texture samples (default: 1)
  34721. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34722. * @param fileName A name for for the downloaded file.
  34723. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34724. * to the src parameter of an <img> to display it
  34725. */
  34726. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34727. /**
  34728. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34729. * Be aware Math.random() could cause collisions, but:
  34730. * "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"
  34731. * @returns a pseudo random id
  34732. */
  34733. static RandomId(): string;
  34734. /**
  34735. * Test if the given uri is a base64 string
  34736. * @param uri The uri to test
  34737. * @return True if the uri is a base64 string or false otherwise
  34738. */
  34739. static IsBase64(uri: string): boolean;
  34740. /**
  34741. * Decode the given base64 uri.
  34742. * @param uri The uri to decode
  34743. * @return The decoded base64 data.
  34744. */
  34745. static DecodeBase64(uri: string): ArrayBuffer;
  34746. /**
  34747. * Gets the absolute url.
  34748. * @param url the input url
  34749. * @return the absolute url
  34750. */
  34751. static GetAbsoluteUrl(url: string): string;
  34752. /**
  34753. * No log
  34754. */
  34755. static readonly NoneLogLevel: number;
  34756. /**
  34757. * Only message logs
  34758. */
  34759. static readonly MessageLogLevel: number;
  34760. /**
  34761. * Only warning logs
  34762. */
  34763. static readonly WarningLogLevel: number;
  34764. /**
  34765. * Only error logs
  34766. */
  34767. static readonly ErrorLogLevel: number;
  34768. /**
  34769. * All logs
  34770. */
  34771. static readonly AllLogLevel: number;
  34772. /**
  34773. * Gets a value indicating the number of loading errors
  34774. * @ignorenaming
  34775. */
  34776. static readonly errorsCount: number;
  34777. /**
  34778. * Callback called when a new log is added
  34779. */
  34780. static OnNewCacheEntry: (entry: string) => void;
  34781. /**
  34782. * Log a message to the console
  34783. * @param message defines the message to log
  34784. */
  34785. static Log(message: string): void;
  34786. /**
  34787. * Write a warning message to the console
  34788. * @param message defines the message to log
  34789. */
  34790. static Warn(message: string): void;
  34791. /**
  34792. * Write an error message to the console
  34793. * @param message defines the message to log
  34794. */
  34795. static Error(message: string): void;
  34796. /**
  34797. * Gets current log cache (list of logs)
  34798. */
  34799. static readonly LogCache: string;
  34800. /**
  34801. * Clears the log cache
  34802. */
  34803. static ClearLogCache(): void;
  34804. /**
  34805. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34806. */
  34807. static LogLevels: number;
  34808. /**
  34809. * Checks if the window object exists
  34810. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34811. */
  34812. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34813. /**
  34814. * No performance log
  34815. */
  34816. static readonly PerformanceNoneLogLevel: number;
  34817. /**
  34818. * Use user marks to log performance
  34819. */
  34820. static readonly PerformanceUserMarkLogLevel: number;
  34821. /**
  34822. * Log performance to the console
  34823. */
  34824. static readonly PerformanceConsoleLogLevel: number;
  34825. private static _performance;
  34826. /**
  34827. * Sets the current performance log level
  34828. */
  34829. static PerformanceLogLevel: number;
  34830. private static _StartPerformanceCounterDisabled;
  34831. private static _EndPerformanceCounterDisabled;
  34832. private static _StartUserMark;
  34833. private static _EndUserMark;
  34834. private static _StartPerformanceConsole;
  34835. private static _EndPerformanceConsole;
  34836. /**
  34837. * Starts a performance counter
  34838. */
  34839. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34840. /**
  34841. * Ends a specific performance coutner
  34842. */
  34843. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34844. /**
  34845. * Gets either window.performance.now() if supported or Date.now() else
  34846. */
  34847. static readonly Now: number;
  34848. /**
  34849. * This method will return the name of the class used to create the instance of the given object.
  34850. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34851. * @param object the object to get the class name from
  34852. * @param isType defines if the object is actually a type
  34853. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34854. */
  34855. static GetClassName(object: any, isType?: boolean): string;
  34856. /**
  34857. * Gets the first element of an array satisfying a given predicate
  34858. * @param array defines the array to browse
  34859. * @param predicate defines the predicate to use
  34860. * @returns null if not found or the element
  34861. */
  34862. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34863. /**
  34864. * This method will return the name of the full name of the class, including its owning module (if any).
  34865. * 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).
  34866. * @param object the object to get the class name from
  34867. * @param isType defines if the object is actually a type
  34868. * @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.
  34869. * @ignorenaming
  34870. */
  34871. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34872. /**
  34873. * Returns a promise that resolves after the given amount of time.
  34874. * @param delay Number of milliseconds to delay
  34875. * @returns Promise that resolves after the given amount of time
  34876. */
  34877. static DelayAsync(delay: number): Promise<void>;
  34878. }
  34879. /**
  34880. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34881. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34882. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34883. * @param name The name of the class, case should be preserved
  34884. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34885. */
  34886. export function className(name: string, module?: string): (target: Object) => void;
  34887. /**
  34888. * An implementation of a loop for asynchronous functions.
  34889. */
  34890. export class AsyncLoop {
  34891. /**
  34892. * Defines the number of iterations for the loop
  34893. */
  34894. iterations: number;
  34895. /**
  34896. * Defines the current index of the loop.
  34897. */
  34898. index: number;
  34899. private _done;
  34900. private _fn;
  34901. private _successCallback;
  34902. /**
  34903. * Constructor.
  34904. * @param iterations the number of iterations.
  34905. * @param func the function to run each iteration
  34906. * @param successCallback the callback that will be called upon succesful execution
  34907. * @param offset starting offset.
  34908. */
  34909. constructor(
  34910. /**
  34911. * Defines the number of iterations for the loop
  34912. */
  34913. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  34914. /**
  34915. * Execute the next iteration. Must be called after the last iteration was finished.
  34916. */
  34917. executeNext(): void;
  34918. /**
  34919. * Break the loop and run the success callback.
  34920. */
  34921. breakLoop(): void;
  34922. /**
  34923. * Create and run an async loop.
  34924. * @param iterations the number of iterations.
  34925. * @param fn the function to run each iteration
  34926. * @param successCallback the callback that will be called upon succesful execution
  34927. * @param offset starting offset.
  34928. * @returns the created async loop object
  34929. */
  34930. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  34931. /**
  34932. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34933. * @param iterations total number of iterations
  34934. * @param syncedIterations number of synchronous iterations in each async iteration.
  34935. * @param fn the function to call each iteration.
  34936. * @param callback a success call back that will be called when iterating stops.
  34937. * @param breakFunction a break condition (optional)
  34938. * @param timeout timeout settings for the setTimeout function. default - 0.
  34939. * @returns the created async loop object
  34940. */
  34941. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34942. }
  34943. }
  34944. declare module "babylonjs/Misc/stringDictionary" {
  34945. import { Nullable } from "babylonjs/types";
  34946. /**
  34947. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34948. * The underlying implementation relies on an associative array to ensure the best performances.
  34949. * The value can be anything including 'null' but except 'undefined'
  34950. */
  34951. export class StringDictionary<T> {
  34952. /**
  34953. * This will clear this dictionary and copy the content from the 'source' one.
  34954. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34955. * @param source the dictionary to take the content from and copy to this dictionary
  34956. */
  34957. copyFrom(source: StringDictionary<T>): void;
  34958. /**
  34959. * Get a value based from its key
  34960. * @param key the given key to get the matching value from
  34961. * @return the value if found, otherwise undefined is returned
  34962. */
  34963. get(key: string): T | undefined;
  34964. /**
  34965. * Get a value from its key or add it if it doesn't exist.
  34966. * This method will ensure you that a given key/data will be present in the dictionary.
  34967. * @param key the given key to get the matching value from
  34968. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34969. * The factory will only be invoked if there's no data for the given key.
  34970. * @return the value corresponding to the key.
  34971. */
  34972. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34973. /**
  34974. * Get a value from its key if present in the dictionary otherwise add it
  34975. * @param key the key to get the value from
  34976. * @param val if there's no such key/value pair in the dictionary add it with this value
  34977. * @return the value corresponding to the key
  34978. */
  34979. getOrAdd(key: string, val: T): T;
  34980. /**
  34981. * Check if there's a given key in the dictionary
  34982. * @param key the key to check for
  34983. * @return true if the key is present, false otherwise
  34984. */
  34985. contains(key: string): boolean;
  34986. /**
  34987. * Add a new key and its corresponding value
  34988. * @param key the key to add
  34989. * @param value the value corresponding to the key
  34990. * @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
  34991. */
  34992. add(key: string, value: T): boolean;
  34993. /**
  34994. * Update a specific value associated to a key
  34995. * @param key defines the key to use
  34996. * @param value defines the value to store
  34997. * @returns true if the value was updated (or false if the key was not found)
  34998. */
  34999. set(key: string, value: T): boolean;
  35000. /**
  35001. * Get the element of the given key and remove it from the dictionary
  35002. * @param key defines the key to search
  35003. * @returns the value associated with the key or null if not found
  35004. */
  35005. getAndRemove(key: string): Nullable<T>;
  35006. /**
  35007. * Remove a key/value from the dictionary.
  35008. * @param key the key to remove
  35009. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35010. */
  35011. remove(key: string): boolean;
  35012. /**
  35013. * Clear the whole content of the dictionary
  35014. */
  35015. clear(): void;
  35016. /**
  35017. * Gets the current count
  35018. */
  35019. readonly count: number;
  35020. /**
  35021. * Execute a callback on each key/val of the dictionary.
  35022. * Note that you can remove any element in this dictionary in the callback implementation
  35023. * @param callback the callback to execute on a given key/value pair
  35024. */
  35025. forEach(callback: (key: string, val: T) => void): void;
  35026. /**
  35027. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35028. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35029. * Note that you can remove any element in this dictionary in the callback implementation
  35030. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35031. * @returns the first item
  35032. */
  35033. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35034. private _count;
  35035. private _data;
  35036. }
  35037. }
  35038. declare module "babylonjs/Collisions/collisionCoordinator" {
  35039. import { Nullable } from "babylonjs/types";
  35040. import { Scene } from "babylonjs/scene";
  35041. import { Vector3 } from "babylonjs/Maths/math.vector";
  35042. import { Collider } from "babylonjs/Collisions/collider";
  35043. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35044. /** @hidden */
  35045. export interface ICollisionCoordinator {
  35046. createCollider(): Collider;
  35047. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35048. init(scene: Scene): void;
  35049. }
  35050. /** @hidden */
  35051. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35052. private _scene;
  35053. private _scaledPosition;
  35054. private _scaledVelocity;
  35055. private _finalPosition;
  35056. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35057. createCollider(): Collider;
  35058. init(scene: Scene): void;
  35059. private _collideWithWorld;
  35060. }
  35061. }
  35062. declare module "babylonjs/Inputs/scene.inputManager" {
  35063. import { Nullable } from "babylonjs/types";
  35064. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35065. import { Vector2 } from "babylonjs/Maths/math.vector";
  35066. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35067. import { Scene } from "babylonjs/scene";
  35068. /**
  35069. * Class used to manage all inputs for the scene.
  35070. */
  35071. export class InputManager {
  35072. /** The distance in pixel that you have to move to prevent some events */
  35073. static DragMovementThreshold: number;
  35074. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35075. static LongPressDelay: number;
  35076. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35077. static DoubleClickDelay: number;
  35078. /** If you need to check double click without raising a single click at first click, enable this flag */
  35079. static ExclusiveDoubleClickMode: boolean;
  35080. private _wheelEventName;
  35081. private _onPointerMove;
  35082. private _onPointerDown;
  35083. private _onPointerUp;
  35084. private _initClickEvent;
  35085. private _initActionManager;
  35086. private _delayedSimpleClick;
  35087. private _delayedSimpleClickTimeout;
  35088. private _previousDelayedSimpleClickTimeout;
  35089. private _meshPickProceed;
  35090. private _previousButtonPressed;
  35091. private _currentPickResult;
  35092. private _previousPickResult;
  35093. private _totalPointersPressed;
  35094. private _doubleClickOccured;
  35095. private _pointerOverMesh;
  35096. private _pickedDownMesh;
  35097. private _pickedUpMesh;
  35098. private _pointerX;
  35099. private _pointerY;
  35100. private _unTranslatedPointerX;
  35101. private _unTranslatedPointerY;
  35102. private _startingPointerPosition;
  35103. private _previousStartingPointerPosition;
  35104. private _startingPointerTime;
  35105. private _previousStartingPointerTime;
  35106. private _pointerCaptures;
  35107. private _onKeyDown;
  35108. private _onKeyUp;
  35109. private _onCanvasFocusObserver;
  35110. private _onCanvasBlurObserver;
  35111. private _scene;
  35112. /**
  35113. * Creates a new InputManager
  35114. * @param scene defines the hosting scene
  35115. */
  35116. constructor(scene: Scene);
  35117. /**
  35118. * Gets the mesh that is currently under the pointer
  35119. */
  35120. readonly meshUnderPointer: Nullable<AbstractMesh>;
  35121. /**
  35122. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35123. */
  35124. readonly unTranslatedPointer: Vector2;
  35125. /**
  35126. * Gets or sets the current on-screen X position of the pointer
  35127. */
  35128. pointerX: number;
  35129. /**
  35130. * Gets or sets the current on-screen Y position of the pointer
  35131. */
  35132. pointerY: number;
  35133. private _updatePointerPosition;
  35134. private _processPointerMove;
  35135. private _setRayOnPointerInfo;
  35136. private _checkPrePointerObservable;
  35137. /**
  35138. * Use this method to simulate a pointer move on a mesh
  35139. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35140. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35141. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35142. */
  35143. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35144. /**
  35145. * Use this method to simulate a pointer down on a mesh
  35146. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35147. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35148. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35149. */
  35150. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35151. private _processPointerDown;
  35152. /** @hidden */
  35153. _isPointerSwiping(): boolean;
  35154. /**
  35155. * Use this method to simulate a pointer up on a mesh
  35156. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35157. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35158. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35159. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35160. */
  35161. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35162. private _processPointerUp;
  35163. /**
  35164. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35165. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35166. * @returns true if the pointer was captured
  35167. */
  35168. isPointerCaptured(pointerId?: number): boolean;
  35169. /**
  35170. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35171. * @param attachUp defines if you want to attach events to pointerup
  35172. * @param attachDown defines if you want to attach events to pointerdown
  35173. * @param attachMove defines if you want to attach events to pointermove
  35174. */
  35175. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35176. /**
  35177. * Detaches all event handlers
  35178. */
  35179. detachControl(): void;
  35180. /**
  35181. * Force the value of meshUnderPointer
  35182. * @param mesh defines the mesh to use
  35183. */
  35184. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35185. /**
  35186. * Gets the mesh under the pointer
  35187. * @returns a Mesh or null if no mesh is under the pointer
  35188. */
  35189. getPointerOverMesh(): Nullable<AbstractMesh>;
  35190. }
  35191. }
  35192. declare module "babylonjs/Misc/uniqueIdGenerator" {
  35193. /**
  35194. * Helper class used to generate session unique ID
  35195. */
  35196. export class UniqueIdGenerator {
  35197. private static _UniqueIdCounter;
  35198. /**
  35199. * Gets an unique (relatively to the current scene) Id
  35200. */
  35201. static readonly UniqueId: number;
  35202. }
  35203. }
  35204. declare module "babylonjs/Animations/animationGroup" {
  35205. import { Animatable } from "babylonjs/Animations/animatable";
  35206. import { Animation } from "babylonjs/Animations/animation";
  35207. import { Scene, IDisposable } from "babylonjs/scene";
  35208. import { Observable } from "babylonjs/Misc/observable";
  35209. import { Nullable } from "babylonjs/types";
  35210. import "babylonjs/Animations/animatable";
  35211. /**
  35212. * This class defines the direct association between an animation and a target
  35213. */
  35214. export class TargetedAnimation {
  35215. /**
  35216. * Animation to perform
  35217. */
  35218. animation: Animation;
  35219. /**
  35220. * Target to animate
  35221. */
  35222. target: any;
  35223. /**
  35224. * Serialize the object
  35225. * @returns the JSON object representing the current entity
  35226. */
  35227. serialize(): any;
  35228. }
  35229. /**
  35230. * Use this class to create coordinated animations on multiple targets
  35231. */
  35232. export class AnimationGroup implements IDisposable {
  35233. /** The name of the animation group */
  35234. name: string;
  35235. private _scene;
  35236. private _targetedAnimations;
  35237. private _animatables;
  35238. private _from;
  35239. private _to;
  35240. private _isStarted;
  35241. private _isPaused;
  35242. private _speedRatio;
  35243. private _loopAnimation;
  35244. /**
  35245. * Gets or sets the unique id of the node
  35246. */
  35247. uniqueId: number;
  35248. /**
  35249. * This observable will notify when one animation have ended
  35250. */
  35251. onAnimationEndObservable: Observable<TargetedAnimation>;
  35252. /**
  35253. * Observer raised when one animation loops
  35254. */
  35255. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35256. /**
  35257. * Observer raised when all animations have looped
  35258. */
  35259. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35260. /**
  35261. * This observable will notify when all animations have ended.
  35262. */
  35263. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35264. /**
  35265. * This observable will notify when all animations have paused.
  35266. */
  35267. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35268. /**
  35269. * This observable will notify when all animations are playing.
  35270. */
  35271. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35272. /**
  35273. * Gets the first frame
  35274. */
  35275. readonly from: number;
  35276. /**
  35277. * Gets the last frame
  35278. */
  35279. readonly to: number;
  35280. /**
  35281. * Define if the animations are started
  35282. */
  35283. readonly isStarted: boolean;
  35284. /**
  35285. * Gets a value indicating that the current group is playing
  35286. */
  35287. readonly isPlaying: boolean;
  35288. /**
  35289. * Gets or sets the speed ratio to use for all animations
  35290. */
  35291. /**
  35292. * Gets or sets the speed ratio to use for all animations
  35293. */
  35294. speedRatio: number;
  35295. /**
  35296. * Gets or sets if all animations should loop or not
  35297. */
  35298. loopAnimation: boolean;
  35299. /**
  35300. * Gets the targeted animations for this animation group
  35301. */
  35302. readonly targetedAnimations: Array<TargetedAnimation>;
  35303. /**
  35304. * returning the list of animatables controlled by this animation group.
  35305. */
  35306. readonly animatables: Array<Animatable>;
  35307. /**
  35308. * Instantiates a new Animation Group.
  35309. * This helps managing several animations at once.
  35310. * @see http://doc.babylonjs.com/how_to/group
  35311. * @param name Defines the name of the group
  35312. * @param scene Defines the scene the group belongs to
  35313. */
  35314. constructor(
  35315. /** The name of the animation group */
  35316. name: string, scene?: Nullable<Scene>);
  35317. /**
  35318. * Add an animation (with its target) in the group
  35319. * @param animation defines the animation we want to add
  35320. * @param target defines the target of the animation
  35321. * @returns the TargetedAnimation object
  35322. */
  35323. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35324. /**
  35325. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35326. * It can add constant keys at begin or end
  35327. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35328. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35329. * @returns the animation group
  35330. */
  35331. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35332. private _animationLoopCount;
  35333. private _animationLoopFlags;
  35334. private _processLoop;
  35335. /**
  35336. * Start all animations on given targets
  35337. * @param loop defines if animations must loop
  35338. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35339. * @param from defines the from key (optional)
  35340. * @param to defines the to key (optional)
  35341. * @returns the current animation group
  35342. */
  35343. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  35344. /**
  35345. * Pause all animations
  35346. * @returns the animation group
  35347. */
  35348. pause(): AnimationGroup;
  35349. /**
  35350. * Play all animations to initial state
  35351. * This function will start() the animations if they were not started or will restart() them if they were paused
  35352. * @param loop defines if animations must loop
  35353. * @returns the animation group
  35354. */
  35355. play(loop?: boolean): AnimationGroup;
  35356. /**
  35357. * Reset all animations to initial state
  35358. * @returns the animation group
  35359. */
  35360. reset(): AnimationGroup;
  35361. /**
  35362. * Restart animations from key 0
  35363. * @returns the animation group
  35364. */
  35365. restart(): AnimationGroup;
  35366. /**
  35367. * Stop all animations
  35368. * @returns the animation group
  35369. */
  35370. stop(): AnimationGroup;
  35371. /**
  35372. * Set animation weight for all animatables
  35373. * @param weight defines the weight to use
  35374. * @return the animationGroup
  35375. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35376. */
  35377. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35378. /**
  35379. * Synchronize and normalize all animatables with a source animatable
  35380. * @param root defines the root animatable to synchronize with
  35381. * @return the animationGroup
  35382. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35383. */
  35384. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35385. /**
  35386. * Goes to a specific frame in this animation group
  35387. * @param frame the frame number to go to
  35388. * @return the animationGroup
  35389. */
  35390. goToFrame(frame: number): AnimationGroup;
  35391. /**
  35392. * Dispose all associated resources
  35393. */
  35394. dispose(): void;
  35395. private _checkAnimationGroupEnded;
  35396. /**
  35397. * Clone the current animation group and returns a copy
  35398. * @param newName defines the name of the new group
  35399. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35400. * @returns the new aniamtion group
  35401. */
  35402. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35403. /**
  35404. * Serializes the animationGroup to an object
  35405. * @returns Serialized object
  35406. */
  35407. serialize(): any;
  35408. /**
  35409. * Returns a new AnimationGroup object parsed from the source provided.
  35410. * @param parsedAnimationGroup defines the source
  35411. * @param scene defines the scene that will receive the animationGroup
  35412. * @returns a new AnimationGroup
  35413. */
  35414. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35415. /**
  35416. * Returns the string "AnimationGroup"
  35417. * @returns "AnimationGroup"
  35418. */
  35419. getClassName(): string;
  35420. /**
  35421. * Creates a detailled string about the object
  35422. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35423. * @returns a string representing the object
  35424. */
  35425. toString(fullDetails?: boolean): string;
  35426. }
  35427. }
  35428. declare module "babylonjs/scene" {
  35429. import { Nullable } from "babylonjs/types";
  35430. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35431. import { Observable } from "babylonjs/Misc/observable";
  35432. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  35433. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  35434. import { Geometry } from "babylonjs/Meshes/geometry";
  35435. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35436. import { SubMesh } from "babylonjs/Meshes/subMesh";
  35437. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35438. import { Mesh } from "babylonjs/Meshes/mesh";
  35439. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35440. import { Bone } from "babylonjs/Bones/bone";
  35441. import { Skeleton } from "babylonjs/Bones/skeleton";
  35442. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35443. import { Camera } from "babylonjs/Cameras/camera";
  35444. import { AbstractScene } from "babylonjs/abstractScene";
  35445. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35446. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35447. import { Material } from "babylonjs/Materials/material";
  35448. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  35449. import { Effect } from "babylonjs/Materials/effect";
  35450. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  35451. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35452. import { Light } from "babylonjs/Lights/light";
  35453. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35454. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  35455. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  35456. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  35457. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35458. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  35459. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35460. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  35461. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  35462. import { Engine } from "babylonjs/Engines/engine";
  35463. import { Node } from "babylonjs/node";
  35464. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  35465. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35466. import { WebRequest } from "babylonjs/Misc/webRequest";
  35467. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  35468. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  35469. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35470. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  35471. import { Plane } from "babylonjs/Maths/math.plane";
  35472. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  35473. import { Ray } from "babylonjs/Culling/ray";
  35474. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  35475. import { Animation } from "babylonjs/Animations/animation";
  35476. import { Animatable } from "babylonjs/Animations/animatable";
  35477. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35478. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  35479. import { Collider } from "babylonjs/Collisions/collider";
  35480. /**
  35481. * Define an interface for all classes that will hold resources
  35482. */
  35483. export interface IDisposable {
  35484. /**
  35485. * Releases all held resources
  35486. */
  35487. dispose(): void;
  35488. }
  35489. /** Interface defining initialization parameters for Scene class */
  35490. export interface SceneOptions {
  35491. /**
  35492. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35493. * It will improve performance when the number of geometries becomes important.
  35494. */
  35495. useGeometryUniqueIdsMap?: boolean;
  35496. /**
  35497. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35498. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35499. */
  35500. useMaterialMeshMap?: boolean;
  35501. /**
  35502. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35503. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35504. */
  35505. useClonedMeshhMap?: boolean;
  35506. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35507. virtual?: boolean;
  35508. }
  35509. /**
  35510. * Represents a scene to be rendered by the engine.
  35511. * @see http://doc.babylonjs.com/features/scene
  35512. */
  35513. export class Scene extends AbstractScene implements IAnimatable {
  35514. /** The fog is deactivated */
  35515. static readonly FOGMODE_NONE: number;
  35516. /** The fog density is following an exponential function */
  35517. static readonly FOGMODE_EXP: number;
  35518. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35519. static readonly FOGMODE_EXP2: number;
  35520. /** The fog density is following a linear function. */
  35521. static readonly FOGMODE_LINEAR: number;
  35522. /**
  35523. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35524. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35525. */
  35526. static MinDeltaTime: number;
  35527. /**
  35528. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35529. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35530. */
  35531. static MaxDeltaTime: number;
  35532. /**
  35533. * Factory used to create the default material.
  35534. * @param name The name of the material to create
  35535. * @param scene The scene to create the material for
  35536. * @returns The default material
  35537. */
  35538. static DefaultMaterialFactory(scene: Scene): Material;
  35539. /**
  35540. * Factory used to create the a collision coordinator.
  35541. * @returns The collision coordinator
  35542. */
  35543. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35544. /** @hidden */
  35545. _inputManager: InputManager;
  35546. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35547. cameraToUseForPointers: Nullable<Camera>;
  35548. /** @hidden */
  35549. readonly _isScene: boolean;
  35550. /**
  35551. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35552. */
  35553. autoClear: boolean;
  35554. /**
  35555. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35556. */
  35557. autoClearDepthAndStencil: boolean;
  35558. /**
  35559. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35560. */
  35561. clearColor: Color4;
  35562. /**
  35563. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35564. */
  35565. ambientColor: Color3;
  35566. /**
  35567. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35568. * It should only be one of the following (if not the default embedded one):
  35569. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35570. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35571. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35572. * The material properties need to be setup according to the type of texture in use.
  35573. */
  35574. environmentBRDFTexture: BaseTexture;
  35575. /** @hidden */
  35576. protected _environmentTexture: Nullable<BaseTexture>;
  35577. /**
  35578. * Texture used in all pbr material as the reflection texture.
  35579. * As in the majority of the scene they are the same (exception for multi room and so on),
  35580. * this is easier to reference from here than from all the materials.
  35581. */
  35582. /**
  35583. * Texture used in all pbr material as the reflection texture.
  35584. * As in the majority of the scene they are the same (exception for multi room and so on),
  35585. * this is easier to set here than in all the materials.
  35586. */
  35587. environmentTexture: Nullable<BaseTexture>;
  35588. /** @hidden */
  35589. protected _environmentIntensity: number;
  35590. /**
  35591. * Intensity of the environment in all pbr material.
  35592. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35593. * As in the majority of the scene they are the same (exception for multi room and so on),
  35594. * this is easier to reference from here than from all the materials.
  35595. */
  35596. /**
  35597. * Intensity of the environment in all pbr material.
  35598. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35599. * As in the majority of the scene they are the same (exception for multi room and so on),
  35600. * this is easier to set here than in all the materials.
  35601. */
  35602. environmentIntensity: number;
  35603. /** @hidden */
  35604. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35605. /**
  35606. * Default image processing configuration used either in the rendering
  35607. * Forward main pass or through the imageProcessingPostProcess if present.
  35608. * As in the majority of the scene they are the same (exception for multi camera),
  35609. * this is easier to reference from here than from all the materials and post process.
  35610. *
  35611. * No setter as we it is a shared configuration, you can set the values instead.
  35612. */
  35613. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  35614. private _forceWireframe;
  35615. /**
  35616. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35617. */
  35618. forceWireframe: boolean;
  35619. private _forcePointsCloud;
  35620. /**
  35621. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35622. */
  35623. forcePointsCloud: boolean;
  35624. /**
  35625. * Gets or sets the active clipplane 1
  35626. */
  35627. clipPlane: Nullable<Plane>;
  35628. /**
  35629. * Gets or sets the active clipplane 2
  35630. */
  35631. clipPlane2: Nullable<Plane>;
  35632. /**
  35633. * Gets or sets the active clipplane 3
  35634. */
  35635. clipPlane3: Nullable<Plane>;
  35636. /**
  35637. * Gets or sets the active clipplane 4
  35638. */
  35639. clipPlane4: Nullable<Plane>;
  35640. /**
  35641. * Gets or sets a boolean indicating if animations are enabled
  35642. */
  35643. animationsEnabled: boolean;
  35644. private _animationPropertiesOverride;
  35645. /**
  35646. * Gets or sets the animation properties override
  35647. */
  35648. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  35649. /**
  35650. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35651. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35652. */
  35653. useConstantAnimationDeltaTime: boolean;
  35654. /**
  35655. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35656. * Please note that it requires to run a ray cast through the scene on every frame
  35657. */
  35658. constantlyUpdateMeshUnderPointer: boolean;
  35659. /**
  35660. * Defines the HTML cursor to use when hovering over interactive elements
  35661. */
  35662. hoverCursor: string;
  35663. /**
  35664. * Defines the HTML default cursor to use (empty by default)
  35665. */
  35666. defaultCursor: string;
  35667. /**
  35668. * Defines wether cursors are handled by the scene.
  35669. */
  35670. doNotHandleCursors: boolean;
  35671. /**
  35672. * This is used to call preventDefault() on pointer down
  35673. * in order to block unwanted artifacts like system double clicks
  35674. */
  35675. preventDefaultOnPointerDown: boolean;
  35676. /**
  35677. * This is used to call preventDefault() on pointer up
  35678. * in order to block unwanted artifacts like system double clicks
  35679. */
  35680. preventDefaultOnPointerUp: boolean;
  35681. /**
  35682. * Gets or sets user defined metadata
  35683. */
  35684. metadata: any;
  35685. /**
  35686. * For internal use only. Please do not use.
  35687. */
  35688. reservedDataStore: any;
  35689. /**
  35690. * Gets the name of the plugin used to load this scene (null by default)
  35691. */
  35692. loadingPluginName: string;
  35693. /**
  35694. * Use this array to add regular expressions used to disable offline support for specific urls
  35695. */
  35696. disableOfflineSupportExceptionRules: RegExp[];
  35697. /**
  35698. * An event triggered when the scene is disposed.
  35699. */
  35700. onDisposeObservable: Observable<Scene>;
  35701. private _onDisposeObserver;
  35702. /** Sets a function to be executed when this scene is disposed. */
  35703. onDispose: () => void;
  35704. /**
  35705. * An event triggered before rendering the scene (right after animations and physics)
  35706. */
  35707. onBeforeRenderObservable: Observable<Scene>;
  35708. private _onBeforeRenderObserver;
  35709. /** Sets a function to be executed before rendering this scene */
  35710. beforeRender: Nullable<() => void>;
  35711. /**
  35712. * An event triggered after rendering the scene
  35713. */
  35714. onAfterRenderObservable: Observable<Scene>;
  35715. /**
  35716. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35717. */
  35718. onAfterRenderCameraObservable: Observable<Camera>;
  35719. private _onAfterRenderObserver;
  35720. /** Sets a function to be executed after rendering this scene */
  35721. afterRender: Nullable<() => void>;
  35722. /**
  35723. * An event triggered before animating the scene
  35724. */
  35725. onBeforeAnimationsObservable: Observable<Scene>;
  35726. /**
  35727. * An event triggered after animations processing
  35728. */
  35729. onAfterAnimationsObservable: Observable<Scene>;
  35730. /**
  35731. * An event triggered before draw calls are ready to be sent
  35732. */
  35733. onBeforeDrawPhaseObservable: Observable<Scene>;
  35734. /**
  35735. * An event triggered after draw calls have been sent
  35736. */
  35737. onAfterDrawPhaseObservable: Observable<Scene>;
  35738. /**
  35739. * An event triggered when the scene is ready
  35740. */
  35741. onReadyObservable: Observable<Scene>;
  35742. /**
  35743. * An event triggered before rendering a camera
  35744. */
  35745. onBeforeCameraRenderObservable: Observable<Camera>;
  35746. private _onBeforeCameraRenderObserver;
  35747. /** Sets a function to be executed before rendering a camera*/
  35748. beforeCameraRender: () => void;
  35749. /**
  35750. * An event triggered after rendering a camera
  35751. */
  35752. onAfterCameraRenderObservable: Observable<Camera>;
  35753. private _onAfterCameraRenderObserver;
  35754. /** Sets a function to be executed after rendering a camera*/
  35755. afterCameraRender: () => void;
  35756. /**
  35757. * An event triggered when active meshes evaluation is about to start
  35758. */
  35759. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35760. /**
  35761. * An event triggered when active meshes evaluation is done
  35762. */
  35763. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35764. /**
  35765. * An event triggered when particles rendering is about to start
  35766. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35767. */
  35768. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35769. /**
  35770. * An event triggered when particles rendering is done
  35771. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35772. */
  35773. onAfterParticlesRenderingObservable: Observable<Scene>;
  35774. /**
  35775. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35776. */
  35777. onDataLoadedObservable: Observable<Scene>;
  35778. /**
  35779. * An event triggered when a camera is created
  35780. */
  35781. onNewCameraAddedObservable: Observable<Camera>;
  35782. /**
  35783. * An event triggered when a camera is removed
  35784. */
  35785. onCameraRemovedObservable: Observable<Camera>;
  35786. /**
  35787. * An event triggered when a light is created
  35788. */
  35789. onNewLightAddedObservable: Observable<Light>;
  35790. /**
  35791. * An event triggered when a light is removed
  35792. */
  35793. onLightRemovedObservable: Observable<Light>;
  35794. /**
  35795. * An event triggered when a geometry is created
  35796. */
  35797. onNewGeometryAddedObservable: Observable<Geometry>;
  35798. /**
  35799. * An event triggered when a geometry is removed
  35800. */
  35801. onGeometryRemovedObservable: Observable<Geometry>;
  35802. /**
  35803. * An event triggered when a transform node is created
  35804. */
  35805. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35806. /**
  35807. * An event triggered when a transform node is removed
  35808. */
  35809. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35810. /**
  35811. * An event triggered when a mesh is created
  35812. */
  35813. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35814. /**
  35815. * An event triggered when a mesh is removed
  35816. */
  35817. onMeshRemovedObservable: Observable<AbstractMesh>;
  35818. /**
  35819. * An event triggered when a skeleton is created
  35820. */
  35821. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35822. /**
  35823. * An event triggered when a skeleton is removed
  35824. */
  35825. onSkeletonRemovedObservable: Observable<Skeleton>;
  35826. /**
  35827. * An event triggered when a material is created
  35828. */
  35829. onNewMaterialAddedObservable: Observable<Material>;
  35830. /**
  35831. * An event triggered when a material is removed
  35832. */
  35833. onMaterialRemovedObservable: Observable<Material>;
  35834. /**
  35835. * An event triggered when a texture is created
  35836. */
  35837. onNewTextureAddedObservable: Observable<BaseTexture>;
  35838. /**
  35839. * An event triggered when a texture is removed
  35840. */
  35841. onTextureRemovedObservable: Observable<BaseTexture>;
  35842. /**
  35843. * An event triggered when render targets are about to be rendered
  35844. * Can happen multiple times per frame.
  35845. */
  35846. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35847. /**
  35848. * An event triggered when render targets were rendered.
  35849. * Can happen multiple times per frame.
  35850. */
  35851. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35852. /**
  35853. * An event triggered before calculating deterministic simulation step
  35854. */
  35855. onBeforeStepObservable: Observable<Scene>;
  35856. /**
  35857. * An event triggered after calculating deterministic simulation step
  35858. */
  35859. onAfterStepObservable: Observable<Scene>;
  35860. /**
  35861. * An event triggered when the activeCamera property is updated
  35862. */
  35863. onActiveCameraChanged: Observable<Scene>;
  35864. /**
  35865. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35866. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35867. * 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)
  35868. */
  35869. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35870. /**
  35871. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35872. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35873. * 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)
  35874. */
  35875. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35876. /**
  35877. * This Observable will when a mesh has been imported into the scene.
  35878. */
  35879. onMeshImportedObservable: Observable<AbstractMesh>;
  35880. /**
  35881. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35882. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35883. */
  35884. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35885. /** @hidden */
  35886. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35887. /**
  35888. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35889. */
  35890. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35891. /**
  35892. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35893. */
  35894. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35895. /**
  35896. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35897. */
  35898. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35899. /** Callback called when a pointer move is detected */
  35900. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35901. /** Callback called when a pointer down is detected */
  35902. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35903. /** Callback called when a pointer up is detected */
  35904. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35905. /** Callback called when a pointer pick is detected */
  35906. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35907. /**
  35908. * 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).
  35909. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35910. */
  35911. onPrePointerObservable: Observable<PointerInfoPre>;
  35912. /**
  35913. * Observable event triggered each time an input event is received from the rendering canvas
  35914. */
  35915. onPointerObservable: Observable<PointerInfo>;
  35916. /**
  35917. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35918. */
  35919. readonly unTranslatedPointer: Vector2;
  35920. /**
  35921. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35922. */
  35923. static DragMovementThreshold: number;
  35924. /**
  35925. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35926. */
  35927. static LongPressDelay: number;
  35928. /**
  35929. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  35930. */
  35931. static DoubleClickDelay: number;
  35932. /** If you need to check double click without raising a single click at first click, enable this flag */
  35933. static ExclusiveDoubleClickMode: boolean;
  35934. /** @hidden */
  35935. _mirroredCameraPosition: Nullable<Vector3>;
  35936. /**
  35937. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  35938. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  35939. */
  35940. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  35941. /**
  35942. * Observable event triggered each time an keyboard event is received from the hosting window
  35943. */
  35944. onKeyboardObservable: Observable<KeyboardInfo>;
  35945. private _useRightHandedSystem;
  35946. /**
  35947. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  35948. */
  35949. useRightHandedSystem: boolean;
  35950. private _timeAccumulator;
  35951. private _currentStepId;
  35952. private _currentInternalStep;
  35953. /**
  35954. * Sets the step Id used by deterministic lock step
  35955. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35956. * @param newStepId defines the step Id
  35957. */
  35958. setStepId(newStepId: number): void;
  35959. /**
  35960. * Gets the step Id used by deterministic lock step
  35961. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35962. * @returns the step Id
  35963. */
  35964. getStepId(): number;
  35965. /**
  35966. * Gets the internal step used by deterministic lock step
  35967. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35968. * @returns the internal step
  35969. */
  35970. getInternalStep(): number;
  35971. private _fogEnabled;
  35972. /**
  35973. * Gets or sets a boolean indicating if fog is enabled on this scene
  35974. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35975. * (Default is true)
  35976. */
  35977. fogEnabled: boolean;
  35978. private _fogMode;
  35979. /**
  35980. * Gets or sets the fog mode to use
  35981. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35982. * | mode | value |
  35983. * | --- | --- |
  35984. * | FOGMODE_NONE | 0 |
  35985. * | FOGMODE_EXP | 1 |
  35986. * | FOGMODE_EXP2 | 2 |
  35987. * | FOGMODE_LINEAR | 3 |
  35988. */
  35989. fogMode: number;
  35990. /**
  35991. * Gets or sets the fog color to use
  35992. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35993. * (Default is Color3(0.2, 0.2, 0.3))
  35994. */
  35995. fogColor: Color3;
  35996. /**
  35997. * Gets or sets the fog density to use
  35998. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35999. * (Default is 0.1)
  36000. */
  36001. fogDensity: number;
  36002. /**
  36003. * Gets or sets the fog start distance to use
  36004. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36005. * (Default is 0)
  36006. */
  36007. fogStart: number;
  36008. /**
  36009. * Gets or sets the fog end distance to use
  36010. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36011. * (Default is 1000)
  36012. */
  36013. fogEnd: number;
  36014. private _shadowsEnabled;
  36015. /**
  36016. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36017. */
  36018. shadowsEnabled: boolean;
  36019. private _lightsEnabled;
  36020. /**
  36021. * Gets or sets a boolean indicating if lights are enabled on this scene
  36022. */
  36023. lightsEnabled: boolean;
  36024. /** All of the active cameras added to this scene. */
  36025. activeCameras: Camera[];
  36026. /** @hidden */
  36027. _activeCamera: Nullable<Camera>;
  36028. /** Gets or sets the current active camera */
  36029. activeCamera: Nullable<Camera>;
  36030. private _defaultMaterial;
  36031. /** The default material used on meshes when no material is affected */
  36032. /** The default material used on meshes when no material is affected */
  36033. defaultMaterial: Material;
  36034. private _texturesEnabled;
  36035. /**
  36036. * Gets or sets a boolean indicating if textures are enabled on this scene
  36037. */
  36038. texturesEnabled: boolean;
  36039. /**
  36040. * Gets or sets a boolean indicating if particles are enabled on this scene
  36041. */
  36042. particlesEnabled: boolean;
  36043. /**
  36044. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36045. */
  36046. spritesEnabled: boolean;
  36047. private _skeletonsEnabled;
  36048. /**
  36049. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36050. */
  36051. skeletonsEnabled: boolean;
  36052. /**
  36053. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36054. */
  36055. lensFlaresEnabled: boolean;
  36056. /**
  36057. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36058. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36059. */
  36060. collisionsEnabled: boolean;
  36061. private _collisionCoordinator;
  36062. /** @hidden */
  36063. readonly collisionCoordinator: ICollisionCoordinator;
  36064. /**
  36065. * Defines the gravity applied to this scene (used only for collisions)
  36066. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36067. */
  36068. gravity: Vector3;
  36069. /**
  36070. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36071. */
  36072. postProcessesEnabled: boolean;
  36073. /**
  36074. * The list of postprocesses added to the scene
  36075. */
  36076. postProcesses: PostProcess[];
  36077. /**
  36078. * Gets the current postprocess manager
  36079. */
  36080. postProcessManager: PostProcessManager;
  36081. /**
  36082. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36083. */
  36084. renderTargetsEnabled: boolean;
  36085. /**
  36086. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36087. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36088. */
  36089. dumpNextRenderTargets: boolean;
  36090. /**
  36091. * The list of user defined render targets added to the scene
  36092. */
  36093. customRenderTargets: RenderTargetTexture[];
  36094. /**
  36095. * Defines if texture loading must be delayed
  36096. * If true, textures will only be loaded when they need to be rendered
  36097. */
  36098. useDelayedTextureLoading: boolean;
  36099. /**
  36100. * Gets the list of meshes imported to the scene through SceneLoader
  36101. */
  36102. importedMeshesFiles: String[];
  36103. /**
  36104. * Gets or sets a boolean indicating if probes are enabled on this scene
  36105. */
  36106. probesEnabled: boolean;
  36107. /**
  36108. * Gets or sets the current offline provider to use to store scene data
  36109. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36110. */
  36111. offlineProvider: IOfflineProvider;
  36112. /**
  36113. * Gets or sets the action manager associated with the scene
  36114. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36115. */
  36116. actionManager: AbstractActionManager;
  36117. private _meshesForIntersections;
  36118. /**
  36119. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36120. */
  36121. proceduralTexturesEnabled: boolean;
  36122. private _engine;
  36123. private _totalVertices;
  36124. /** @hidden */
  36125. _activeIndices: PerfCounter;
  36126. /** @hidden */
  36127. _activeParticles: PerfCounter;
  36128. /** @hidden */
  36129. _activeBones: PerfCounter;
  36130. private _animationRatio;
  36131. /** @hidden */
  36132. _animationTimeLast: number;
  36133. /** @hidden */
  36134. _animationTime: number;
  36135. /**
  36136. * Gets or sets a general scale for animation speed
  36137. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36138. */
  36139. animationTimeScale: number;
  36140. /** @hidden */
  36141. _cachedMaterial: Nullable<Material>;
  36142. /** @hidden */
  36143. _cachedEffect: Nullable<Effect>;
  36144. /** @hidden */
  36145. _cachedVisibility: Nullable<number>;
  36146. private _renderId;
  36147. private _frameId;
  36148. private _executeWhenReadyTimeoutId;
  36149. private _intermediateRendering;
  36150. private _viewUpdateFlag;
  36151. private _projectionUpdateFlag;
  36152. /** @hidden */
  36153. _toBeDisposed: Nullable<IDisposable>[];
  36154. private _activeRequests;
  36155. /** @hidden */
  36156. _pendingData: any[];
  36157. private _isDisposed;
  36158. /**
  36159. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36160. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36161. */
  36162. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36163. private _activeMeshes;
  36164. private _processedMaterials;
  36165. private _renderTargets;
  36166. /** @hidden */
  36167. _activeParticleSystems: SmartArray<IParticleSystem>;
  36168. private _activeSkeletons;
  36169. private _softwareSkinnedMeshes;
  36170. private _renderingManager;
  36171. /** @hidden */
  36172. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  36173. private _transformMatrix;
  36174. private _sceneUbo;
  36175. /** @hidden */
  36176. _viewMatrix: Matrix;
  36177. private _projectionMatrix;
  36178. /** @hidden */
  36179. _forcedViewPosition: Nullable<Vector3>;
  36180. /** @hidden */
  36181. _frustumPlanes: Plane[];
  36182. /**
  36183. * Gets the list of frustum planes (built from the active camera)
  36184. */
  36185. readonly frustumPlanes: Plane[];
  36186. /**
  36187. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36188. * This is useful if there are more lights that the maximum simulteanous authorized
  36189. */
  36190. requireLightSorting: boolean;
  36191. /** @hidden */
  36192. readonly useMaterialMeshMap: boolean;
  36193. /** @hidden */
  36194. readonly useClonedMeshhMap: boolean;
  36195. private _externalData;
  36196. private _uid;
  36197. /**
  36198. * @hidden
  36199. * Backing store of defined scene components.
  36200. */
  36201. _components: ISceneComponent[];
  36202. /**
  36203. * @hidden
  36204. * Backing store of defined scene components.
  36205. */
  36206. _serializableComponents: ISceneSerializableComponent[];
  36207. /**
  36208. * List of components to register on the next registration step.
  36209. */
  36210. private _transientComponents;
  36211. /**
  36212. * Registers the transient components if needed.
  36213. */
  36214. private _registerTransientComponents;
  36215. /**
  36216. * @hidden
  36217. * Add a component to the scene.
  36218. * Note that the ccomponent could be registered on th next frame if this is called after
  36219. * the register component stage.
  36220. * @param component Defines the component to add to the scene
  36221. */
  36222. _addComponent(component: ISceneComponent): void;
  36223. /**
  36224. * @hidden
  36225. * Gets a component from the scene.
  36226. * @param name defines the name of the component to retrieve
  36227. * @returns the component or null if not present
  36228. */
  36229. _getComponent(name: string): Nullable<ISceneComponent>;
  36230. /**
  36231. * @hidden
  36232. * Defines the actions happening before camera updates.
  36233. */
  36234. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36235. /**
  36236. * @hidden
  36237. * Defines the actions happening before clear the canvas.
  36238. */
  36239. _beforeClearStage: Stage<SimpleStageAction>;
  36240. /**
  36241. * @hidden
  36242. * Defines the actions when collecting render targets for the frame.
  36243. */
  36244. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36245. /**
  36246. * @hidden
  36247. * Defines the actions happening for one camera in the frame.
  36248. */
  36249. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36250. /**
  36251. * @hidden
  36252. * Defines the actions happening during the per mesh ready checks.
  36253. */
  36254. _isReadyForMeshStage: Stage<MeshStageAction>;
  36255. /**
  36256. * @hidden
  36257. * Defines the actions happening before evaluate active mesh checks.
  36258. */
  36259. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36260. /**
  36261. * @hidden
  36262. * Defines the actions happening during the evaluate sub mesh checks.
  36263. */
  36264. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36265. /**
  36266. * @hidden
  36267. * Defines the actions happening during the active mesh stage.
  36268. */
  36269. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36270. /**
  36271. * @hidden
  36272. * Defines the actions happening during the per camera render target step.
  36273. */
  36274. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36275. /**
  36276. * @hidden
  36277. * Defines the actions happening just before the active camera is drawing.
  36278. */
  36279. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36280. /**
  36281. * @hidden
  36282. * Defines the actions happening just before a render target is drawing.
  36283. */
  36284. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36285. /**
  36286. * @hidden
  36287. * Defines the actions happening just before a rendering group is drawing.
  36288. */
  36289. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36290. /**
  36291. * @hidden
  36292. * Defines the actions happening just before a mesh is drawing.
  36293. */
  36294. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36295. /**
  36296. * @hidden
  36297. * Defines the actions happening just after a mesh has been drawn.
  36298. */
  36299. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36300. /**
  36301. * @hidden
  36302. * Defines the actions happening just after a rendering group has been drawn.
  36303. */
  36304. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36305. /**
  36306. * @hidden
  36307. * Defines the actions happening just after the active camera has been drawn.
  36308. */
  36309. _afterCameraDrawStage: Stage<CameraStageAction>;
  36310. /**
  36311. * @hidden
  36312. * Defines the actions happening just after a render target has been drawn.
  36313. */
  36314. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36315. /**
  36316. * @hidden
  36317. * Defines the actions happening just after rendering all cameras and computing intersections.
  36318. */
  36319. _afterRenderStage: Stage<SimpleStageAction>;
  36320. /**
  36321. * @hidden
  36322. * Defines the actions happening when a pointer move event happens.
  36323. */
  36324. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36325. /**
  36326. * @hidden
  36327. * Defines the actions happening when a pointer down event happens.
  36328. */
  36329. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36330. /**
  36331. * @hidden
  36332. * Defines the actions happening when a pointer up event happens.
  36333. */
  36334. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36335. /**
  36336. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36337. */
  36338. private geometriesByUniqueId;
  36339. /**
  36340. * Creates a new Scene
  36341. * @param engine defines the engine to use to render this scene
  36342. * @param options defines the scene options
  36343. */
  36344. constructor(engine: Engine, options?: SceneOptions);
  36345. /**
  36346. * Gets a string idenfifying the name of the class
  36347. * @returns "Scene" string
  36348. */
  36349. getClassName(): string;
  36350. private _defaultMeshCandidates;
  36351. /**
  36352. * @hidden
  36353. */
  36354. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36355. private _defaultSubMeshCandidates;
  36356. /**
  36357. * @hidden
  36358. */
  36359. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36360. /**
  36361. * Sets the default candidate providers for the scene.
  36362. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36363. * and getCollidingSubMeshCandidates to their default function
  36364. */
  36365. setDefaultCandidateProviders(): void;
  36366. /**
  36367. * Gets the mesh that is currently under the pointer
  36368. */
  36369. readonly meshUnderPointer: Nullable<AbstractMesh>;
  36370. /**
  36371. * Gets or sets the current on-screen X position of the pointer
  36372. */
  36373. pointerX: number;
  36374. /**
  36375. * Gets or sets the current on-screen Y position of the pointer
  36376. */
  36377. pointerY: number;
  36378. /**
  36379. * Gets the cached material (ie. the latest rendered one)
  36380. * @returns the cached material
  36381. */
  36382. getCachedMaterial(): Nullable<Material>;
  36383. /**
  36384. * Gets the cached effect (ie. the latest rendered one)
  36385. * @returns the cached effect
  36386. */
  36387. getCachedEffect(): Nullable<Effect>;
  36388. /**
  36389. * Gets the cached visibility state (ie. the latest rendered one)
  36390. * @returns the cached visibility state
  36391. */
  36392. getCachedVisibility(): Nullable<number>;
  36393. /**
  36394. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36395. * @param material defines the current material
  36396. * @param effect defines the current effect
  36397. * @param visibility defines the current visibility state
  36398. * @returns true if one parameter is not cached
  36399. */
  36400. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36401. /**
  36402. * Gets the engine associated with the scene
  36403. * @returns an Engine
  36404. */
  36405. getEngine(): Engine;
  36406. /**
  36407. * Gets the total number of vertices rendered per frame
  36408. * @returns the total number of vertices rendered per frame
  36409. */
  36410. getTotalVertices(): number;
  36411. /**
  36412. * Gets the performance counter for total vertices
  36413. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36414. */
  36415. readonly totalVerticesPerfCounter: PerfCounter;
  36416. /**
  36417. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36418. * @returns the total number of active indices rendered per frame
  36419. */
  36420. getActiveIndices(): number;
  36421. /**
  36422. * Gets the performance counter for active indices
  36423. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36424. */
  36425. readonly totalActiveIndicesPerfCounter: PerfCounter;
  36426. /**
  36427. * Gets the total number of active particles rendered per frame
  36428. * @returns the total number of active particles rendered per frame
  36429. */
  36430. getActiveParticles(): number;
  36431. /**
  36432. * Gets the performance counter for active particles
  36433. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36434. */
  36435. readonly activeParticlesPerfCounter: PerfCounter;
  36436. /**
  36437. * Gets the total number of active bones rendered per frame
  36438. * @returns the total number of active bones rendered per frame
  36439. */
  36440. getActiveBones(): number;
  36441. /**
  36442. * Gets the performance counter for active bones
  36443. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36444. */
  36445. readonly activeBonesPerfCounter: PerfCounter;
  36446. /**
  36447. * Gets the array of active meshes
  36448. * @returns an array of AbstractMesh
  36449. */
  36450. getActiveMeshes(): SmartArray<AbstractMesh>;
  36451. /**
  36452. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36453. * @returns a number
  36454. */
  36455. getAnimationRatio(): number;
  36456. /**
  36457. * Gets an unique Id for the current render phase
  36458. * @returns a number
  36459. */
  36460. getRenderId(): number;
  36461. /**
  36462. * Gets an unique Id for the current frame
  36463. * @returns a number
  36464. */
  36465. getFrameId(): number;
  36466. /** Call this function if you want to manually increment the render Id*/
  36467. incrementRenderId(): void;
  36468. private _createUbo;
  36469. /**
  36470. * Use this method to simulate a pointer move on a mesh
  36471. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36472. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36473. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36474. * @returns the current scene
  36475. */
  36476. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36477. /**
  36478. * Use this method to simulate a pointer down on a mesh
  36479. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36480. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36481. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36482. * @returns the current scene
  36483. */
  36484. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36485. /**
  36486. * Use this method to simulate a pointer up on a mesh
  36487. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36488. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36489. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36490. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36491. * @returns the current scene
  36492. */
  36493. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36494. /**
  36495. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36496. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36497. * @returns true if the pointer was captured
  36498. */
  36499. isPointerCaptured(pointerId?: number): boolean;
  36500. /**
  36501. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36502. * @param attachUp defines if you want to attach events to pointerup
  36503. * @param attachDown defines if you want to attach events to pointerdown
  36504. * @param attachMove defines if you want to attach events to pointermove
  36505. */
  36506. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36507. /** Detaches all event handlers*/
  36508. detachControl(): void;
  36509. /**
  36510. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36511. * Delay loaded resources are not taking in account
  36512. * @return true if all required resources are ready
  36513. */
  36514. isReady(): boolean;
  36515. /** Resets all cached information relative to material (including effect and visibility) */
  36516. resetCachedMaterial(): void;
  36517. /**
  36518. * Registers a function to be called before every frame render
  36519. * @param func defines the function to register
  36520. */
  36521. registerBeforeRender(func: () => void): void;
  36522. /**
  36523. * Unregisters a function called before every frame render
  36524. * @param func defines the function to unregister
  36525. */
  36526. unregisterBeforeRender(func: () => void): void;
  36527. /**
  36528. * Registers a function to be called after every frame render
  36529. * @param func defines the function to register
  36530. */
  36531. registerAfterRender(func: () => void): void;
  36532. /**
  36533. * Unregisters a function called after every frame render
  36534. * @param func defines the function to unregister
  36535. */
  36536. unregisterAfterRender(func: () => void): void;
  36537. private _executeOnceBeforeRender;
  36538. /**
  36539. * The provided function will run before render once and will be disposed afterwards.
  36540. * A timeout delay can be provided so that the function will be executed in N ms.
  36541. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36542. * @param func The function to be executed.
  36543. * @param timeout optional delay in ms
  36544. */
  36545. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36546. /** @hidden */
  36547. _addPendingData(data: any): void;
  36548. /** @hidden */
  36549. _removePendingData(data: any): void;
  36550. /**
  36551. * Returns the number of items waiting to be loaded
  36552. * @returns the number of items waiting to be loaded
  36553. */
  36554. getWaitingItemsCount(): number;
  36555. /**
  36556. * Returns a boolean indicating if the scene is still loading data
  36557. */
  36558. readonly isLoading: boolean;
  36559. /**
  36560. * Registers a function to be executed when the scene is ready
  36561. * @param {Function} func - the function to be executed
  36562. */
  36563. executeWhenReady(func: () => void): void;
  36564. /**
  36565. * Returns a promise that resolves when the scene is ready
  36566. * @returns A promise that resolves when the scene is ready
  36567. */
  36568. whenReadyAsync(): Promise<void>;
  36569. /** @hidden */
  36570. _checkIsReady(): void;
  36571. /**
  36572. * Gets all animatable attached to the scene
  36573. */
  36574. readonly animatables: Animatable[];
  36575. /**
  36576. * Resets the last animation time frame.
  36577. * Useful to override when animations start running when loading a scene for the first time.
  36578. */
  36579. resetLastAnimationTimeFrame(): void;
  36580. /**
  36581. * Gets the current view matrix
  36582. * @returns a Matrix
  36583. */
  36584. getViewMatrix(): Matrix;
  36585. /**
  36586. * Gets the current projection matrix
  36587. * @returns a Matrix
  36588. */
  36589. getProjectionMatrix(): Matrix;
  36590. /**
  36591. * Gets the current transform matrix
  36592. * @returns a Matrix made of View * Projection
  36593. */
  36594. getTransformMatrix(): Matrix;
  36595. /**
  36596. * Sets the current transform matrix
  36597. * @param viewL defines the View matrix to use
  36598. * @param projectionL defines the Projection matrix to use
  36599. * @param viewR defines the right View matrix to use (if provided)
  36600. * @param projectionR defines the right Projection matrix to use (if provided)
  36601. */
  36602. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36603. /**
  36604. * Gets the uniform buffer used to store scene data
  36605. * @returns a UniformBuffer
  36606. */
  36607. getSceneUniformBuffer(): UniformBuffer;
  36608. /**
  36609. * Gets an unique (relatively to the current scene) Id
  36610. * @returns an unique number for the scene
  36611. */
  36612. getUniqueId(): number;
  36613. /**
  36614. * Add a mesh to the list of scene's meshes
  36615. * @param newMesh defines the mesh to add
  36616. * @param recursive if all child meshes should also be added to the scene
  36617. */
  36618. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36619. /**
  36620. * Remove a mesh for the list of scene's meshes
  36621. * @param toRemove defines the mesh to remove
  36622. * @param recursive if all child meshes should also be removed from the scene
  36623. * @returns the index where the mesh was in the mesh list
  36624. */
  36625. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36626. /**
  36627. * Add a transform node to the list of scene's transform nodes
  36628. * @param newTransformNode defines the transform node to add
  36629. */
  36630. addTransformNode(newTransformNode: TransformNode): void;
  36631. /**
  36632. * Remove a transform node for the list of scene's transform nodes
  36633. * @param toRemove defines the transform node to remove
  36634. * @returns the index where the transform node was in the transform node list
  36635. */
  36636. removeTransformNode(toRemove: TransformNode): number;
  36637. /**
  36638. * Remove a skeleton for the list of scene's skeletons
  36639. * @param toRemove defines the skeleton to remove
  36640. * @returns the index where the skeleton was in the skeleton list
  36641. */
  36642. removeSkeleton(toRemove: Skeleton): number;
  36643. /**
  36644. * Remove a morph target for the list of scene's morph targets
  36645. * @param toRemove defines the morph target to remove
  36646. * @returns the index where the morph target was in the morph target list
  36647. */
  36648. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36649. /**
  36650. * Remove a light for the list of scene's lights
  36651. * @param toRemove defines the light to remove
  36652. * @returns the index where the light was in the light list
  36653. */
  36654. removeLight(toRemove: Light): number;
  36655. /**
  36656. * Remove a camera for the list of scene's cameras
  36657. * @param toRemove defines the camera to remove
  36658. * @returns the index where the camera was in the camera list
  36659. */
  36660. removeCamera(toRemove: Camera): number;
  36661. /**
  36662. * Remove a particle system for the list of scene's particle systems
  36663. * @param toRemove defines the particle system to remove
  36664. * @returns the index where the particle system was in the particle system list
  36665. */
  36666. removeParticleSystem(toRemove: IParticleSystem): number;
  36667. /**
  36668. * Remove a animation for the list of scene's animations
  36669. * @param toRemove defines the animation to remove
  36670. * @returns the index where the animation was in the animation list
  36671. */
  36672. removeAnimation(toRemove: Animation): number;
  36673. /**
  36674. * Will stop the animation of the given target
  36675. * @param target - the target
  36676. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36677. * @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)
  36678. */
  36679. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36680. /**
  36681. * Removes the given animation group from this scene.
  36682. * @param toRemove The animation group to remove
  36683. * @returns The index of the removed animation group
  36684. */
  36685. removeAnimationGroup(toRemove: AnimationGroup): number;
  36686. /**
  36687. * Removes the given multi-material from this scene.
  36688. * @param toRemove The multi-material to remove
  36689. * @returns The index of the removed multi-material
  36690. */
  36691. removeMultiMaterial(toRemove: MultiMaterial): number;
  36692. /**
  36693. * Removes the given material from this scene.
  36694. * @param toRemove The material to remove
  36695. * @returns The index of the removed material
  36696. */
  36697. removeMaterial(toRemove: Material): number;
  36698. /**
  36699. * Removes the given action manager from this scene.
  36700. * @param toRemove The action manager to remove
  36701. * @returns The index of the removed action manager
  36702. */
  36703. removeActionManager(toRemove: AbstractActionManager): number;
  36704. /**
  36705. * Removes the given texture from this scene.
  36706. * @param toRemove The texture to remove
  36707. * @returns The index of the removed texture
  36708. */
  36709. removeTexture(toRemove: BaseTexture): number;
  36710. /**
  36711. * Adds the given light to this scene
  36712. * @param newLight The light to add
  36713. */
  36714. addLight(newLight: Light): void;
  36715. /**
  36716. * Sorts the list list based on light priorities
  36717. */
  36718. sortLightsByPriority(): void;
  36719. /**
  36720. * Adds the given camera to this scene
  36721. * @param newCamera The camera to add
  36722. */
  36723. addCamera(newCamera: Camera): void;
  36724. /**
  36725. * Adds the given skeleton to this scene
  36726. * @param newSkeleton The skeleton to add
  36727. */
  36728. addSkeleton(newSkeleton: Skeleton): void;
  36729. /**
  36730. * Adds the given particle system to this scene
  36731. * @param newParticleSystem The particle system to add
  36732. */
  36733. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36734. /**
  36735. * Adds the given animation to this scene
  36736. * @param newAnimation The animation to add
  36737. */
  36738. addAnimation(newAnimation: Animation): void;
  36739. /**
  36740. * Adds the given animation group to this scene.
  36741. * @param newAnimationGroup The animation group to add
  36742. */
  36743. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36744. /**
  36745. * Adds the given multi-material to this scene
  36746. * @param newMultiMaterial The multi-material to add
  36747. */
  36748. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36749. /**
  36750. * Adds the given material to this scene
  36751. * @param newMaterial The material to add
  36752. */
  36753. addMaterial(newMaterial: Material): void;
  36754. /**
  36755. * Adds the given morph target to this scene
  36756. * @param newMorphTargetManager The morph target to add
  36757. */
  36758. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36759. /**
  36760. * Adds the given geometry to this scene
  36761. * @param newGeometry The geometry to add
  36762. */
  36763. addGeometry(newGeometry: Geometry): void;
  36764. /**
  36765. * Adds the given action manager to this scene
  36766. * @param newActionManager The action manager to add
  36767. */
  36768. addActionManager(newActionManager: AbstractActionManager): void;
  36769. /**
  36770. * Adds the given texture to this scene.
  36771. * @param newTexture The texture to add
  36772. */
  36773. addTexture(newTexture: BaseTexture): void;
  36774. /**
  36775. * Switch active camera
  36776. * @param newCamera defines the new active camera
  36777. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36778. */
  36779. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36780. /**
  36781. * sets the active camera of the scene using its ID
  36782. * @param id defines the camera's ID
  36783. * @return the new active camera or null if none found.
  36784. */
  36785. setActiveCameraByID(id: string): Nullable<Camera>;
  36786. /**
  36787. * sets the active camera of the scene using its name
  36788. * @param name defines the camera's name
  36789. * @returns the new active camera or null if none found.
  36790. */
  36791. setActiveCameraByName(name: string): Nullable<Camera>;
  36792. /**
  36793. * get an animation group using its name
  36794. * @param name defines the material's name
  36795. * @return the animation group or null if none found.
  36796. */
  36797. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36798. /**
  36799. * Get a material using its unique id
  36800. * @param uniqueId defines the material's unique id
  36801. * @return the material or null if none found.
  36802. */
  36803. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36804. /**
  36805. * get a material using its id
  36806. * @param id defines the material's ID
  36807. * @return the material or null if none found.
  36808. */
  36809. getMaterialByID(id: string): Nullable<Material>;
  36810. /**
  36811. * Gets a the last added material using a given id
  36812. * @param id defines the material's ID
  36813. * @return the last material with the given id or null if none found.
  36814. */
  36815. getLastMaterialByID(id: string): Nullable<Material>;
  36816. /**
  36817. * Gets a material using its name
  36818. * @param name defines the material's name
  36819. * @return the material or null if none found.
  36820. */
  36821. getMaterialByName(name: string): Nullable<Material>;
  36822. /**
  36823. * Get a texture using its unique id
  36824. * @param uniqueId defines the texture's unique id
  36825. * @return the texture or null if none found.
  36826. */
  36827. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36828. /**
  36829. * Gets a camera using its id
  36830. * @param id defines the id to look for
  36831. * @returns the camera or null if not found
  36832. */
  36833. getCameraByID(id: string): Nullable<Camera>;
  36834. /**
  36835. * Gets a camera using its unique id
  36836. * @param uniqueId defines the unique id to look for
  36837. * @returns the camera or null if not found
  36838. */
  36839. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36840. /**
  36841. * Gets a camera using its name
  36842. * @param name defines the camera's name
  36843. * @return the camera or null if none found.
  36844. */
  36845. getCameraByName(name: string): Nullable<Camera>;
  36846. /**
  36847. * Gets a bone using its id
  36848. * @param id defines the bone's id
  36849. * @return the bone or null if not found
  36850. */
  36851. getBoneByID(id: string): Nullable<Bone>;
  36852. /**
  36853. * Gets a bone using its id
  36854. * @param name defines the bone's name
  36855. * @return the bone or null if not found
  36856. */
  36857. getBoneByName(name: string): Nullable<Bone>;
  36858. /**
  36859. * Gets a light node using its name
  36860. * @param name defines the the light's name
  36861. * @return the light or null if none found.
  36862. */
  36863. getLightByName(name: string): Nullable<Light>;
  36864. /**
  36865. * Gets a light node using its id
  36866. * @param id defines the light's id
  36867. * @return the light or null if none found.
  36868. */
  36869. getLightByID(id: string): Nullable<Light>;
  36870. /**
  36871. * Gets a light node using its scene-generated unique ID
  36872. * @param uniqueId defines the light's unique id
  36873. * @return the light or null if none found.
  36874. */
  36875. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36876. /**
  36877. * Gets a particle system by id
  36878. * @param id defines the particle system id
  36879. * @return the corresponding system or null if none found
  36880. */
  36881. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36882. /**
  36883. * Gets a geometry using its ID
  36884. * @param id defines the geometry's id
  36885. * @return the geometry or null if none found.
  36886. */
  36887. getGeometryByID(id: string): Nullable<Geometry>;
  36888. private _getGeometryByUniqueID;
  36889. /**
  36890. * Add a new geometry to this scene
  36891. * @param geometry defines the geometry to be added to the scene.
  36892. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36893. * @return a boolean defining if the geometry was added or not
  36894. */
  36895. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36896. /**
  36897. * Removes an existing geometry
  36898. * @param geometry defines the geometry to be removed from the scene
  36899. * @return a boolean defining if the geometry was removed or not
  36900. */
  36901. removeGeometry(geometry: Geometry): boolean;
  36902. /**
  36903. * Gets the list of geometries attached to the scene
  36904. * @returns an array of Geometry
  36905. */
  36906. getGeometries(): Geometry[];
  36907. /**
  36908. * Gets the first added mesh found of a given ID
  36909. * @param id defines the id to search for
  36910. * @return the mesh found or null if not found at all
  36911. */
  36912. getMeshByID(id: string): Nullable<AbstractMesh>;
  36913. /**
  36914. * Gets a list of meshes using their id
  36915. * @param id defines the id to search for
  36916. * @returns a list of meshes
  36917. */
  36918. getMeshesByID(id: string): Array<AbstractMesh>;
  36919. /**
  36920. * Gets the first added transform node found of a given ID
  36921. * @param id defines the id to search for
  36922. * @return the found transform node or null if not found at all.
  36923. */
  36924. getTransformNodeByID(id: string): Nullable<TransformNode>;
  36925. /**
  36926. * Gets a transform node with its auto-generated unique id
  36927. * @param uniqueId efines the unique id to search for
  36928. * @return the found transform node or null if not found at all.
  36929. */
  36930. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  36931. /**
  36932. * Gets a list of transform nodes using their id
  36933. * @param id defines the id to search for
  36934. * @returns a list of transform nodes
  36935. */
  36936. getTransformNodesByID(id: string): Array<TransformNode>;
  36937. /**
  36938. * Gets a mesh with its auto-generated unique id
  36939. * @param uniqueId defines the unique id to search for
  36940. * @return the found mesh or null if not found at all.
  36941. */
  36942. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  36943. /**
  36944. * Gets a the last added mesh using a given id
  36945. * @param id defines the id to search for
  36946. * @return the found mesh or null if not found at all.
  36947. */
  36948. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  36949. /**
  36950. * Gets a the last added node (Mesh, Camera, Light) using a given id
  36951. * @param id defines the id to search for
  36952. * @return the found node or null if not found at all
  36953. */
  36954. getLastEntryByID(id: string): Nullable<Node>;
  36955. /**
  36956. * Gets a node (Mesh, Camera, Light) using a given id
  36957. * @param id defines the id to search for
  36958. * @return the found node or null if not found at all
  36959. */
  36960. getNodeByID(id: string): Nullable<Node>;
  36961. /**
  36962. * Gets a node (Mesh, Camera, Light) using a given name
  36963. * @param name defines the name to search for
  36964. * @return the found node or null if not found at all.
  36965. */
  36966. getNodeByName(name: string): Nullable<Node>;
  36967. /**
  36968. * Gets a mesh using a given name
  36969. * @param name defines the name to search for
  36970. * @return the found mesh or null if not found at all.
  36971. */
  36972. getMeshByName(name: string): Nullable<AbstractMesh>;
  36973. /**
  36974. * Gets a transform node using a given name
  36975. * @param name defines the name to search for
  36976. * @return the found transform node or null if not found at all.
  36977. */
  36978. getTransformNodeByName(name: string): Nullable<TransformNode>;
  36979. /**
  36980. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  36981. * @param id defines the id to search for
  36982. * @return the found skeleton or null if not found at all.
  36983. */
  36984. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  36985. /**
  36986. * Gets a skeleton using a given auto generated unique id
  36987. * @param uniqueId defines the unique id to search for
  36988. * @return the found skeleton or null if not found at all.
  36989. */
  36990. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  36991. /**
  36992. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  36993. * @param id defines the id to search for
  36994. * @return the found skeleton or null if not found at all.
  36995. */
  36996. getSkeletonById(id: string): Nullable<Skeleton>;
  36997. /**
  36998. * Gets a skeleton using a given name
  36999. * @param name defines the name to search for
  37000. * @return the found skeleton or null if not found at all.
  37001. */
  37002. getSkeletonByName(name: string): Nullable<Skeleton>;
  37003. /**
  37004. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37005. * @param id defines the id to search for
  37006. * @return the found morph target manager or null if not found at all.
  37007. */
  37008. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37009. /**
  37010. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37011. * @param id defines the id to search for
  37012. * @return the found morph target or null if not found at all.
  37013. */
  37014. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37015. /**
  37016. * Gets a boolean indicating if the given mesh is active
  37017. * @param mesh defines the mesh to look for
  37018. * @returns true if the mesh is in the active list
  37019. */
  37020. isActiveMesh(mesh: AbstractMesh): boolean;
  37021. /**
  37022. * Return a unique id as a string which can serve as an identifier for the scene
  37023. */
  37024. readonly uid: string;
  37025. /**
  37026. * Add an externaly attached data from its key.
  37027. * This method call will fail and return false, if such key already exists.
  37028. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37029. * @param key the unique key that identifies the data
  37030. * @param data the data object to associate to the key for this Engine instance
  37031. * @return true if no such key were already present and the data was added successfully, false otherwise
  37032. */
  37033. addExternalData<T>(key: string, data: T): boolean;
  37034. /**
  37035. * Get an externaly attached data from its key
  37036. * @param key the unique key that identifies the data
  37037. * @return the associated data, if present (can be null), or undefined if not present
  37038. */
  37039. getExternalData<T>(key: string): Nullable<T>;
  37040. /**
  37041. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37042. * @param key the unique key that identifies the data
  37043. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37044. * @return the associated data, can be null if the factory returned null.
  37045. */
  37046. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37047. /**
  37048. * Remove an externaly attached data from the Engine instance
  37049. * @param key the unique key that identifies the data
  37050. * @return true if the data was successfully removed, false if it doesn't exist
  37051. */
  37052. removeExternalData(key: string): boolean;
  37053. private _evaluateSubMesh;
  37054. /**
  37055. * Clear the processed materials smart array preventing retention point in material dispose.
  37056. */
  37057. freeProcessedMaterials(): void;
  37058. private _preventFreeActiveMeshesAndRenderingGroups;
  37059. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37060. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37061. * when disposing several meshes in a row or a hierarchy of meshes.
  37062. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37063. */
  37064. blockfreeActiveMeshesAndRenderingGroups: boolean;
  37065. /**
  37066. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37067. */
  37068. freeActiveMeshes(): void;
  37069. /**
  37070. * Clear the info related to rendering groups preventing retention points during dispose.
  37071. */
  37072. freeRenderingGroups(): void;
  37073. /** @hidden */
  37074. _isInIntermediateRendering(): boolean;
  37075. /**
  37076. * Lambda returning the list of potentially active meshes.
  37077. */
  37078. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37079. /**
  37080. * Lambda returning the list of potentially active sub meshes.
  37081. */
  37082. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37083. /**
  37084. * Lambda returning the list of potentially intersecting sub meshes.
  37085. */
  37086. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37087. /**
  37088. * Lambda returning the list of potentially colliding sub meshes.
  37089. */
  37090. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37091. private _activeMeshesFrozen;
  37092. private _skipEvaluateActiveMeshesCompletely;
  37093. /**
  37094. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37095. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37096. * @returns the current scene
  37097. */
  37098. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37099. /**
  37100. * Use this function to restart evaluating active meshes on every frame
  37101. * @returns the current scene
  37102. */
  37103. unfreezeActiveMeshes(): Scene;
  37104. private _evaluateActiveMeshes;
  37105. private _activeMesh;
  37106. /**
  37107. * Update the transform matrix to update from the current active camera
  37108. * @param force defines a boolean used to force the update even if cache is up to date
  37109. */
  37110. updateTransformMatrix(force?: boolean): void;
  37111. private _bindFrameBuffer;
  37112. /** @hidden */
  37113. _allowPostProcessClearColor: boolean;
  37114. /** @hidden */
  37115. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37116. private _processSubCameras;
  37117. private _checkIntersections;
  37118. /** @hidden */
  37119. _advancePhysicsEngineStep(step: number): void;
  37120. /**
  37121. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37122. */
  37123. getDeterministicFrameTime: () => number;
  37124. /** @hidden */
  37125. _animate(): void;
  37126. /** Execute all animations (for a frame) */
  37127. animate(): void;
  37128. /**
  37129. * Render the scene
  37130. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37131. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37132. */
  37133. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37134. /**
  37135. * Freeze all materials
  37136. * A frozen material will not be updatable but should be faster to render
  37137. */
  37138. freezeMaterials(): void;
  37139. /**
  37140. * Unfreeze all materials
  37141. * A frozen material will not be updatable but should be faster to render
  37142. */
  37143. unfreezeMaterials(): void;
  37144. /**
  37145. * Releases all held ressources
  37146. */
  37147. dispose(): void;
  37148. /**
  37149. * Gets if the scene is already disposed
  37150. */
  37151. readonly isDisposed: boolean;
  37152. /**
  37153. * Call this function to reduce memory footprint of the scene.
  37154. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37155. */
  37156. clearCachedVertexData(): void;
  37157. /**
  37158. * This function will remove the local cached buffer data from texture.
  37159. * It will save memory but will prevent the texture from being rebuilt
  37160. */
  37161. cleanCachedTextureBuffer(): void;
  37162. /**
  37163. * Get the world extend vectors with an optional filter
  37164. *
  37165. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37166. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37167. */
  37168. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37169. min: Vector3;
  37170. max: Vector3;
  37171. };
  37172. /**
  37173. * Creates a ray that can be used to pick in the scene
  37174. * @param x defines the x coordinate of the origin (on-screen)
  37175. * @param y defines the y coordinate of the origin (on-screen)
  37176. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37177. * @param camera defines the camera to use for the picking
  37178. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37179. * @returns a Ray
  37180. */
  37181. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37182. /**
  37183. * Creates a ray that can be used to pick in the scene
  37184. * @param x defines the x coordinate of the origin (on-screen)
  37185. * @param y defines the y coordinate of the origin (on-screen)
  37186. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37187. * @param result defines the ray where to store the picking ray
  37188. * @param camera defines the camera to use for the picking
  37189. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37190. * @returns the current scene
  37191. */
  37192. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37193. /**
  37194. * Creates a ray that can be used to pick in the scene
  37195. * @param x defines the x coordinate of the origin (on-screen)
  37196. * @param y defines the y coordinate of the origin (on-screen)
  37197. * @param camera defines the camera to use for the picking
  37198. * @returns a Ray
  37199. */
  37200. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37201. /**
  37202. * Creates a ray that can be used to pick in the scene
  37203. * @param x defines the x coordinate of the origin (on-screen)
  37204. * @param y defines the y coordinate of the origin (on-screen)
  37205. * @param result defines the ray where to store the picking ray
  37206. * @param camera defines the camera to use for the picking
  37207. * @returns the current scene
  37208. */
  37209. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37210. /** Launch a ray to try to pick a mesh in the scene
  37211. * @param x position on screen
  37212. * @param y position on screen
  37213. * @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
  37214. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37215. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37216. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37217. * @returns a PickingInfo
  37218. */
  37219. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37220. /** Use the given ray to pick a mesh in the scene
  37221. * @param ray The ray to use to pick meshes
  37222. * @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
  37223. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37224. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37225. * @returns a PickingInfo
  37226. */
  37227. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37228. /**
  37229. * Launch a ray to try to pick a mesh in the scene
  37230. * @param x X position on screen
  37231. * @param y Y position on screen
  37232. * @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
  37233. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37234. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37235. * @returns an array of PickingInfo
  37236. */
  37237. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37238. /**
  37239. * Launch a ray to try to pick a mesh in the scene
  37240. * @param ray Ray to use
  37241. * @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
  37242. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37243. * @returns an array of PickingInfo
  37244. */
  37245. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37246. /**
  37247. * Force the value of meshUnderPointer
  37248. * @param mesh defines the mesh to use
  37249. */
  37250. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37251. /**
  37252. * Gets the mesh under the pointer
  37253. * @returns a Mesh or null if no mesh is under the pointer
  37254. */
  37255. getPointerOverMesh(): Nullable<AbstractMesh>;
  37256. /** @hidden */
  37257. _rebuildGeometries(): void;
  37258. /** @hidden */
  37259. _rebuildTextures(): void;
  37260. private _getByTags;
  37261. /**
  37262. * Get a list of meshes by tags
  37263. * @param tagsQuery defines the tags query to use
  37264. * @param forEach defines a predicate used to filter results
  37265. * @returns an array of Mesh
  37266. */
  37267. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37268. /**
  37269. * Get a list of cameras by tags
  37270. * @param tagsQuery defines the tags query to use
  37271. * @param forEach defines a predicate used to filter results
  37272. * @returns an array of Camera
  37273. */
  37274. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37275. /**
  37276. * Get a list of lights by tags
  37277. * @param tagsQuery defines the tags query to use
  37278. * @param forEach defines a predicate used to filter results
  37279. * @returns an array of Light
  37280. */
  37281. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37282. /**
  37283. * Get a list of materials by tags
  37284. * @param tagsQuery defines the tags query to use
  37285. * @param forEach defines a predicate used to filter results
  37286. * @returns an array of Material
  37287. */
  37288. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37289. /**
  37290. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37291. * This allowed control for front to back rendering or reversly depending of the special needs.
  37292. *
  37293. * @param renderingGroupId The rendering group id corresponding to its index
  37294. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37295. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37296. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37297. */
  37298. 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;
  37299. /**
  37300. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37301. *
  37302. * @param renderingGroupId The rendering group id corresponding to its index
  37303. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37304. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37305. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37306. */
  37307. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37308. /**
  37309. * Gets the current auto clear configuration for one rendering group of the rendering
  37310. * manager.
  37311. * @param index the rendering group index to get the information for
  37312. * @returns The auto clear setup for the requested rendering group
  37313. */
  37314. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37315. private _blockMaterialDirtyMechanism;
  37316. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37317. blockMaterialDirtyMechanism: boolean;
  37318. /**
  37319. * Will flag all materials as dirty to trigger new shader compilation
  37320. * @param flag defines the flag used to specify which material part must be marked as dirty
  37321. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37322. */
  37323. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37324. /** @hidden */
  37325. _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;
  37326. /** @hidden */
  37327. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37328. /** @hidden */
  37329. _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;
  37330. /** @hidden */
  37331. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37332. /** @hidden */
  37333. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37334. /** @hidden */
  37335. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37336. }
  37337. }
  37338. declare module "babylonjs/assetContainer" {
  37339. import { AbstractScene } from "babylonjs/abstractScene";
  37340. import { Scene } from "babylonjs/scene";
  37341. import { Mesh } from "babylonjs/Meshes/mesh";
  37342. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37343. import { Skeleton } from "babylonjs/Bones/skeleton";
  37344. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37345. /**
  37346. * Set of assets to keep when moving a scene into an asset container.
  37347. */
  37348. export class KeepAssets extends AbstractScene {
  37349. }
  37350. /**
  37351. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37352. */
  37353. export class InstantiatedEntries {
  37354. /**
  37355. * List of new root nodes (eg. nodes with no parent)
  37356. */
  37357. rootNodes: TransformNode[];
  37358. /**
  37359. * List of new skeletons
  37360. */
  37361. skeletons: Skeleton[];
  37362. /**
  37363. * List of new animation groups
  37364. */
  37365. animationGroups: AnimationGroup[];
  37366. }
  37367. /**
  37368. * Container with a set of assets that can be added or removed from a scene.
  37369. */
  37370. export class AssetContainer extends AbstractScene {
  37371. /**
  37372. * The scene the AssetContainer belongs to.
  37373. */
  37374. scene: Scene;
  37375. /**
  37376. * Instantiates an AssetContainer.
  37377. * @param scene The scene the AssetContainer belongs to.
  37378. */
  37379. constructor(scene: Scene);
  37380. /**
  37381. * Instantiate or clone all meshes and add the new ones to the scene.
  37382. * Skeletons and animation groups will all be cloned
  37383. * @param nameFunction defines an optional function used to get new names for clones
  37384. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37385. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37386. */
  37387. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37388. /**
  37389. * Adds all the assets from the container to the scene.
  37390. */
  37391. addAllToScene(): void;
  37392. /**
  37393. * Removes all the assets in the container from the scene
  37394. */
  37395. removeAllFromScene(): void;
  37396. /**
  37397. * Disposes all the assets in the container
  37398. */
  37399. dispose(): void;
  37400. private _moveAssets;
  37401. /**
  37402. * Removes all the assets contained in the scene and adds them to the container.
  37403. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37404. */
  37405. moveAllFromScene(keepAssets?: KeepAssets): void;
  37406. /**
  37407. * 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.
  37408. * @returns the root mesh
  37409. */
  37410. createRootMesh(): Mesh;
  37411. }
  37412. }
  37413. declare module "babylonjs/abstractScene" {
  37414. import { Scene } from "babylonjs/scene";
  37415. import { Nullable } from "babylonjs/types";
  37416. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37417. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37418. import { Geometry } from "babylonjs/Meshes/geometry";
  37419. import { Skeleton } from "babylonjs/Bones/skeleton";
  37420. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  37421. import { AssetContainer } from "babylonjs/assetContainer";
  37422. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  37423. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37424. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37425. import { Material } from "babylonjs/Materials/material";
  37426. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  37427. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  37428. import { Camera } from "babylonjs/Cameras/camera";
  37429. import { Light } from "babylonjs/Lights/light";
  37430. import { Node } from "babylonjs/node";
  37431. import { Animation } from "babylonjs/Animations/animation";
  37432. /**
  37433. * Defines how the parser contract is defined.
  37434. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37435. */
  37436. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37437. /**
  37438. * Defines how the individual parser contract is defined.
  37439. * These parser can parse an individual asset
  37440. */
  37441. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37442. /**
  37443. * Base class of the scene acting as a container for the different elements composing a scene.
  37444. * This class is dynamically extended by the different components of the scene increasing
  37445. * flexibility and reducing coupling
  37446. */
  37447. export abstract class AbstractScene {
  37448. /**
  37449. * Stores the list of available parsers in the application.
  37450. */
  37451. private static _BabylonFileParsers;
  37452. /**
  37453. * Stores the list of available individual parsers in the application.
  37454. */
  37455. private static _IndividualBabylonFileParsers;
  37456. /**
  37457. * Adds a parser in the list of available ones
  37458. * @param name Defines the name of the parser
  37459. * @param parser Defines the parser to add
  37460. */
  37461. static AddParser(name: string, parser: BabylonFileParser): void;
  37462. /**
  37463. * Gets a general parser from the list of avaialble ones
  37464. * @param name Defines the name of the parser
  37465. * @returns the requested parser or null
  37466. */
  37467. static GetParser(name: string): Nullable<BabylonFileParser>;
  37468. /**
  37469. * Adds n individual parser in the list of available ones
  37470. * @param name Defines the name of the parser
  37471. * @param parser Defines the parser to add
  37472. */
  37473. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37474. /**
  37475. * Gets an individual parser from the list of avaialble ones
  37476. * @param name Defines the name of the parser
  37477. * @returns the requested parser or null
  37478. */
  37479. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37480. /**
  37481. * Parser json data and populate both a scene and its associated container object
  37482. * @param jsonData Defines the data to parse
  37483. * @param scene Defines the scene to parse the data for
  37484. * @param container Defines the container attached to the parsing sequence
  37485. * @param rootUrl Defines the root url of the data
  37486. */
  37487. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37488. /**
  37489. * Gets the list of root nodes (ie. nodes with no parent)
  37490. */
  37491. rootNodes: Node[];
  37492. /** All of the cameras added to this scene
  37493. * @see http://doc.babylonjs.com/babylon101/cameras
  37494. */
  37495. cameras: Camera[];
  37496. /**
  37497. * All of the lights added to this scene
  37498. * @see http://doc.babylonjs.com/babylon101/lights
  37499. */
  37500. lights: Light[];
  37501. /**
  37502. * All of the (abstract) meshes added to this scene
  37503. */
  37504. meshes: AbstractMesh[];
  37505. /**
  37506. * The list of skeletons added to the scene
  37507. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37508. */
  37509. skeletons: Skeleton[];
  37510. /**
  37511. * All of the particle systems added to this scene
  37512. * @see http://doc.babylonjs.com/babylon101/particles
  37513. */
  37514. particleSystems: IParticleSystem[];
  37515. /**
  37516. * Gets a list of Animations associated with the scene
  37517. */
  37518. animations: Animation[];
  37519. /**
  37520. * All of the animation groups added to this scene
  37521. * @see http://doc.babylonjs.com/how_to/group
  37522. */
  37523. animationGroups: AnimationGroup[];
  37524. /**
  37525. * All of the multi-materials added to this scene
  37526. * @see http://doc.babylonjs.com/how_to/multi_materials
  37527. */
  37528. multiMaterials: MultiMaterial[];
  37529. /**
  37530. * All of the materials added to this scene
  37531. * In the context of a Scene, it is not supposed to be modified manually.
  37532. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37533. * Note also that the order of the Material within the array is not significant and might change.
  37534. * @see http://doc.babylonjs.com/babylon101/materials
  37535. */
  37536. materials: Material[];
  37537. /**
  37538. * The list of morph target managers added to the scene
  37539. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37540. */
  37541. morphTargetManagers: MorphTargetManager[];
  37542. /**
  37543. * The list of geometries used in the scene.
  37544. */
  37545. geometries: Geometry[];
  37546. /**
  37547. * All of the tranform nodes added to this scene
  37548. * In the context of a Scene, it is not supposed to be modified manually.
  37549. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37550. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37551. * @see http://doc.babylonjs.com/how_to/transformnode
  37552. */
  37553. transformNodes: TransformNode[];
  37554. /**
  37555. * ActionManagers available on the scene.
  37556. */
  37557. actionManagers: AbstractActionManager[];
  37558. /**
  37559. * Textures to keep.
  37560. */
  37561. textures: BaseTexture[];
  37562. /**
  37563. * Environment texture for the scene
  37564. */
  37565. environmentTexture: Nullable<BaseTexture>;
  37566. }
  37567. }
  37568. declare module "babylonjs/Audio/sound" {
  37569. import { Observable } from "babylonjs/Misc/observable";
  37570. import { Vector3 } from "babylonjs/Maths/math.vector";
  37571. import { Nullable } from "babylonjs/types";
  37572. import { Scene } from "babylonjs/scene";
  37573. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37574. /**
  37575. * Interface used to define options for Sound class
  37576. */
  37577. export interface ISoundOptions {
  37578. /**
  37579. * Does the sound autoplay once loaded.
  37580. */
  37581. autoplay?: boolean;
  37582. /**
  37583. * Does the sound loop after it finishes playing once.
  37584. */
  37585. loop?: boolean;
  37586. /**
  37587. * Sound's volume
  37588. */
  37589. volume?: number;
  37590. /**
  37591. * Is it a spatial sound?
  37592. */
  37593. spatialSound?: boolean;
  37594. /**
  37595. * Maximum distance to hear that sound
  37596. */
  37597. maxDistance?: number;
  37598. /**
  37599. * Uses user defined attenuation function
  37600. */
  37601. useCustomAttenuation?: boolean;
  37602. /**
  37603. * Define the roll off factor of spatial sounds.
  37604. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37605. */
  37606. rolloffFactor?: number;
  37607. /**
  37608. * Define the reference distance the sound should be heard perfectly.
  37609. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37610. */
  37611. refDistance?: number;
  37612. /**
  37613. * Define the distance attenuation model the sound will follow.
  37614. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37615. */
  37616. distanceModel?: string;
  37617. /**
  37618. * Defines the playback speed (1 by default)
  37619. */
  37620. playbackRate?: number;
  37621. /**
  37622. * Defines if the sound is from a streaming source
  37623. */
  37624. streaming?: boolean;
  37625. /**
  37626. * Defines an optional length (in seconds) inside the sound file
  37627. */
  37628. length?: number;
  37629. /**
  37630. * Defines an optional offset (in seconds) inside the sound file
  37631. */
  37632. offset?: number;
  37633. /**
  37634. * If true, URLs will not be required to state the audio file codec to use.
  37635. */
  37636. skipCodecCheck?: boolean;
  37637. }
  37638. /**
  37639. * Defines a sound that can be played in the application.
  37640. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37641. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37642. */
  37643. export class Sound {
  37644. /**
  37645. * The name of the sound in the scene.
  37646. */
  37647. name: string;
  37648. /**
  37649. * Does the sound autoplay once loaded.
  37650. */
  37651. autoplay: boolean;
  37652. /**
  37653. * Does the sound loop after it finishes playing once.
  37654. */
  37655. loop: boolean;
  37656. /**
  37657. * Does the sound use a custom attenuation curve to simulate the falloff
  37658. * happening when the source gets further away from the camera.
  37659. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37660. */
  37661. useCustomAttenuation: boolean;
  37662. /**
  37663. * The sound track id this sound belongs to.
  37664. */
  37665. soundTrackId: number;
  37666. /**
  37667. * Is this sound currently played.
  37668. */
  37669. isPlaying: boolean;
  37670. /**
  37671. * Is this sound currently paused.
  37672. */
  37673. isPaused: boolean;
  37674. /**
  37675. * Does this sound enables spatial sound.
  37676. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37677. */
  37678. spatialSound: boolean;
  37679. /**
  37680. * Define the reference distance the sound should be heard perfectly.
  37681. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37682. */
  37683. refDistance: number;
  37684. /**
  37685. * Define the roll off factor of spatial sounds.
  37686. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37687. */
  37688. rolloffFactor: number;
  37689. /**
  37690. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37691. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37692. */
  37693. maxDistance: number;
  37694. /**
  37695. * Define the distance attenuation model the sound will follow.
  37696. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37697. */
  37698. distanceModel: string;
  37699. /**
  37700. * @hidden
  37701. * Back Compat
  37702. **/
  37703. onended: () => any;
  37704. /**
  37705. * Observable event when the current playing sound finishes.
  37706. */
  37707. onEndedObservable: Observable<Sound>;
  37708. private _panningModel;
  37709. private _playbackRate;
  37710. private _streaming;
  37711. private _startTime;
  37712. private _startOffset;
  37713. private _position;
  37714. /** @hidden */
  37715. _positionInEmitterSpace: boolean;
  37716. private _localDirection;
  37717. private _volume;
  37718. private _isReadyToPlay;
  37719. private _isDirectional;
  37720. private _readyToPlayCallback;
  37721. private _audioBuffer;
  37722. private _soundSource;
  37723. private _streamingSource;
  37724. private _soundPanner;
  37725. private _soundGain;
  37726. private _inputAudioNode;
  37727. private _outputAudioNode;
  37728. private _coneInnerAngle;
  37729. private _coneOuterAngle;
  37730. private _coneOuterGain;
  37731. private _scene;
  37732. private _connectedTransformNode;
  37733. private _customAttenuationFunction;
  37734. private _registerFunc;
  37735. private _isOutputConnected;
  37736. private _htmlAudioElement;
  37737. private _urlType;
  37738. private _length?;
  37739. private _offset?;
  37740. /** @hidden */
  37741. static _SceneComponentInitialization: (scene: Scene) => void;
  37742. /**
  37743. * Create a sound and attach it to a scene
  37744. * @param name Name of your sound
  37745. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37746. * @param scene defines the scene the sound belongs to
  37747. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37748. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37749. */
  37750. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37751. /**
  37752. * Release the sound and its associated resources
  37753. */
  37754. dispose(): void;
  37755. /**
  37756. * Gets if the sounds is ready to be played or not.
  37757. * @returns true if ready, otherwise false
  37758. */
  37759. isReady(): boolean;
  37760. private _soundLoaded;
  37761. /**
  37762. * Sets the data of the sound from an audiobuffer
  37763. * @param audioBuffer The audioBuffer containing the data
  37764. */
  37765. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37766. /**
  37767. * Updates the current sounds options such as maxdistance, loop...
  37768. * @param options A JSON object containing values named as the object properties
  37769. */
  37770. updateOptions(options: ISoundOptions): void;
  37771. private _createSpatialParameters;
  37772. private _updateSpatialParameters;
  37773. /**
  37774. * Switch the panning model to HRTF:
  37775. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37776. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37777. */
  37778. switchPanningModelToHRTF(): void;
  37779. /**
  37780. * Switch the panning model to Equal Power:
  37781. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37782. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37783. */
  37784. switchPanningModelToEqualPower(): void;
  37785. private _switchPanningModel;
  37786. /**
  37787. * Connect this sound to a sound track audio node like gain...
  37788. * @param soundTrackAudioNode the sound track audio node to connect to
  37789. */
  37790. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37791. /**
  37792. * Transform this sound into a directional source
  37793. * @param coneInnerAngle Size of the inner cone in degree
  37794. * @param coneOuterAngle Size of the outer cone in degree
  37795. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37796. */
  37797. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37798. /**
  37799. * Gets or sets the inner angle for the directional cone.
  37800. */
  37801. /**
  37802. * Gets or sets the inner angle for the directional cone.
  37803. */
  37804. directionalConeInnerAngle: number;
  37805. /**
  37806. * Gets or sets the outer angle for the directional cone.
  37807. */
  37808. /**
  37809. * Gets or sets the outer angle for the directional cone.
  37810. */
  37811. directionalConeOuterAngle: number;
  37812. /**
  37813. * Sets the position of the emitter if spatial sound is enabled
  37814. * @param newPosition Defines the new posisiton
  37815. */
  37816. setPosition(newPosition: Vector3): void;
  37817. /**
  37818. * Sets the local direction of the emitter if spatial sound is enabled
  37819. * @param newLocalDirection Defines the new local direction
  37820. */
  37821. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37822. private _updateDirection;
  37823. /** @hidden */
  37824. updateDistanceFromListener(): void;
  37825. /**
  37826. * Sets a new custom attenuation function for the sound.
  37827. * @param callback Defines the function used for the attenuation
  37828. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37829. */
  37830. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37831. /**
  37832. * Play the sound
  37833. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37834. * @param offset (optional) Start the sound at a specific time in seconds
  37835. * @param length (optional) Sound duration (in seconds)
  37836. */
  37837. play(time?: number, offset?: number, length?: number): void;
  37838. private _onended;
  37839. /**
  37840. * Stop the sound
  37841. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37842. */
  37843. stop(time?: number): void;
  37844. /**
  37845. * Put the sound in pause
  37846. */
  37847. pause(): void;
  37848. /**
  37849. * Sets a dedicated volume for this sounds
  37850. * @param newVolume Define the new volume of the sound
  37851. * @param time Define time for gradual change to new volume
  37852. */
  37853. setVolume(newVolume: number, time?: number): void;
  37854. /**
  37855. * Set the sound play back rate
  37856. * @param newPlaybackRate Define the playback rate the sound should be played at
  37857. */
  37858. setPlaybackRate(newPlaybackRate: number): void;
  37859. /**
  37860. * Gets the volume of the sound.
  37861. * @returns the volume of the sound
  37862. */
  37863. getVolume(): number;
  37864. /**
  37865. * Attach the sound to a dedicated mesh
  37866. * @param transformNode The transform node to connect the sound with
  37867. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37868. */
  37869. attachToMesh(transformNode: TransformNode): void;
  37870. /**
  37871. * Detach the sound from the previously attached mesh
  37872. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37873. */
  37874. detachFromMesh(): void;
  37875. private _onRegisterAfterWorldMatrixUpdate;
  37876. /**
  37877. * Clone the current sound in the scene.
  37878. * @returns the new sound clone
  37879. */
  37880. clone(): Nullable<Sound>;
  37881. /**
  37882. * Gets the current underlying audio buffer containing the data
  37883. * @returns the audio buffer
  37884. */
  37885. getAudioBuffer(): Nullable<AudioBuffer>;
  37886. /**
  37887. * Serializes the Sound in a JSON representation
  37888. * @returns the JSON representation of the sound
  37889. */
  37890. serialize(): any;
  37891. /**
  37892. * Parse a JSON representation of a sound to innstantiate in a given scene
  37893. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37894. * @param scene Define the scene the new parsed sound should be created in
  37895. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37896. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37897. * @returns the newly parsed sound
  37898. */
  37899. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37900. }
  37901. }
  37902. declare module "babylonjs/Actions/directAudioActions" {
  37903. import { Action } from "babylonjs/Actions/action";
  37904. import { Condition } from "babylonjs/Actions/condition";
  37905. import { Sound } from "babylonjs/Audio/sound";
  37906. /**
  37907. * This defines an action helpful to play a defined sound on a triggered action.
  37908. */
  37909. export class PlaySoundAction extends Action {
  37910. private _sound;
  37911. /**
  37912. * Instantiate the action
  37913. * @param triggerOptions defines the trigger options
  37914. * @param sound defines the sound to play
  37915. * @param condition defines the trigger related conditions
  37916. */
  37917. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37918. /** @hidden */
  37919. _prepare(): void;
  37920. /**
  37921. * Execute the action and play the sound.
  37922. */
  37923. execute(): void;
  37924. /**
  37925. * Serializes the actions and its related information.
  37926. * @param parent defines the object to serialize in
  37927. * @returns the serialized object
  37928. */
  37929. serialize(parent: any): any;
  37930. }
  37931. /**
  37932. * This defines an action helpful to stop a defined sound on a triggered action.
  37933. */
  37934. export class StopSoundAction extends Action {
  37935. private _sound;
  37936. /**
  37937. * Instantiate the action
  37938. * @param triggerOptions defines the trigger options
  37939. * @param sound defines the sound to stop
  37940. * @param condition defines the trigger related conditions
  37941. */
  37942. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37943. /** @hidden */
  37944. _prepare(): void;
  37945. /**
  37946. * Execute the action and stop the sound.
  37947. */
  37948. execute(): void;
  37949. /**
  37950. * Serializes the actions and its related information.
  37951. * @param parent defines the object to serialize in
  37952. * @returns the serialized object
  37953. */
  37954. serialize(parent: any): any;
  37955. }
  37956. }
  37957. declare module "babylonjs/Actions/interpolateValueAction" {
  37958. import { Action } from "babylonjs/Actions/action";
  37959. import { Condition } from "babylonjs/Actions/condition";
  37960. import { Observable } from "babylonjs/Misc/observable";
  37961. /**
  37962. * This defines an action responsible to change the value of a property
  37963. * by interpolating between its current value and the newly set one once triggered.
  37964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37965. */
  37966. export class InterpolateValueAction extends Action {
  37967. /**
  37968. * Defines the path of the property where the value should be interpolated
  37969. */
  37970. propertyPath: string;
  37971. /**
  37972. * Defines the target value at the end of the interpolation.
  37973. */
  37974. value: any;
  37975. /**
  37976. * Defines the time it will take for the property to interpolate to the value.
  37977. */
  37978. duration: number;
  37979. /**
  37980. * Defines if the other scene animations should be stopped when the action has been triggered
  37981. */
  37982. stopOtherAnimations?: boolean;
  37983. /**
  37984. * Defines a callback raised once the interpolation animation has been done.
  37985. */
  37986. onInterpolationDone?: () => void;
  37987. /**
  37988. * Observable triggered once the interpolation animation has been done.
  37989. */
  37990. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  37991. private _target;
  37992. private _effectiveTarget;
  37993. private _property;
  37994. /**
  37995. * Instantiate the action
  37996. * @param triggerOptions defines the trigger options
  37997. * @param target defines the object containing the value to interpolate
  37998. * @param propertyPath defines the path to the property in the target object
  37999. * @param value defines the target value at the end of the interpolation
  38000. * @param duration deines the time it will take for the property to interpolate to the value.
  38001. * @param condition defines the trigger related conditions
  38002. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38003. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38004. */
  38005. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38006. /** @hidden */
  38007. _prepare(): void;
  38008. /**
  38009. * Execute the action starts the value interpolation.
  38010. */
  38011. execute(): void;
  38012. /**
  38013. * Serializes the actions and its related information.
  38014. * @param parent defines the object to serialize in
  38015. * @returns the serialized object
  38016. */
  38017. serialize(parent: any): any;
  38018. }
  38019. }
  38020. declare module "babylonjs/Actions/index" {
  38021. export * from "babylonjs/Actions/abstractActionManager";
  38022. export * from "babylonjs/Actions/action";
  38023. export * from "babylonjs/Actions/actionEvent";
  38024. export * from "babylonjs/Actions/actionManager";
  38025. export * from "babylonjs/Actions/condition";
  38026. export * from "babylonjs/Actions/directActions";
  38027. export * from "babylonjs/Actions/directAudioActions";
  38028. export * from "babylonjs/Actions/interpolateValueAction";
  38029. }
  38030. declare module "babylonjs/Animations/index" {
  38031. export * from "babylonjs/Animations/animatable";
  38032. export * from "babylonjs/Animations/animation";
  38033. export * from "babylonjs/Animations/animationGroup";
  38034. export * from "babylonjs/Animations/animationPropertiesOverride";
  38035. export * from "babylonjs/Animations/easing";
  38036. export * from "babylonjs/Animations/runtimeAnimation";
  38037. export * from "babylonjs/Animations/animationEvent";
  38038. export * from "babylonjs/Animations/animationGroup";
  38039. export * from "babylonjs/Animations/animationKey";
  38040. export * from "babylonjs/Animations/animationRange";
  38041. export * from "babylonjs/Animations/animatable.interface";
  38042. }
  38043. declare module "babylonjs/Audio/soundTrack" {
  38044. import { Sound } from "babylonjs/Audio/sound";
  38045. import { Analyser } from "babylonjs/Audio/analyser";
  38046. import { Scene } from "babylonjs/scene";
  38047. /**
  38048. * Options allowed during the creation of a sound track.
  38049. */
  38050. export interface ISoundTrackOptions {
  38051. /**
  38052. * The volume the sound track should take during creation
  38053. */
  38054. volume?: number;
  38055. /**
  38056. * Define if the sound track is the main sound track of the scene
  38057. */
  38058. mainTrack?: boolean;
  38059. }
  38060. /**
  38061. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38062. * It will be also used in a future release to apply effects on a specific track.
  38063. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38064. */
  38065. export class SoundTrack {
  38066. /**
  38067. * The unique identifier of the sound track in the scene.
  38068. */
  38069. id: number;
  38070. /**
  38071. * The list of sounds included in the sound track.
  38072. */
  38073. soundCollection: Array<Sound>;
  38074. private _outputAudioNode;
  38075. private _scene;
  38076. private _connectedAnalyser;
  38077. private _options;
  38078. private _isInitialized;
  38079. /**
  38080. * Creates a new sound track.
  38081. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38082. * @param scene Define the scene the sound track belongs to
  38083. * @param options
  38084. */
  38085. constructor(scene: Scene, options?: ISoundTrackOptions);
  38086. private _initializeSoundTrackAudioGraph;
  38087. /**
  38088. * Release the sound track and its associated resources
  38089. */
  38090. dispose(): void;
  38091. /**
  38092. * Adds a sound to this sound track
  38093. * @param sound define the cound to add
  38094. * @ignoreNaming
  38095. */
  38096. AddSound(sound: Sound): void;
  38097. /**
  38098. * Removes a sound to this sound track
  38099. * @param sound define the cound to remove
  38100. * @ignoreNaming
  38101. */
  38102. RemoveSound(sound: Sound): void;
  38103. /**
  38104. * Set a global volume for the full sound track.
  38105. * @param newVolume Define the new volume of the sound track
  38106. */
  38107. setVolume(newVolume: number): void;
  38108. /**
  38109. * Switch the panning model to HRTF:
  38110. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38111. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38112. */
  38113. switchPanningModelToHRTF(): void;
  38114. /**
  38115. * Switch the panning model to Equal Power:
  38116. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38117. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38118. */
  38119. switchPanningModelToEqualPower(): void;
  38120. /**
  38121. * Connect the sound track to an audio analyser allowing some amazing
  38122. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38123. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38124. * @param analyser The analyser to connect to the engine
  38125. */
  38126. connectToAnalyser(analyser: Analyser): void;
  38127. }
  38128. }
  38129. declare module "babylonjs/Audio/audioSceneComponent" {
  38130. import { Sound } from "babylonjs/Audio/sound";
  38131. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  38132. import { Nullable } from "babylonjs/types";
  38133. import { Vector3 } from "babylonjs/Maths/math.vector";
  38134. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  38135. import { Scene } from "babylonjs/scene";
  38136. import { AbstractScene } from "babylonjs/abstractScene";
  38137. import "babylonjs/Audio/audioEngine";
  38138. module "babylonjs/abstractScene" {
  38139. interface AbstractScene {
  38140. /**
  38141. * The list of sounds used in the scene.
  38142. */
  38143. sounds: Nullable<Array<Sound>>;
  38144. }
  38145. }
  38146. module "babylonjs/scene" {
  38147. interface Scene {
  38148. /**
  38149. * @hidden
  38150. * Backing field
  38151. */
  38152. _mainSoundTrack: SoundTrack;
  38153. /**
  38154. * The main sound track played by the scene.
  38155. * It cotains your primary collection of sounds.
  38156. */
  38157. mainSoundTrack: SoundTrack;
  38158. /**
  38159. * The list of sound tracks added to the scene
  38160. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38161. */
  38162. soundTracks: Nullable<Array<SoundTrack>>;
  38163. /**
  38164. * Gets a sound using a given name
  38165. * @param name defines the name to search for
  38166. * @return the found sound or null if not found at all.
  38167. */
  38168. getSoundByName(name: string): Nullable<Sound>;
  38169. /**
  38170. * Gets or sets if audio support is enabled
  38171. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38172. */
  38173. audioEnabled: boolean;
  38174. /**
  38175. * Gets or sets if audio will be output to headphones
  38176. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38177. */
  38178. headphone: boolean;
  38179. /**
  38180. * Gets or sets custom audio listener position provider
  38181. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38182. */
  38183. audioListenerPositionProvider: Nullable<() => Vector3>;
  38184. /**
  38185. * Gets or sets a refresh rate when using 3D audio positioning
  38186. */
  38187. audioPositioningRefreshRate: number;
  38188. }
  38189. }
  38190. /**
  38191. * Defines the sound scene component responsible to manage any sounds
  38192. * in a given scene.
  38193. */
  38194. export class AudioSceneComponent implements ISceneSerializableComponent {
  38195. /**
  38196. * The component name helpfull to identify the component in the list of scene components.
  38197. */
  38198. readonly name: string;
  38199. /**
  38200. * The scene the component belongs to.
  38201. */
  38202. scene: Scene;
  38203. private _audioEnabled;
  38204. /**
  38205. * Gets whether audio is enabled or not.
  38206. * Please use related enable/disable method to switch state.
  38207. */
  38208. readonly audioEnabled: boolean;
  38209. private _headphone;
  38210. /**
  38211. * Gets whether audio is outputing to headphone or not.
  38212. * Please use the according Switch methods to change output.
  38213. */
  38214. readonly headphone: boolean;
  38215. /**
  38216. * Gets or sets a refresh rate when using 3D audio positioning
  38217. */
  38218. audioPositioningRefreshRate: number;
  38219. private _audioListenerPositionProvider;
  38220. /**
  38221. * Gets the current audio listener position provider
  38222. */
  38223. /**
  38224. * Sets a custom listener position for all sounds in the scene
  38225. * By default, this is the position of the first active camera
  38226. */
  38227. audioListenerPositionProvider: Nullable<() => Vector3>;
  38228. /**
  38229. * Creates a new instance of the component for the given scene
  38230. * @param scene Defines the scene to register the component in
  38231. */
  38232. constructor(scene: Scene);
  38233. /**
  38234. * Registers the component in a given scene
  38235. */
  38236. register(): void;
  38237. /**
  38238. * Rebuilds the elements related to this component in case of
  38239. * context lost for instance.
  38240. */
  38241. rebuild(): void;
  38242. /**
  38243. * Serializes the component data to the specified json object
  38244. * @param serializationObject The object to serialize to
  38245. */
  38246. serialize(serializationObject: any): void;
  38247. /**
  38248. * Adds all the elements from the container to the scene
  38249. * @param container the container holding the elements
  38250. */
  38251. addFromContainer(container: AbstractScene): void;
  38252. /**
  38253. * Removes all the elements in the container from the scene
  38254. * @param container contains the elements to remove
  38255. * @param dispose if the removed element should be disposed (default: false)
  38256. */
  38257. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38258. /**
  38259. * Disposes the component and the associated ressources.
  38260. */
  38261. dispose(): void;
  38262. /**
  38263. * Disables audio in the associated scene.
  38264. */
  38265. disableAudio(): void;
  38266. /**
  38267. * Enables audio in the associated scene.
  38268. */
  38269. enableAudio(): void;
  38270. /**
  38271. * Switch audio to headphone output.
  38272. */
  38273. switchAudioModeForHeadphones(): void;
  38274. /**
  38275. * Switch audio to normal speakers.
  38276. */
  38277. switchAudioModeForNormalSpeakers(): void;
  38278. private _cachedCameraDirection;
  38279. private _cachedCameraPosition;
  38280. private _lastCheck;
  38281. private _afterRender;
  38282. }
  38283. }
  38284. declare module "babylonjs/Audio/weightedsound" {
  38285. import { Sound } from "babylonjs/Audio/sound";
  38286. /**
  38287. * Wraps one or more Sound objects and selects one with random weight for playback.
  38288. */
  38289. export class WeightedSound {
  38290. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38291. loop: boolean;
  38292. private _coneInnerAngle;
  38293. private _coneOuterAngle;
  38294. private _volume;
  38295. /** A Sound is currently playing. */
  38296. isPlaying: boolean;
  38297. /** A Sound is currently paused. */
  38298. isPaused: boolean;
  38299. private _sounds;
  38300. private _weights;
  38301. private _currentIndex?;
  38302. /**
  38303. * Creates a new WeightedSound from the list of sounds given.
  38304. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38305. * @param sounds Array of Sounds that will be selected from.
  38306. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38307. */
  38308. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38309. /**
  38310. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38311. */
  38312. /**
  38313. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38314. */
  38315. directionalConeInnerAngle: number;
  38316. /**
  38317. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38318. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38319. */
  38320. /**
  38321. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38322. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38323. */
  38324. directionalConeOuterAngle: number;
  38325. /**
  38326. * Playback volume.
  38327. */
  38328. /**
  38329. * Playback volume.
  38330. */
  38331. volume: number;
  38332. private _onended;
  38333. /**
  38334. * Suspend playback
  38335. */
  38336. pause(): void;
  38337. /**
  38338. * Stop playback
  38339. */
  38340. stop(): void;
  38341. /**
  38342. * Start playback.
  38343. * @param startOffset Position the clip head at a specific time in seconds.
  38344. */
  38345. play(startOffset?: number): void;
  38346. }
  38347. }
  38348. declare module "babylonjs/Audio/index" {
  38349. export * from "babylonjs/Audio/analyser";
  38350. export * from "babylonjs/Audio/audioEngine";
  38351. export * from "babylonjs/Audio/audioSceneComponent";
  38352. export * from "babylonjs/Audio/sound";
  38353. export * from "babylonjs/Audio/soundTrack";
  38354. export * from "babylonjs/Audio/weightedsound";
  38355. }
  38356. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  38357. import { Behavior } from "babylonjs/Behaviors/behavior";
  38358. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38359. import { BackEase } from "babylonjs/Animations/easing";
  38360. /**
  38361. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38362. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38363. */
  38364. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38365. /**
  38366. * Gets the name of the behavior.
  38367. */
  38368. readonly name: string;
  38369. /**
  38370. * The easing function used by animations
  38371. */
  38372. static EasingFunction: BackEase;
  38373. /**
  38374. * The easing mode used by animations
  38375. */
  38376. static EasingMode: number;
  38377. /**
  38378. * The duration of the animation, in milliseconds
  38379. */
  38380. transitionDuration: number;
  38381. /**
  38382. * Length of the distance animated by the transition when lower radius is reached
  38383. */
  38384. lowerRadiusTransitionRange: number;
  38385. /**
  38386. * Length of the distance animated by the transition when upper radius is reached
  38387. */
  38388. upperRadiusTransitionRange: number;
  38389. private _autoTransitionRange;
  38390. /**
  38391. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38392. */
  38393. /**
  38394. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38395. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38396. */
  38397. autoTransitionRange: boolean;
  38398. private _attachedCamera;
  38399. private _onAfterCheckInputsObserver;
  38400. private _onMeshTargetChangedObserver;
  38401. /**
  38402. * Initializes the behavior.
  38403. */
  38404. init(): void;
  38405. /**
  38406. * Attaches the behavior to its arc rotate camera.
  38407. * @param camera Defines the camera to attach the behavior to
  38408. */
  38409. attach(camera: ArcRotateCamera): void;
  38410. /**
  38411. * Detaches the behavior from its current arc rotate camera.
  38412. */
  38413. detach(): void;
  38414. private _radiusIsAnimating;
  38415. private _radiusBounceTransition;
  38416. private _animatables;
  38417. private _cachedWheelPrecision;
  38418. /**
  38419. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38420. * @param radiusLimit The limit to check against.
  38421. * @return Bool to indicate if at limit.
  38422. */
  38423. private _isRadiusAtLimit;
  38424. /**
  38425. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38426. * @param radiusDelta The delta by which to animate to. Can be negative.
  38427. */
  38428. private _applyBoundRadiusAnimation;
  38429. /**
  38430. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38431. */
  38432. protected _clearAnimationLocks(): void;
  38433. /**
  38434. * Stops and removes all animations that have been applied to the camera
  38435. */
  38436. stopAllAnimations(): void;
  38437. }
  38438. }
  38439. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  38440. import { Behavior } from "babylonjs/Behaviors/behavior";
  38441. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38442. import { ExponentialEase } from "babylonjs/Animations/easing";
  38443. import { Nullable } from "babylonjs/types";
  38444. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38445. import { Vector3 } from "babylonjs/Maths/math.vector";
  38446. /**
  38447. * 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.
  38448. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38449. */
  38450. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38451. /**
  38452. * Gets the name of the behavior.
  38453. */
  38454. readonly name: string;
  38455. private _mode;
  38456. private _radiusScale;
  38457. private _positionScale;
  38458. private _defaultElevation;
  38459. private _elevationReturnTime;
  38460. private _elevationReturnWaitTime;
  38461. private _zoomStopsAnimation;
  38462. private _framingTime;
  38463. /**
  38464. * The easing function used by animations
  38465. */
  38466. static EasingFunction: ExponentialEase;
  38467. /**
  38468. * The easing mode used by animations
  38469. */
  38470. static EasingMode: number;
  38471. /**
  38472. * Sets the current mode used by the behavior
  38473. */
  38474. /**
  38475. * Gets current mode used by the behavior.
  38476. */
  38477. mode: number;
  38478. /**
  38479. * Sets the scale applied to the radius (1 by default)
  38480. */
  38481. /**
  38482. * Gets the scale applied to the radius
  38483. */
  38484. radiusScale: number;
  38485. /**
  38486. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38487. */
  38488. /**
  38489. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38490. */
  38491. positionScale: number;
  38492. /**
  38493. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38494. * behaviour is triggered, in radians.
  38495. */
  38496. /**
  38497. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38498. * behaviour is triggered, in radians.
  38499. */
  38500. defaultElevation: number;
  38501. /**
  38502. * Sets the time (in milliseconds) taken to return to the default beta position.
  38503. * Negative value indicates camera should not return to default.
  38504. */
  38505. /**
  38506. * Gets the time (in milliseconds) taken to return to the default beta position.
  38507. * Negative value indicates camera should not return to default.
  38508. */
  38509. elevationReturnTime: number;
  38510. /**
  38511. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38512. */
  38513. /**
  38514. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38515. */
  38516. elevationReturnWaitTime: number;
  38517. /**
  38518. * Sets the flag that indicates if user zooming should stop animation.
  38519. */
  38520. /**
  38521. * Gets the flag that indicates if user zooming should stop animation.
  38522. */
  38523. zoomStopsAnimation: boolean;
  38524. /**
  38525. * Sets the transition time when framing the mesh, in milliseconds
  38526. */
  38527. /**
  38528. * Gets the transition time when framing the mesh, in milliseconds
  38529. */
  38530. framingTime: number;
  38531. /**
  38532. * Define if the behavior should automatically change the configured
  38533. * camera limits and sensibilities.
  38534. */
  38535. autoCorrectCameraLimitsAndSensibility: boolean;
  38536. private _onPrePointerObservableObserver;
  38537. private _onAfterCheckInputsObserver;
  38538. private _onMeshTargetChangedObserver;
  38539. private _attachedCamera;
  38540. private _isPointerDown;
  38541. private _lastInteractionTime;
  38542. /**
  38543. * Initializes the behavior.
  38544. */
  38545. init(): void;
  38546. /**
  38547. * Attaches the behavior to its arc rotate camera.
  38548. * @param camera Defines the camera to attach the behavior to
  38549. */
  38550. attach(camera: ArcRotateCamera): void;
  38551. /**
  38552. * Detaches the behavior from its current arc rotate camera.
  38553. */
  38554. detach(): void;
  38555. private _animatables;
  38556. private _betaIsAnimating;
  38557. private _betaTransition;
  38558. private _radiusTransition;
  38559. private _vectorTransition;
  38560. /**
  38561. * Targets the given mesh and updates zoom level accordingly.
  38562. * @param mesh The mesh to target.
  38563. * @param radius Optional. If a cached radius position already exists, overrides default.
  38564. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38565. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38566. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38567. */
  38568. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38569. /**
  38570. * Targets the given mesh with its children and updates zoom level accordingly.
  38571. * @param mesh The mesh to target.
  38572. * @param radius Optional. If a cached radius position already exists, overrides default.
  38573. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38574. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38575. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38576. */
  38577. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38578. /**
  38579. * Targets the given meshes with their children and updates zoom level accordingly.
  38580. * @param meshes The mesh to target.
  38581. * @param radius Optional. If a cached radius position already exists, overrides default.
  38582. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38583. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38584. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38585. */
  38586. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38587. /**
  38588. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38589. * @param minimumWorld Determines the smaller position of the bounding box extend
  38590. * @param maximumWorld Determines the bigger position of the bounding box extend
  38591. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38592. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38593. */
  38594. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38595. /**
  38596. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38597. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38598. * frustum width.
  38599. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38600. * to fully enclose the mesh in the viewing frustum.
  38601. */
  38602. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38603. /**
  38604. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38605. * is automatically returned to its default position (expected to be above ground plane).
  38606. */
  38607. private _maintainCameraAboveGround;
  38608. /**
  38609. * Returns the frustum slope based on the canvas ratio and camera FOV
  38610. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38611. */
  38612. private _getFrustumSlope;
  38613. /**
  38614. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38615. */
  38616. private _clearAnimationLocks;
  38617. /**
  38618. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38619. */
  38620. private _applyUserInteraction;
  38621. /**
  38622. * Stops and removes all animations that have been applied to the camera
  38623. */
  38624. stopAllAnimations(): void;
  38625. /**
  38626. * Gets a value indicating if the user is moving the camera
  38627. */
  38628. readonly isUserIsMoving: boolean;
  38629. /**
  38630. * The camera can move all the way towards the mesh.
  38631. */
  38632. static IgnoreBoundsSizeMode: number;
  38633. /**
  38634. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38635. */
  38636. static FitFrustumSidesMode: number;
  38637. }
  38638. }
  38639. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  38640. import { Nullable } from "babylonjs/types";
  38641. import { Camera } from "babylonjs/Cameras/camera";
  38642. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38643. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38644. /**
  38645. * Base class for Camera Pointer Inputs.
  38646. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38647. * for example usage.
  38648. */
  38649. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38650. /**
  38651. * Defines the camera the input is attached to.
  38652. */
  38653. abstract camera: Camera;
  38654. /**
  38655. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38656. */
  38657. protected _altKey: boolean;
  38658. protected _ctrlKey: boolean;
  38659. protected _metaKey: boolean;
  38660. protected _shiftKey: boolean;
  38661. /**
  38662. * Which mouse buttons were pressed at time of last mouse event.
  38663. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38664. */
  38665. protected _buttonsPressed: number;
  38666. /**
  38667. * Defines the buttons associated with the input to handle camera move.
  38668. */
  38669. buttons: number[];
  38670. /**
  38671. * Attach the input controls to a specific dom element to get the input from.
  38672. * @param element Defines the element the controls should be listened from
  38673. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38674. */
  38675. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38676. /**
  38677. * Detach the current controls from the specified dom element.
  38678. * @param element Defines the element to stop listening the inputs from
  38679. */
  38680. detachControl(element: Nullable<HTMLElement>): void;
  38681. /**
  38682. * Gets the class name of the current input.
  38683. * @returns the class name
  38684. */
  38685. getClassName(): string;
  38686. /**
  38687. * Get the friendly name associated with the input class.
  38688. * @returns the input friendly name
  38689. */
  38690. getSimpleName(): string;
  38691. /**
  38692. * Called on pointer POINTERDOUBLETAP event.
  38693. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38694. */
  38695. protected onDoubleTap(type: string): void;
  38696. /**
  38697. * Called on pointer POINTERMOVE event if only a single touch is active.
  38698. * Override this method to provide functionality.
  38699. */
  38700. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38701. /**
  38702. * Called on pointer POINTERMOVE event if multiple touches are active.
  38703. * Override this method to provide functionality.
  38704. */
  38705. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38706. /**
  38707. * Called on JS contextmenu event.
  38708. * Override this method to provide functionality.
  38709. */
  38710. protected onContextMenu(evt: PointerEvent): void;
  38711. /**
  38712. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38713. * press.
  38714. * Override this method to provide functionality.
  38715. */
  38716. protected onButtonDown(evt: PointerEvent): void;
  38717. /**
  38718. * Called each time a new POINTERUP event occurs. Ie, for each button
  38719. * release.
  38720. * Override this method to provide functionality.
  38721. */
  38722. protected onButtonUp(evt: PointerEvent): void;
  38723. /**
  38724. * Called when window becomes inactive.
  38725. * Override this method to provide functionality.
  38726. */
  38727. protected onLostFocus(): void;
  38728. private _pointerInput;
  38729. private _observer;
  38730. private _onLostFocus;
  38731. private pointA;
  38732. private pointB;
  38733. }
  38734. }
  38735. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  38736. import { Nullable } from "babylonjs/types";
  38737. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38738. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38739. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38740. /**
  38741. * Manage the pointers inputs to control an arc rotate camera.
  38742. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38743. */
  38744. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38745. /**
  38746. * Defines the camera the input is attached to.
  38747. */
  38748. camera: ArcRotateCamera;
  38749. /**
  38750. * Gets the class name of the current input.
  38751. * @returns the class name
  38752. */
  38753. getClassName(): string;
  38754. /**
  38755. * Defines the buttons associated with the input to handle camera move.
  38756. */
  38757. buttons: number[];
  38758. /**
  38759. * Defines the pointer angular sensibility along the X axis or how fast is
  38760. * the camera rotating.
  38761. */
  38762. angularSensibilityX: number;
  38763. /**
  38764. * Defines the pointer angular sensibility along the Y axis or how fast is
  38765. * the camera rotating.
  38766. */
  38767. angularSensibilityY: number;
  38768. /**
  38769. * Defines the pointer pinch precision or how fast is the camera zooming.
  38770. */
  38771. pinchPrecision: number;
  38772. /**
  38773. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38774. * from 0.
  38775. * It defines the percentage of current camera.radius to use as delta when
  38776. * pinch zoom is used.
  38777. */
  38778. pinchDeltaPercentage: number;
  38779. /**
  38780. * Defines the pointer panning sensibility or how fast is the camera moving.
  38781. */
  38782. panningSensibility: number;
  38783. /**
  38784. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38785. */
  38786. multiTouchPanning: boolean;
  38787. /**
  38788. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38789. * zoom (pinch) through multitouch.
  38790. */
  38791. multiTouchPanAndZoom: boolean;
  38792. /**
  38793. * Revers pinch action direction.
  38794. */
  38795. pinchInwards: boolean;
  38796. private _isPanClick;
  38797. private _twoFingerActivityCount;
  38798. private _isPinching;
  38799. /**
  38800. * Called on pointer POINTERMOVE event if only a single touch is active.
  38801. */
  38802. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38803. /**
  38804. * Called on pointer POINTERDOUBLETAP event.
  38805. */
  38806. protected onDoubleTap(type: string): void;
  38807. /**
  38808. * Called on pointer POINTERMOVE event if multiple touches are active.
  38809. */
  38810. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38811. /**
  38812. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38813. * press.
  38814. */
  38815. protected onButtonDown(evt: PointerEvent): void;
  38816. /**
  38817. * Called each time a new POINTERUP event occurs. Ie, for each button
  38818. * release.
  38819. */
  38820. protected onButtonUp(evt: PointerEvent): void;
  38821. /**
  38822. * Called when window becomes inactive.
  38823. */
  38824. protected onLostFocus(): void;
  38825. }
  38826. }
  38827. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  38828. import { Nullable } from "babylonjs/types";
  38829. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38830. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38831. /**
  38832. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38833. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38834. */
  38835. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38836. /**
  38837. * Defines the camera the input is attached to.
  38838. */
  38839. camera: ArcRotateCamera;
  38840. /**
  38841. * Defines the list of key codes associated with the up action (increase alpha)
  38842. */
  38843. keysUp: number[];
  38844. /**
  38845. * Defines the list of key codes associated with the down action (decrease alpha)
  38846. */
  38847. keysDown: number[];
  38848. /**
  38849. * Defines the list of key codes associated with the left action (increase beta)
  38850. */
  38851. keysLeft: number[];
  38852. /**
  38853. * Defines the list of key codes associated with the right action (decrease beta)
  38854. */
  38855. keysRight: number[];
  38856. /**
  38857. * Defines the list of key codes associated with the reset action.
  38858. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38859. */
  38860. keysReset: number[];
  38861. /**
  38862. * Defines the panning sensibility of the inputs.
  38863. * (How fast is the camera paning)
  38864. */
  38865. panningSensibility: number;
  38866. /**
  38867. * Defines the zooming sensibility of the inputs.
  38868. * (How fast is the camera zooming)
  38869. */
  38870. zoomingSensibility: number;
  38871. /**
  38872. * Defines wether maintaining the alt key down switch the movement mode from
  38873. * orientation to zoom.
  38874. */
  38875. useAltToZoom: boolean;
  38876. /**
  38877. * Rotation speed of the camera
  38878. */
  38879. angularSpeed: number;
  38880. private _keys;
  38881. private _ctrlPressed;
  38882. private _altPressed;
  38883. private _onCanvasBlurObserver;
  38884. private _onKeyboardObserver;
  38885. private _engine;
  38886. private _scene;
  38887. /**
  38888. * Attach the input controls to a specific dom element to get the input from.
  38889. * @param element Defines the element the controls should be listened from
  38890. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38891. */
  38892. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38893. /**
  38894. * Detach the current controls from the specified dom element.
  38895. * @param element Defines the element to stop listening the inputs from
  38896. */
  38897. detachControl(element: Nullable<HTMLElement>): void;
  38898. /**
  38899. * Update the current camera state depending on the inputs that have been used this frame.
  38900. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38901. */
  38902. checkInputs(): void;
  38903. /**
  38904. * Gets the class name of the current intput.
  38905. * @returns the class name
  38906. */
  38907. getClassName(): string;
  38908. /**
  38909. * Get the friendly name associated with the input class.
  38910. * @returns the input friendly name
  38911. */
  38912. getSimpleName(): string;
  38913. }
  38914. }
  38915. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  38916. import { Nullable } from "babylonjs/types";
  38917. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38918. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38919. /**
  38920. * Manage the mouse wheel inputs to control an arc rotate camera.
  38921. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38922. */
  38923. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38924. /**
  38925. * Defines the camera the input is attached to.
  38926. */
  38927. camera: ArcRotateCamera;
  38928. /**
  38929. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38930. */
  38931. wheelPrecision: number;
  38932. /**
  38933. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38934. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38935. */
  38936. wheelDeltaPercentage: number;
  38937. private _wheel;
  38938. private _observer;
  38939. private computeDeltaFromMouseWheelLegacyEvent;
  38940. /**
  38941. * Attach the input controls to a specific dom element to get the input from.
  38942. * @param element Defines the element the controls should be listened from
  38943. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38944. */
  38945. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38946. /**
  38947. * Detach the current controls from the specified dom element.
  38948. * @param element Defines the element to stop listening the inputs from
  38949. */
  38950. detachControl(element: Nullable<HTMLElement>): void;
  38951. /**
  38952. * Gets the class name of the current intput.
  38953. * @returns the class name
  38954. */
  38955. getClassName(): string;
  38956. /**
  38957. * Get the friendly name associated with the input class.
  38958. * @returns the input friendly name
  38959. */
  38960. getSimpleName(): string;
  38961. }
  38962. }
  38963. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38964. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38965. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38966. /**
  38967. * Default Inputs manager for the ArcRotateCamera.
  38968. * It groups all the default supported inputs for ease of use.
  38969. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38970. */
  38971. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  38972. /**
  38973. * Instantiates a new ArcRotateCameraInputsManager.
  38974. * @param camera Defines the camera the inputs belong to
  38975. */
  38976. constructor(camera: ArcRotateCamera);
  38977. /**
  38978. * Add mouse wheel input support to the input manager.
  38979. * @returns the current input manager
  38980. */
  38981. addMouseWheel(): ArcRotateCameraInputsManager;
  38982. /**
  38983. * Add pointers input support to the input manager.
  38984. * @returns the current input manager
  38985. */
  38986. addPointers(): ArcRotateCameraInputsManager;
  38987. /**
  38988. * Add keyboard input support to the input manager.
  38989. * @returns the current input manager
  38990. */
  38991. addKeyboard(): ArcRotateCameraInputsManager;
  38992. }
  38993. }
  38994. declare module "babylonjs/Cameras/arcRotateCamera" {
  38995. import { Observable } from "babylonjs/Misc/observable";
  38996. import { Nullable } from "babylonjs/types";
  38997. import { Scene } from "babylonjs/scene";
  38998. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  38999. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39000. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39001. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39002. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  39003. import { Camera } from "babylonjs/Cameras/camera";
  39004. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39005. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  39006. import { Collider } from "babylonjs/Collisions/collider";
  39007. /**
  39008. * This represents an orbital type of camera.
  39009. *
  39010. * 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.
  39011. * 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.
  39012. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39013. */
  39014. export class ArcRotateCamera extends TargetCamera {
  39015. /**
  39016. * Defines the rotation angle of the camera along the longitudinal axis.
  39017. */
  39018. alpha: number;
  39019. /**
  39020. * Defines the rotation angle of the camera along the latitudinal axis.
  39021. */
  39022. beta: number;
  39023. /**
  39024. * Defines the radius of the camera from it s target point.
  39025. */
  39026. radius: number;
  39027. protected _target: Vector3;
  39028. protected _targetHost: Nullable<AbstractMesh>;
  39029. /**
  39030. * Defines the target point of the camera.
  39031. * The camera looks towards it form the radius distance.
  39032. */
  39033. target: Vector3;
  39034. /**
  39035. * Define the current local position of the camera in the scene
  39036. */
  39037. position: Vector3;
  39038. protected _upVector: Vector3;
  39039. protected _upToYMatrix: Matrix;
  39040. protected _YToUpMatrix: Matrix;
  39041. /**
  39042. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39043. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39044. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39045. */
  39046. upVector: Vector3;
  39047. /**
  39048. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39049. */
  39050. setMatUp(): void;
  39051. /**
  39052. * Current inertia value on the longitudinal axis.
  39053. * The bigger this number the longer it will take for the camera to stop.
  39054. */
  39055. inertialAlphaOffset: number;
  39056. /**
  39057. * Current inertia value on the latitudinal axis.
  39058. * The bigger this number the longer it will take for the camera to stop.
  39059. */
  39060. inertialBetaOffset: number;
  39061. /**
  39062. * Current inertia value on the radius axis.
  39063. * The bigger this number the longer it will take for the camera to stop.
  39064. */
  39065. inertialRadiusOffset: number;
  39066. /**
  39067. * Minimum allowed angle on the longitudinal axis.
  39068. * This can help limiting how the Camera is able to move in the scene.
  39069. */
  39070. lowerAlphaLimit: Nullable<number>;
  39071. /**
  39072. * Maximum allowed angle on the longitudinal axis.
  39073. * This can help limiting how the Camera is able to move in the scene.
  39074. */
  39075. upperAlphaLimit: Nullable<number>;
  39076. /**
  39077. * Minimum allowed angle on the latitudinal axis.
  39078. * This can help limiting how the Camera is able to move in the scene.
  39079. */
  39080. lowerBetaLimit: number;
  39081. /**
  39082. * Maximum allowed angle on the latitudinal axis.
  39083. * This can help limiting how the Camera is able to move in the scene.
  39084. */
  39085. upperBetaLimit: number;
  39086. /**
  39087. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39088. * This can help limiting how the Camera is able to move in the scene.
  39089. */
  39090. lowerRadiusLimit: Nullable<number>;
  39091. /**
  39092. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39093. * This can help limiting how the Camera is able to move in the scene.
  39094. */
  39095. upperRadiusLimit: Nullable<number>;
  39096. /**
  39097. * Defines the current inertia value used during panning of the camera along the X axis.
  39098. */
  39099. inertialPanningX: number;
  39100. /**
  39101. * Defines the current inertia value used during panning of the camera along the Y axis.
  39102. */
  39103. inertialPanningY: number;
  39104. /**
  39105. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39106. * Basically if your fingers moves away from more than this distance you will be considered
  39107. * in pinch mode.
  39108. */
  39109. pinchToPanMaxDistance: number;
  39110. /**
  39111. * Defines the maximum distance the camera can pan.
  39112. * This could help keeping the cammera always in your scene.
  39113. */
  39114. panningDistanceLimit: Nullable<number>;
  39115. /**
  39116. * Defines the target of the camera before paning.
  39117. */
  39118. panningOriginTarget: Vector3;
  39119. /**
  39120. * Defines the value of the inertia used during panning.
  39121. * 0 would mean stop inertia and one would mean no decelleration at all.
  39122. */
  39123. panningInertia: number;
  39124. /**
  39125. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39126. */
  39127. angularSensibilityX: number;
  39128. /**
  39129. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39130. */
  39131. angularSensibilityY: number;
  39132. /**
  39133. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39134. */
  39135. pinchPrecision: number;
  39136. /**
  39137. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39138. * It will be used instead of pinchDeltaPrecision if different from 0.
  39139. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39140. */
  39141. pinchDeltaPercentage: number;
  39142. /**
  39143. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39144. */
  39145. panningSensibility: number;
  39146. /**
  39147. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39148. */
  39149. keysUp: number[];
  39150. /**
  39151. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39152. */
  39153. keysDown: number[];
  39154. /**
  39155. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39156. */
  39157. keysLeft: number[];
  39158. /**
  39159. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39160. */
  39161. keysRight: number[];
  39162. /**
  39163. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39164. */
  39165. wheelPrecision: number;
  39166. /**
  39167. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39168. * It will be used instead of pinchDeltaPrecision if different from 0.
  39169. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39170. */
  39171. wheelDeltaPercentage: number;
  39172. /**
  39173. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39174. */
  39175. zoomOnFactor: number;
  39176. /**
  39177. * Defines a screen offset for the camera position.
  39178. */
  39179. targetScreenOffset: Vector2;
  39180. /**
  39181. * Allows the camera to be completely reversed.
  39182. * If false the camera can not arrive upside down.
  39183. */
  39184. allowUpsideDown: boolean;
  39185. /**
  39186. * Define if double tap/click is used to restore the previously saved state of the camera.
  39187. */
  39188. useInputToRestoreState: boolean;
  39189. /** @hidden */
  39190. _viewMatrix: Matrix;
  39191. /** @hidden */
  39192. _useCtrlForPanning: boolean;
  39193. /** @hidden */
  39194. _panningMouseButton: number;
  39195. /**
  39196. * Defines the input associated to the camera.
  39197. */
  39198. inputs: ArcRotateCameraInputsManager;
  39199. /** @hidden */
  39200. _reset: () => void;
  39201. /**
  39202. * Defines the allowed panning axis.
  39203. */
  39204. panningAxis: Vector3;
  39205. protected _localDirection: Vector3;
  39206. protected _transformedDirection: Vector3;
  39207. private _bouncingBehavior;
  39208. /**
  39209. * Gets the bouncing behavior of the camera if it has been enabled.
  39210. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39211. */
  39212. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  39213. /**
  39214. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39215. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39216. */
  39217. useBouncingBehavior: boolean;
  39218. private _framingBehavior;
  39219. /**
  39220. * Gets the framing behavior of the camera if it has been enabled.
  39221. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39222. */
  39223. readonly framingBehavior: Nullable<FramingBehavior>;
  39224. /**
  39225. * Defines if the framing behavior of the camera is enabled on the camera.
  39226. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39227. */
  39228. useFramingBehavior: boolean;
  39229. private _autoRotationBehavior;
  39230. /**
  39231. * Gets the auto rotation behavior of the camera if it has been enabled.
  39232. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39233. */
  39234. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  39235. /**
  39236. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39237. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39238. */
  39239. useAutoRotationBehavior: boolean;
  39240. /**
  39241. * Observable triggered when the mesh target has been changed on the camera.
  39242. */
  39243. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39244. /**
  39245. * Event raised when the camera is colliding with a mesh.
  39246. */
  39247. onCollide: (collidedMesh: AbstractMesh) => void;
  39248. /**
  39249. * Defines whether the camera should check collision with the objects oh the scene.
  39250. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39251. */
  39252. checkCollisions: boolean;
  39253. /**
  39254. * Defines the collision radius of the camera.
  39255. * This simulates a sphere around the camera.
  39256. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39257. */
  39258. collisionRadius: Vector3;
  39259. protected _collider: Collider;
  39260. protected _previousPosition: Vector3;
  39261. protected _collisionVelocity: Vector3;
  39262. protected _newPosition: Vector3;
  39263. protected _previousAlpha: number;
  39264. protected _previousBeta: number;
  39265. protected _previousRadius: number;
  39266. protected _collisionTriggered: boolean;
  39267. protected _targetBoundingCenter: Nullable<Vector3>;
  39268. private _computationVector;
  39269. /**
  39270. * Instantiates a new ArcRotateCamera in a given scene
  39271. * @param name Defines the name of the camera
  39272. * @param alpha Defines the camera rotation along the logitudinal axis
  39273. * @param beta Defines the camera rotation along the latitudinal axis
  39274. * @param radius Defines the camera distance from its target
  39275. * @param target Defines the camera target
  39276. * @param scene Defines the scene the camera belongs to
  39277. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39278. */
  39279. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39280. /** @hidden */
  39281. _initCache(): void;
  39282. /** @hidden */
  39283. _updateCache(ignoreParentClass?: boolean): void;
  39284. protected _getTargetPosition(): Vector3;
  39285. private _storedAlpha;
  39286. private _storedBeta;
  39287. private _storedRadius;
  39288. private _storedTarget;
  39289. private _storedTargetScreenOffset;
  39290. /**
  39291. * Stores the current state of the camera (alpha, beta, radius and target)
  39292. * @returns the camera itself
  39293. */
  39294. storeState(): Camera;
  39295. /**
  39296. * @hidden
  39297. * Restored camera state. You must call storeState() first
  39298. */
  39299. _restoreStateValues(): boolean;
  39300. /** @hidden */
  39301. _isSynchronizedViewMatrix(): boolean;
  39302. /**
  39303. * Attached controls to the current camera.
  39304. * @param element Defines the element the controls should be listened from
  39305. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39306. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39307. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39308. */
  39309. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39310. /**
  39311. * Detach the current controls from the camera.
  39312. * The camera will stop reacting to inputs.
  39313. * @param element Defines the element to stop listening the inputs from
  39314. */
  39315. detachControl(element: HTMLElement): void;
  39316. /** @hidden */
  39317. _checkInputs(): void;
  39318. protected _checkLimits(): void;
  39319. /**
  39320. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39321. */
  39322. rebuildAnglesAndRadius(): void;
  39323. /**
  39324. * Use a position to define the current camera related information like alpha, beta and radius
  39325. * @param position Defines the position to set the camera at
  39326. */
  39327. setPosition(position: Vector3): void;
  39328. /**
  39329. * Defines the target the camera should look at.
  39330. * This will automatically adapt alpha beta and radius to fit within the new target.
  39331. * @param target Defines the new target as a Vector or a mesh
  39332. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  39333. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39334. */
  39335. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39336. /** @hidden */
  39337. _getViewMatrix(): Matrix;
  39338. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39339. /**
  39340. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39341. * @param meshes Defines the mesh to zoom on
  39342. * @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)
  39343. */
  39344. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39345. /**
  39346. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39347. * The target will be changed but the radius
  39348. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39349. * @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)
  39350. */
  39351. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39352. min: Vector3;
  39353. max: Vector3;
  39354. distance: number;
  39355. }, doNotUpdateMaxZ?: boolean): void;
  39356. /**
  39357. * @override
  39358. * Override Camera.createRigCamera
  39359. */
  39360. createRigCamera(name: string, cameraIndex: number): Camera;
  39361. /**
  39362. * @hidden
  39363. * @override
  39364. * Override Camera._updateRigCameras
  39365. */
  39366. _updateRigCameras(): void;
  39367. /**
  39368. * Destroy the camera and release the current resources hold by it.
  39369. */
  39370. dispose(): void;
  39371. /**
  39372. * Gets the current object class name.
  39373. * @return the class name
  39374. */
  39375. getClassName(): string;
  39376. }
  39377. }
  39378. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  39379. import { Behavior } from "babylonjs/Behaviors/behavior";
  39380. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39381. /**
  39382. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39383. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39384. */
  39385. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39386. /**
  39387. * Gets the name of the behavior.
  39388. */
  39389. readonly name: string;
  39390. private _zoomStopsAnimation;
  39391. private _idleRotationSpeed;
  39392. private _idleRotationWaitTime;
  39393. private _idleRotationSpinupTime;
  39394. /**
  39395. * Sets the flag that indicates if user zooming should stop animation.
  39396. */
  39397. /**
  39398. * Gets the flag that indicates if user zooming should stop animation.
  39399. */
  39400. zoomStopsAnimation: boolean;
  39401. /**
  39402. * Sets the default speed at which the camera rotates around the model.
  39403. */
  39404. /**
  39405. * Gets the default speed at which the camera rotates around the model.
  39406. */
  39407. idleRotationSpeed: number;
  39408. /**
  39409. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39410. */
  39411. /**
  39412. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39413. */
  39414. idleRotationWaitTime: number;
  39415. /**
  39416. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39417. */
  39418. /**
  39419. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39420. */
  39421. idleRotationSpinupTime: number;
  39422. /**
  39423. * Gets a value indicating if the camera is currently rotating because of this behavior
  39424. */
  39425. readonly rotationInProgress: boolean;
  39426. private _onPrePointerObservableObserver;
  39427. private _onAfterCheckInputsObserver;
  39428. private _attachedCamera;
  39429. private _isPointerDown;
  39430. private _lastFrameTime;
  39431. private _lastInteractionTime;
  39432. private _cameraRotationSpeed;
  39433. /**
  39434. * Initializes the behavior.
  39435. */
  39436. init(): void;
  39437. /**
  39438. * Attaches the behavior to its arc rotate camera.
  39439. * @param camera Defines the camera to attach the behavior to
  39440. */
  39441. attach(camera: ArcRotateCamera): void;
  39442. /**
  39443. * Detaches the behavior from its current arc rotate camera.
  39444. */
  39445. detach(): void;
  39446. /**
  39447. * Returns true if user is scrolling.
  39448. * @return true if user is scrolling.
  39449. */
  39450. private _userIsZooming;
  39451. private _lastFrameRadius;
  39452. private _shouldAnimationStopForInteraction;
  39453. /**
  39454. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39455. */
  39456. private _applyUserInteraction;
  39457. private _userIsMoving;
  39458. }
  39459. }
  39460. declare module "babylonjs/Behaviors/Cameras/index" {
  39461. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39462. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39463. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  39464. }
  39465. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  39466. import { Mesh } from "babylonjs/Meshes/mesh";
  39467. import { TransformNode } from "babylonjs/Meshes/transformNode";
  39468. import { Behavior } from "babylonjs/Behaviors/behavior";
  39469. /**
  39470. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39471. */
  39472. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39473. private ui;
  39474. /**
  39475. * The name of the behavior
  39476. */
  39477. name: string;
  39478. /**
  39479. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39480. */
  39481. distanceAwayFromFace: number;
  39482. /**
  39483. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39484. */
  39485. distanceAwayFromBottomOfFace: number;
  39486. private _faceVectors;
  39487. private _target;
  39488. private _scene;
  39489. private _onRenderObserver;
  39490. private _tmpMatrix;
  39491. private _tmpVector;
  39492. /**
  39493. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39494. * @param ui The transform node that should be attched to the mesh
  39495. */
  39496. constructor(ui: TransformNode);
  39497. /**
  39498. * Initializes the behavior
  39499. */
  39500. init(): void;
  39501. private _closestFace;
  39502. private _zeroVector;
  39503. private _lookAtTmpMatrix;
  39504. private _lookAtToRef;
  39505. /**
  39506. * Attaches the AttachToBoxBehavior to the passed in mesh
  39507. * @param target The mesh that the specified node will be attached to
  39508. */
  39509. attach(target: Mesh): void;
  39510. /**
  39511. * Detaches the behavior from the mesh
  39512. */
  39513. detach(): void;
  39514. }
  39515. }
  39516. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  39517. import { Behavior } from "babylonjs/Behaviors/behavior";
  39518. import { Mesh } from "babylonjs/Meshes/mesh";
  39519. /**
  39520. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39521. */
  39522. export class FadeInOutBehavior implements Behavior<Mesh> {
  39523. /**
  39524. * Time in milliseconds to delay before fading in (Default: 0)
  39525. */
  39526. delay: number;
  39527. /**
  39528. * Time in milliseconds for the mesh to fade in (Default: 300)
  39529. */
  39530. fadeInTime: number;
  39531. private _millisecondsPerFrame;
  39532. private _hovered;
  39533. private _hoverValue;
  39534. private _ownerNode;
  39535. /**
  39536. * Instatiates the FadeInOutBehavior
  39537. */
  39538. constructor();
  39539. /**
  39540. * The name of the behavior
  39541. */
  39542. readonly name: string;
  39543. /**
  39544. * Initializes the behavior
  39545. */
  39546. init(): void;
  39547. /**
  39548. * Attaches the fade behavior on the passed in mesh
  39549. * @param ownerNode The mesh that will be faded in/out once attached
  39550. */
  39551. attach(ownerNode: Mesh): void;
  39552. /**
  39553. * Detaches the behavior from the mesh
  39554. */
  39555. detach(): void;
  39556. /**
  39557. * Triggers the mesh to begin fading in or out
  39558. * @param value if the object should fade in or out (true to fade in)
  39559. */
  39560. fadeIn(value: boolean): void;
  39561. private _update;
  39562. private _setAllVisibility;
  39563. }
  39564. }
  39565. declare module "babylonjs/Misc/pivotTools" {
  39566. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39567. /**
  39568. * Class containing a set of static utilities functions for managing Pivots
  39569. * @hidden
  39570. */
  39571. export class PivotTools {
  39572. private static _PivotCached;
  39573. private static _OldPivotPoint;
  39574. private static _PivotTranslation;
  39575. private static _PivotTmpVector;
  39576. /** @hidden */
  39577. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39578. /** @hidden */
  39579. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39580. }
  39581. }
  39582. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  39583. import { Scene } from "babylonjs/scene";
  39584. import { Vector4 } from "babylonjs/Maths/math.vector";
  39585. import { Mesh } from "babylonjs/Meshes/mesh";
  39586. import { Nullable } from "babylonjs/types";
  39587. import { Plane } from "babylonjs/Maths/math.plane";
  39588. /**
  39589. * Class containing static functions to help procedurally build meshes
  39590. */
  39591. export class PlaneBuilder {
  39592. /**
  39593. * Creates a plane mesh
  39594. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39595. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39596. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39597. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39598. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39599. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39600. * @param name defines the name of the mesh
  39601. * @param options defines the options used to create the mesh
  39602. * @param scene defines the hosting scene
  39603. * @returns the plane mesh
  39604. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39605. */
  39606. static CreatePlane(name: string, options: {
  39607. size?: number;
  39608. width?: number;
  39609. height?: number;
  39610. sideOrientation?: number;
  39611. frontUVs?: Vector4;
  39612. backUVs?: Vector4;
  39613. updatable?: boolean;
  39614. sourcePlane?: Plane;
  39615. }, scene?: Nullable<Scene>): Mesh;
  39616. }
  39617. }
  39618. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  39619. import { Behavior } from "babylonjs/Behaviors/behavior";
  39620. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39621. import { Observable } from "babylonjs/Misc/observable";
  39622. import { Vector3 } from "babylonjs/Maths/math.vector";
  39623. import { Ray } from "babylonjs/Culling/ray";
  39624. import "babylonjs/Meshes/Builders/planeBuilder";
  39625. /**
  39626. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39627. */
  39628. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39629. private static _AnyMouseID;
  39630. /**
  39631. * Abstract mesh the behavior is set on
  39632. */
  39633. attachedNode: AbstractMesh;
  39634. private _dragPlane;
  39635. private _scene;
  39636. private _pointerObserver;
  39637. private _beforeRenderObserver;
  39638. private static _planeScene;
  39639. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39640. /**
  39641. * 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)
  39642. */
  39643. maxDragAngle: number;
  39644. /**
  39645. * @hidden
  39646. */
  39647. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39648. /**
  39649. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39650. */
  39651. currentDraggingPointerID: number;
  39652. /**
  39653. * The last position where the pointer hit the drag plane in world space
  39654. */
  39655. lastDragPosition: Vector3;
  39656. /**
  39657. * If the behavior is currently in a dragging state
  39658. */
  39659. dragging: boolean;
  39660. /**
  39661. * 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)
  39662. */
  39663. dragDeltaRatio: number;
  39664. /**
  39665. * If the drag plane orientation should be updated during the dragging (Default: true)
  39666. */
  39667. updateDragPlane: boolean;
  39668. private _debugMode;
  39669. private _moving;
  39670. /**
  39671. * Fires each time the attached mesh is dragged with the pointer
  39672. * * delta between last drag position and current drag position in world space
  39673. * * dragDistance along the drag axis
  39674. * * dragPlaneNormal normal of the current drag plane used during the drag
  39675. * * dragPlanePoint in world space where the drag intersects the drag plane
  39676. */
  39677. onDragObservable: Observable<{
  39678. delta: Vector3;
  39679. dragPlanePoint: Vector3;
  39680. dragPlaneNormal: Vector3;
  39681. dragDistance: number;
  39682. pointerId: number;
  39683. }>;
  39684. /**
  39685. * Fires each time a drag begins (eg. mouse down on mesh)
  39686. */
  39687. onDragStartObservable: Observable<{
  39688. dragPlanePoint: Vector3;
  39689. pointerId: number;
  39690. }>;
  39691. /**
  39692. * Fires each time a drag ends (eg. mouse release after drag)
  39693. */
  39694. onDragEndObservable: Observable<{
  39695. dragPlanePoint: Vector3;
  39696. pointerId: number;
  39697. }>;
  39698. /**
  39699. * If the attached mesh should be moved when dragged
  39700. */
  39701. moveAttached: boolean;
  39702. /**
  39703. * If the drag behavior will react to drag events (Default: true)
  39704. */
  39705. enabled: boolean;
  39706. /**
  39707. * If pointer events should start and release the drag (Default: true)
  39708. */
  39709. startAndReleaseDragOnPointerEvents: boolean;
  39710. /**
  39711. * If camera controls should be detached during the drag
  39712. */
  39713. detachCameraControls: boolean;
  39714. /**
  39715. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39716. */
  39717. useObjectOrienationForDragging: boolean;
  39718. private _options;
  39719. /**
  39720. * Gets the options used by the behavior
  39721. */
  39722. /**
  39723. * Sets the options used by the behavior
  39724. */
  39725. options: {
  39726. dragAxis?: Vector3;
  39727. dragPlaneNormal?: Vector3;
  39728. };
  39729. /**
  39730. * Creates a pointer drag behavior that can be attached to a mesh
  39731. * @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)
  39732. */
  39733. constructor(options?: {
  39734. dragAxis?: Vector3;
  39735. dragPlaneNormal?: Vector3;
  39736. });
  39737. /**
  39738. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39739. */
  39740. validateDrag: (targetPosition: Vector3) => boolean;
  39741. /**
  39742. * The name of the behavior
  39743. */
  39744. readonly name: string;
  39745. /**
  39746. * Initializes the behavior
  39747. */
  39748. init(): void;
  39749. private _tmpVector;
  39750. private _alternatePickedPoint;
  39751. private _worldDragAxis;
  39752. private _targetPosition;
  39753. private _attachedElement;
  39754. /**
  39755. * Attaches the drag behavior the passed in mesh
  39756. * @param ownerNode The mesh that will be dragged around once attached
  39757. * @param predicate Predicate to use for pick filtering
  39758. */
  39759. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39760. /**
  39761. * Force relase the drag action by code.
  39762. */
  39763. releaseDrag(): void;
  39764. private _startDragRay;
  39765. private _lastPointerRay;
  39766. /**
  39767. * Simulates the start of a pointer drag event on the behavior
  39768. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39769. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39770. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39771. */
  39772. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39773. private _startDrag;
  39774. private _dragDelta;
  39775. private _moveDrag;
  39776. private _pickWithRayOnDragPlane;
  39777. private _pointA;
  39778. private _pointB;
  39779. private _pointC;
  39780. private _lineA;
  39781. private _lineB;
  39782. private _localAxis;
  39783. private _lookAt;
  39784. private _updateDragPlanePosition;
  39785. /**
  39786. * Detaches the behavior from the mesh
  39787. */
  39788. detach(): void;
  39789. }
  39790. }
  39791. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  39792. import { Mesh } from "babylonjs/Meshes/mesh";
  39793. import { Behavior } from "babylonjs/Behaviors/behavior";
  39794. /**
  39795. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39796. */
  39797. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39798. private _dragBehaviorA;
  39799. private _dragBehaviorB;
  39800. private _startDistance;
  39801. private _initialScale;
  39802. private _targetScale;
  39803. private _ownerNode;
  39804. private _sceneRenderObserver;
  39805. /**
  39806. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39807. */
  39808. constructor();
  39809. /**
  39810. * The name of the behavior
  39811. */
  39812. readonly name: string;
  39813. /**
  39814. * Initializes the behavior
  39815. */
  39816. init(): void;
  39817. private _getCurrentDistance;
  39818. /**
  39819. * Attaches the scale behavior the passed in mesh
  39820. * @param ownerNode The mesh that will be scaled around once attached
  39821. */
  39822. attach(ownerNode: Mesh): void;
  39823. /**
  39824. * Detaches the behavior from the mesh
  39825. */
  39826. detach(): void;
  39827. }
  39828. }
  39829. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  39830. import { Behavior } from "babylonjs/Behaviors/behavior";
  39831. import { Mesh } from "babylonjs/Meshes/mesh";
  39832. import { Observable } from "babylonjs/Misc/observable";
  39833. /**
  39834. * 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
  39835. */
  39836. export class SixDofDragBehavior implements Behavior<Mesh> {
  39837. private static _virtualScene;
  39838. private _ownerNode;
  39839. private _sceneRenderObserver;
  39840. private _scene;
  39841. private _targetPosition;
  39842. private _virtualOriginMesh;
  39843. private _virtualDragMesh;
  39844. private _pointerObserver;
  39845. private _moving;
  39846. private _startingOrientation;
  39847. /**
  39848. * 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)
  39849. */
  39850. private zDragFactor;
  39851. /**
  39852. * If the object should rotate to face the drag origin
  39853. */
  39854. rotateDraggedObject: boolean;
  39855. /**
  39856. * If the behavior is currently in a dragging state
  39857. */
  39858. dragging: boolean;
  39859. /**
  39860. * 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)
  39861. */
  39862. dragDeltaRatio: number;
  39863. /**
  39864. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39865. */
  39866. currentDraggingPointerID: number;
  39867. /**
  39868. * If camera controls should be detached during the drag
  39869. */
  39870. detachCameraControls: boolean;
  39871. /**
  39872. * Fires each time a drag starts
  39873. */
  39874. onDragStartObservable: Observable<{}>;
  39875. /**
  39876. * Fires each time a drag ends (eg. mouse release after drag)
  39877. */
  39878. onDragEndObservable: Observable<{}>;
  39879. /**
  39880. * 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
  39881. */
  39882. constructor();
  39883. /**
  39884. * The name of the behavior
  39885. */
  39886. readonly name: string;
  39887. /**
  39888. * Initializes the behavior
  39889. */
  39890. init(): void;
  39891. /**
  39892. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39893. */
  39894. private readonly _pointerCamera;
  39895. /**
  39896. * Attaches the scale behavior the passed in mesh
  39897. * @param ownerNode The mesh that will be scaled around once attached
  39898. */
  39899. attach(ownerNode: Mesh): void;
  39900. /**
  39901. * Detaches the behavior from the mesh
  39902. */
  39903. detach(): void;
  39904. }
  39905. }
  39906. declare module "babylonjs/Behaviors/Meshes/index" {
  39907. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  39908. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  39909. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  39910. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  39911. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  39912. }
  39913. declare module "babylonjs/Behaviors/index" {
  39914. export * from "babylonjs/Behaviors/behavior";
  39915. export * from "babylonjs/Behaviors/Cameras/index";
  39916. export * from "babylonjs/Behaviors/Meshes/index";
  39917. }
  39918. declare module "babylonjs/Bones/boneIKController" {
  39919. import { Bone } from "babylonjs/Bones/bone";
  39920. import { Vector3 } from "babylonjs/Maths/math.vector";
  39921. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39922. import { Nullable } from "babylonjs/types";
  39923. /**
  39924. * Class used to apply inverse kinematics to bones
  39925. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39926. */
  39927. export class BoneIKController {
  39928. private static _tmpVecs;
  39929. private static _tmpQuat;
  39930. private static _tmpMats;
  39931. /**
  39932. * Gets or sets the target mesh
  39933. */
  39934. targetMesh: AbstractMesh;
  39935. /** Gets or sets the mesh used as pole */
  39936. poleTargetMesh: AbstractMesh;
  39937. /**
  39938. * Gets or sets the bone used as pole
  39939. */
  39940. poleTargetBone: Nullable<Bone>;
  39941. /**
  39942. * Gets or sets the target position
  39943. */
  39944. targetPosition: Vector3;
  39945. /**
  39946. * Gets or sets the pole target position
  39947. */
  39948. poleTargetPosition: Vector3;
  39949. /**
  39950. * Gets or sets the pole target local offset
  39951. */
  39952. poleTargetLocalOffset: Vector3;
  39953. /**
  39954. * Gets or sets the pole angle
  39955. */
  39956. poleAngle: number;
  39957. /**
  39958. * Gets or sets the mesh associated with the controller
  39959. */
  39960. mesh: AbstractMesh;
  39961. /**
  39962. * 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)
  39963. */
  39964. slerpAmount: number;
  39965. private _bone1Quat;
  39966. private _bone1Mat;
  39967. private _bone2Ang;
  39968. private _bone1;
  39969. private _bone2;
  39970. private _bone1Length;
  39971. private _bone2Length;
  39972. private _maxAngle;
  39973. private _maxReach;
  39974. private _rightHandedSystem;
  39975. private _bendAxis;
  39976. private _slerping;
  39977. private _adjustRoll;
  39978. /**
  39979. * Gets or sets maximum allowed angle
  39980. */
  39981. maxAngle: number;
  39982. /**
  39983. * Creates a new BoneIKController
  39984. * @param mesh defines the mesh to control
  39985. * @param bone defines the bone to control
  39986. * @param options defines options to set up the controller
  39987. */
  39988. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  39989. targetMesh?: AbstractMesh;
  39990. poleTargetMesh?: AbstractMesh;
  39991. poleTargetBone?: Bone;
  39992. poleTargetLocalOffset?: Vector3;
  39993. poleAngle?: number;
  39994. bendAxis?: Vector3;
  39995. maxAngle?: number;
  39996. slerpAmount?: number;
  39997. });
  39998. private _setMaxAngle;
  39999. /**
  40000. * Force the controller to update the bones
  40001. */
  40002. update(): void;
  40003. }
  40004. }
  40005. declare module "babylonjs/Bones/boneLookController" {
  40006. import { Vector3 } from "babylonjs/Maths/math.vector";
  40007. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40008. import { Bone } from "babylonjs/Bones/bone";
  40009. import { Space } from "babylonjs/Maths/math.axis";
  40010. /**
  40011. * Class used to make a bone look toward a point in space
  40012. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40013. */
  40014. export class BoneLookController {
  40015. private static _tmpVecs;
  40016. private static _tmpQuat;
  40017. private static _tmpMats;
  40018. /**
  40019. * The target Vector3 that the bone will look at
  40020. */
  40021. target: Vector3;
  40022. /**
  40023. * The mesh that the bone is attached to
  40024. */
  40025. mesh: AbstractMesh;
  40026. /**
  40027. * The bone that will be looking to the target
  40028. */
  40029. bone: Bone;
  40030. /**
  40031. * The up axis of the coordinate system that is used when the bone is rotated
  40032. */
  40033. upAxis: Vector3;
  40034. /**
  40035. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40036. */
  40037. upAxisSpace: Space;
  40038. /**
  40039. * Used to make an adjustment to the yaw of the bone
  40040. */
  40041. adjustYaw: number;
  40042. /**
  40043. * Used to make an adjustment to the pitch of the bone
  40044. */
  40045. adjustPitch: number;
  40046. /**
  40047. * Used to make an adjustment to the roll of the bone
  40048. */
  40049. adjustRoll: number;
  40050. /**
  40051. * 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)
  40052. */
  40053. slerpAmount: number;
  40054. private _minYaw;
  40055. private _maxYaw;
  40056. private _minPitch;
  40057. private _maxPitch;
  40058. private _minYawSin;
  40059. private _minYawCos;
  40060. private _maxYawSin;
  40061. private _maxYawCos;
  40062. private _midYawConstraint;
  40063. private _minPitchTan;
  40064. private _maxPitchTan;
  40065. private _boneQuat;
  40066. private _slerping;
  40067. private _transformYawPitch;
  40068. private _transformYawPitchInv;
  40069. private _firstFrameSkipped;
  40070. private _yawRange;
  40071. private _fowardAxis;
  40072. /**
  40073. * Gets or sets the minimum yaw angle that the bone can look to
  40074. */
  40075. minYaw: number;
  40076. /**
  40077. * Gets or sets the maximum yaw angle that the bone can look to
  40078. */
  40079. maxYaw: number;
  40080. /**
  40081. * Gets or sets the minimum pitch angle that the bone can look to
  40082. */
  40083. minPitch: number;
  40084. /**
  40085. * Gets or sets the maximum pitch angle that the bone can look to
  40086. */
  40087. maxPitch: number;
  40088. /**
  40089. * Create a BoneLookController
  40090. * @param mesh the mesh that the bone belongs to
  40091. * @param bone the bone that will be looking to the target
  40092. * @param target the target Vector3 to look at
  40093. * @param options optional settings:
  40094. * * maxYaw: the maximum angle the bone will yaw to
  40095. * * minYaw: the minimum angle the bone will yaw to
  40096. * * maxPitch: the maximum angle the bone will pitch to
  40097. * * minPitch: the minimum angle the bone will yaw to
  40098. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40099. * * upAxis: the up axis of the coordinate system
  40100. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40101. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40102. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40103. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40104. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40105. * * adjustRoll: used to make an adjustment to the roll of the bone
  40106. **/
  40107. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40108. maxYaw?: number;
  40109. minYaw?: number;
  40110. maxPitch?: number;
  40111. minPitch?: number;
  40112. slerpAmount?: number;
  40113. upAxis?: Vector3;
  40114. upAxisSpace?: Space;
  40115. yawAxis?: Vector3;
  40116. pitchAxis?: Vector3;
  40117. adjustYaw?: number;
  40118. adjustPitch?: number;
  40119. adjustRoll?: number;
  40120. });
  40121. /**
  40122. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40123. */
  40124. update(): void;
  40125. private _getAngleDiff;
  40126. private _getAngleBetween;
  40127. private _isAngleBetween;
  40128. }
  40129. }
  40130. declare module "babylonjs/Bones/index" {
  40131. export * from "babylonjs/Bones/bone";
  40132. export * from "babylonjs/Bones/boneIKController";
  40133. export * from "babylonjs/Bones/boneLookController";
  40134. export * from "babylonjs/Bones/skeleton";
  40135. }
  40136. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  40137. import { Nullable } from "babylonjs/types";
  40138. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40139. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40140. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40141. /**
  40142. * Manage the gamepad inputs to control an arc rotate camera.
  40143. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40144. */
  40145. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40146. /**
  40147. * Defines the camera the input is attached to.
  40148. */
  40149. camera: ArcRotateCamera;
  40150. /**
  40151. * Defines the gamepad the input is gathering event from.
  40152. */
  40153. gamepad: Nullable<Gamepad>;
  40154. /**
  40155. * Defines the gamepad rotation sensiblity.
  40156. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40157. */
  40158. gamepadRotationSensibility: number;
  40159. /**
  40160. * Defines the gamepad move sensiblity.
  40161. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40162. */
  40163. gamepadMoveSensibility: number;
  40164. private _yAxisScale;
  40165. /**
  40166. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40167. */
  40168. invertYAxis: boolean;
  40169. private _onGamepadConnectedObserver;
  40170. private _onGamepadDisconnectedObserver;
  40171. /**
  40172. * Attach the input controls to a specific dom element to get the input from.
  40173. * @param element Defines the element the controls should be listened from
  40174. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40175. */
  40176. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40177. /**
  40178. * Detach the current controls from the specified dom element.
  40179. * @param element Defines the element to stop listening the inputs from
  40180. */
  40181. detachControl(element: Nullable<HTMLElement>): void;
  40182. /**
  40183. * Update the current camera state depending on the inputs that have been used this frame.
  40184. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40185. */
  40186. checkInputs(): void;
  40187. /**
  40188. * Gets the class name of the current intput.
  40189. * @returns the class name
  40190. */
  40191. getClassName(): string;
  40192. /**
  40193. * Get the friendly name associated with the input class.
  40194. * @returns the input friendly name
  40195. */
  40196. getSimpleName(): string;
  40197. }
  40198. }
  40199. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  40200. import { Nullable } from "babylonjs/types";
  40201. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40202. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40203. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40204. interface ArcRotateCameraInputsManager {
  40205. /**
  40206. * Add orientation input support to the input manager.
  40207. * @returns the current input manager
  40208. */
  40209. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40210. }
  40211. }
  40212. /**
  40213. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40214. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40215. */
  40216. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40217. /**
  40218. * Defines the camera the input is attached to.
  40219. */
  40220. camera: ArcRotateCamera;
  40221. /**
  40222. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40223. */
  40224. alphaCorrection: number;
  40225. /**
  40226. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40227. */
  40228. gammaCorrection: number;
  40229. private _alpha;
  40230. private _gamma;
  40231. private _dirty;
  40232. private _deviceOrientationHandler;
  40233. /**
  40234. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40235. */
  40236. constructor();
  40237. /**
  40238. * Attach the input controls to a specific dom element to get the input from.
  40239. * @param element Defines the element the controls should be listened from
  40240. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40241. */
  40242. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40243. /** @hidden */
  40244. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40245. /**
  40246. * Update the current camera state depending on the inputs that have been used this frame.
  40247. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40248. */
  40249. checkInputs(): void;
  40250. /**
  40251. * Detach the current controls from the specified dom element.
  40252. * @param element Defines the element to stop listening the inputs from
  40253. */
  40254. detachControl(element: Nullable<HTMLElement>): void;
  40255. /**
  40256. * Gets the class name of the current intput.
  40257. * @returns the class name
  40258. */
  40259. getClassName(): string;
  40260. /**
  40261. * Get the friendly name associated with the input class.
  40262. * @returns the input friendly name
  40263. */
  40264. getSimpleName(): string;
  40265. }
  40266. }
  40267. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  40268. import { Nullable } from "babylonjs/types";
  40269. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40270. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40271. /**
  40272. * Listen to mouse events to control the camera.
  40273. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40274. */
  40275. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40276. /**
  40277. * Defines the camera the input is attached to.
  40278. */
  40279. camera: FlyCamera;
  40280. /**
  40281. * Defines if touch is enabled. (Default is true.)
  40282. */
  40283. touchEnabled: boolean;
  40284. /**
  40285. * Defines the buttons associated with the input to handle camera rotation.
  40286. */
  40287. buttons: number[];
  40288. /**
  40289. * Assign buttons for Yaw control.
  40290. */
  40291. buttonsYaw: number[];
  40292. /**
  40293. * Assign buttons for Pitch control.
  40294. */
  40295. buttonsPitch: number[];
  40296. /**
  40297. * Assign buttons for Roll control.
  40298. */
  40299. buttonsRoll: number[];
  40300. /**
  40301. * Detect if any button is being pressed while mouse is moved.
  40302. * -1 = Mouse locked.
  40303. * 0 = Left button.
  40304. * 1 = Middle Button.
  40305. * 2 = Right Button.
  40306. */
  40307. activeButton: number;
  40308. /**
  40309. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40310. * Higher values reduce its sensitivity.
  40311. */
  40312. angularSensibility: number;
  40313. private _mousemoveCallback;
  40314. private _observer;
  40315. private _rollObserver;
  40316. private previousPosition;
  40317. private noPreventDefault;
  40318. private element;
  40319. /**
  40320. * Listen to mouse events to control the camera.
  40321. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40322. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40323. */
  40324. constructor(touchEnabled?: boolean);
  40325. /**
  40326. * Attach the mouse control to the HTML DOM element.
  40327. * @param element Defines the element that listens to the input events.
  40328. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40329. */
  40330. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40331. /**
  40332. * Detach the current controls from the specified dom element.
  40333. * @param element Defines the element to stop listening the inputs from
  40334. */
  40335. detachControl(element: Nullable<HTMLElement>): void;
  40336. /**
  40337. * Gets the class name of the current input.
  40338. * @returns the class name.
  40339. */
  40340. getClassName(): string;
  40341. /**
  40342. * Get the friendly name associated with the input class.
  40343. * @returns the input's friendly name.
  40344. */
  40345. getSimpleName(): string;
  40346. private _pointerInput;
  40347. private _onMouseMove;
  40348. /**
  40349. * Rotate camera by mouse offset.
  40350. */
  40351. private rotateCamera;
  40352. }
  40353. }
  40354. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  40355. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40356. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  40357. /**
  40358. * Default Inputs manager for the FlyCamera.
  40359. * It groups all the default supported inputs for ease of use.
  40360. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40361. */
  40362. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40363. /**
  40364. * Instantiates a new FlyCameraInputsManager.
  40365. * @param camera Defines the camera the inputs belong to.
  40366. */
  40367. constructor(camera: FlyCamera);
  40368. /**
  40369. * Add keyboard input support to the input manager.
  40370. * @returns the new FlyCameraKeyboardMoveInput().
  40371. */
  40372. addKeyboard(): FlyCameraInputsManager;
  40373. /**
  40374. * Add mouse input support to the input manager.
  40375. * @param touchEnabled Enable touch screen support.
  40376. * @returns the new FlyCameraMouseInput().
  40377. */
  40378. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40379. }
  40380. }
  40381. declare module "babylonjs/Cameras/flyCamera" {
  40382. import { Scene } from "babylonjs/scene";
  40383. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  40384. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40385. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  40386. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  40387. /**
  40388. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40389. * such as in a 3D Space Shooter or a Flight Simulator.
  40390. */
  40391. export class FlyCamera extends TargetCamera {
  40392. /**
  40393. * Define the collision ellipsoid of the camera.
  40394. * This is helpful for simulating a camera body, like a player's body.
  40395. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40396. */
  40397. ellipsoid: Vector3;
  40398. /**
  40399. * Define an offset for the position of the ellipsoid around the camera.
  40400. * This can be helpful if the camera is attached away from the player's body center,
  40401. * such as at its head.
  40402. */
  40403. ellipsoidOffset: Vector3;
  40404. /**
  40405. * Enable or disable collisions of the camera with the rest of the scene objects.
  40406. */
  40407. checkCollisions: boolean;
  40408. /**
  40409. * Enable or disable gravity on the camera.
  40410. */
  40411. applyGravity: boolean;
  40412. /**
  40413. * Define the current direction the camera is moving to.
  40414. */
  40415. cameraDirection: Vector3;
  40416. /**
  40417. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  40418. * This overrides and empties cameraRotation.
  40419. */
  40420. rotationQuaternion: Quaternion;
  40421. /**
  40422. * Track Roll to maintain the wanted Rolling when looking around.
  40423. */
  40424. _trackRoll: number;
  40425. /**
  40426. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  40427. */
  40428. rollCorrect: number;
  40429. /**
  40430. * Mimic a banked turn, Rolling the camera when Yawing.
  40431. * It's recommended to use rollCorrect = 10 for faster banking correction.
  40432. */
  40433. bankedTurn: boolean;
  40434. /**
  40435. * Limit in radians for how much Roll banking will add. (Default: 90°)
  40436. */
  40437. bankedTurnLimit: number;
  40438. /**
  40439. * Value of 0 disables the banked Roll.
  40440. * Value of 1 is equal to the Yaw angle in radians.
  40441. */
  40442. bankedTurnMultiplier: number;
  40443. /**
  40444. * The inputs manager loads all the input sources, such as keyboard and mouse.
  40445. */
  40446. inputs: FlyCameraInputsManager;
  40447. /**
  40448. * Gets the input sensibility for mouse input.
  40449. * Higher values reduce sensitivity.
  40450. */
  40451. /**
  40452. * Sets the input sensibility for a mouse input.
  40453. * Higher values reduce sensitivity.
  40454. */
  40455. angularSensibility: number;
  40456. /**
  40457. * Get the keys for camera movement forward.
  40458. */
  40459. /**
  40460. * Set the keys for camera movement forward.
  40461. */
  40462. keysForward: number[];
  40463. /**
  40464. * Get the keys for camera movement backward.
  40465. */
  40466. keysBackward: number[];
  40467. /**
  40468. * Get the keys for camera movement up.
  40469. */
  40470. /**
  40471. * Set the keys for camera movement up.
  40472. */
  40473. keysUp: number[];
  40474. /**
  40475. * Get the keys for camera movement down.
  40476. */
  40477. /**
  40478. * Set the keys for camera movement down.
  40479. */
  40480. keysDown: number[];
  40481. /**
  40482. * Get the keys for camera movement left.
  40483. */
  40484. /**
  40485. * Set the keys for camera movement left.
  40486. */
  40487. keysLeft: number[];
  40488. /**
  40489. * Set the keys for camera movement right.
  40490. */
  40491. /**
  40492. * Set the keys for camera movement right.
  40493. */
  40494. keysRight: number[];
  40495. /**
  40496. * Event raised when the camera collides with a mesh in the scene.
  40497. */
  40498. onCollide: (collidedMesh: AbstractMesh) => void;
  40499. private _collider;
  40500. private _needMoveForGravity;
  40501. private _oldPosition;
  40502. private _diffPosition;
  40503. private _newPosition;
  40504. /** @hidden */
  40505. _localDirection: Vector3;
  40506. /** @hidden */
  40507. _transformedDirection: Vector3;
  40508. /**
  40509. * Instantiates a FlyCamera.
  40510. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40511. * such as in a 3D Space Shooter or a Flight Simulator.
  40512. * @param name Define the name of the camera in the scene.
  40513. * @param position Define the starting position of the camera in the scene.
  40514. * @param scene Define the scene the camera belongs to.
  40515. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  40516. */
  40517. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40518. /**
  40519. * Attach a control to the HTML DOM element.
  40520. * @param element Defines the element that listens to the input events.
  40521. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  40522. */
  40523. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40524. /**
  40525. * Detach a control from the HTML DOM element.
  40526. * The camera will stop reacting to that input.
  40527. * @param element Defines the element that listens to the input events.
  40528. */
  40529. detachControl(element: HTMLElement): void;
  40530. private _collisionMask;
  40531. /**
  40532. * Get the mask that the camera ignores in collision events.
  40533. */
  40534. /**
  40535. * Set the mask that the camera ignores in collision events.
  40536. */
  40537. collisionMask: number;
  40538. /** @hidden */
  40539. _collideWithWorld(displacement: Vector3): void;
  40540. /** @hidden */
  40541. private _onCollisionPositionChange;
  40542. /** @hidden */
  40543. _checkInputs(): void;
  40544. /** @hidden */
  40545. _decideIfNeedsToMove(): boolean;
  40546. /** @hidden */
  40547. _updatePosition(): void;
  40548. /**
  40549. * Restore the Roll to its target value at the rate specified.
  40550. * @param rate - Higher means slower restoring.
  40551. * @hidden
  40552. */
  40553. restoreRoll(rate: number): void;
  40554. /**
  40555. * Destroy the camera and release the current resources held by it.
  40556. */
  40557. dispose(): void;
  40558. /**
  40559. * Get the current object class name.
  40560. * @returns the class name.
  40561. */
  40562. getClassName(): string;
  40563. }
  40564. }
  40565. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  40566. import { Nullable } from "babylonjs/types";
  40567. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40568. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40569. /**
  40570. * Listen to keyboard events to control the camera.
  40571. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40572. */
  40573. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40574. /**
  40575. * Defines the camera the input is attached to.
  40576. */
  40577. camera: FlyCamera;
  40578. /**
  40579. * The list of keyboard keys used to control the forward move of the camera.
  40580. */
  40581. keysForward: number[];
  40582. /**
  40583. * The list of keyboard keys used to control the backward move of the camera.
  40584. */
  40585. keysBackward: number[];
  40586. /**
  40587. * The list of keyboard keys used to control the forward move of the camera.
  40588. */
  40589. keysUp: number[];
  40590. /**
  40591. * The list of keyboard keys used to control the backward move of the camera.
  40592. */
  40593. keysDown: number[];
  40594. /**
  40595. * The list of keyboard keys used to control the right strafe move of the camera.
  40596. */
  40597. keysRight: number[];
  40598. /**
  40599. * The list of keyboard keys used to control the left strafe move of the camera.
  40600. */
  40601. keysLeft: number[];
  40602. private _keys;
  40603. private _onCanvasBlurObserver;
  40604. private _onKeyboardObserver;
  40605. private _engine;
  40606. private _scene;
  40607. /**
  40608. * Attach the input controls to a specific dom element to get the input from.
  40609. * @param element Defines the element the controls should be listened from
  40610. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40611. */
  40612. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40613. /**
  40614. * Detach the current controls from the specified dom element.
  40615. * @param element Defines the element to stop listening the inputs from
  40616. */
  40617. detachControl(element: Nullable<HTMLElement>): void;
  40618. /**
  40619. * Gets the class name of the current intput.
  40620. * @returns the class name
  40621. */
  40622. getClassName(): string;
  40623. /** @hidden */
  40624. _onLostFocus(e: FocusEvent): void;
  40625. /**
  40626. * Get the friendly name associated with the input class.
  40627. * @returns the input friendly name
  40628. */
  40629. getSimpleName(): string;
  40630. /**
  40631. * Update the current camera state depending on the inputs that have been used this frame.
  40632. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40633. */
  40634. checkInputs(): void;
  40635. }
  40636. }
  40637. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  40638. import { Nullable } from "babylonjs/types";
  40639. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  40640. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40641. /**
  40642. * Manage the mouse wheel inputs to control a follow camera.
  40643. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40644. */
  40645. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40646. /**
  40647. * Defines the camera the input is attached to.
  40648. */
  40649. camera: FollowCamera;
  40650. /**
  40651. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40652. */
  40653. axisControlRadius: boolean;
  40654. /**
  40655. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40656. */
  40657. axisControlHeight: boolean;
  40658. /**
  40659. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40660. */
  40661. axisControlRotation: boolean;
  40662. /**
  40663. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40664. * relation to mouseWheel events.
  40665. */
  40666. wheelPrecision: number;
  40667. /**
  40668. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40669. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40670. */
  40671. wheelDeltaPercentage: number;
  40672. private _wheel;
  40673. private _observer;
  40674. /**
  40675. * Attach the input controls to a specific dom element to get the input from.
  40676. * @param element Defines the element the controls should be listened from
  40677. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40678. */
  40679. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40680. /**
  40681. * Detach the current controls from the specified dom element.
  40682. * @param element Defines the element to stop listening the inputs from
  40683. */
  40684. detachControl(element: Nullable<HTMLElement>): void;
  40685. /**
  40686. * Gets the class name of the current intput.
  40687. * @returns the class name
  40688. */
  40689. getClassName(): string;
  40690. /**
  40691. * Get the friendly name associated with the input class.
  40692. * @returns the input friendly name
  40693. */
  40694. getSimpleName(): string;
  40695. }
  40696. }
  40697. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  40698. import { Nullable } from "babylonjs/types";
  40699. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  40700. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  40701. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  40702. /**
  40703. * Manage the pointers inputs to control an follow camera.
  40704. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40705. */
  40706. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40707. /**
  40708. * Defines the camera the input is attached to.
  40709. */
  40710. camera: FollowCamera;
  40711. /**
  40712. * Gets the class name of the current input.
  40713. * @returns the class name
  40714. */
  40715. getClassName(): string;
  40716. /**
  40717. * Defines the pointer angular sensibility along the X axis or how fast is
  40718. * the camera rotating.
  40719. * A negative number will reverse the axis direction.
  40720. */
  40721. angularSensibilityX: number;
  40722. /**
  40723. * Defines the pointer angular sensibility along the Y axis or how fast is
  40724. * the camera rotating.
  40725. * A negative number will reverse the axis direction.
  40726. */
  40727. angularSensibilityY: number;
  40728. /**
  40729. * Defines the pointer pinch precision or how fast is the camera zooming.
  40730. * A negative number will reverse the axis direction.
  40731. */
  40732. pinchPrecision: number;
  40733. /**
  40734. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40735. * from 0.
  40736. * It defines the percentage of current camera.radius to use as delta when
  40737. * pinch zoom is used.
  40738. */
  40739. pinchDeltaPercentage: number;
  40740. /**
  40741. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40742. */
  40743. axisXControlRadius: boolean;
  40744. /**
  40745. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40746. */
  40747. axisXControlHeight: boolean;
  40748. /**
  40749. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40750. */
  40751. axisXControlRotation: boolean;
  40752. /**
  40753. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40754. */
  40755. axisYControlRadius: boolean;
  40756. /**
  40757. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40758. */
  40759. axisYControlHeight: boolean;
  40760. /**
  40761. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40762. */
  40763. axisYControlRotation: boolean;
  40764. /**
  40765. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40766. */
  40767. axisPinchControlRadius: boolean;
  40768. /**
  40769. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40770. */
  40771. axisPinchControlHeight: boolean;
  40772. /**
  40773. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40774. */
  40775. axisPinchControlRotation: boolean;
  40776. /**
  40777. * Log error messages if basic misconfiguration has occurred.
  40778. */
  40779. warningEnable: boolean;
  40780. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40781. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40782. private _warningCounter;
  40783. private _warning;
  40784. }
  40785. }
  40786. declare module "babylonjs/Cameras/followCameraInputsManager" {
  40787. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  40788. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  40789. /**
  40790. * Default Inputs manager for the FollowCamera.
  40791. * It groups all the default supported inputs for ease of use.
  40792. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40793. */
  40794. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40795. /**
  40796. * Instantiates a new FollowCameraInputsManager.
  40797. * @param camera Defines the camera the inputs belong to
  40798. */
  40799. constructor(camera: FollowCamera);
  40800. /**
  40801. * Add keyboard input support to the input manager.
  40802. * @returns the current input manager
  40803. */
  40804. addKeyboard(): FollowCameraInputsManager;
  40805. /**
  40806. * Add mouse wheel input support to the input manager.
  40807. * @returns the current input manager
  40808. */
  40809. addMouseWheel(): FollowCameraInputsManager;
  40810. /**
  40811. * Add pointers input support to the input manager.
  40812. * @returns the current input manager
  40813. */
  40814. addPointers(): FollowCameraInputsManager;
  40815. /**
  40816. * Add orientation input support to the input manager.
  40817. * @returns the current input manager
  40818. */
  40819. addVRDeviceOrientation(): FollowCameraInputsManager;
  40820. }
  40821. }
  40822. declare module "babylonjs/Cameras/followCamera" {
  40823. import { Nullable } from "babylonjs/types";
  40824. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  40825. import { Scene } from "babylonjs/scene";
  40826. import { Vector3 } from "babylonjs/Maths/math.vector";
  40827. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40828. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  40829. /**
  40830. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40831. * an arc rotate version arcFollowCamera are available.
  40832. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40833. */
  40834. export class FollowCamera extends TargetCamera {
  40835. /**
  40836. * Distance the follow camera should follow an object at
  40837. */
  40838. radius: number;
  40839. /**
  40840. * Minimum allowed distance of the camera to the axis of rotation
  40841. * (The camera can not get closer).
  40842. * This can help limiting how the Camera is able to move in the scene.
  40843. */
  40844. lowerRadiusLimit: Nullable<number>;
  40845. /**
  40846. * Maximum allowed distance of the camera to the axis of rotation
  40847. * (The camera can not get further).
  40848. * This can help limiting how the Camera is able to move in the scene.
  40849. */
  40850. upperRadiusLimit: Nullable<number>;
  40851. /**
  40852. * Define a rotation offset between the camera and the object it follows
  40853. */
  40854. rotationOffset: number;
  40855. /**
  40856. * Minimum allowed angle to camera position relative to target object.
  40857. * This can help limiting how the Camera is able to move in the scene.
  40858. */
  40859. lowerRotationOffsetLimit: Nullable<number>;
  40860. /**
  40861. * Maximum allowed angle to camera position relative to target object.
  40862. * This can help limiting how the Camera is able to move in the scene.
  40863. */
  40864. upperRotationOffsetLimit: Nullable<number>;
  40865. /**
  40866. * Define a height offset between the camera and the object it follows.
  40867. * It can help following an object from the top (like a car chaing a plane)
  40868. */
  40869. heightOffset: number;
  40870. /**
  40871. * Minimum allowed height of camera position relative to target object.
  40872. * This can help limiting how the Camera is able to move in the scene.
  40873. */
  40874. lowerHeightOffsetLimit: Nullable<number>;
  40875. /**
  40876. * Maximum allowed height of camera position relative to target object.
  40877. * This can help limiting how the Camera is able to move in the scene.
  40878. */
  40879. upperHeightOffsetLimit: Nullable<number>;
  40880. /**
  40881. * Define how fast the camera can accelerate to follow it s target.
  40882. */
  40883. cameraAcceleration: number;
  40884. /**
  40885. * Define the speed limit of the camera following an object.
  40886. */
  40887. maxCameraSpeed: number;
  40888. /**
  40889. * Define the target of the camera.
  40890. */
  40891. lockedTarget: Nullable<AbstractMesh>;
  40892. /**
  40893. * Defines the input associated with the camera.
  40894. */
  40895. inputs: FollowCameraInputsManager;
  40896. /**
  40897. * Instantiates the follow camera.
  40898. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40899. * @param name Define the name of the camera in the scene
  40900. * @param position Define the position of the camera
  40901. * @param scene Define the scene the camera belong to
  40902. * @param lockedTarget Define the target of the camera
  40903. */
  40904. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40905. private _follow;
  40906. /**
  40907. * Attached controls to the current camera.
  40908. * @param element Defines the element the controls should be listened from
  40909. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40910. */
  40911. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40912. /**
  40913. * Detach the current controls from the camera.
  40914. * The camera will stop reacting to inputs.
  40915. * @param element Defines the element to stop listening the inputs from
  40916. */
  40917. detachControl(element: HTMLElement): void;
  40918. /** @hidden */
  40919. _checkInputs(): void;
  40920. private _checkLimits;
  40921. /**
  40922. * Gets the camera class name.
  40923. * @returns the class name
  40924. */
  40925. getClassName(): string;
  40926. }
  40927. /**
  40928. * Arc Rotate version of the follow camera.
  40929. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40930. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40931. */
  40932. export class ArcFollowCamera extends TargetCamera {
  40933. /** The longitudinal angle of the camera */
  40934. alpha: number;
  40935. /** The latitudinal angle of the camera */
  40936. beta: number;
  40937. /** The radius of the camera from its target */
  40938. radius: number;
  40939. /** Define the camera target (the messh it should follow) */
  40940. target: Nullable<AbstractMesh>;
  40941. private _cartesianCoordinates;
  40942. /**
  40943. * Instantiates a new ArcFollowCamera
  40944. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40945. * @param name Define the name of the camera
  40946. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40947. * @param beta Define the rotation angle of the camera around the elevation axis
  40948. * @param radius Define the radius of the camera from its target point
  40949. * @param target Define the target of the camera
  40950. * @param scene Define the scene the camera belongs to
  40951. */
  40952. constructor(name: string,
  40953. /** The longitudinal angle of the camera */
  40954. alpha: number,
  40955. /** The latitudinal angle of the camera */
  40956. beta: number,
  40957. /** The radius of the camera from its target */
  40958. radius: number,
  40959. /** Define the camera target (the messh it should follow) */
  40960. target: Nullable<AbstractMesh>, scene: Scene);
  40961. private _follow;
  40962. /** @hidden */
  40963. _checkInputs(): void;
  40964. /**
  40965. * Returns the class name of the object.
  40966. * It is mostly used internally for serialization purposes.
  40967. */
  40968. getClassName(): string;
  40969. }
  40970. }
  40971. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  40972. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40973. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  40974. import { Nullable } from "babylonjs/types";
  40975. /**
  40976. * Manage the keyboard inputs to control the movement of a follow camera.
  40977. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40978. */
  40979. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40980. /**
  40981. * Defines the camera the input is attached to.
  40982. */
  40983. camera: FollowCamera;
  40984. /**
  40985. * Defines the list of key codes associated with the up action (increase heightOffset)
  40986. */
  40987. keysHeightOffsetIncr: number[];
  40988. /**
  40989. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40990. */
  40991. keysHeightOffsetDecr: number[];
  40992. /**
  40993. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40994. */
  40995. keysHeightOffsetModifierAlt: boolean;
  40996. /**
  40997. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40998. */
  40999. keysHeightOffsetModifierCtrl: boolean;
  41000. /**
  41001. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41002. */
  41003. keysHeightOffsetModifierShift: boolean;
  41004. /**
  41005. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41006. */
  41007. keysRotationOffsetIncr: number[];
  41008. /**
  41009. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41010. */
  41011. keysRotationOffsetDecr: number[];
  41012. /**
  41013. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41014. */
  41015. keysRotationOffsetModifierAlt: boolean;
  41016. /**
  41017. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41018. */
  41019. keysRotationOffsetModifierCtrl: boolean;
  41020. /**
  41021. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41022. */
  41023. keysRotationOffsetModifierShift: boolean;
  41024. /**
  41025. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41026. */
  41027. keysRadiusIncr: number[];
  41028. /**
  41029. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41030. */
  41031. keysRadiusDecr: number[];
  41032. /**
  41033. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41034. */
  41035. keysRadiusModifierAlt: boolean;
  41036. /**
  41037. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41038. */
  41039. keysRadiusModifierCtrl: boolean;
  41040. /**
  41041. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41042. */
  41043. keysRadiusModifierShift: boolean;
  41044. /**
  41045. * Defines the rate of change of heightOffset.
  41046. */
  41047. heightSensibility: number;
  41048. /**
  41049. * Defines the rate of change of rotationOffset.
  41050. */
  41051. rotationSensibility: number;
  41052. /**
  41053. * Defines the rate of change of radius.
  41054. */
  41055. radiusSensibility: number;
  41056. private _keys;
  41057. private _ctrlPressed;
  41058. private _altPressed;
  41059. private _shiftPressed;
  41060. private _onCanvasBlurObserver;
  41061. private _onKeyboardObserver;
  41062. private _engine;
  41063. private _scene;
  41064. /**
  41065. * Attach the input controls to a specific dom element to get the input from.
  41066. * @param element Defines the element the controls should be listened from
  41067. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41068. */
  41069. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41070. /**
  41071. * Detach the current controls from the specified dom element.
  41072. * @param element Defines the element to stop listening the inputs from
  41073. */
  41074. detachControl(element: Nullable<HTMLElement>): void;
  41075. /**
  41076. * Update the current camera state depending on the inputs that have been used this frame.
  41077. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41078. */
  41079. checkInputs(): void;
  41080. /**
  41081. * Gets the class name of the current input.
  41082. * @returns the class name
  41083. */
  41084. getClassName(): string;
  41085. /**
  41086. * Get the friendly name associated with the input class.
  41087. * @returns the input friendly name
  41088. */
  41089. getSimpleName(): string;
  41090. /**
  41091. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41092. * allow modification of the heightOffset value.
  41093. */
  41094. private _modifierHeightOffset;
  41095. /**
  41096. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41097. * allow modification of the rotationOffset value.
  41098. */
  41099. private _modifierRotationOffset;
  41100. /**
  41101. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41102. * allow modification of the radius value.
  41103. */
  41104. private _modifierRadius;
  41105. }
  41106. }
  41107. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  41108. import { Nullable } from "babylonjs/types";
  41109. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41110. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41111. import { Observable } from "babylonjs/Misc/observable";
  41112. module "babylonjs/Cameras/freeCameraInputsManager" {
  41113. interface FreeCameraInputsManager {
  41114. /**
  41115. * @hidden
  41116. */
  41117. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41118. /**
  41119. * Add orientation input support to the input manager.
  41120. * @returns the current input manager
  41121. */
  41122. addDeviceOrientation(): FreeCameraInputsManager;
  41123. }
  41124. }
  41125. /**
  41126. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41127. * Screen rotation is taken into account.
  41128. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41129. */
  41130. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41131. private _camera;
  41132. private _screenOrientationAngle;
  41133. private _constantTranform;
  41134. private _screenQuaternion;
  41135. private _alpha;
  41136. private _beta;
  41137. private _gamma;
  41138. /**
  41139. * Can be used to detect if a device orientation sensor is available on a device
  41140. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41141. * @returns a promise that will resolve on orientation change
  41142. */
  41143. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41144. /**
  41145. * @hidden
  41146. */
  41147. _onDeviceOrientationChangedObservable: Observable<void>;
  41148. /**
  41149. * Instantiates a new input
  41150. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41151. */
  41152. constructor();
  41153. /**
  41154. * Define the camera controlled by the input.
  41155. */
  41156. camera: FreeCamera;
  41157. /**
  41158. * Attach the input controls to a specific dom element to get the input from.
  41159. * @param element Defines the element the controls should be listened from
  41160. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41161. */
  41162. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41163. private _orientationChanged;
  41164. private _deviceOrientation;
  41165. /**
  41166. * Detach the current controls from the specified dom element.
  41167. * @param element Defines the element to stop listening the inputs from
  41168. */
  41169. detachControl(element: Nullable<HTMLElement>): void;
  41170. /**
  41171. * Update the current camera state depending on the inputs that have been used this frame.
  41172. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41173. */
  41174. checkInputs(): void;
  41175. /**
  41176. * Gets the class name of the current intput.
  41177. * @returns the class name
  41178. */
  41179. getClassName(): string;
  41180. /**
  41181. * Get the friendly name associated with the input class.
  41182. * @returns the input friendly name
  41183. */
  41184. getSimpleName(): string;
  41185. }
  41186. }
  41187. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  41188. import { Nullable } from "babylonjs/types";
  41189. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41190. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41191. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41192. /**
  41193. * Manage the gamepad inputs to control a free camera.
  41194. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41195. */
  41196. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41197. /**
  41198. * Define the camera the input is attached to.
  41199. */
  41200. camera: FreeCamera;
  41201. /**
  41202. * Define the Gamepad controlling the input
  41203. */
  41204. gamepad: Nullable<Gamepad>;
  41205. /**
  41206. * Defines the gamepad rotation sensiblity.
  41207. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41208. */
  41209. gamepadAngularSensibility: number;
  41210. /**
  41211. * Defines the gamepad move sensiblity.
  41212. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41213. */
  41214. gamepadMoveSensibility: number;
  41215. private _yAxisScale;
  41216. /**
  41217. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41218. */
  41219. invertYAxis: boolean;
  41220. private _onGamepadConnectedObserver;
  41221. private _onGamepadDisconnectedObserver;
  41222. private _cameraTransform;
  41223. private _deltaTransform;
  41224. private _vector3;
  41225. private _vector2;
  41226. /**
  41227. * Attach the input controls to a specific dom element to get the input from.
  41228. * @param element Defines the element the controls should be listened from
  41229. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41230. */
  41231. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41232. /**
  41233. * Detach the current controls from the specified dom element.
  41234. * @param element Defines the element to stop listening the inputs from
  41235. */
  41236. detachControl(element: Nullable<HTMLElement>): void;
  41237. /**
  41238. * Update the current camera state depending on the inputs that have been used this frame.
  41239. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41240. */
  41241. checkInputs(): void;
  41242. /**
  41243. * Gets the class name of the current intput.
  41244. * @returns the class name
  41245. */
  41246. getClassName(): string;
  41247. /**
  41248. * Get the friendly name associated with the input class.
  41249. * @returns the input friendly name
  41250. */
  41251. getSimpleName(): string;
  41252. }
  41253. }
  41254. declare module "babylonjs/Misc/virtualJoystick" {
  41255. import { Nullable } from "babylonjs/types";
  41256. import { Vector3 } from "babylonjs/Maths/math.vector";
  41257. /**
  41258. * Defines the potential axis of a Joystick
  41259. */
  41260. export enum JoystickAxis {
  41261. /** X axis */
  41262. X = 0,
  41263. /** Y axis */
  41264. Y = 1,
  41265. /** Z axis */
  41266. Z = 2
  41267. }
  41268. /**
  41269. * Class used to define virtual joystick (used in touch mode)
  41270. */
  41271. export class VirtualJoystick {
  41272. /**
  41273. * Gets or sets a boolean indicating that left and right values must be inverted
  41274. */
  41275. reverseLeftRight: boolean;
  41276. /**
  41277. * Gets or sets a boolean indicating that up and down values must be inverted
  41278. */
  41279. reverseUpDown: boolean;
  41280. /**
  41281. * Gets the offset value for the position (ie. the change of the position value)
  41282. */
  41283. deltaPosition: Vector3;
  41284. /**
  41285. * Gets a boolean indicating if the virtual joystick was pressed
  41286. */
  41287. pressed: boolean;
  41288. /**
  41289. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41290. */
  41291. static Canvas: Nullable<HTMLCanvasElement>;
  41292. private static _globalJoystickIndex;
  41293. private static vjCanvasContext;
  41294. private static vjCanvasWidth;
  41295. private static vjCanvasHeight;
  41296. private static halfWidth;
  41297. private _action;
  41298. private _axisTargetedByLeftAndRight;
  41299. private _axisTargetedByUpAndDown;
  41300. private _joystickSensibility;
  41301. private _inversedSensibility;
  41302. private _joystickPointerID;
  41303. private _joystickColor;
  41304. private _joystickPointerPos;
  41305. private _joystickPreviousPointerPos;
  41306. private _joystickPointerStartPos;
  41307. private _deltaJoystickVector;
  41308. private _leftJoystick;
  41309. private _touches;
  41310. private _onPointerDownHandlerRef;
  41311. private _onPointerMoveHandlerRef;
  41312. private _onPointerUpHandlerRef;
  41313. private _onResize;
  41314. /**
  41315. * Creates a new virtual joystick
  41316. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41317. */
  41318. constructor(leftJoystick?: boolean);
  41319. /**
  41320. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41321. * @param newJoystickSensibility defines the new sensibility
  41322. */
  41323. setJoystickSensibility(newJoystickSensibility: number): void;
  41324. private _onPointerDown;
  41325. private _onPointerMove;
  41326. private _onPointerUp;
  41327. /**
  41328. * Change the color of the virtual joystick
  41329. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41330. */
  41331. setJoystickColor(newColor: string): void;
  41332. /**
  41333. * Defines a callback to call when the joystick is touched
  41334. * @param action defines the callback
  41335. */
  41336. setActionOnTouch(action: () => any): void;
  41337. /**
  41338. * Defines which axis you'd like to control for left & right
  41339. * @param axis defines the axis to use
  41340. */
  41341. setAxisForLeftRight(axis: JoystickAxis): void;
  41342. /**
  41343. * Defines which axis you'd like to control for up & down
  41344. * @param axis defines the axis to use
  41345. */
  41346. setAxisForUpDown(axis: JoystickAxis): void;
  41347. private _drawVirtualJoystick;
  41348. /**
  41349. * Release internal HTML canvas
  41350. */
  41351. releaseCanvas(): void;
  41352. }
  41353. }
  41354. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  41355. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  41356. import { Nullable } from "babylonjs/types";
  41357. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41358. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41359. module "babylonjs/Cameras/freeCameraInputsManager" {
  41360. interface FreeCameraInputsManager {
  41361. /**
  41362. * Add virtual joystick input support to the input manager.
  41363. * @returns the current input manager
  41364. */
  41365. addVirtualJoystick(): FreeCameraInputsManager;
  41366. }
  41367. }
  41368. /**
  41369. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41370. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41371. */
  41372. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41373. /**
  41374. * Defines the camera the input is attached to.
  41375. */
  41376. camera: FreeCamera;
  41377. private _leftjoystick;
  41378. private _rightjoystick;
  41379. /**
  41380. * Gets the left stick of the virtual joystick.
  41381. * @returns The virtual Joystick
  41382. */
  41383. getLeftJoystick(): VirtualJoystick;
  41384. /**
  41385. * Gets the right stick of the virtual joystick.
  41386. * @returns The virtual Joystick
  41387. */
  41388. getRightJoystick(): VirtualJoystick;
  41389. /**
  41390. * Update the current camera state depending on the inputs that have been used this frame.
  41391. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41392. */
  41393. checkInputs(): void;
  41394. /**
  41395. * Attach the input controls to a specific dom element to get the input from.
  41396. * @param element Defines the element the controls should be listened from
  41397. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41398. */
  41399. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41400. /**
  41401. * Detach the current controls from the specified dom element.
  41402. * @param element Defines the element to stop listening the inputs from
  41403. */
  41404. detachControl(element: Nullable<HTMLElement>): void;
  41405. /**
  41406. * Gets the class name of the current intput.
  41407. * @returns the class name
  41408. */
  41409. getClassName(): string;
  41410. /**
  41411. * Get the friendly name associated with the input class.
  41412. * @returns the input friendly name
  41413. */
  41414. getSimpleName(): string;
  41415. }
  41416. }
  41417. declare module "babylonjs/Cameras/Inputs/index" {
  41418. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  41419. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  41420. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  41421. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  41422. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41423. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  41424. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  41425. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  41426. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  41427. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  41428. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  41429. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  41430. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  41431. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  41432. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  41433. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  41434. }
  41435. declare module "babylonjs/Cameras/touchCamera" {
  41436. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41437. import { Scene } from "babylonjs/scene";
  41438. import { Vector3 } from "babylonjs/Maths/math.vector";
  41439. /**
  41440. * This represents a FPS type of camera controlled by touch.
  41441. * This is like a universal camera minus the Gamepad controls.
  41442. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41443. */
  41444. export class TouchCamera extends FreeCamera {
  41445. /**
  41446. * Defines the touch sensibility for rotation.
  41447. * The higher the faster.
  41448. */
  41449. touchAngularSensibility: number;
  41450. /**
  41451. * Defines the touch sensibility for move.
  41452. * The higher the faster.
  41453. */
  41454. touchMoveSensibility: number;
  41455. /**
  41456. * Instantiates a new touch camera.
  41457. * This represents a FPS type of camera controlled by touch.
  41458. * This is like a universal camera minus the Gamepad controls.
  41459. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41460. * @param name Define the name of the camera in the scene
  41461. * @param position Define the start position of the camera in the scene
  41462. * @param scene Define the scene the camera belongs to
  41463. */
  41464. constructor(name: string, position: Vector3, scene: Scene);
  41465. /**
  41466. * Gets the current object class name.
  41467. * @return the class name
  41468. */
  41469. getClassName(): string;
  41470. /** @hidden */
  41471. _setupInputs(): void;
  41472. }
  41473. }
  41474. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  41475. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41476. import { Scene } from "babylonjs/scene";
  41477. import { Vector3 } from "babylonjs/Maths/math.vector";
  41478. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  41479. import { Axis } from "babylonjs/Maths/math.axis";
  41480. /**
  41481. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  41482. * being tilted forward or back and left or right.
  41483. */
  41484. export class DeviceOrientationCamera extends FreeCamera {
  41485. private _initialQuaternion;
  41486. private _quaternionCache;
  41487. private _tmpDragQuaternion;
  41488. private _disablePointerInputWhenUsingDeviceOrientation;
  41489. /**
  41490. * Creates a new device orientation camera
  41491. * @param name The name of the camera
  41492. * @param position The start position camera
  41493. * @param scene The scene the camera belongs to
  41494. */
  41495. constructor(name: string, position: Vector3, scene: Scene);
  41496. /**
  41497. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  41498. */
  41499. disablePointerInputWhenUsingDeviceOrientation: boolean;
  41500. private _dragFactor;
  41501. /**
  41502. * Enabled turning on the y axis when the orientation sensor is active
  41503. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  41504. */
  41505. enableHorizontalDragging(dragFactor?: number): void;
  41506. /**
  41507. * Gets the current instance class name ("DeviceOrientationCamera").
  41508. * This helps avoiding instanceof at run time.
  41509. * @returns the class name
  41510. */
  41511. getClassName(): string;
  41512. /**
  41513. * @hidden
  41514. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  41515. */
  41516. _checkInputs(): void;
  41517. /**
  41518. * Reset the camera to its default orientation on the specified axis only.
  41519. * @param axis The axis to reset
  41520. */
  41521. resetToCurrentRotation(axis?: Axis): void;
  41522. }
  41523. }
  41524. declare module "babylonjs/Gamepads/xboxGamepad" {
  41525. import { Observable } from "babylonjs/Misc/observable";
  41526. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41527. /**
  41528. * Defines supported buttons for XBox360 compatible gamepads
  41529. */
  41530. export enum Xbox360Button {
  41531. /** A */
  41532. A = 0,
  41533. /** B */
  41534. B = 1,
  41535. /** X */
  41536. X = 2,
  41537. /** Y */
  41538. Y = 3,
  41539. /** Start */
  41540. Start = 4,
  41541. /** Back */
  41542. Back = 5,
  41543. /** Left button */
  41544. LB = 6,
  41545. /** Right button */
  41546. RB = 7,
  41547. /** Left stick */
  41548. LeftStick = 8,
  41549. /** Right stick */
  41550. RightStick = 9
  41551. }
  41552. /** Defines values for XBox360 DPad */
  41553. export enum Xbox360Dpad {
  41554. /** Up */
  41555. Up = 0,
  41556. /** Down */
  41557. Down = 1,
  41558. /** Left */
  41559. Left = 2,
  41560. /** Right */
  41561. Right = 3
  41562. }
  41563. /**
  41564. * Defines a XBox360 gamepad
  41565. */
  41566. export class Xbox360Pad extends Gamepad {
  41567. private _leftTrigger;
  41568. private _rightTrigger;
  41569. private _onlefttriggerchanged;
  41570. private _onrighttriggerchanged;
  41571. private _onbuttondown;
  41572. private _onbuttonup;
  41573. private _ondpaddown;
  41574. private _ondpadup;
  41575. /** Observable raised when a button is pressed */
  41576. onButtonDownObservable: Observable<Xbox360Button>;
  41577. /** Observable raised when a button is released */
  41578. onButtonUpObservable: Observable<Xbox360Button>;
  41579. /** Observable raised when a pad is pressed */
  41580. onPadDownObservable: Observable<Xbox360Dpad>;
  41581. /** Observable raised when a pad is released */
  41582. onPadUpObservable: Observable<Xbox360Dpad>;
  41583. private _buttonA;
  41584. private _buttonB;
  41585. private _buttonX;
  41586. private _buttonY;
  41587. private _buttonBack;
  41588. private _buttonStart;
  41589. private _buttonLB;
  41590. private _buttonRB;
  41591. private _buttonLeftStick;
  41592. private _buttonRightStick;
  41593. private _dPadUp;
  41594. private _dPadDown;
  41595. private _dPadLeft;
  41596. private _dPadRight;
  41597. private _isXboxOnePad;
  41598. /**
  41599. * Creates a new XBox360 gamepad object
  41600. * @param id defines the id of this gamepad
  41601. * @param index defines its index
  41602. * @param gamepad defines the internal HTML gamepad object
  41603. * @param xboxOne defines if it is a XBox One gamepad
  41604. */
  41605. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  41606. /**
  41607. * Defines the callback to call when left trigger is pressed
  41608. * @param callback defines the callback to use
  41609. */
  41610. onlefttriggerchanged(callback: (value: number) => void): void;
  41611. /**
  41612. * Defines the callback to call when right trigger is pressed
  41613. * @param callback defines the callback to use
  41614. */
  41615. onrighttriggerchanged(callback: (value: number) => void): void;
  41616. /**
  41617. * Gets the left trigger value
  41618. */
  41619. /**
  41620. * Sets the left trigger value
  41621. */
  41622. leftTrigger: number;
  41623. /**
  41624. * Gets the right trigger value
  41625. */
  41626. /**
  41627. * Sets the right trigger value
  41628. */
  41629. rightTrigger: number;
  41630. /**
  41631. * Defines the callback to call when a button is pressed
  41632. * @param callback defines the callback to use
  41633. */
  41634. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  41635. /**
  41636. * Defines the callback to call when a button is released
  41637. * @param callback defines the callback to use
  41638. */
  41639. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  41640. /**
  41641. * Defines the callback to call when a pad is pressed
  41642. * @param callback defines the callback to use
  41643. */
  41644. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  41645. /**
  41646. * Defines the callback to call when a pad is released
  41647. * @param callback defines the callback to use
  41648. */
  41649. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  41650. private _setButtonValue;
  41651. private _setDPadValue;
  41652. /**
  41653. * Gets the value of the `A` button
  41654. */
  41655. /**
  41656. * Sets the value of the `A` button
  41657. */
  41658. buttonA: number;
  41659. /**
  41660. * Gets the value of the `B` button
  41661. */
  41662. /**
  41663. * Sets the value of the `B` button
  41664. */
  41665. buttonB: number;
  41666. /**
  41667. * Gets the value of the `X` button
  41668. */
  41669. /**
  41670. * Sets the value of the `X` button
  41671. */
  41672. buttonX: number;
  41673. /**
  41674. * Gets the value of the `Y` button
  41675. */
  41676. /**
  41677. * Sets the value of the `Y` button
  41678. */
  41679. buttonY: number;
  41680. /**
  41681. * Gets the value of the `Start` button
  41682. */
  41683. /**
  41684. * Sets the value of the `Start` button
  41685. */
  41686. buttonStart: number;
  41687. /**
  41688. * Gets the value of the `Back` button
  41689. */
  41690. /**
  41691. * Sets the value of the `Back` button
  41692. */
  41693. buttonBack: number;
  41694. /**
  41695. * Gets the value of the `Left` button
  41696. */
  41697. /**
  41698. * Sets the value of the `Left` button
  41699. */
  41700. buttonLB: number;
  41701. /**
  41702. * Gets the value of the `Right` button
  41703. */
  41704. /**
  41705. * Sets the value of the `Right` button
  41706. */
  41707. buttonRB: number;
  41708. /**
  41709. * Gets the value of the Left joystick
  41710. */
  41711. /**
  41712. * Sets the value of the Left joystick
  41713. */
  41714. buttonLeftStick: number;
  41715. /**
  41716. * Gets the value of the Right joystick
  41717. */
  41718. /**
  41719. * Sets the value of the Right joystick
  41720. */
  41721. buttonRightStick: number;
  41722. /**
  41723. * Gets the value of D-pad up
  41724. */
  41725. /**
  41726. * Sets the value of D-pad up
  41727. */
  41728. dPadUp: number;
  41729. /**
  41730. * Gets the value of D-pad down
  41731. */
  41732. /**
  41733. * Sets the value of D-pad down
  41734. */
  41735. dPadDown: number;
  41736. /**
  41737. * Gets the value of D-pad left
  41738. */
  41739. /**
  41740. * Sets the value of D-pad left
  41741. */
  41742. dPadLeft: number;
  41743. /**
  41744. * Gets the value of D-pad right
  41745. */
  41746. /**
  41747. * Sets the value of D-pad right
  41748. */
  41749. dPadRight: number;
  41750. /**
  41751. * Force the gamepad to synchronize with device values
  41752. */
  41753. update(): void;
  41754. /**
  41755. * Disposes the gamepad
  41756. */
  41757. dispose(): void;
  41758. }
  41759. }
  41760. declare module "babylonjs/Gamepads/dualShockGamepad" {
  41761. import { Observable } from "babylonjs/Misc/observable";
  41762. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41763. /**
  41764. * Defines supported buttons for DualShock compatible gamepads
  41765. */
  41766. export enum DualShockButton {
  41767. /** Cross */
  41768. Cross = 0,
  41769. /** Circle */
  41770. Circle = 1,
  41771. /** Square */
  41772. Square = 2,
  41773. /** Triangle */
  41774. Triangle = 3,
  41775. /** Options */
  41776. Options = 4,
  41777. /** Share */
  41778. Share = 5,
  41779. /** L1 */
  41780. L1 = 6,
  41781. /** R1 */
  41782. R1 = 7,
  41783. /** Left stick */
  41784. LeftStick = 8,
  41785. /** Right stick */
  41786. RightStick = 9
  41787. }
  41788. /** Defines values for DualShock DPad */
  41789. export enum DualShockDpad {
  41790. /** Up */
  41791. Up = 0,
  41792. /** Down */
  41793. Down = 1,
  41794. /** Left */
  41795. Left = 2,
  41796. /** Right */
  41797. Right = 3
  41798. }
  41799. /**
  41800. * Defines a DualShock gamepad
  41801. */
  41802. export class DualShockPad extends Gamepad {
  41803. private _leftTrigger;
  41804. private _rightTrigger;
  41805. private _onlefttriggerchanged;
  41806. private _onrighttriggerchanged;
  41807. private _onbuttondown;
  41808. private _onbuttonup;
  41809. private _ondpaddown;
  41810. private _ondpadup;
  41811. /** Observable raised when a button is pressed */
  41812. onButtonDownObservable: Observable<DualShockButton>;
  41813. /** Observable raised when a button is released */
  41814. onButtonUpObservable: Observable<DualShockButton>;
  41815. /** Observable raised when a pad is pressed */
  41816. onPadDownObservable: Observable<DualShockDpad>;
  41817. /** Observable raised when a pad is released */
  41818. onPadUpObservable: Observable<DualShockDpad>;
  41819. private _buttonCross;
  41820. private _buttonCircle;
  41821. private _buttonSquare;
  41822. private _buttonTriangle;
  41823. private _buttonShare;
  41824. private _buttonOptions;
  41825. private _buttonL1;
  41826. private _buttonR1;
  41827. private _buttonLeftStick;
  41828. private _buttonRightStick;
  41829. private _dPadUp;
  41830. private _dPadDown;
  41831. private _dPadLeft;
  41832. private _dPadRight;
  41833. /**
  41834. * Creates a new DualShock gamepad object
  41835. * @param id defines the id of this gamepad
  41836. * @param index defines its index
  41837. * @param gamepad defines the internal HTML gamepad object
  41838. */
  41839. constructor(id: string, index: number, gamepad: any);
  41840. /**
  41841. * Defines the callback to call when left trigger is pressed
  41842. * @param callback defines the callback to use
  41843. */
  41844. onlefttriggerchanged(callback: (value: number) => void): void;
  41845. /**
  41846. * Defines the callback to call when right trigger is pressed
  41847. * @param callback defines the callback to use
  41848. */
  41849. onrighttriggerchanged(callback: (value: number) => void): void;
  41850. /**
  41851. * Gets the left trigger value
  41852. */
  41853. /**
  41854. * Sets the left trigger value
  41855. */
  41856. leftTrigger: number;
  41857. /**
  41858. * Gets the right trigger value
  41859. */
  41860. /**
  41861. * Sets the right trigger value
  41862. */
  41863. rightTrigger: number;
  41864. /**
  41865. * Defines the callback to call when a button is pressed
  41866. * @param callback defines the callback to use
  41867. */
  41868. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41869. /**
  41870. * Defines the callback to call when a button is released
  41871. * @param callback defines the callback to use
  41872. */
  41873. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41874. /**
  41875. * Defines the callback to call when a pad is pressed
  41876. * @param callback defines the callback to use
  41877. */
  41878. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41879. /**
  41880. * Defines the callback to call when a pad is released
  41881. * @param callback defines the callback to use
  41882. */
  41883. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41884. private _setButtonValue;
  41885. private _setDPadValue;
  41886. /**
  41887. * Gets the value of the `Cross` button
  41888. */
  41889. /**
  41890. * Sets the value of the `Cross` button
  41891. */
  41892. buttonCross: number;
  41893. /**
  41894. * Gets the value of the `Circle` button
  41895. */
  41896. /**
  41897. * Sets the value of the `Circle` button
  41898. */
  41899. buttonCircle: number;
  41900. /**
  41901. * Gets the value of the `Square` button
  41902. */
  41903. /**
  41904. * Sets the value of the `Square` button
  41905. */
  41906. buttonSquare: number;
  41907. /**
  41908. * Gets the value of the `Triangle` button
  41909. */
  41910. /**
  41911. * Sets the value of the `Triangle` button
  41912. */
  41913. buttonTriangle: number;
  41914. /**
  41915. * Gets the value of the `Options` button
  41916. */
  41917. /**
  41918. * Sets the value of the `Options` button
  41919. */
  41920. buttonOptions: number;
  41921. /**
  41922. * Gets the value of the `Share` button
  41923. */
  41924. /**
  41925. * Sets the value of the `Share` button
  41926. */
  41927. buttonShare: number;
  41928. /**
  41929. * Gets the value of the `L1` button
  41930. */
  41931. /**
  41932. * Sets the value of the `L1` button
  41933. */
  41934. buttonL1: number;
  41935. /**
  41936. * Gets the value of the `R1` button
  41937. */
  41938. /**
  41939. * Sets the value of the `R1` button
  41940. */
  41941. buttonR1: number;
  41942. /**
  41943. * Gets the value of the Left joystick
  41944. */
  41945. /**
  41946. * Sets the value of the Left joystick
  41947. */
  41948. buttonLeftStick: number;
  41949. /**
  41950. * Gets the value of the Right joystick
  41951. */
  41952. /**
  41953. * Sets the value of the Right joystick
  41954. */
  41955. buttonRightStick: number;
  41956. /**
  41957. * Gets the value of D-pad up
  41958. */
  41959. /**
  41960. * Sets the value of D-pad up
  41961. */
  41962. dPadUp: number;
  41963. /**
  41964. * Gets the value of D-pad down
  41965. */
  41966. /**
  41967. * Sets the value of D-pad down
  41968. */
  41969. dPadDown: number;
  41970. /**
  41971. * Gets the value of D-pad left
  41972. */
  41973. /**
  41974. * Sets the value of D-pad left
  41975. */
  41976. dPadLeft: number;
  41977. /**
  41978. * Gets the value of D-pad right
  41979. */
  41980. /**
  41981. * Sets the value of D-pad right
  41982. */
  41983. dPadRight: number;
  41984. /**
  41985. * Force the gamepad to synchronize with device values
  41986. */
  41987. update(): void;
  41988. /**
  41989. * Disposes the gamepad
  41990. */
  41991. dispose(): void;
  41992. }
  41993. }
  41994. declare module "babylonjs/Gamepads/gamepadManager" {
  41995. import { Observable } from "babylonjs/Misc/observable";
  41996. import { Nullable } from "babylonjs/types";
  41997. import { Scene } from "babylonjs/scene";
  41998. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41999. /**
  42000. * Manager for handling gamepads
  42001. */
  42002. export class GamepadManager {
  42003. private _scene?;
  42004. private _babylonGamepads;
  42005. private _oneGamepadConnected;
  42006. /** @hidden */
  42007. _isMonitoring: boolean;
  42008. private _gamepadEventSupported;
  42009. private _gamepadSupport;
  42010. /**
  42011. * observable to be triggered when the gamepad controller has been connected
  42012. */
  42013. onGamepadConnectedObservable: Observable<Gamepad>;
  42014. /**
  42015. * observable to be triggered when the gamepad controller has been disconnected
  42016. */
  42017. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42018. private _onGamepadConnectedEvent;
  42019. private _onGamepadDisconnectedEvent;
  42020. /**
  42021. * Initializes the gamepad manager
  42022. * @param _scene BabylonJS scene
  42023. */
  42024. constructor(_scene?: Scene | undefined);
  42025. /**
  42026. * The gamepads in the game pad manager
  42027. */
  42028. readonly gamepads: Gamepad[];
  42029. /**
  42030. * Get the gamepad controllers based on type
  42031. * @param type The type of gamepad controller
  42032. * @returns Nullable gamepad
  42033. */
  42034. getGamepadByType(type?: number): Nullable<Gamepad>;
  42035. /**
  42036. * Disposes the gamepad manager
  42037. */
  42038. dispose(): void;
  42039. private _addNewGamepad;
  42040. private _startMonitoringGamepads;
  42041. private _stopMonitoringGamepads;
  42042. /** @hidden */
  42043. _checkGamepadsStatus(): void;
  42044. private _updateGamepadObjects;
  42045. }
  42046. }
  42047. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  42048. import { Nullable } from "babylonjs/types";
  42049. import { Scene } from "babylonjs/scene";
  42050. import { ISceneComponent } from "babylonjs/sceneComponent";
  42051. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  42052. module "babylonjs/scene" {
  42053. interface Scene {
  42054. /** @hidden */
  42055. _gamepadManager: Nullable<GamepadManager>;
  42056. /**
  42057. * Gets the gamepad manager associated with the scene
  42058. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42059. */
  42060. gamepadManager: GamepadManager;
  42061. }
  42062. }
  42063. module "babylonjs/Cameras/freeCameraInputsManager" {
  42064. /**
  42065. * Interface representing a free camera inputs manager
  42066. */
  42067. interface FreeCameraInputsManager {
  42068. /**
  42069. * Adds gamepad input support to the FreeCameraInputsManager.
  42070. * @returns the FreeCameraInputsManager
  42071. */
  42072. addGamepad(): FreeCameraInputsManager;
  42073. }
  42074. }
  42075. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42076. /**
  42077. * Interface representing an arc rotate camera inputs manager
  42078. */
  42079. interface ArcRotateCameraInputsManager {
  42080. /**
  42081. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42082. * @returns the camera inputs manager
  42083. */
  42084. addGamepad(): ArcRotateCameraInputsManager;
  42085. }
  42086. }
  42087. /**
  42088. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42089. */
  42090. export class GamepadSystemSceneComponent implements ISceneComponent {
  42091. /**
  42092. * The component name helpfull to identify the component in the list of scene components.
  42093. */
  42094. readonly name: string;
  42095. /**
  42096. * The scene the component belongs to.
  42097. */
  42098. scene: Scene;
  42099. /**
  42100. * Creates a new instance of the component for the given scene
  42101. * @param scene Defines the scene to register the component in
  42102. */
  42103. constructor(scene: Scene);
  42104. /**
  42105. * Registers the component in a given scene
  42106. */
  42107. register(): void;
  42108. /**
  42109. * Rebuilds the elements related to this component in case of
  42110. * context lost for instance.
  42111. */
  42112. rebuild(): void;
  42113. /**
  42114. * Disposes the component and the associated ressources
  42115. */
  42116. dispose(): void;
  42117. private _beforeCameraUpdate;
  42118. }
  42119. }
  42120. declare module "babylonjs/Cameras/universalCamera" {
  42121. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  42122. import { Scene } from "babylonjs/scene";
  42123. import { Vector3 } from "babylonjs/Maths/math.vector";
  42124. import "babylonjs/Gamepads/gamepadSceneComponent";
  42125. /**
  42126. * 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,
  42127. * which still works and will still be found in many Playgrounds.
  42128. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42129. */
  42130. export class UniversalCamera extends TouchCamera {
  42131. /**
  42132. * Defines the gamepad rotation sensiblity.
  42133. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42134. */
  42135. gamepadAngularSensibility: number;
  42136. /**
  42137. * Defines the gamepad move sensiblity.
  42138. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42139. */
  42140. gamepadMoveSensibility: number;
  42141. /**
  42142. * 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,
  42143. * which still works and will still be found in many Playgrounds.
  42144. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42145. * @param name Define the name of the camera in the scene
  42146. * @param position Define the start position of the camera in the scene
  42147. * @param scene Define the scene the camera belongs to
  42148. */
  42149. constructor(name: string, position: Vector3, scene: Scene);
  42150. /**
  42151. * Gets the current object class name.
  42152. * @return the class name
  42153. */
  42154. getClassName(): string;
  42155. }
  42156. }
  42157. declare module "babylonjs/Cameras/gamepadCamera" {
  42158. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42159. import { Scene } from "babylonjs/scene";
  42160. import { Vector3 } from "babylonjs/Maths/math.vector";
  42161. /**
  42162. * This represents a FPS type of camera. This is only here for back compat purpose.
  42163. * Please use the UniversalCamera instead as both are identical.
  42164. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42165. */
  42166. export class GamepadCamera extends UniversalCamera {
  42167. /**
  42168. * Instantiates a new Gamepad Camera
  42169. * This represents a FPS type of camera. This is only here for back compat purpose.
  42170. * Please use the UniversalCamera instead as both are identical.
  42171. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42172. * @param name Define the name of the camera in the scene
  42173. * @param position Define the start position of the camera in the scene
  42174. * @param scene Define the scene the camera belongs to
  42175. */
  42176. constructor(name: string, position: Vector3, scene: Scene);
  42177. /**
  42178. * Gets the current object class name.
  42179. * @return the class name
  42180. */
  42181. getClassName(): string;
  42182. }
  42183. }
  42184. declare module "babylonjs/Shaders/pass.fragment" {
  42185. /** @hidden */
  42186. export var passPixelShader: {
  42187. name: string;
  42188. shader: string;
  42189. };
  42190. }
  42191. declare module "babylonjs/Shaders/passCube.fragment" {
  42192. /** @hidden */
  42193. export var passCubePixelShader: {
  42194. name: string;
  42195. shader: string;
  42196. };
  42197. }
  42198. declare module "babylonjs/PostProcesses/passPostProcess" {
  42199. import { Nullable } from "babylonjs/types";
  42200. import { Camera } from "babylonjs/Cameras/camera";
  42201. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42202. import { Engine } from "babylonjs/Engines/engine";
  42203. import "babylonjs/Shaders/pass.fragment";
  42204. import "babylonjs/Shaders/passCube.fragment";
  42205. /**
  42206. * PassPostProcess which produces an output the same as it's input
  42207. */
  42208. export class PassPostProcess extends PostProcess {
  42209. /**
  42210. * Creates the PassPostProcess
  42211. * @param name The name of the effect.
  42212. * @param options The required width/height ratio to downsize to before computing the render pass.
  42213. * @param camera The camera to apply the render pass to.
  42214. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42215. * @param engine The engine which the post process will be applied. (default: current engine)
  42216. * @param reusable If the post process can be reused on the same frame. (default: false)
  42217. * @param textureType The type of texture to be used when performing the post processing.
  42218. * @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)
  42219. */
  42220. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42221. }
  42222. /**
  42223. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42224. */
  42225. export class PassCubePostProcess extends PostProcess {
  42226. private _face;
  42227. /**
  42228. * Gets or sets the cube face to display.
  42229. * * 0 is +X
  42230. * * 1 is -X
  42231. * * 2 is +Y
  42232. * * 3 is -Y
  42233. * * 4 is +Z
  42234. * * 5 is -Z
  42235. */
  42236. face: number;
  42237. /**
  42238. * Creates the PassCubePostProcess
  42239. * @param name The name of the effect.
  42240. * @param options The required width/height ratio to downsize to before computing the render pass.
  42241. * @param camera The camera to apply the render pass to.
  42242. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42243. * @param engine The engine which the post process will be applied. (default: current engine)
  42244. * @param reusable If the post process can be reused on the same frame. (default: false)
  42245. * @param textureType The type of texture to be used when performing the post processing.
  42246. * @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)
  42247. */
  42248. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42249. }
  42250. }
  42251. declare module "babylonjs/Shaders/anaglyph.fragment" {
  42252. /** @hidden */
  42253. export var anaglyphPixelShader: {
  42254. name: string;
  42255. shader: string;
  42256. };
  42257. }
  42258. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  42259. import { Engine } from "babylonjs/Engines/engine";
  42260. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42261. import { Camera } from "babylonjs/Cameras/camera";
  42262. import "babylonjs/Shaders/anaglyph.fragment";
  42263. /**
  42264. * Postprocess used to generate anaglyphic rendering
  42265. */
  42266. export class AnaglyphPostProcess extends PostProcess {
  42267. private _passedProcess;
  42268. /**
  42269. * Creates a new AnaglyphPostProcess
  42270. * @param name defines postprocess name
  42271. * @param options defines creation options or target ratio scale
  42272. * @param rigCameras defines cameras using this postprocess
  42273. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42274. * @param engine defines hosting engine
  42275. * @param reusable defines if the postprocess will be reused multiple times per frame
  42276. */
  42277. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42278. }
  42279. }
  42280. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  42281. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  42282. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42283. import { Scene } from "babylonjs/scene";
  42284. import { Vector3 } from "babylonjs/Maths/math.vector";
  42285. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42286. /**
  42287. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42288. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42289. */
  42290. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42291. /**
  42292. * Creates a new AnaglyphArcRotateCamera
  42293. * @param name defines camera name
  42294. * @param alpha defines alpha angle (in radians)
  42295. * @param beta defines beta angle (in radians)
  42296. * @param radius defines radius
  42297. * @param target defines camera target
  42298. * @param interaxialDistance defines distance between each color axis
  42299. * @param scene defines the hosting scene
  42300. */
  42301. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42302. /**
  42303. * Gets camera class name
  42304. * @returns AnaglyphArcRotateCamera
  42305. */
  42306. getClassName(): string;
  42307. }
  42308. }
  42309. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  42310. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42311. import { Scene } from "babylonjs/scene";
  42312. import { Vector3 } from "babylonjs/Maths/math.vector";
  42313. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42314. /**
  42315. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42316. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42317. */
  42318. export class AnaglyphFreeCamera extends FreeCamera {
  42319. /**
  42320. * Creates a new AnaglyphFreeCamera
  42321. * @param name defines camera name
  42322. * @param position defines initial position
  42323. * @param interaxialDistance defines distance between each color axis
  42324. * @param scene defines the hosting scene
  42325. */
  42326. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42327. /**
  42328. * Gets camera class name
  42329. * @returns AnaglyphFreeCamera
  42330. */
  42331. getClassName(): string;
  42332. }
  42333. }
  42334. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  42335. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  42336. import { Scene } from "babylonjs/scene";
  42337. import { Vector3 } from "babylonjs/Maths/math.vector";
  42338. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42339. /**
  42340. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42341. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42342. */
  42343. export class AnaglyphGamepadCamera extends GamepadCamera {
  42344. /**
  42345. * Creates a new AnaglyphGamepadCamera
  42346. * @param name defines camera name
  42347. * @param position defines initial position
  42348. * @param interaxialDistance defines distance between each color axis
  42349. * @param scene defines the hosting scene
  42350. */
  42351. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42352. /**
  42353. * Gets camera class name
  42354. * @returns AnaglyphGamepadCamera
  42355. */
  42356. getClassName(): string;
  42357. }
  42358. }
  42359. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  42360. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42361. import { Scene } from "babylonjs/scene";
  42362. import { Vector3 } from "babylonjs/Maths/math.vector";
  42363. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42364. /**
  42365. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42366. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42367. */
  42368. export class AnaglyphUniversalCamera extends UniversalCamera {
  42369. /**
  42370. * Creates a new AnaglyphUniversalCamera
  42371. * @param name defines camera name
  42372. * @param position defines initial position
  42373. * @param interaxialDistance defines distance between each color axis
  42374. * @param scene defines the hosting scene
  42375. */
  42376. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42377. /**
  42378. * Gets camera class name
  42379. * @returns AnaglyphUniversalCamera
  42380. */
  42381. getClassName(): string;
  42382. }
  42383. }
  42384. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  42385. /** @hidden */
  42386. export var stereoscopicInterlacePixelShader: {
  42387. name: string;
  42388. shader: string;
  42389. };
  42390. }
  42391. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  42392. import { Camera } from "babylonjs/Cameras/camera";
  42393. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  42394. import { Engine } from "babylonjs/Engines/engine";
  42395. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  42396. /**
  42397. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  42398. */
  42399. export class StereoscopicInterlacePostProcess extends PostProcess {
  42400. private _stepSize;
  42401. private _passedProcess;
  42402. /**
  42403. * Initializes a StereoscopicInterlacePostProcess
  42404. * @param name The name of the effect.
  42405. * @param rigCameras The rig cameras to be appled to the post process
  42406. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  42407. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42408. * @param engine The engine which the post process will be applied. (default: current engine)
  42409. * @param reusable If the post process can be reused on the same frame. (default: false)
  42410. */
  42411. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42412. }
  42413. }
  42414. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  42415. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  42416. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42417. import { Scene } from "babylonjs/scene";
  42418. import { Vector3 } from "babylonjs/Maths/math.vector";
  42419. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42420. /**
  42421. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42422. * @see http://doc.babylonjs.com/features/cameras
  42423. */
  42424. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42425. /**
  42426. * Creates a new StereoscopicArcRotateCamera
  42427. * @param name defines camera name
  42428. * @param alpha defines alpha angle (in radians)
  42429. * @param beta defines beta angle (in radians)
  42430. * @param radius defines radius
  42431. * @param target defines camera target
  42432. * @param interaxialDistance defines distance between each color axis
  42433. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42434. * @param scene defines the hosting scene
  42435. */
  42436. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42437. /**
  42438. * Gets camera class name
  42439. * @returns StereoscopicArcRotateCamera
  42440. */
  42441. getClassName(): string;
  42442. }
  42443. }
  42444. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  42445. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42446. import { Scene } from "babylonjs/scene";
  42447. import { Vector3 } from "babylonjs/Maths/math.vector";
  42448. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42449. /**
  42450. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42451. * @see http://doc.babylonjs.com/features/cameras
  42452. */
  42453. export class StereoscopicFreeCamera extends FreeCamera {
  42454. /**
  42455. * Creates a new StereoscopicFreeCamera
  42456. * @param name defines camera name
  42457. * @param position defines initial position
  42458. * @param interaxialDistance defines distance between each color axis
  42459. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42460. * @param scene defines the hosting scene
  42461. */
  42462. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42463. /**
  42464. * Gets camera class name
  42465. * @returns StereoscopicFreeCamera
  42466. */
  42467. getClassName(): string;
  42468. }
  42469. }
  42470. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  42471. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  42472. import { Scene } from "babylonjs/scene";
  42473. import { Vector3 } from "babylonjs/Maths/math.vector";
  42474. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42475. /**
  42476. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42477. * @see http://doc.babylonjs.com/features/cameras
  42478. */
  42479. export class StereoscopicGamepadCamera extends GamepadCamera {
  42480. /**
  42481. * Creates a new StereoscopicGamepadCamera
  42482. * @param name defines camera name
  42483. * @param position defines initial position
  42484. * @param interaxialDistance defines distance between each color axis
  42485. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42486. * @param scene defines the hosting scene
  42487. */
  42488. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42489. /**
  42490. * Gets camera class name
  42491. * @returns StereoscopicGamepadCamera
  42492. */
  42493. getClassName(): string;
  42494. }
  42495. }
  42496. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  42497. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42498. import { Scene } from "babylonjs/scene";
  42499. import { Vector3 } from "babylonjs/Maths/math.vector";
  42500. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42501. /**
  42502. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42503. * @see http://doc.babylonjs.com/features/cameras
  42504. */
  42505. export class StereoscopicUniversalCamera extends UniversalCamera {
  42506. /**
  42507. * Creates a new StereoscopicUniversalCamera
  42508. * @param name defines camera name
  42509. * @param position defines initial position
  42510. * @param interaxialDistance defines distance between each color axis
  42511. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42512. * @param scene defines the hosting scene
  42513. */
  42514. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42515. /**
  42516. * Gets camera class name
  42517. * @returns StereoscopicUniversalCamera
  42518. */
  42519. getClassName(): string;
  42520. }
  42521. }
  42522. declare module "babylonjs/Cameras/Stereoscopic/index" {
  42523. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  42524. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  42525. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  42526. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  42527. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  42528. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  42529. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  42530. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  42531. }
  42532. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  42533. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42534. import { Scene } from "babylonjs/scene";
  42535. import { Vector3 } from "babylonjs/Maths/math.vector";
  42536. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42537. /**
  42538. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  42539. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42540. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42541. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42542. */
  42543. export class VirtualJoysticksCamera extends FreeCamera {
  42544. /**
  42545. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  42546. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42547. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42548. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42549. * @param name Define the name of the camera in the scene
  42550. * @param position Define the start position of the camera in the scene
  42551. * @param scene Define the scene the camera belongs to
  42552. */
  42553. constructor(name: string, position: Vector3, scene: Scene);
  42554. /**
  42555. * Gets the current object class name.
  42556. * @return the class name
  42557. */
  42558. getClassName(): string;
  42559. }
  42560. }
  42561. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  42562. import { Matrix } from "babylonjs/Maths/math.vector";
  42563. /**
  42564. * This represents all the required metrics to create a VR camera.
  42565. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42566. */
  42567. export class VRCameraMetrics {
  42568. /**
  42569. * Define the horizontal resolution off the screen.
  42570. */
  42571. hResolution: number;
  42572. /**
  42573. * Define the vertical resolution off the screen.
  42574. */
  42575. vResolution: number;
  42576. /**
  42577. * Define the horizontal screen size.
  42578. */
  42579. hScreenSize: number;
  42580. /**
  42581. * Define the vertical screen size.
  42582. */
  42583. vScreenSize: number;
  42584. /**
  42585. * Define the vertical screen center position.
  42586. */
  42587. vScreenCenter: number;
  42588. /**
  42589. * Define the distance of the eyes to the screen.
  42590. */
  42591. eyeToScreenDistance: number;
  42592. /**
  42593. * Define the distance between both lenses
  42594. */
  42595. lensSeparationDistance: number;
  42596. /**
  42597. * Define the distance between both viewer's eyes.
  42598. */
  42599. interpupillaryDistance: number;
  42600. /**
  42601. * Define the distortion factor of the VR postprocess.
  42602. * Please, touch with care.
  42603. */
  42604. distortionK: number[];
  42605. /**
  42606. * Define the chromatic aberration correction factors for the VR post process.
  42607. */
  42608. chromaAbCorrection: number[];
  42609. /**
  42610. * Define the scale factor of the post process.
  42611. * The smaller the better but the slower.
  42612. */
  42613. postProcessScaleFactor: number;
  42614. /**
  42615. * Define an offset for the lens center.
  42616. */
  42617. lensCenterOffset: number;
  42618. /**
  42619. * Define if the current vr camera should compensate the distortion of the lense or not.
  42620. */
  42621. compensateDistortion: boolean;
  42622. /**
  42623. * Defines if multiview should be enabled when rendering (Default: false)
  42624. */
  42625. multiviewEnabled: boolean;
  42626. /**
  42627. * Gets the rendering aspect ratio based on the provided resolutions.
  42628. */
  42629. readonly aspectRatio: number;
  42630. /**
  42631. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42632. */
  42633. readonly aspectRatioFov: number;
  42634. /**
  42635. * @hidden
  42636. */
  42637. readonly leftHMatrix: Matrix;
  42638. /**
  42639. * @hidden
  42640. */
  42641. readonly rightHMatrix: Matrix;
  42642. /**
  42643. * @hidden
  42644. */
  42645. readonly leftPreViewMatrix: Matrix;
  42646. /**
  42647. * @hidden
  42648. */
  42649. readonly rightPreViewMatrix: Matrix;
  42650. /**
  42651. * Get the default VRMetrics based on the most generic setup.
  42652. * @returns the default vr metrics
  42653. */
  42654. static GetDefault(): VRCameraMetrics;
  42655. }
  42656. }
  42657. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  42658. /** @hidden */
  42659. export var vrDistortionCorrectionPixelShader: {
  42660. name: string;
  42661. shader: string;
  42662. };
  42663. }
  42664. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  42665. import { Camera } from "babylonjs/Cameras/camera";
  42666. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42667. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  42668. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  42669. /**
  42670. * VRDistortionCorrectionPostProcess used for mobile VR
  42671. */
  42672. export class VRDistortionCorrectionPostProcess extends PostProcess {
  42673. private _isRightEye;
  42674. private _distortionFactors;
  42675. private _postProcessScaleFactor;
  42676. private _lensCenterOffset;
  42677. private _scaleIn;
  42678. private _scaleFactor;
  42679. private _lensCenter;
  42680. /**
  42681. * Initializes the VRDistortionCorrectionPostProcess
  42682. * @param name The name of the effect.
  42683. * @param camera The camera to apply the render pass to.
  42684. * @param isRightEye If this is for the right eye distortion
  42685. * @param vrMetrics All the required metrics for the VR camera
  42686. */
  42687. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  42688. }
  42689. }
  42690. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  42691. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  42692. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42693. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42694. import { Scene } from "babylonjs/scene";
  42695. import { Vector3 } from "babylonjs/Maths/math.vector";
  42696. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42697. import "babylonjs/Cameras/RigModes/vrRigMode";
  42698. /**
  42699. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42700. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42701. */
  42702. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42703. /**
  42704. * Creates a new VRDeviceOrientationArcRotateCamera
  42705. * @param name defines camera name
  42706. * @param alpha defines the camera rotation along the logitudinal axis
  42707. * @param beta defines the camera rotation along the latitudinal axis
  42708. * @param radius defines the camera distance from its target
  42709. * @param target defines the camera target
  42710. * @param scene defines the scene the camera belongs to
  42711. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42712. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42713. */
  42714. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42715. /**
  42716. * Gets camera class name
  42717. * @returns VRDeviceOrientationArcRotateCamera
  42718. */
  42719. getClassName(): string;
  42720. }
  42721. }
  42722. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  42723. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42724. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42725. import { Scene } from "babylonjs/scene";
  42726. import { Vector3 } from "babylonjs/Maths/math.vector";
  42727. import "babylonjs/Cameras/RigModes/vrRigMode";
  42728. /**
  42729. * Camera used to simulate VR rendering (based on FreeCamera)
  42730. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42731. */
  42732. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42733. /**
  42734. * Creates a new VRDeviceOrientationFreeCamera
  42735. * @param name defines camera name
  42736. * @param position defines the start position of the camera
  42737. * @param scene defines the scene the camera belongs to
  42738. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42739. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42740. */
  42741. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42742. /**
  42743. * Gets camera class name
  42744. * @returns VRDeviceOrientationFreeCamera
  42745. */
  42746. getClassName(): string;
  42747. }
  42748. }
  42749. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  42750. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42751. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42752. import { Scene } from "babylonjs/scene";
  42753. import { Vector3 } from "babylonjs/Maths/math.vector";
  42754. import "babylonjs/Gamepads/gamepadSceneComponent";
  42755. /**
  42756. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42757. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42758. */
  42759. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42760. /**
  42761. * Creates a new VRDeviceOrientationGamepadCamera
  42762. * @param name defines camera name
  42763. * @param position defines the start position of the camera
  42764. * @param scene defines the scene the camera belongs to
  42765. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42766. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42767. */
  42768. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42769. /**
  42770. * Gets camera class name
  42771. * @returns VRDeviceOrientationGamepadCamera
  42772. */
  42773. getClassName(): string;
  42774. }
  42775. }
  42776. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  42777. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  42778. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  42779. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  42780. /** @hidden */
  42781. export var imageProcessingPixelShader: {
  42782. name: string;
  42783. shader: string;
  42784. };
  42785. }
  42786. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  42787. import { Nullable } from "babylonjs/types";
  42788. import { Color4 } from "babylonjs/Maths/math.color";
  42789. import { Camera } from "babylonjs/Cameras/camera";
  42790. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42791. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  42792. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  42793. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42794. import { Engine } from "babylonjs/Engines/engine";
  42795. import "babylonjs/Shaders/imageProcessing.fragment";
  42796. import "babylonjs/Shaders/postprocess.vertex";
  42797. /**
  42798. * ImageProcessingPostProcess
  42799. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42800. */
  42801. export class ImageProcessingPostProcess extends PostProcess {
  42802. /**
  42803. * Default configuration related to image processing available in the PBR Material.
  42804. */
  42805. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42806. /**
  42807. * Gets the image processing configuration used either in this material.
  42808. */
  42809. /**
  42810. * Sets the Default image processing configuration used either in the this material.
  42811. *
  42812. * If sets to null, the scene one is in use.
  42813. */
  42814. imageProcessingConfiguration: ImageProcessingConfiguration;
  42815. /**
  42816. * Keep track of the image processing observer to allow dispose and replace.
  42817. */
  42818. private _imageProcessingObserver;
  42819. /**
  42820. * Attaches a new image processing configuration to the PBR Material.
  42821. * @param configuration
  42822. */
  42823. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42824. /**
  42825. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42826. */
  42827. /**
  42828. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42829. */
  42830. colorCurves: Nullable<ColorCurves>;
  42831. /**
  42832. * Gets wether the color curves effect is enabled.
  42833. */
  42834. /**
  42835. * Sets wether the color curves effect is enabled.
  42836. */
  42837. colorCurvesEnabled: boolean;
  42838. /**
  42839. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42840. */
  42841. /**
  42842. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42843. */
  42844. colorGradingTexture: Nullable<BaseTexture>;
  42845. /**
  42846. * Gets wether the color grading effect is enabled.
  42847. */
  42848. /**
  42849. * Gets wether the color grading effect is enabled.
  42850. */
  42851. colorGradingEnabled: boolean;
  42852. /**
  42853. * Gets exposure used in the effect.
  42854. */
  42855. /**
  42856. * Sets exposure used in the effect.
  42857. */
  42858. exposure: number;
  42859. /**
  42860. * Gets wether tonemapping is enabled or not.
  42861. */
  42862. /**
  42863. * Sets wether tonemapping is enabled or not
  42864. */
  42865. toneMappingEnabled: boolean;
  42866. /**
  42867. * Gets the type of tone mapping effect.
  42868. */
  42869. /**
  42870. * Sets the type of tone mapping effect.
  42871. */
  42872. toneMappingType: number;
  42873. /**
  42874. * Gets contrast used in the effect.
  42875. */
  42876. /**
  42877. * Sets contrast used in the effect.
  42878. */
  42879. contrast: number;
  42880. /**
  42881. * Gets Vignette stretch size.
  42882. */
  42883. /**
  42884. * Sets Vignette stretch size.
  42885. */
  42886. vignetteStretch: number;
  42887. /**
  42888. * Gets Vignette centre X Offset.
  42889. */
  42890. /**
  42891. * Sets Vignette centre X Offset.
  42892. */
  42893. vignetteCentreX: number;
  42894. /**
  42895. * Gets Vignette centre Y Offset.
  42896. */
  42897. /**
  42898. * Sets Vignette centre Y Offset.
  42899. */
  42900. vignetteCentreY: number;
  42901. /**
  42902. * Gets Vignette weight or intensity of the vignette effect.
  42903. */
  42904. /**
  42905. * Sets Vignette weight or intensity of the vignette effect.
  42906. */
  42907. vignetteWeight: number;
  42908. /**
  42909. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42910. * if vignetteEnabled is set to true.
  42911. */
  42912. /**
  42913. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42914. * if vignetteEnabled is set to true.
  42915. */
  42916. vignetteColor: Color4;
  42917. /**
  42918. * Gets Camera field of view used by the Vignette effect.
  42919. */
  42920. /**
  42921. * Sets Camera field of view used by the Vignette effect.
  42922. */
  42923. vignetteCameraFov: number;
  42924. /**
  42925. * Gets the vignette blend mode allowing different kind of effect.
  42926. */
  42927. /**
  42928. * Sets the vignette blend mode allowing different kind of effect.
  42929. */
  42930. vignetteBlendMode: number;
  42931. /**
  42932. * Gets wether the vignette effect is enabled.
  42933. */
  42934. /**
  42935. * Sets wether the vignette effect is enabled.
  42936. */
  42937. vignetteEnabled: boolean;
  42938. private _fromLinearSpace;
  42939. /**
  42940. * Gets wether the input of the processing is in Gamma or Linear Space.
  42941. */
  42942. /**
  42943. * Sets wether the input of the processing is in Gamma or Linear Space.
  42944. */
  42945. fromLinearSpace: boolean;
  42946. /**
  42947. * Defines cache preventing GC.
  42948. */
  42949. private _defines;
  42950. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42951. /**
  42952. * "ImageProcessingPostProcess"
  42953. * @returns "ImageProcessingPostProcess"
  42954. */
  42955. getClassName(): string;
  42956. protected _updateParameters(): void;
  42957. dispose(camera?: Camera): void;
  42958. }
  42959. }
  42960. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42961. import { Scene } from "babylonjs/scene";
  42962. import { Color3 } from "babylonjs/Maths/math.color";
  42963. import { Mesh } from "babylonjs/Meshes/mesh";
  42964. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42965. import { Nullable } from "babylonjs/types";
  42966. /**
  42967. * Class containing static functions to help procedurally build meshes
  42968. */
  42969. export class GroundBuilder {
  42970. /**
  42971. * Creates a ground mesh
  42972. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42973. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42974. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42975. * @param name defines the name of the mesh
  42976. * @param options defines the options used to create the mesh
  42977. * @param scene defines the hosting scene
  42978. * @returns the ground mesh
  42979. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42980. */
  42981. static CreateGround(name: string, options: {
  42982. width?: number;
  42983. height?: number;
  42984. subdivisions?: number;
  42985. subdivisionsX?: number;
  42986. subdivisionsY?: number;
  42987. updatable?: boolean;
  42988. }, scene: any): Mesh;
  42989. /**
  42990. * Creates a tiled ground mesh
  42991. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42992. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42993. * * 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
  42994. * * 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
  42995. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42996. * @param name defines the name of the mesh
  42997. * @param options defines the options used to create the mesh
  42998. * @param scene defines the hosting scene
  42999. * @returns the tiled ground mesh
  43000. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  43001. */
  43002. static CreateTiledGround(name: string, options: {
  43003. xmin: number;
  43004. zmin: number;
  43005. xmax: number;
  43006. zmax: number;
  43007. subdivisions?: {
  43008. w: number;
  43009. h: number;
  43010. };
  43011. precision?: {
  43012. w: number;
  43013. h: number;
  43014. };
  43015. updatable?: boolean;
  43016. }, scene?: Nullable<Scene>): Mesh;
  43017. /**
  43018. * Creates a ground mesh from a height map
  43019. * * The parameter `url` sets the URL of the height map image resource.
  43020. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  43021. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  43022. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  43023. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  43024. * * 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.
  43025. * * 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).
  43026. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  43027. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43028. * @param name defines the name of the mesh
  43029. * @param url defines the url to the height map
  43030. * @param options defines the options used to create the mesh
  43031. * @param scene defines the hosting scene
  43032. * @returns the ground mesh
  43033. * @see https://doc.babylonjs.com/babylon101/height_map
  43034. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  43035. */
  43036. static CreateGroundFromHeightMap(name: string, url: string, options: {
  43037. width?: number;
  43038. height?: number;
  43039. subdivisions?: number;
  43040. minHeight?: number;
  43041. maxHeight?: number;
  43042. colorFilter?: Color3;
  43043. alphaFilter?: number;
  43044. updatable?: boolean;
  43045. onReady?: (mesh: GroundMesh) => void;
  43046. }, scene?: Nullable<Scene>): GroundMesh;
  43047. }
  43048. }
  43049. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  43050. import { Vector4 } from "babylonjs/Maths/math.vector";
  43051. import { Mesh } from "babylonjs/Meshes/mesh";
  43052. /**
  43053. * Class containing static functions to help procedurally build meshes
  43054. */
  43055. export class TorusBuilder {
  43056. /**
  43057. * Creates a torus mesh
  43058. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  43059. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  43060. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  43061. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43062. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43063. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43064. * @param name defines the name of the mesh
  43065. * @param options defines the options used to create the mesh
  43066. * @param scene defines the hosting scene
  43067. * @returns the torus mesh
  43068. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  43069. */
  43070. static CreateTorus(name: string, options: {
  43071. diameter?: number;
  43072. thickness?: number;
  43073. tessellation?: number;
  43074. updatable?: boolean;
  43075. sideOrientation?: number;
  43076. frontUVs?: Vector4;
  43077. backUVs?: Vector4;
  43078. }, scene: any): Mesh;
  43079. }
  43080. }
  43081. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  43082. import { Vector4 } from "babylonjs/Maths/math.vector";
  43083. import { Color4 } from "babylonjs/Maths/math.color";
  43084. import { Mesh } from "babylonjs/Meshes/mesh";
  43085. /**
  43086. * Class containing static functions to help procedurally build meshes
  43087. */
  43088. export class CylinderBuilder {
  43089. /**
  43090. * Creates a cylinder or a cone mesh
  43091. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43092. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43093. * * 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.
  43094. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43095. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43096. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43097. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43098. * * 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).
  43099. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43100. * * 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).
  43101. * * 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
  43102. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43103. * * 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
  43104. * * 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.
  43105. * * If `enclose` is false, a ring surface is one element.
  43106. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43107. * * 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
  43108. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43109. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43110. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43111. * @param name defines the name of the mesh
  43112. * @param options defines the options used to create the mesh
  43113. * @param scene defines the hosting scene
  43114. * @returns the cylinder mesh
  43115. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  43116. */
  43117. static CreateCylinder(name: string, options: {
  43118. height?: number;
  43119. diameterTop?: number;
  43120. diameterBottom?: number;
  43121. diameter?: number;
  43122. tessellation?: number;
  43123. subdivisions?: number;
  43124. arc?: number;
  43125. faceColors?: Color4[];
  43126. faceUV?: Vector4[];
  43127. updatable?: boolean;
  43128. hasRings?: boolean;
  43129. enclose?: boolean;
  43130. cap?: number;
  43131. sideOrientation?: number;
  43132. frontUVs?: Vector4;
  43133. backUVs?: Vector4;
  43134. }, scene: any): Mesh;
  43135. }
  43136. }
  43137. declare module "babylonjs/Cameras/XR/webXRTypes" {
  43138. import { Nullable } from "babylonjs/types";
  43139. import { IDisposable } from "babylonjs/scene";
  43140. /**
  43141. * States of the webXR experience
  43142. */
  43143. export enum WebXRState {
  43144. /**
  43145. * Transitioning to being in XR mode
  43146. */
  43147. ENTERING_XR = 0,
  43148. /**
  43149. * Transitioning to non XR mode
  43150. */
  43151. EXITING_XR = 1,
  43152. /**
  43153. * In XR mode and presenting
  43154. */
  43155. IN_XR = 2,
  43156. /**
  43157. * Not entered XR mode
  43158. */
  43159. NOT_IN_XR = 3
  43160. }
  43161. /**
  43162. * Abstraction of the XR render target
  43163. */
  43164. export interface WebXRRenderTarget extends IDisposable {
  43165. /**
  43166. * xrpresent context of the canvas which can be used to display/mirror xr content
  43167. */
  43168. canvasContext: WebGLRenderingContext;
  43169. /**
  43170. * xr layer for the canvas
  43171. */
  43172. xrLayer: Nullable<XRWebGLLayer>;
  43173. /**
  43174. * Initializes the xr layer for the session
  43175. * @param xrSession xr session
  43176. * @returns a promise that will resolve once the XR Layer has been created
  43177. */
  43178. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  43179. }
  43180. }
  43181. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  43182. import { Nullable } from "babylonjs/types";
  43183. import { Observable } from "babylonjs/Misc/observable";
  43184. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  43185. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43186. /**
  43187. * COnfiguration object for WebXR output canvas
  43188. */
  43189. export class WebXRManagedOutputCanvasOptions {
  43190. /**
  43191. * Options for this XR Layer output
  43192. */
  43193. canvasOptions: XRWebGLLayerOptions;
  43194. /**
  43195. * CSS styling for a newly created canvas (if not provided)
  43196. */
  43197. newCanvasCssStyle?: string;
  43198. /**
  43199. * Get the default values of the configuration object
  43200. * @returns default values of this configuration object
  43201. */
  43202. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  43203. }
  43204. /**
  43205. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43206. */
  43207. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43208. private configuration;
  43209. private _engine;
  43210. private _canvas;
  43211. /**
  43212. * xrpresent context of the canvas which can be used to display/mirror xr content
  43213. */
  43214. canvasContext: WebGLRenderingContext;
  43215. /**
  43216. * xr layer for the canvas
  43217. */
  43218. xrLayer: Nullable<XRWebGLLayer>;
  43219. /**
  43220. * Initializes the xr layer for the session
  43221. * @param xrSession xr session
  43222. * @returns a promise that will resolve once the XR Layer has been created
  43223. */
  43224. initializeXRLayerAsync(xrSession: any): any;
  43225. /**
  43226. * Initializes the canvas to be added/removed upon entering/exiting xr
  43227. * @param engine the Babylon engine
  43228. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43229. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  43230. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  43231. */
  43232. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  43233. /**
  43234. * Disposes of the object
  43235. */
  43236. dispose(): void;
  43237. private _setManagedOutputCanvas;
  43238. private _addCanvas;
  43239. private _removeCanvas;
  43240. }
  43241. }
  43242. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  43243. import { Observable } from "babylonjs/Misc/observable";
  43244. import { Nullable } from "babylonjs/types";
  43245. import { IDisposable, Scene } from "babylonjs/scene";
  43246. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43247. import { WebXRRenderTarget, WebXRState } from "babylonjs/Cameras/XR/webXRTypes";
  43248. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43249. /**
  43250. * Manages an XRSession to work with Babylon's engine
  43251. * @see https://doc.babylonjs.com/how_to/webxr
  43252. */
  43253. export class WebXRSessionManager implements IDisposable {
  43254. private scene;
  43255. /**
  43256. * Fires every time a new xrFrame arrives which can be used to update the camera
  43257. */
  43258. onXRFrameObservable: Observable<any>;
  43259. /**
  43260. * Fires when the xr session is ended either by the device or manually done
  43261. */
  43262. onXRSessionEnded: Observable<any>;
  43263. /**
  43264. * Underlying xr session
  43265. */
  43266. session: XRSession;
  43267. /**
  43268. * Type of reference space used when creating the session
  43269. */
  43270. referenceSpace: XRReferenceSpace;
  43271. /**
  43272. * Current XR frame
  43273. */
  43274. currentFrame: Nullable<XRFrame>;
  43275. private _xrNavigator;
  43276. private baseLayer;
  43277. private _rttProvider;
  43278. private _sessionEnded;
  43279. /**
  43280. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43281. * @param scene The scene which the session should be created for
  43282. */
  43283. constructor(scene: Scene);
  43284. /**
  43285. * Initializes the manager
  43286. * After initialization enterXR can be called to start an XR session
  43287. * @returns Promise which resolves after it is initialized
  43288. */
  43289. initializeAsync(): Promise<void>;
  43290. /**
  43291. * Initializes an xr session
  43292. * @param xrSessionMode mode to initialize
  43293. * @param optionalFeatures defines optional values to pass to the session builder
  43294. * @returns a promise which will resolve once the session has been initialized
  43295. */
  43296. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  43297. /**
  43298. * Sets the reference space on the xr session
  43299. * @param referenceSpace space to set
  43300. * @returns a promise that will resolve once the reference space has been set
  43301. */
  43302. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  43303. /**
  43304. * Updates the render state of the session
  43305. * @param state state to set
  43306. * @returns a promise that resolves once the render state has been updated
  43307. */
  43308. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43309. /**
  43310. * Starts rendering to the xr layer
  43311. * @returns a promise that will resolve once rendering has started
  43312. */
  43313. startRenderingToXRAsync(): Promise<void>;
  43314. /**
  43315. * Gets the correct render target texture to be rendered this frame for this eye
  43316. * @param eye the eye for which to get the render target
  43317. * @returns the render target for the specified eye
  43318. */
  43319. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43320. /**
  43321. * Stops the xrSession and restores the renderloop
  43322. * @returns Promise which resolves after it exits XR
  43323. */
  43324. exitXRAsync(): Promise<void>;
  43325. /**
  43326. * Checks if a session would be supported for the creation options specified
  43327. * @param sessionMode session mode to check if supported eg. immersive-vr
  43328. * @returns true if supported
  43329. */
  43330. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43331. /**
  43332. * Creates a WebXRRenderTarget object for the XR session
  43333. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43334. * @param options optional options to provide when creating a new render target
  43335. * @returns a WebXR render target to which the session can render
  43336. */
  43337. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43338. /**
  43339. * @hidden
  43340. * Converts the render layer of xrSession to a render target
  43341. * @param session session to create render target for
  43342. * @param scene scene the new render target should be created for
  43343. */
  43344. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  43345. /**
  43346. * Disposes of the session manager
  43347. */
  43348. dispose(): void;
  43349. /**
  43350. * Gets a promise returning true when fullfiled if the given session mode is supported
  43351. * @param sessionMode defines the session to test
  43352. * @returns a promise
  43353. */
  43354. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43355. }
  43356. }
  43357. declare module "babylonjs/Cameras/XR/webXRCamera" {
  43358. import { Scene } from "babylonjs/scene";
  43359. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43360. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43361. /**
  43362. * WebXR Camera which holds the views for the xrSession
  43363. * @see https://doc.babylonjs.com/how_to/webxr
  43364. */
  43365. export class WebXRCamera extends FreeCamera {
  43366. /**
  43367. * Is the camera in debug mode. Used when using an emulator
  43368. */
  43369. debugMode: boolean;
  43370. /**
  43371. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43372. * @param name the name of the camera
  43373. * @param scene the scene to add the camera to
  43374. */
  43375. constructor(name: string, scene: Scene);
  43376. private _updateNumberOfRigCameras;
  43377. /** @hidden */
  43378. _updateForDualEyeDebugging(): void;
  43379. /**
  43380. * Updates the cameras position from the current pose information of the XR session
  43381. * @param xrSessionManager the session containing pose information
  43382. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  43383. */
  43384. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  43385. }
  43386. }
  43387. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  43388. import { Observable } from "babylonjs/Misc/observable";
  43389. import { IDisposable, Scene } from "babylonjs/scene";
  43390. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  43391. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43392. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43393. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  43394. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43395. /**
  43396. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  43397. * @see https://doc.babylonjs.com/how_to/webxr
  43398. */
  43399. export class WebXRExperienceHelper implements IDisposable {
  43400. private scene;
  43401. /**
  43402. * 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
  43403. */
  43404. container: AbstractMesh;
  43405. /**
  43406. * Camera used to render xr content
  43407. */
  43408. camera: WebXRCamera;
  43409. /**
  43410. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43411. */
  43412. state: WebXRState;
  43413. private _setState;
  43414. private static _TmpVector;
  43415. /**
  43416. * Fires when the state of the experience helper has changed
  43417. */
  43418. onStateChangedObservable: Observable<WebXRState>;
  43419. /** Session manager used to keep track of xr session */
  43420. sessionManager: WebXRSessionManager;
  43421. private _nonVRCamera;
  43422. private _originalSceneAutoClear;
  43423. private _supported;
  43424. /**
  43425. * Creates the experience helper
  43426. * @param scene the scene to attach the experience helper to
  43427. * @returns a promise for the experience helper
  43428. */
  43429. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43430. /**
  43431. * Creates a WebXRExperienceHelper
  43432. * @param scene The scene the helper should be created in
  43433. */
  43434. private constructor();
  43435. /**
  43436. * Exits XR mode and returns the scene to its original state
  43437. * @returns promise that resolves after xr mode has exited
  43438. */
  43439. exitXRAsync(): Promise<void>;
  43440. /**
  43441. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43442. * @param sessionMode options for the XR session
  43443. * @param referenceSpaceType frame of reference of the XR session
  43444. * @param renderTarget the output canvas that will be used to enter XR mode
  43445. * @returns promise that resolves after xr mode has entered
  43446. */
  43447. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  43448. /**
  43449. * Updates the global position of the camera by moving the camera's container
  43450. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43451. * @param position The desired global position of the camera
  43452. */
  43453. setPositionOfCameraUsingContainer(position: Vector3): void;
  43454. /**
  43455. * Rotates the xr camera by rotating the camera's container around the camera's position
  43456. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43457. * @param rotation the desired quaternion rotation to apply to the camera
  43458. */
  43459. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43460. /**
  43461. * Disposes of the experience helper
  43462. */
  43463. dispose(): void;
  43464. }
  43465. }
  43466. declare module "babylonjs/Cameras/XR/webXRController" {
  43467. import { Nullable } from "babylonjs/types";
  43468. import { Observable } from "babylonjs/Misc/observable";
  43469. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43470. import { Ray } from "babylonjs/Culling/ray";
  43471. import { Scene } from "babylonjs/scene";
  43472. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43473. /**
  43474. * Represents an XR input
  43475. */
  43476. export class WebXRController {
  43477. private scene;
  43478. /** The underlying input source for the controller */
  43479. inputSource: XRInputSource;
  43480. private parentContainer;
  43481. /**
  43482. * 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
  43483. */
  43484. grip?: AbstractMesh;
  43485. /**
  43486. * Pointer which can be used to select objects or attach a visible laser to
  43487. */
  43488. pointer: AbstractMesh;
  43489. private _gamepadMode;
  43490. /**
  43491. * If available, this is the gamepad object related to this controller.
  43492. * Using this object it is possible to get click events and trackpad changes of the
  43493. * webxr controller that is currently being used.
  43494. */
  43495. gamepadController?: WebVRController;
  43496. /**
  43497. * Event that fires when the controller is removed/disposed
  43498. */
  43499. onDisposeObservable: Observable<{}>;
  43500. private _tmpQuaternion;
  43501. private _tmpVector;
  43502. /**
  43503. * Creates the controller
  43504. * @see https://doc.babylonjs.com/how_to/webxr
  43505. * @param scene the scene which the controller should be associated to
  43506. * @param inputSource the underlying input source for the controller
  43507. * @param parentContainer parent that the controller meshes should be children of
  43508. */
  43509. constructor(scene: Scene,
  43510. /** The underlying input source for the controller */
  43511. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43512. /**
  43513. * Updates the controller pose based on the given XRFrame
  43514. * @param xrFrame xr frame to update the pose with
  43515. * @param referenceSpace reference space to use
  43516. */
  43517. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43518. /**
  43519. * Gets a world space ray coming from the controller
  43520. * @param result the resulting ray
  43521. */
  43522. getWorldPointerRayToRef(result: Ray): void;
  43523. /**
  43524. * Get the scene associated with this controller
  43525. * @returns the scene object
  43526. */
  43527. getScene(): Scene;
  43528. /**
  43529. * Disposes of the object
  43530. */
  43531. dispose(): void;
  43532. }
  43533. }
  43534. declare module "babylonjs/Cameras/XR/webXRInput" {
  43535. import { Observable } from "babylonjs/Misc/observable";
  43536. import { IDisposable } from "babylonjs/scene";
  43537. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43538. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43539. /**
  43540. * XR input used to track XR inputs such as controllers/rays
  43541. */
  43542. export class WebXRInput implements IDisposable {
  43543. /**
  43544. * Base experience the input listens to
  43545. */
  43546. baseExperience: WebXRExperienceHelper;
  43547. /**
  43548. * XR controllers being tracked
  43549. */
  43550. controllers: Array<WebXRController>;
  43551. private _frameObserver;
  43552. private _stateObserver;
  43553. /**
  43554. * Event when a controller has been connected/added
  43555. */
  43556. onControllerAddedObservable: Observable<WebXRController>;
  43557. /**
  43558. * Event when a controller has been removed/disconnected
  43559. */
  43560. onControllerRemovedObservable: Observable<WebXRController>;
  43561. /**
  43562. * Initializes the WebXRInput
  43563. * @param baseExperience experience helper which the input should be created for
  43564. */
  43565. constructor(
  43566. /**
  43567. * Base experience the input listens to
  43568. */
  43569. baseExperience: WebXRExperienceHelper);
  43570. private _onInputSourcesChange;
  43571. private _addAndRemoveControllers;
  43572. /**
  43573. * Disposes of the object
  43574. */
  43575. dispose(): void;
  43576. }
  43577. }
  43578. declare module "babylonjs/Loading/sceneLoader" {
  43579. import { Observable } from "babylonjs/Misc/observable";
  43580. import { Nullable } from "babylonjs/types";
  43581. import { Scene } from "babylonjs/scene";
  43582. import { Engine } from "babylonjs/Engines/engine";
  43583. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43584. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43585. import { AssetContainer } from "babylonjs/assetContainer";
  43586. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43587. import { Skeleton } from "babylonjs/Bones/skeleton";
  43588. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  43589. import { WebRequest } from "babylonjs/Misc/webRequest";
  43590. /**
  43591. * Class used to represent data loading progression
  43592. */
  43593. export class SceneLoaderProgressEvent {
  43594. /** defines if data length to load can be evaluated */
  43595. readonly lengthComputable: boolean;
  43596. /** defines the loaded data length */
  43597. readonly loaded: number;
  43598. /** defines the data length to load */
  43599. readonly total: number;
  43600. /**
  43601. * Create a new progress event
  43602. * @param lengthComputable defines if data length to load can be evaluated
  43603. * @param loaded defines the loaded data length
  43604. * @param total defines the data length to load
  43605. */
  43606. constructor(
  43607. /** defines if data length to load can be evaluated */
  43608. lengthComputable: boolean,
  43609. /** defines the loaded data length */
  43610. loaded: number,
  43611. /** defines the data length to load */
  43612. total: number);
  43613. /**
  43614. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43615. * @param event defines the source event
  43616. * @returns a new SceneLoaderProgressEvent
  43617. */
  43618. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43619. }
  43620. /**
  43621. * Interface used by SceneLoader plugins to define supported file extensions
  43622. */
  43623. export interface ISceneLoaderPluginExtensions {
  43624. /**
  43625. * Defines the list of supported extensions
  43626. */
  43627. [extension: string]: {
  43628. isBinary: boolean;
  43629. };
  43630. }
  43631. /**
  43632. * Interface used by SceneLoader plugin factory
  43633. */
  43634. export interface ISceneLoaderPluginFactory {
  43635. /**
  43636. * Defines the name of the factory
  43637. */
  43638. name: string;
  43639. /**
  43640. * Function called to create a new plugin
  43641. * @return the new plugin
  43642. */
  43643. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43644. /**
  43645. * The callback that returns true if the data can be directly loaded.
  43646. * @param data string containing the file data
  43647. * @returns if the data can be loaded directly
  43648. */
  43649. canDirectLoad?(data: string): boolean;
  43650. }
  43651. /**
  43652. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43653. */
  43654. export interface ISceneLoaderPluginBase {
  43655. /**
  43656. * The friendly name of this plugin.
  43657. */
  43658. name: string;
  43659. /**
  43660. * The file extensions supported by this plugin.
  43661. */
  43662. extensions: string | ISceneLoaderPluginExtensions;
  43663. /**
  43664. * The callback called when loading from a url.
  43665. * @param scene scene loading this url
  43666. * @param url url to load
  43667. * @param onSuccess callback called when the file successfully loads
  43668. * @param onProgress callback called while file is loading (if the server supports this mode)
  43669. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43670. * @param onError callback called when the file fails to load
  43671. * @returns a file request object
  43672. */
  43673. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43674. /**
  43675. * The callback called when loading from a file object.
  43676. * @param scene scene loading this file
  43677. * @param file defines the file to load
  43678. * @param onSuccess defines the callback to call when data is loaded
  43679. * @param onProgress defines the callback to call during loading process
  43680. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43681. * @param onError defines the callback to call when an error occurs
  43682. * @returns a file request object
  43683. */
  43684. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43685. /**
  43686. * The callback that returns true if the data can be directly loaded.
  43687. * @param data string containing the file data
  43688. * @returns if the data can be loaded directly
  43689. */
  43690. canDirectLoad?(data: string): boolean;
  43691. /**
  43692. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43693. * @param scene scene loading this data
  43694. * @param data string containing the data
  43695. * @returns data to pass to the plugin
  43696. */
  43697. directLoad?(scene: Scene, data: string): any;
  43698. /**
  43699. * The callback that allows custom handling of the root url based on the response url.
  43700. * @param rootUrl the original root url
  43701. * @param responseURL the response url if available
  43702. * @returns the new root url
  43703. */
  43704. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43705. }
  43706. /**
  43707. * Interface used to define a SceneLoader plugin
  43708. */
  43709. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43710. /**
  43711. * Import meshes into a scene.
  43712. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43713. * @param scene The scene to import into
  43714. * @param data The data to import
  43715. * @param rootUrl The root url for scene and resources
  43716. * @param meshes The meshes array to import into
  43717. * @param particleSystems The particle systems array to import into
  43718. * @param skeletons The skeletons array to import into
  43719. * @param onError The callback when import fails
  43720. * @returns True if successful or false otherwise
  43721. */
  43722. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43723. /**
  43724. * Load into a scene.
  43725. * @param scene The scene to load into
  43726. * @param data The data to import
  43727. * @param rootUrl The root url for scene and resources
  43728. * @param onError The callback when import fails
  43729. * @returns True if successful or false otherwise
  43730. */
  43731. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43732. /**
  43733. * Load into an asset container.
  43734. * @param scene The scene to load into
  43735. * @param data The data to import
  43736. * @param rootUrl The root url for scene and resources
  43737. * @param onError The callback when import fails
  43738. * @returns The loaded asset container
  43739. */
  43740. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43741. }
  43742. /**
  43743. * Interface used to define an async SceneLoader plugin
  43744. */
  43745. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43746. /**
  43747. * Import meshes into a scene.
  43748. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43749. * @param scene The scene to import into
  43750. * @param data The data to import
  43751. * @param rootUrl The root url for scene and resources
  43752. * @param onProgress The callback when the load progresses
  43753. * @param fileName Defines the name of the file to load
  43754. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43755. */
  43756. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43757. meshes: AbstractMesh[];
  43758. particleSystems: IParticleSystem[];
  43759. skeletons: Skeleton[];
  43760. animationGroups: AnimationGroup[];
  43761. }>;
  43762. /**
  43763. * Load into a scene.
  43764. * @param scene The scene to load into
  43765. * @param data The data to import
  43766. * @param rootUrl The root url for scene and resources
  43767. * @param onProgress The callback when the load progresses
  43768. * @param fileName Defines the name of the file to load
  43769. * @returns Nothing
  43770. */
  43771. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43772. /**
  43773. * Load into an asset container.
  43774. * @param scene The scene to load into
  43775. * @param data The data to import
  43776. * @param rootUrl The root url for scene and resources
  43777. * @param onProgress The callback when the load progresses
  43778. * @param fileName Defines the name of the file to load
  43779. * @returns The loaded asset container
  43780. */
  43781. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43782. }
  43783. /**
  43784. * Class used to load scene from various file formats using registered plugins
  43785. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43786. */
  43787. export class SceneLoader {
  43788. /**
  43789. * No logging while loading
  43790. */
  43791. static readonly NO_LOGGING: number;
  43792. /**
  43793. * Minimal logging while loading
  43794. */
  43795. static readonly MINIMAL_LOGGING: number;
  43796. /**
  43797. * Summary logging while loading
  43798. */
  43799. static readonly SUMMARY_LOGGING: number;
  43800. /**
  43801. * Detailled logging while loading
  43802. */
  43803. static readonly DETAILED_LOGGING: number;
  43804. /**
  43805. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43806. */
  43807. static ForceFullSceneLoadingForIncremental: boolean;
  43808. /**
  43809. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43810. */
  43811. static ShowLoadingScreen: boolean;
  43812. /**
  43813. * Defines the current logging level (while loading the scene)
  43814. * @ignorenaming
  43815. */
  43816. static loggingLevel: number;
  43817. /**
  43818. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43819. */
  43820. static CleanBoneMatrixWeights: boolean;
  43821. /**
  43822. * Event raised when a plugin is used to load a scene
  43823. */
  43824. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43825. private static _registeredPlugins;
  43826. private static _getDefaultPlugin;
  43827. private static _getPluginForExtension;
  43828. private static _getPluginForDirectLoad;
  43829. private static _getPluginForFilename;
  43830. private static _getDirectLoad;
  43831. private static _loadData;
  43832. private static _getFileInfo;
  43833. /**
  43834. * Gets a plugin that can load the given extension
  43835. * @param extension defines the extension to load
  43836. * @returns a plugin or null if none works
  43837. */
  43838. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43839. /**
  43840. * Gets a boolean indicating that the given extension can be loaded
  43841. * @param extension defines the extension to load
  43842. * @returns true if the extension is supported
  43843. */
  43844. static IsPluginForExtensionAvailable(extension: string): boolean;
  43845. /**
  43846. * Adds a new plugin to the list of registered plugins
  43847. * @param plugin defines the plugin to add
  43848. */
  43849. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43850. /**
  43851. * Import meshes into a scene
  43852. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43853. * @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)
  43854. * @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)
  43855. * @param scene the instance of BABYLON.Scene to append to
  43856. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43857. * @param onProgress a callback with a progress event for each file being loaded
  43858. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43859. * @param pluginExtension the extension used to determine the plugin
  43860. * @returns The loaded plugin
  43861. */
  43862. 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>;
  43863. /**
  43864. * Import meshes into a scene
  43865. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43866. * @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)
  43867. * @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)
  43868. * @param scene the instance of BABYLON.Scene to append to
  43869. * @param onProgress a callback with a progress event for each file being loaded
  43870. * @param pluginExtension the extension used to determine the plugin
  43871. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43872. */
  43873. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43874. meshes: AbstractMesh[];
  43875. particleSystems: IParticleSystem[];
  43876. skeletons: Skeleton[];
  43877. animationGroups: AnimationGroup[];
  43878. }>;
  43879. /**
  43880. * Load a scene
  43881. * @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)
  43882. * @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)
  43883. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43884. * @param onSuccess a callback with the scene when import succeeds
  43885. * @param onProgress a callback with a progress event for each file being loaded
  43886. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43887. * @param pluginExtension the extension used to determine the plugin
  43888. * @returns The loaded plugin
  43889. */
  43890. 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>;
  43891. /**
  43892. * Load a scene
  43893. * @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)
  43894. * @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)
  43895. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43896. * @param onProgress a callback with a progress event for each file being loaded
  43897. * @param pluginExtension the extension used to determine the plugin
  43898. * @returns The loaded scene
  43899. */
  43900. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43901. /**
  43902. * Append a scene
  43903. * @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)
  43904. * @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)
  43905. * @param scene is the instance of BABYLON.Scene to append to
  43906. * @param onSuccess a callback with the scene when import succeeds
  43907. * @param onProgress a callback with a progress event for each file being loaded
  43908. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43909. * @param pluginExtension the extension used to determine the plugin
  43910. * @returns The loaded plugin
  43911. */
  43912. 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>;
  43913. /**
  43914. * Append a scene
  43915. * @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)
  43916. * @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)
  43917. * @param scene is the instance of BABYLON.Scene to append to
  43918. * @param onProgress a callback with a progress event for each file being loaded
  43919. * @param pluginExtension the extension used to determine the plugin
  43920. * @returns The given scene
  43921. */
  43922. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43923. /**
  43924. * Load a scene into an asset container
  43925. * @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)
  43926. * @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)
  43927. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43928. * @param onSuccess a callback with the scene when import succeeds
  43929. * @param onProgress a callback with a progress event for each file being loaded
  43930. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43931. * @param pluginExtension the extension used to determine the plugin
  43932. * @returns The loaded plugin
  43933. */
  43934. 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>;
  43935. /**
  43936. * Load a scene into an asset container
  43937. * @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)
  43938. * @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)
  43939. * @param scene is the instance of Scene to append to
  43940. * @param onProgress a callback with a progress event for each file being loaded
  43941. * @param pluginExtension the extension used to determine the plugin
  43942. * @returns The loaded asset container
  43943. */
  43944. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43945. }
  43946. }
  43947. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43948. import { Scene } from "babylonjs/scene";
  43949. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43950. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43951. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43952. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43953. /**
  43954. * Generic Controller
  43955. */
  43956. export class GenericController extends WebVRController {
  43957. /**
  43958. * Base Url for the controller model.
  43959. */
  43960. static readonly MODEL_BASE_URL: string;
  43961. /**
  43962. * File name for the controller model.
  43963. */
  43964. static readonly MODEL_FILENAME: string;
  43965. /**
  43966. * Creates a new GenericController from a gamepad
  43967. * @param vrGamepad the gamepad that the controller should be created from
  43968. */
  43969. constructor(vrGamepad: any);
  43970. /**
  43971. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43972. * @param scene scene in which to add meshes
  43973. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43974. */
  43975. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43976. /**
  43977. * Called once for each button that changed state since the last frame
  43978. * @param buttonIdx Which button index changed
  43979. * @param state New state of the button
  43980. * @param changes Which properties on the state changed since last frame
  43981. */
  43982. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43983. }
  43984. }
  43985. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43986. import { Observable } from "babylonjs/Misc/observable";
  43987. import { Scene } from "babylonjs/scene";
  43988. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43989. import { Ray } from "babylonjs/Culling/ray";
  43990. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43991. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43992. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43993. /**
  43994. * Defines the WindowsMotionController object that the state of the windows motion controller
  43995. */
  43996. export class WindowsMotionController extends WebVRController {
  43997. /**
  43998. * The base url used to load the left and right controller models
  43999. */
  44000. static MODEL_BASE_URL: string;
  44001. /**
  44002. * The name of the left controller model file
  44003. */
  44004. static MODEL_LEFT_FILENAME: string;
  44005. /**
  44006. * The name of the right controller model file
  44007. */
  44008. static MODEL_RIGHT_FILENAME: string;
  44009. /**
  44010. * The controller name prefix for this controller type
  44011. */
  44012. static readonly GAMEPAD_ID_PREFIX: string;
  44013. /**
  44014. * The controller id pattern for this controller type
  44015. */
  44016. private static readonly GAMEPAD_ID_PATTERN;
  44017. private _loadedMeshInfo;
  44018. protected readonly _mapping: {
  44019. buttons: string[];
  44020. buttonMeshNames: {
  44021. 'trigger': string;
  44022. 'menu': string;
  44023. 'grip': string;
  44024. 'thumbstick': string;
  44025. 'trackpad': string;
  44026. };
  44027. buttonObservableNames: {
  44028. 'trigger': string;
  44029. 'menu': string;
  44030. 'grip': string;
  44031. 'thumbstick': string;
  44032. 'trackpad': string;
  44033. };
  44034. axisMeshNames: string[];
  44035. pointingPoseMeshName: string;
  44036. };
  44037. /**
  44038. * Fired when the trackpad on this controller is clicked
  44039. */
  44040. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44041. /**
  44042. * Fired when the trackpad on this controller is modified
  44043. */
  44044. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44045. /**
  44046. * The current x and y values of this controller's trackpad
  44047. */
  44048. trackpad: StickValues;
  44049. /**
  44050. * Creates a new WindowsMotionController from a gamepad
  44051. * @param vrGamepad the gamepad that the controller should be created from
  44052. */
  44053. constructor(vrGamepad: any);
  44054. /**
  44055. * Fired when the trigger on this controller is modified
  44056. */
  44057. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44058. /**
  44059. * Fired when the menu button on this controller is modified
  44060. */
  44061. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44062. /**
  44063. * Fired when the grip button on this controller is modified
  44064. */
  44065. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44066. /**
  44067. * Fired when the thumbstick button on this controller is modified
  44068. */
  44069. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44070. /**
  44071. * Fired when the touchpad button on this controller is modified
  44072. */
  44073. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44074. /**
  44075. * Fired when the touchpad values on this controller are modified
  44076. */
  44077. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44078. protected _updateTrackpad(): void;
  44079. /**
  44080. * Called once per frame by the engine.
  44081. */
  44082. update(): void;
  44083. /**
  44084. * Called once for each button that changed state since the last frame
  44085. * @param buttonIdx Which button index changed
  44086. * @param state New state of the button
  44087. * @param changes Which properties on the state changed since last frame
  44088. */
  44089. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44090. /**
  44091. * Moves the buttons on the controller mesh based on their current state
  44092. * @param buttonName the name of the button to move
  44093. * @param buttonValue the value of the button which determines the buttons new position
  44094. */
  44095. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44096. /**
  44097. * Moves the axis on the controller mesh based on its current state
  44098. * @param axis the index of the axis
  44099. * @param axisValue the value of the axis which determines the meshes new position
  44100. * @hidden
  44101. */
  44102. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44103. /**
  44104. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44105. * @param scene scene in which to add meshes
  44106. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44107. */
  44108. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44109. /**
  44110. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44111. * can be transformed by button presses and axes values, based on this._mapping.
  44112. *
  44113. * @param scene scene in which the meshes exist
  44114. * @param meshes list of meshes that make up the controller model to process
  44115. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44116. */
  44117. private processModel;
  44118. private createMeshInfo;
  44119. /**
  44120. * Gets the ray of the controller in the direction the controller is pointing
  44121. * @param length the length the resulting ray should be
  44122. * @returns a ray in the direction the controller is pointing
  44123. */
  44124. getForwardRay(length?: number): Ray;
  44125. /**
  44126. * Disposes of the controller
  44127. */
  44128. dispose(): void;
  44129. }
  44130. /**
  44131. * This class represents a new windows motion controller in XR.
  44132. */
  44133. export class XRWindowsMotionController extends WindowsMotionController {
  44134. /**
  44135. * Changing the original WIndowsMotionController mapping to fir the new mapping
  44136. */
  44137. protected readonly _mapping: {
  44138. buttons: string[];
  44139. buttonMeshNames: {
  44140. 'trigger': string;
  44141. 'menu': string;
  44142. 'grip': string;
  44143. 'thumbstick': string;
  44144. 'trackpad': string;
  44145. };
  44146. buttonObservableNames: {
  44147. 'trigger': string;
  44148. 'menu': string;
  44149. 'grip': string;
  44150. 'thumbstick': string;
  44151. 'trackpad': string;
  44152. };
  44153. axisMeshNames: string[];
  44154. pointingPoseMeshName: string;
  44155. };
  44156. /**
  44157. * Construct a new XR-Based windows motion controller
  44158. *
  44159. * @param gamepadInfo the gamepad object from the browser
  44160. */
  44161. constructor(gamepadInfo: any);
  44162. /**
  44163. * holds the thumbstick values (X,Y)
  44164. */
  44165. thumbstickValues: StickValues;
  44166. /**
  44167. * Fired when the thumbstick on this controller is clicked
  44168. */
  44169. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  44170. /**
  44171. * Fired when the thumbstick on this controller is modified
  44172. */
  44173. onThumbstickValuesChangedObservable: Observable<StickValues>;
  44174. /**
  44175. * Fired when the touchpad button on this controller is modified
  44176. */
  44177. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44178. /**
  44179. * Fired when the touchpad values on this controller are modified
  44180. */
  44181. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44182. /**
  44183. * Fired when the thumbstick button on this controller is modified
  44184. * here to prevent breaking changes
  44185. */
  44186. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44187. /**
  44188. * updating the thumbstick(!) and not the trackpad.
  44189. * This is named this way due to the difference between WebVR and XR and to avoid
  44190. * changing the parent class.
  44191. */
  44192. protected _updateTrackpad(): void;
  44193. /**
  44194. * Disposes the class with joy
  44195. */
  44196. dispose(): void;
  44197. }
  44198. }
  44199. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  44200. import { Observable } from "babylonjs/Misc/observable";
  44201. import { Scene } from "babylonjs/scene";
  44202. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44203. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44204. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44205. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44206. /**
  44207. * Oculus Touch Controller
  44208. */
  44209. export class OculusTouchController extends WebVRController {
  44210. /**
  44211. * Base Url for the controller model.
  44212. */
  44213. static MODEL_BASE_URL: string;
  44214. /**
  44215. * File name for the left controller model.
  44216. */
  44217. static MODEL_LEFT_FILENAME: string;
  44218. /**
  44219. * File name for the right controller model.
  44220. */
  44221. static MODEL_RIGHT_FILENAME: string;
  44222. /**
  44223. * Base Url for the Quest controller model.
  44224. */
  44225. static QUEST_MODEL_BASE_URL: string;
  44226. /**
  44227. * @hidden
  44228. * If the controllers are running on a device that needs the updated Quest controller models
  44229. */
  44230. static _IsQuest: boolean;
  44231. /**
  44232. * Fired when the secondary trigger on this controller is modified
  44233. */
  44234. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44235. /**
  44236. * Fired when the thumb rest on this controller is modified
  44237. */
  44238. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44239. /**
  44240. * Creates a new OculusTouchController from a gamepad
  44241. * @param vrGamepad the gamepad that the controller should be created from
  44242. */
  44243. constructor(vrGamepad: any);
  44244. /**
  44245. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44246. * @param scene scene in which to add meshes
  44247. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44248. */
  44249. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44250. /**
  44251. * Fired when the A button on this controller is modified
  44252. */
  44253. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44254. /**
  44255. * Fired when the B button on this controller is modified
  44256. */
  44257. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44258. /**
  44259. * Fired when the X button on this controller is modified
  44260. */
  44261. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44262. /**
  44263. * Fired when the Y button on this controller is modified
  44264. */
  44265. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44266. /**
  44267. * Called once for each button that changed state since the last frame
  44268. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44269. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44270. * 2) secondary trigger (same)
  44271. * 3) A (right) X (left), touch, pressed = value
  44272. * 4) B / Y
  44273. * 5) thumb rest
  44274. * @param buttonIdx Which button index changed
  44275. * @param state New state of the button
  44276. * @param changes Which properties on the state changed since last frame
  44277. */
  44278. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44279. }
  44280. }
  44281. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44282. import { Scene } from "babylonjs/scene";
  44283. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44284. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44285. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44286. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44287. import { Observable } from "babylonjs/Misc/observable";
  44288. /**
  44289. * Vive Controller
  44290. */
  44291. export class ViveController extends WebVRController {
  44292. /**
  44293. * Base Url for the controller model.
  44294. */
  44295. static MODEL_BASE_URL: string;
  44296. /**
  44297. * File name for the controller model.
  44298. */
  44299. static MODEL_FILENAME: string;
  44300. /**
  44301. * Creates a new ViveController from a gamepad
  44302. * @param vrGamepad the gamepad that the controller should be created from
  44303. */
  44304. constructor(vrGamepad: any);
  44305. /**
  44306. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44307. * @param scene scene in which to add meshes
  44308. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44309. */
  44310. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44311. /**
  44312. * Fired when the left button on this controller is modified
  44313. */
  44314. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44315. /**
  44316. * Fired when the right button on this controller is modified
  44317. */
  44318. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44319. /**
  44320. * Fired when the menu button on this controller is modified
  44321. */
  44322. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44323. /**
  44324. * Called once for each button that changed state since the last frame
  44325. * Vive mapping:
  44326. * 0: touchpad
  44327. * 1: trigger
  44328. * 2: left AND right buttons
  44329. * 3: menu button
  44330. * @param buttonIdx Which button index changed
  44331. * @param state New state of the button
  44332. * @param changes Which properties on the state changed since last frame
  44333. */
  44334. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44335. }
  44336. }
  44337. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  44338. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44339. import { Observable } from "babylonjs/Misc/observable";
  44340. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  44341. /**
  44342. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  44343. */
  44344. export class WebXRControllerModelLoader {
  44345. /**
  44346. * an observable that triggers when a new model (the mesh itself) was initialized.
  44347. * To know when the mesh was loaded use the controller's own modelLoaded() method
  44348. */
  44349. onControllerModelLoaded: Observable<WebXRController>;
  44350. /**
  44351. * Creates the WebXRControllerModelLoader
  44352. * @param input xr input that creates the controllers
  44353. */
  44354. constructor(input: WebXRInput);
  44355. }
  44356. }
  44357. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  44358. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44359. /**
  44360. * Handles pointer input automatically for the pointer of XR controllers
  44361. */
  44362. export class WebXRControllerPointerSelection {
  44363. private static _idCounter;
  44364. private _tmpRay;
  44365. /**
  44366. * Creates a WebXRControllerPointerSelection
  44367. * @param input input manager to setup pointer selection
  44368. */
  44369. constructor(input: WebXRInput);
  44370. private _convertNormalToDirectionOfRay;
  44371. private _updatePointerDistance;
  44372. }
  44373. }
  44374. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  44375. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44376. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44377. /**
  44378. * Enables teleportation
  44379. */
  44380. export class WebXRControllerTeleportation {
  44381. private _teleportationFillColor;
  44382. private _teleportationBorderColor;
  44383. private _tmpRay;
  44384. private _tmpVector;
  44385. /**
  44386. * Creates a WebXRControllerTeleportation
  44387. * @param input input manager to add teleportation to
  44388. * @param floorMeshes floormeshes which can be teleported to
  44389. */
  44390. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  44391. }
  44392. }
  44393. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  44394. import { Nullable } from "babylonjs/types";
  44395. import { Observable } from "babylonjs/Misc/observable";
  44396. import { IDisposable, Scene } from "babylonjs/scene";
  44397. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44398. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  44399. /**
  44400. * Button which can be used to enter a different mode of XR
  44401. */
  44402. export class WebXREnterExitUIButton {
  44403. /** button element */
  44404. element: HTMLElement;
  44405. /** XR initialization options for the button */
  44406. sessionMode: XRSessionMode;
  44407. /** Reference space type */
  44408. referenceSpaceType: XRReferenceSpaceType;
  44409. /**
  44410. * Creates a WebXREnterExitUIButton
  44411. * @param element button element
  44412. * @param sessionMode XR initialization session mode
  44413. * @param referenceSpaceType the type of reference space to be used
  44414. */
  44415. constructor(
  44416. /** button element */
  44417. element: HTMLElement,
  44418. /** XR initialization options for the button */
  44419. sessionMode: XRSessionMode,
  44420. /** Reference space type */
  44421. referenceSpaceType: XRReferenceSpaceType);
  44422. /**
  44423. * Overwritable function which can be used to update the button's visuals when the state changes
  44424. * @param activeButton the current active button in the UI
  44425. */
  44426. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  44427. }
  44428. /**
  44429. * Options to create the webXR UI
  44430. */
  44431. export class WebXREnterExitUIOptions {
  44432. /**
  44433. * Context to enter xr with
  44434. */
  44435. renderTarget?: Nullable<WebXRRenderTarget>;
  44436. /**
  44437. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  44438. */
  44439. customButtons?: Array<WebXREnterExitUIButton>;
  44440. /**
  44441. * A session mode to use when creating the default button.
  44442. * Default is immersive-vr
  44443. */
  44444. sessionMode?: XRSessionMode;
  44445. /**
  44446. * A reference space type to use when creating the default button.
  44447. * Default is local-floor
  44448. */
  44449. referenceSpaceType?: XRReferenceSpaceType;
  44450. }
  44451. /**
  44452. * UI to allow the user to enter/exit XR mode
  44453. */
  44454. export class WebXREnterExitUI implements IDisposable {
  44455. private scene;
  44456. private _overlay;
  44457. private _buttons;
  44458. private _activeButton;
  44459. /**
  44460. * Fired every time the active button is changed.
  44461. *
  44462. * When xr is entered via a button that launches xr that button will be the callback parameter
  44463. *
  44464. * When exiting xr the callback parameter will be null)
  44465. */
  44466. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  44467. /**
  44468. * Creates UI to allow the user to enter/exit XR mode
  44469. * @param scene the scene to add the ui to
  44470. * @param helper the xr experience helper to enter/exit xr with
  44471. * @param options options to configure the UI
  44472. * @returns the created ui
  44473. */
  44474. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  44475. private constructor();
  44476. private _updateButtons;
  44477. /**
  44478. * Disposes of the object
  44479. */
  44480. dispose(): void;
  44481. }
  44482. }
  44483. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  44484. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44485. import { Scene } from "babylonjs/scene";
  44486. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44487. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  44488. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  44489. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  44490. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  44491. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  44492. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44493. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  44494. /**
  44495. * Options for the default xr helper
  44496. */
  44497. export class WebXRDefaultExperienceOptions {
  44498. /**
  44499. * Floor meshes that should be used for teleporting
  44500. */
  44501. floorMeshes: Array<AbstractMesh>;
  44502. /**
  44503. * Enable or disable default UI to enter XR
  44504. */
  44505. disableDefaultUI?: boolean;
  44506. /**
  44507. * optional configuration for the output canvas
  44508. */
  44509. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  44510. }
  44511. /**
  44512. * Default experience which provides a similar setup to the previous webVRExperience
  44513. */
  44514. export class WebXRDefaultExperience {
  44515. /**
  44516. * Base experience
  44517. */
  44518. baseExperience: WebXRExperienceHelper;
  44519. /**
  44520. * Input experience extension
  44521. */
  44522. input: WebXRInput;
  44523. /**
  44524. * Loads the controller models
  44525. */
  44526. controllerModelLoader: WebXRControllerModelLoader;
  44527. /**
  44528. * Enables laser pointer and selection
  44529. */
  44530. pointerSelection: WebXRControllerPointerSelection;
  44531. /**
  44532. * Enables teleportation
  44533. */
  44534. teleportation: WebXRControllerTeleportation;
  44535. /**
  44536. * Enables ui for enetering/exiting xr
  44537. */
  44538. enterExitUI: WebXREnterExitUI;
  44539. /**
  44540. * Default target xr should render to
  44541. */
  44542. renderTarget: WebXRRenderTarget;
  44543. /**
  44544. * Creates the default xr experience
  44545. * @param scene scene
  44546. * @param options options for basic configuration
  44547. * @returns resulting WebXRDefaultExperience
  44548. */
  44549. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  44550. private constructor();
  44551. /**
  44552. * DIsposes of the experience helper
  44553. */
  44554. dispose(): void;
  44555. }
  44556. }
  44557. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  44558. import { Observable } from "babylonjs/Misc/observable";
  44559. import { Nullable } from "babylonjs/types";
  44560. import { Camera } from "babylonjs/Cameras/camera";
  44561. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  44562. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  44563. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  44564. import { Scene } from "babylonjs/scene";
  44565. import { Vector3 } from "babylonjs/Maths/math.vector";
  44566. import { Color3 } from "babylonjs/Maths/math.color";
  44567. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44568. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44569. import { Mesh } from "babylonjs/Meshes/mesh";
  44570. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  44571. import { EasingFunction } from "babylonjs/Animations/easing";
  44572. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  44573. import "babylonjs/Meshes/Builders/groundBuilder";
  44574. import "babylonjs/Meshes/Builders/torusBuilder";
  44575. import "babylonjs/Meshes/Builders/cylinderBuilder";
  44576. import "babylonjs/Gamepads/gamepadSceneComponent";
  44577. import "babylonjs/Animations/animatable";
  44578. import { WebXRDefaultExperience } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  44579. /**
  44580. * Options to modify the vr teleportation behavior.
  44581. */
  44582. export interface VRTeleportationOptions {
  44583. /**
  44584. * The name of the mesh which should be used as the teleportation floor. (default: null)
  44585. */
  44586. floorMeshName?: string;
  44587. /**
  44588. * A list of meshes to be used as the teleportation floor. (default: empty)
  44589. */
  44590. floorMeshes?: Mesh[];
  44591. /**
  44592. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  44593. */
  44594. teleportationMode?: number;
  44595. /**
  44596. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  44597. */
  44598. teleportationTime?: number;
  44599. /**
  44600. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  44601. */
  44602. teleportationSpeed?: number;
  44603. /**
  44604. * The easing function used in the animation or null for Linear. (default CircleEase)
  44605. */
  44606. easingFunction?: EasingFunction;
  44607. }
  44608. /**
  44609. * Options to modify the vr experience helper's behavior.
  44610. */
  44611. export interface VRExperienceHelperOptions extends WebVROptions {
  44612. /**
  44613. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  44614. */
  44615. createDeviceOrientationCamera?: boolean;
  44616. /**
  44617. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  44618. */
  44619. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  44620. /**
  44621. * Uses the main button on the controller to toggle the laser casted. (default: true)
  44622. */
  44623. laserToggle?: boolean;
  44624. /**
  44625. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  44626. */
  44627. floorMeshes?: Mesh[];
  44628. /**
  44629. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  44630. */
  44631. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  44632. /**
  44633. * Defines if WebXR should be used instead of WebVR (if available)
  44634. */
  44635. useXR?: boolean;
  44636. }
  44637. /**
  44638. * Event containing information after VR has been entered
  44639. */
  44640. export class OnAfterEnteringVRObservableEvent {
  44641. /**
  44642. * If entering vr was successful
  44643. */
  44644. success: boolean;
  44645. }
  44646. /**
  44647. * Helps to quickly add VR support to an existing scene.
  44648. * See http://doc.babylonjs.com/how_to/webvr_helper
  44649. */
  44650. export class VRExperienceHelper {
  44651. /** Options to modify the vr experience helper's behavior. */
  44652. webVROptions: VRExperienceHelperOptions;
  44653. private _scene;
  44654. private _position;
  44655. private _btnVR;
  44656. private _btnVRDisplayed;
  44657. private _webVRsupported;
  44658. private _webVRready;
  44659. private _webVRrequesting;
  44660. private _webVRpresenting;
  44661. private _hasEnteredVR;
  44662. private _fullscreenVRpresenting;
  44663. private _inputElement;
  44664. private _webVRCamera;
  44665. private _vrDeviceOrientationCamera;
  44666. private _deviceOrientationCamera;
  44667. private _existingCamera;
  44668. private _onKeyDown;
  44669. private _onVrDisplayPresentChange;
  44670. private _onVRDisplayChanged;
  44671. private _onVRRequestPresentStart;
  44672. private _onVRRequestPresentComplete;
  44673. /**
  44674. * 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)
  44675. */
  44676. enableGazeEvenWhenNoPointerLock: boolean;
  44677. /**
  44678. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  44679. */
  44680. exitVROnDoubleTap: boolean;
  44681. /**
  44682. * Observable raised right before entering VR.
  44683. */
  44684. onEnteringVRObservable: Observable<VRExperienceHelper>;
  44685. /**
  44686. * Observable raised when entering VR has completed.
  44687. */
  44688. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  44689. /**
  44690. * Observable raised when exiting VR.
  44691. */
  44692. onExitingVRObservable: Observable<VRExperienceHelper>;
  44693. /**
  44694. * Observable raised when controller mesh is loaded.
  44695. */
  44696. onControllerMeshLoadedObservable: Observable<WebVRController>;
  44697. /** Return this.onEnteringVRObservable
  44698. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  44699. */
  44700. readonly onEnteringVR: Observable<VRExperienceHelper>;
  44701. /** Return this.onExitingVRObservable
  44702. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  44703. */
  44704. readonly onExitingVR: Observable<VRExperienceHelper>;
  44705. /** Return this.onControllerMeshLoadedObservable
  44706. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  44707. */
  44708. readonly onControllerMeshLoaded: Observable<WebVRController>;
  44709. private _rayLength;
  44710. private _useCustomVRButton;
  44711. private _teleportationRequested;
  44712. private _teleportActive;
  44713. private _floorMeshName;
  44714. private _floorMeshesCollection;
  44715. private _teleportationMode;
  44716. private _teleportationTime;
  44717. private _teleportationSpeed;
  44718. private _teleportationEasing;
  44719. private _rotationAllowed;
  44720. private _teleportBackwardsVector;
  44721. private _teleportationTarget;
  44722. private _isDefaultTeleportationTarget;
  44723. private _postProcessMove;
  44724. private _teleportationFillColor;
  44725. private _teleportationBorderColor;
  44726. private _rotationAngle;
  44727. private _haloCenter;
  44728. private _cameraGazer;
  44729. private _padSensibilityUp;
  44730. private _padSensibilityDown;
  44731. private _leftController;
  44732. private _rightController;
  44733. /**
  44734. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  44735. */
  44736. onNewMeshSelected: Observable<AbstractMesh>;
  44737. /**
  44738. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  44739. * This observable will provide the mesh and the controller used to select the mesh
  44740. */
  44741. onMeshSelectedWithController: Observable<{
  44742. mesh: AbstractMesh;
  44743. controller: WebVRController;
  44744. }>;
  44745. /**
  44746. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  44747. */
  44748. onNewMeshPicked: Observable<PickingInfo>;
  44749. private _circleEase;
  44750. /**
  44751. * Observable raised before camera teleportation
  44752. */
  44753. onBeforeCameraTeleport: Observable<Vector3>;
  44754. /**
  44755. * Observable raised after camera teleportation
  44756. */
  44757. onAfterCameraTeleport: Observable<Vector3>;
  44758. /**
  44759. * Observable raised when current selected mesh gets unselected
  44760. */
  44761. onSelectedMeshUnselected: Observable<AbstractMesh>;
  44762. private _raySelectionPredicate;
  44763. /**
  44764. * To be optionaly changed by user to define custom ray selection
  44765. */
  44766. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  44767. /**
  44768. * To be optionaly changed by user to define custom selection logic (after ray selection)
  44769. */
  44770. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  44771. /**
  44772. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  44773. */
  44774. teleportationEnabled: boolean;
  44775. private _defaultHeight;
  44776. private _teleportationInitialized;
  44777. private _interactionsEnabled;
  44778. private _interactionsRequested;
  44779. private _displayGaze;
  44780. private _displayLaserPointer;
  44781. /**
  44782. * The mesh used to display where the user is going to teleport.
  44783. */
  44784. /**
  44785. * Sets the mesh to be used to display where the user is going to teleport.
  44786. */
  44787. teleportationTarget: Mesh;
  44788. /**
  44789. * 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
  44790. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  44791. * See http://doc.babylonjs.com/resources/baking_transformations
  44792. */
  44793. gazeTrackerMesh: Mesh;
  44794. /**
  44795. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  44796. */
  44797. updateGazeTrackerScale: boolean;
  44798. /**
  44799. * If the gaze trackers color should be updated when selecting meshes
  44800. */
  44801. updateGazeTrackerColor: boolean;
  44802. /**
  44803. * If the controller laser color should be updated when selecting meshes
  44804. */
  44805. updateControllerLaserColor: boolean;
  44806. /**
  44807. * The gaze tracking mesh corresponding to the left controller
  44808. */
  44809. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  44810. /**
  44811. * The gaze tracking mesh corresponding to the right controller
  44812. */
  44813. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  44814. /**
  44815. * If the ray of the gaze should be displayed.
  44816. */
  44817. /**
  44818. * Sets if the ray of the gaze should be displayed.
  44819. */
  44820. displayGaze: boolean;
  44821. /**
  44822. * If the ray of the LaserPointer should be displayed.
  44823. */
  44824. /**
  44825. * Sets if the ray of the LaserPointer should be displayed.
  44826. */
  44827. displayLaserPointer: boolean;
  44828. /**
  44829. * The deviceOrientationCamera used as the camera when not in VR.
  44830. */
  44831. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  44832. /**
  44833. * Based on the current WebVR support, returns the current VR camera used.
  44834. */
  44835. readonly currentVRCamera: Nullable<Camera>;
  44836. /**
  44837. * The webVRCamera which is used when in VR.
  44838. */
  44839. readonly webVRCamera: WebVRFreeCamera;
  44840. /**
  44841. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  44842. */
  44843. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  44844. /**
  44845. * The html button that is used to trigger entering into VR.
  44846. */
  44847. readonly vrButton: Nullable<HTMLButtonElement>;
  44848. private readonly _teleportationRequestInitiated;
  44849. /**
  44850. * Defines wether or not Pointer lock should be requested when switching to
  44851. * full screen.
  44852. */
  44853. requestPointerLockOnFullScreen: boolean;
  44854. /**
  44855. * If asking to force XR, this will be populated with the default xr experience
  44856. */
  44857. xr: WebXRDefaultExperience;
  44858. /**
  44859. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  44860. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  44861. */
  44862. xrTestDone: boolean;
  44863. /**
  44864. * Instantiates a VRExperienceHelper.
  44865. * Helps to quickly add VR support to an existing scene.
  44866. * @param scene The scene the VRExperienceHelper belongs to.
  44867. * @param webVROptions Options to modify the vr experience helper's behavior.
  44868. */
  44869. constructor(scene: Scene,
  44870. /** Options to modify the vr experience helper's behavior. */
  44871. webVROptions?: VRExperienceHelperOptions);
  44872. private completeVRInit;
  44873. private _onDefaultMeshLoaded;
  44874. private _onResize;
  44875. private _onFullscreenChange;
  44876. /**
  44877. * Gets a value indicating if we are currently in VR mode.
  44878. */
  44879. readonly isInVRMode: boolean;
  44880. private onVrDisplayPresentChange;
  44881. private onVRDisplayChanged;
  44882. private moveButtonToBottomRight;
  44883. private displayVRButton;
  44884. private updateButtonVisibility;
  44885. private _cachedAngularSensibility;
  44886. /**
  44887. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  44888. * Otherwise, will use the fullscreen API.
  44889. */
  44890. enterVR(): void;
  44891. /**
  44892. * Attempt to exit VR, or fullscreen.
  44893. */
  44894. exitVR(): void;
  44895. /**
  44896. * The position of the vr experience helper.
  44897. */
  44898. /**
  44899. * Sets the position of the vr experience helper.
  44900. */
  44901. position: Vector3;
  44902. /**
  44903. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  44904. */
  44905. enableInteractions(): void;
  44906. private readonly _noControllerIsActive;
  44907. private beforeRender;
  44908. private _isTeleportationFloor;
  44909. /**
  44910. * Adds a floor mesh to be used for teleportation.
  44911. * @param floorMesh the mesh to be used for teleportation.
  44912. */
  44913. addFloorMesh(floorMesh: Mesh): void;
  44914. /**
  44915. * Removes a floor mesh from being used for teleportation.
  44916. * @param floorMesh the mesh to be removed.
  44917. */
  44918. removeFloorMesh(floorMesh: Mesh): void;
  44919. /**
  44920. * Enables interactions and teleportation using the VR controllers and gaze.
  44921. * @param vrTeleportationOptions options to modify teleportation behavior.
  44922. */
  44923. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  44924. private _onNewGamepadConnected;
  44925. private _tryEnableInteractionOnController;
  44926. private _onNewGamepadDisconnected;
  44927. private _enableInteractionOnController;
  44928. private _checkTeleportWithRay;
  44929. private _checkRotate;
  44930. private _checkTeleportBackwards;
  44931. private _enableTeleportationOnController;
  44932. private _createTeleportationCircles;
  44933. private _displayTeleportationTarget;
  44934. private _hideTeleportationTarget;
  44935. private _rotateCamera;
  44936. private _moveTeleportationSelectorTo;
  44937. private _workingVector;
  44938. private _workingQuaternion;
  44939. private _workingMatrix;
  44940. /**
  44941. * Time Constant Teleportation Mode
  44942. */
  44943. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  44944. /**
  44945. * Speed Constant Teleportation Mode
  44946. */
  44947. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  44948. /**
  44949. * Teleports the users feet to the desired location
  44950. * @param location The location where the user's feet should be placed
  44951. */
  44952. teleportCamera(location: Vector3): void;
  44953. private _convertNormalToDirectionOfRay;
  44954. private _castRayAndSelectObject;
  44955. private _notifySelectedMeshUnselected;
  44956. /**
  44957. * Sets the color of the laser ray from the vr controllers.
  44958. * @param color new color for the ray.
  44959. */
  44960. changeLaserColor(color: Color3): void;
  44961. /**
  44962. * Sets the color of the ray from the vr headsets gaze.
  44963. * @param color new color for the ray.
  44964. */
  44965. changeGazeColor(color: Color3): void;
  44966. /**
  44967. * Exits VR and disposes of the vr experience helper
  44968. */
  44969. dispose(): void;
  44970. /**
  44971. * Gets the name of the VRExperienceHelper class
  44972. * @returns "VRExperienceHelper"
  44973. */
  44974. getClassName(): string;
  44975. }
  44976. }
  44977. declare module "babylonjs/Cameras/VR/index" {
  44978. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  44979. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  44980. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  44981. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  44982. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  44983. export * from "babylonjs/Cameras/VR/webVRCamera";
  44984. }
  44985. declare module "babylonjs/Cameras/XR/index" {
  44986. export * from "babylonjs/Cameras/XR/webXRCamera";
  44987. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  44988. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44989. export * from "babylonjs/Cameras/XR/webXRInput";
  44990. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  44991. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  44992. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  44993. export * from "babylonjs/Cameras/XR/webXRController";
  44994. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  44995. export * from "babylonjs/Cameras/XR/webXRTypes";
  44996. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  44997. export * from "babylonjs/Cameras/XR/webXRDefaultExperience";
  44998. }
  44999. declare module "babylonjs/Cameras/RigModes/index" {
  45000. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  45001. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  45002. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  45003. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  45004. }
  45005. declare module "babylonjs/Cameras/index" {
  45006. export * from "babylonjs/Cameras/Inputs/index";
  45007. export * from "babylonjs/Cameras/cameraInputsManager";
  45008. export * from "babylonjs/Cameras/camera";
  45009. export * from "babylonjs/Cameras/targetCamera";
  45010. export * from "babylonjs/Cameras/freeCamera";
  45011. export * from "babylonjs/Cameras/freeCameraInputsManager";
  45012. export * from "babylonjs/Cameras/touchCamera";
  45013. export * from "babylonjs/Cameras/arcRotateCamera";
  45014. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  45015. export * from "babylonjs/Cameras/deviceOrientationCamera";
  45016. export * from "babylonjs/Cameras/flyCamera";
  45017. export * from "babylonjs/Cameras/flyCameraInputsManager";
  45018. export * from "babylonjs/Cameras/followCamera";
  45019. export * from "babylonjs/Cameras/followCameraInputsManager";
  45020. export * from "babylonjs/Cameras/gamepadCamera";
  45021. export * from "babylonjs/Cameras/Stereoscopic/index";
  45022. export * from "babylonjs/Cameras/universalCamera";
  45023. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  45024. export * from "babylonjs/Cameras/VR/index";
  45025. export * from "babylonjs/Cameras/XR/index";
  45026. export * from "babylonjs/Cameras/RigModes/index";
  45027. }
  45028. declare module "babylonjs/Collisions/index" {
  45029. export * from "babylonjs/Collisions/collider";
  45030. export * from "babylonjs/Collisions/collisionCoordinator";
  45031. export * from "babylonjs/Collisions/pickingInfo";
  45032. export * from "babylonjs/Collisions/intersectionInfo";
  45033. export * from "babylonjs/Collisions/meshCollisionData";
  45034. }
  45035. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  45036. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  45037. import { Vector3 } from "babylonjs/Maths/math.vector";
  45038. import { Ray } from "babylonjs/Culling/ray";
  45039. import { Plane } from "babylonjs/Maths/math.plane";
  45040. /**
  45041. * Contains an array of blocks representing the octree
  45042. */
  45043. export interface IOctreeContainer<T> {
  45044. /**
  45045. * Blocks within the octree
  45046. */
  45047. blocks: Array<OctreeBlock<T>>;
  45048. }
  45049. /**
  45050. * Class used to store a cell in an octree
  45051. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45052. */
  45053. export class OctreeBlock<T> {
  45054. /**
  45055. * Gets the content of the current block
  45056. */
  45057. entries: T[];
  45058. /**
  45059. * Gets the list of block children
  45060. */
  45061. blocks: Array<OctreeBlock<T>>;
  45062. private _depth;
  45063. private _maxDepth;
  45064. private _capacity;
  45065. private _minPoint;
  45066. private _maxPoint;
  45067. private _boundingVectors;
  45068. private _creationFunc;
  45069. /**
  45070. * Creates a new block
  45071. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  45072. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  45073. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45074. * @param depth defines the current depth of this block in the octree
  45075. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  45076. * @param creationFunc defines a callback to call when an element is added to the block
  45077. */
  45078. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  45079. /**
  45080. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45081. */
  45082. readonly capacity: number;
  45083. /**
  45084. * Gets the minimum vector (in world space) of the block's bounding box
  45085. */
  45086. readonly minPoint: Vector3;
  45087. /**
  45088. * Gets the maximum vector (in world space) of the block's bounding box
  45089. */
  45090. readonly maxPoint: Vector3;
  45091. /**
  45092. * Add a new element to this block
  45093. * @param entry defines the element to add
  45094. */
  45095. addEntry(entry: T): void;
  45096. /**
  45097. * Remove an element from this block
  45098. * @param entry defines the element to remove
  45099. */
  45100. removeEntry(entry: T): void;
  45101. /**
  45102. * Add an array of elements to this block
  45103. * @param entries defines the array of elements to add
  45104. */
  45105. addEntries(entries: T[]): void;
  45106. /**
  45107. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  45108. * @param frustumPlanes defines the frustum planes to test
  45109. * @param selection defines the array to store current content if selection is positive
  45110. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45111. */
  45112. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45113. /**
  45114. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  45115. * @param sphereCenter defines the bounding sphere center
  45116. * @param sphereRadius defines the bounding sphere radius
  45117. * @param selection defines the array to store current content if selection is positive
  45118. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45119. */
  45120. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45121. /**
  45122. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  45123. * @param ray defines the ray to test with
  45124. * @param selection defines the array to store current content if selection is positive
  45125. */
  45126. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  45127. /**
  45128. * Subdivide the content into child blocks (this block will then be empty)
  45129. */
  45130. createInnerBlocks(): void;
  45131. /**
  45132. * @hidden
  45133. */
  45134. 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;
  45135. }
  45136. }
  45137. declare module "babylonjs/Culling/Octrees/octree" {
  45138. import { SmartArray } from "babylonjs/Misc/smartArray";
  45139. import { Vector3 } from "babylonjs/Maths/math.vector";
  45140. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45141. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45142. import { Ray } from "babylonjs/Culling/ray";
  45143. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  45144. import { Plane } from "babylonjs/Maths/math.plane";
  45145. /**
  45146. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  45147. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45148. */
  45149. export class Octree<T> {
  45150. /** 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.) */
  45151. maxDepth: number;
  45152. /**
  45153. * Blocks within the octree containing objects
  45154. */
  45155. blocks: Array<OctreeBlock<T>>;
  45156. /**
  45157. * Content stored in the octree
  45158. */
  45159. dynamicContent: T[];
  45160. private _maxBlockCapacity;
  45161. private _selectionContent;
  45162. private _creationFunc;
  45163. /**
  45164. * Creates a octree
  45165. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45166. * @param creationFunc function to be used to instatiate the octree
  45167. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  45168. * @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.)
  45169. */
  45170. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  45171. /** 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.) */
  45172. maxDepth?: number);
  45173. /**
  45174. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  45175. * @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);
  45176. * @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);
  45177. * @param entries meshes to be added to the octree blocks
  45178. */
  45179. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  45180. /**
  45181. * Adds a mesh to the octree
  45182. * @param entry Mesh to add to the octree
  45183. */
  45184. addMesh(entry: T): void;
  45185. /**
  45186. * Remove an element from the octree
  45187. * @param entry defines the element to remove
  45188. */
  45189. removeMesh(entry: T): void;
  45190. /**
  45191. * Selects an array of meshes within the frustum
  45192. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  45193. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  45194. * @returns array of meshes within the frustum
  45195. */
  45196. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  45197. /**
  45198. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  45199. * @param sphereCenter defines the bounding sphere center
  45200. * @param sphereRadius defines the bounding sphere radius
  45201. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45202. * @returns an array of objects that intersect the sphere
  45203. */
  45204. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  45205. /**
  45206. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  45207. * @param ray defines the ray to test with
  45208. * @returns array of intersected objects
  45209. */
  45210. intersectsRay(ray: Ray): SmartArray<T>;
  45211. /**
  45212. * Adds a mesh into the octree block if it intersects the block
  45213. */
  45214. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  45215. /**
  45216. * Adds a submesh into the octree block if it intersects the block
  45217. */
  45218. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  45219. }
  45220. }
  45221. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  45222. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  45223. import { Scene } from "babylonjs/scene";
  45224. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45225. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45226. import { Ray } from "babylonjs/Culling/ray";
  45227. import { Octree } from "babylonjs/Culling/Octrees/octree";
  45228. import { Collider } from "babylonjs/Collisions/collider";
  45229. module "babylonjs/scene" {
  45230. interface Scene {
  45231. /**
  45232. * @hidden
  45233. * Backing Filed
  45234. */
  45235. _selectionOctree: Octree<AbstractMesh>;
  45236. /**
  45237. * Gets the octree used to boost mesh selection (picking)
  45238. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45239. */
  45240. selectionOctree: Octree<AbstractMesh>;
  45241. /**
  45242. * Creates or updates the octree used to boost selection (picking)
  45243. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45244. * @param maxCapacity defines the maximum capacity per leaf
  45245. * @param maxDepth defines the maximum depth of the octree
  45246. * @returns an octree of AbstractMesh
  45247. */
  45248. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  45249. }
  45250. }
  45251. module "babylonjs/Meshes/abstractMesh" {
  45252. interface AbstractMesh {
  45253. /**
  45254. * @hidden
  45255. * Backing Field
  45256. */
  45257. _submeshesOctree: Octree<SubMesh>;
  45258. /**
  45259. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  45260. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  45261. * @param maxCapacity defines the maximum size of each block (64 by default)
  45262. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  45263. * @returns the new octree
  45264. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  45265. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45266. */
  45267. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  45268. }
  45269. }
  45270. /**
  45271. * Defines the octree scene component responsible to manage any octrees
  45272. * in a given scene.
  45273. */
  45274. export class OctreeSceneComponent {
  45275. /**
  45276. * The component name help to identify the component in the list of scene components.
  45277. */
  45278. readonly name: string;
  45279. /**
  45280. * The scene the component belongs to.
  45281. */
  45282. scene: Scene;
  45283. /**
  45284. * Indicates if the meshes have been checked to make sure they are isEnabled()
  45285. */
  45286. readonly checksIsEnabled: boolean;
  45287. /**
  45288. * Creates a new instance of the component for the given scene
  45289. * @param scene Defines the scene to register the component in
  45290. */
  45291. constructor(scene: Scene);
  45292. /**
  45293. * Registers the component in a given scene
  45294. */
  45295. register(): void;
  45296. /**
  45297. * Return the list of active meshes
  45298. * @returns the list of active meshes
  45299. */
  45300. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  45301. /**
  45302. * Return the list of active sub meshes
  45303. * @param mesh The mesh to get the candidates sub meshes from
  45304. * @returns the list of active sub meshes
  45305. */
  45306. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  45307. private _tempRay;
  45308. /**
  45309. * Return the list of sub meshes intersecting with a given local ray
  45310. * @param mesh defines the mesh to find the submesh for
  45311. * @param localRay defines the ray in local space
  45312. * @returns the list of intersecting sub meshes
  45313. */
  45314. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  45315. /**
  45316. * Return the list of sub meshes colliding with a collider
  45317. * @param mesh defines the mesh to find the submesh for
  45318. * @param collider defines the collider to evaluate the collision against
  45319. * @returns the list of colliding sub meshes
  45320. */
  45321. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  45322. /**
  45323. * Rebuilds the elements related to this component in case of
  45324. * context lost for instance.
  45325. */
  45326. rebuild(): void;
  45327. /**
  45328. * Disposes the component and the associated ressources.
  45329. */
  45330. dispose(): void;
  45331. }
  45332. }
  45333. declare module "babylonjs/Culling/Octrees/index" {
  45334. export * from "babylonjs/Culling/Octrees/octree";
  45335. export * from "babylonjs/Culling/Octrees/octreeBlock";
  45336. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  45337. }
  45338. declare module "babylonjs/Culling/index" {
  45339. export * from "babylonjs/Culling/boundingBox";
  45340. export * from "babylonjs/Culling/boundingInfo";
  45341. export * from "babylonjs/Culling/boundingSphere";
  45342. export * from "babylonjs/Culling/Octrees/index";
  45343. export * from "babylonjs/Culling/ray";
  45344. }
  45345. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  45346. import { IDisposable, Scene } from "babylonjs/scene";
  45347. import { Nullable } from "babylonjs/types";
  45348. import { Observable } from "babylonjs/Misc/observable";
  45349. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45350. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  45351. import { Camera } from "babylonjs/Cameras/camera";
  45352. /**
  45353. * Renders a layer on top of an existing scene
  45354. */
  45355. export class UtilityLayerRenderer implements IDisposable {
  45356. /** the original scene that will be rendered on top of */
  45357. originalScene: Scene;
  45358. private _pointerCaptures;
  45359. private _lastPointerEvents;
  45360. private static _DefaultUtilityLayer;
  45361. private static _DefaultKeepDepthUtilityLayer;
  45362. private _sharedGizmoLight;
  45363. private _renderCamera;
  45364. /**
  45365. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  45366. * @returns the camera that is used when rendering the utility layer
  45367. */
  45368. getRenderCamera(): Nullable<Camera>;
  45369. /**
  45370. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  45371. * @param cam the camera that should be used when rendering the utility layer
  45372. */
  45373. setRenderCamera(cam: Nullable<Camera>): void;
  45374. /**
  45375. * @hidden
  45376. * Light which used by gizmos to get light shading
  45377. */
  45378. _getSharedGizmoLight(): HemisphericLight;
  45379. /**
  45380. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  45381. */
  45382. pickUtilitySceneFirst: boolean;
  45383. /**
  45384. * 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)
  45385. */
  45386. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  45387. /**
  45388. * 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)
  45389. */
  45390. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  45391. /**
  45392. * The scene that is rendered on top of the original scene
  45393. */
  45394. utilityLayerScene: Scene;
  45395. /**
  45396. * If the utility layer should automatically be rendered on top of existing scene
  45397. */
  45398. shouldRender: boolean;
  45399. /**
  45400. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  45401. */
  45402. onlyCheckPointerDownEvents: boolean;
  45403. /**
  45404. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  45405. */
  45406. processAllEvents: boolean;
  45407. /**
  45408. * Observable raised when the pointer move from the utility layer scene to the main scene
  45409. */
  45410. onPointerOutObservable: Observable<number>;
  45411. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  45412. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  45413. private _afterRenderObserver;
  45414. private _sceneDisposeObserver;
  45415. private _originalPointerObserver;
  45416. /**
  45417. * Instantiates a UtilityLayerRenderer
  45418. * @param originalScene the original scene that will be rendered on top of
  45419. * @param handleEvents boolean indicating if the utility layer should handle events
  45420. */
  45421. constructor(
  45422. /** the original scene that will be rendered on top of */
  45423. originalScene: Scene, handleEvents?: boolean);
  45424. private _notifyObservers;
  45425. /**
  45426. * Renders the utility layers scene on top of the original scene
  45427. */
  45428. render(): void;
  45429. /**
  45430. * Disposes of the renderer
  45431. */
  45432. dispose(): void;
  45433. private _updateCamera;
  45434. }
  45435. }
  45436. declare module "babylonjs/Gizmos/gizmo" {
  45437. import { Nullable } from "babylonjs/types";
  45438. import { IDisposable } from "babylonjs/scene";
  45439. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45440. import { Mesh } from "babylonjs/Meshes/mesh";
  45441. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45442. /**
  45443. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  45444. */
  45445. export class Gizmo implements IDisposable {
  45446. /** The utility layer the gizmo will be added to */
  45447. gizmoLayer: UtilityLayerRenderer;
  45448. /**
  45449. * The root mesh of the gizmo
  45450. */
  45451. _rootMesh: Mesh;
  45452. private _attachedMesh;
  45453. /**
  45454. * Ratio for the scale of the gizmo (Default: 1)
  45455. */
  45456. scaleRatio: number;
  45457. /**
  45458. * If a custom mesh has been set (Default: false)
  45459. */
  45460. protected _customMeshSet: boolean;
  45461. /**
  45462. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  45463. * * When set, interactions will be enabled
  45464. */
  45465. attachedMesh: Nullable<AbstractMesh>;
  45466. /**
  45467. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45468. * @param mesh The mesh to replace the default mesh of the gizmo
  45469. */
  45470. setCustomMesh(mesh: Mesh): void;
  45471. /**
  45472. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  45473. */
  45474. updateGizmoRotationToMatchAttachedMesh: boolean;
  45475. /**
  45476. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  45477. */
  45478. updateGizmoPositionToMatchAttachedMesh: boolean;
  45479. /**
  45480. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  45481. */
  45482. updateScale: boolean;
  45483. protected _interactionsEnabled: boolean;
  45484. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45485. private _beforeRenderObserver;
  45486. private _tempVector;
  45487. /**
  45488. * Creates a gizmo
  45489. * @param gizmoLayer The utility layer the gizmo will be added to
  45490. */
  45491. constructor(
  45492. /** The utility layer the gizmo will be added to */
  45493. gizmoLayer?: UtilityLayerRenderer);
  45494. /**
  45495. * Updates the gizmo to match the attached mesh's position/rotation
  45496. */
  45497. protected _update(): void;
  45498. /**
  45499. * Disposes of the gizmo
  45500. */
  45501. dispose(): void;
  45502. }
  45503. }
  45504. declare module "babylonjs/Gizmos/planeDragGizmo" {
  45505. import { Observable } from "babylonjs/Misc/observable";
  45506. import { Nullable } from "babylonjs/types";
  45507. import { Vector3 } from "babylonjs/Maths/math.vector";
  45508. import { Color3 } from "babylonjs/Maths/math.color";
  45509. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45510. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45511. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45512. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45513. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45514. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  45515. import { Scene } from "babylonjs/scene";
  45516. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45517. /**
  45518. * Single plane drag gizmo
  45519. */
  45520. export class PlaneDragGizmo extends Gizmo {
  45521. /**
  45522. * Drag behavior responsible for the gizmos dragging interactions
  45523. */
  45524. dragBehavior: PointerDragBehavior;
  45525. private _pointerObserver;
  45526. /**
  45527. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45528. */
  45529. snapDistance: number;
  45530. /**
  45531. * Event that fires each time the gizmo snaps to a new location.
  45532. * * snapDistance is the the change in distance
  45533. */
  45534. onSnapObservable: Observable<{
  45535. snapDistance: number;
  45536. }>;
  45537. private _plane;
  45538. private _coloredMaterial;
  45539. private _hoverMaterial;
  45540. private _isEnabled;
  45541. private _parent;
  45542. /** @hidden */
  45543. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  45544. /** @hidden */
  45545. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45546. /**
  45547. * Creates a PlaneDragGizmo
  45548. * @param gizmoLayer The utility layer the gizmo will be added to
  45549. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  45550. * @param color The color of the gizmo
  45551. */
  45552. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45553. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45554. /**
  45555. * If the gizmo is enabled
  45556. */
  45557. isEnabled: boolean;
  45558. /**
  45559. * Disposes of the gizmo
  45560. */
  45561. dispose(): void;
  45562. }
  45563. }
  45564. declare module "babylonjs/Gizmos/positionGizmo" {
  45565. import { Observable } from "babylonjs/Misc/observable";
  45566. import { Nullable } from "babylonjs/types";
  45567. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45568. import { Mesh } from "babylonjs/Meshes/mesh";
  45569. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45570. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  45571. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  45572. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45573. /**
  45574. * Gizmo that enables dragging a mesh along 3 axis
  45575. */
  45576. export class PositionGizmo extends Gizmo {
  45577. /**
  45578. * Internal gizmo used for interactions on the x axis
  45579. */
  45580. xGizmo: AxisDragGizmo;
  45581. /**
  45582. * Internal gizmo used for interactions on the y axis
  45583. */
  45584. yGizmo: AxisDragGizmo;
  45585. /**
  45586. * Internal gizmo used for interactions on the z axis
  45587. */
  45588. zGizmo: AxisDragGizmo;
  45589. /**
  45590. * Internal gizmo used for interactions on the yz plane
  45591. */
  45592. xPlaneGizmo: PlaneDragGizmo;
  45593. /**
  45594. * Internal gizmo used for interactions on the xz plane
  45595. */
  45596. yPlaneGizmo: PlaneDragGizmo;
  45597. /**
  45598. * Internal gizmo used for interactions on the xy plane
  45599. */
  45600. zPlaneGizmo: PlaneDragGizmo;
  45601. /**
  45602. * private variables
  45603. */
  45604. private _meshAttached;
  45605. private _updateGizmoRotationToMatchAttachedMesh;
  45606. private _snapDistance;
  45607. private _scaleRatio;
  45608. /** Fires an event when any of it's sub gizmos are dragged */
  45609. onDragStartObservable: Observable<unknown>;
  45610. /** Fires an event when any of it's sub gizmos are released from dragging */
  45611. onDragEndObservable: Observable<unknown>;
  45612. /**
  45613. * If set to true, planar drag is enabled
  45614. */
  45615. private _planarGizmoEnabled;
  45616. attachedMesh: Nullable<AbstractMesh>;
  45617. /**
  45618. * Creates a PositionGizmo
  45619. * @param gizmoLayer The utility layer the gizmo will be added to
  45620. */
  45621. constructor(gizmoLayer?: UtilityLayerRenderer);
  45622. /**
  45623. * If the planar drag gizmo is enabled
  45624. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  45625. */
  45626. planarGizmoEnabled: boolean;
  45627. updateGizmoRotationToMatchAttachedMesh: boolean;
  45628. /**
  45629. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45630. */
  45631. snapDistance: number;
  45632. /**
  45633. * Ratio for the scale of the gizmo (Default: 1)
  45634. */
  45635. scaleRatio: number;
  45636. /**
  45637. * Disposes of the gizmo
  45638. */
  45639. dispose(): void;
  45640. /**
  45641. * CustomMeshes are not supported by this gizmo
  45642. * @param mesh The mesh to replace the default mesh of the gizmo
  45643. */
  45644. setCustomMesh(mesh: Mesh): void;
  45645. }
  45646. }
  45647. declare module "babylonjs/Gizmos/axisDragGizmo" {
  45648. import { Observable } from "babylonjs/Misc/observable";
  45649. import { Nullable } from "babylonjs/types";
  45650. import { Vector3 } from "babylonjs/Maths/math.vector";
  45651. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45652. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45653. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45654. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45655. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45656. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  45657. import { Scene } from "babylonjs/scene";
  45658. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45659. import { Color3 } from "babylonjs/Maths/math.color";
  45660. /**
  45661. * Single axis drag gizmo
  45662. */
  45663. export class AxisDragGizmo extends Gizmo {
  45664. /**
  45665. * Drag behavior responsible for the gizmos dragging interactions
  45666. */
  45667. dragBehavior: PointerDragBehavior;
  45668. private _pointerObserver;
  45669. /**
  45670. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45671. */
  45672. snapDistance: number;
  45673. /**
  45674. * Event that fires each time the gizmo snaps to a new location.
  45675. * * snapDistance is the the change in distance
  45676. */
  45677. onSnapObservable: Observable<{
  45678. snapDistance: number;
  45679. }>;
  45680. private _isEnabled;
  45681. private _parent;
  45682. private _arrow;
  45683. private _coloredMaterial;
  45684. private _hoverMaterial;
  45685. /** @hidden */
  45686. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  45687. /** @hidden */
  45688. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45689. /**
  45690. * Creates an AxisDragGizmo
  45691. * @param gizmoLayer The utility layer the gizmo will be added to
  45692. * @param dragAxis The axis which the gizmo will be able to drag on
  45693. * @param color The color of the gizmo
  45694. */
  45695. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45696. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45697. /**
  45698. * If the gizmo is enabled
  45699. */
  45700. isEnabled: boolean;
  45701. /**
  45702. * Disposes of the gizmo
  45703. */
  45704. dispose(): void;
  45705. }
  45706. }
  45707. declare module "babylonjs/Debug/axesViewer" {
  45708. import { Vector3 } from "babylonjs/Maths/math.vector";
  45709. import { Nullable } from "babylonjs/types";
  45710. import { Scene } from "babylonjs/scene";
  45711. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45712. /**
  45713. * The Axes viewer will show 3 axes in a specific point in space
  45714. */
  45715. export class AxesViewer {
  45716. private _xAxis;
  45717. private _yAxis;
  45718. private _zAxis;
  45719. private _scaleLinesFactor;
  45720. private _instanced;
  45721. /**
  45722. * Gets the hosting scene
  45723. */
  45724. scene: Scene;
  45725. /**
  45726. * Gets or sets a number used to scale line length
  45727. */
  45728. scaleLines: number;
  45729. /** Gets the node hierarchy used to render x-axis */
  45730. readonly xAxis: TransformNode;
  45731. /** Gets the node hierarchy used to render y-axis */
  45732. readonly yAxis: TransformNode;
  45733. /** Gets the node hierarchy used to render z-axis */
  45734. readonly zAxis: TransformNode;
  45735. /**
  45736. * Creates a new AxesViewer
  45737. * @param scene defines the hosting scene
  45738. * @param scaleLines defines a number used to scale line length (1 by default)
  45739. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  45740. * @param xAxis defines the node hierarchy used to render the x-axis
  45741. * @param yAxis defines the node hierarchy used to render the y-axis
  45742. * @param zAxis defines the node hierarchy used to render the z-axis
  45743. */
  45744. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  45745. /**
  45746. * Force the viewer to update
  45747. * @param position defines the position of the viewer
  45748. * @param xaxis defines the x axis of the viewer
  45749. * @param yaxis defines the y axis of the viewer
  45750. * @param zaxis defines the z axis of the viewer
  45751. */
  45752. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  45753. /**
  45754. * Creates an instance of this axes viewer.
  45755. * @returns a new axes viewer with instanced meshes
  45756. */
  45757. createInstance(): AxesViewer;
  45758. /** Releases resources */
  45759. dispose(): void;
  45760. private static _SetRenderingGroupId;
  45761. }
  45762. }
  45763. declare module "babylonjs/Debug/boneAxesViewer" {
  45764. import { Nullable } from "babylonjs/types";
  45765. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  45766. import { Vector3 } from "babylonjs/Maths/math.vector";
  45767. import { Mesh } from "babylonjs/Meshes/mesh";
  45768. import { Bone } from "babylonjs/Bones/bone";
  45769. import { Scene } from "babylonjs/scene";
  45770. /**
  45771. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  45772. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  45773. */
  45774. export class BoneAxesViewer extends AxesViewer {
  45775. /**
  45776. * Gets or sets the target mesh where to display the axes viewer
  45777. */
  45778. mesh: Nullable<Mesh>;
  45779. /**
  45780. * Gets or sets the target bone where to display the axes viewer
  45781. */
  45782. bone: Nullable<Bone>;
  45783. /** Gets current position */
  45784. pos: Vector3;
  45785. /** Gets direction of X axis */
  45786. xaxis: Vector3;
  45787. /** Gets direction of Y axis */
  45788. yaxis: Vector3;
  45789. /** Gets direction of Z axis */
  45790. zaxis: Vector3;
  45791. /**
  45792. * Creates a new BoneAxesViewer
  45793. * @param scene defines the hosting scene
  45794. * @param bone defines the target bone
  45795. * @param mesh defines the target mesh
  45796. * @param scaleLines defines a scaling factor for line length (1 by default)
  45797. */
  45798. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  45799. /**
  45800. * Force the viewer to update
  45801. */
  45802. update(): void;
  45803. /** Releases resources */
  45804. dispose(): void;
  45805. }
  45806. }
  45807. declare module "babylonjs/Debug/debugLayer" {
  45808. import { Scene } from "babylonjs/scene";
  45809. /**
  45810. * Interface used to define scene explorer extensibility option
  45811. */
  45812. export interface IExplorerExtensibilityOption {
  45813. /**
  45814. * Define the option label
  45815. */
  45816. label: string;
  45817. /**
  45818. * Defines the action to execute on click
  45819. */
  45820. action: (entity: any) => void;
  45821. }
  45822. /**
  45823. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  45824. */
  45825. export interface IExplorerExtensibilityGroup {
  45826. /**
  45827. * Defines a predicate to test if a given type mut be extended
  45828. */
  45829. predicate: (entity: any) => boolean;
  45830. /**
  45831. * Gets the list of options added to a type
  45832. */
  45833. entries: IExplorerExtensibilityOption[];
  45834. }
  45835. /**
  45836. * Interface used to define the options to use to create the Inspector
  45837. */
  45838. export interface IInspectorOptions {
  45839. /**
  45840. * Display in overlay mode (default: false)
  45841. */
  45842. overlay?: boolean;
  45843. /**
  45844. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  45845. */
  45846. globalRoot?: HTMLElement;
  45847. /**
  45848. * Display the Scene explorer
  45849. */
  45850. showExplorer?: boolean;
  45851. /**
  45852. * Display the property inspector
  45853. */
  45854. showInspector?: boolean;
  45855. /**
  45856. * Display in embed mode (both panes on the right)
  45857. */
  45858. embedMode?: boolean;
  45859. /**
  45860. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  45861. */
  45862. handleResize?: boolean;
  45863. /**
  45864. * Allow the panes to popup (default: true)
  45865. */
  45866. enablePopup?: boolean;
  45867. /**
  45868. * Allow the panes to be closed by users (default: true)
  45869. */
  45870. enableClose?: boolean;
  45871. /**
  45872. * Optional list of extensibility entries
  45873. */
  45874. explorerExtensibility?: IExplorerExtensibilityGroup[];
  45875. /**
  45876. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  45877. */
  45878. inspectorURL?: string;
  45879. /**
  45880. * Optional initial tab (default to DebugLayerTab.Properties)
  45881. */
  45882. initialTab?: DebugLayerTab;
  45883. }
  45884. module "babylonjs/scene" {
  45885. interface Scene {
  45886. /**
  45887. * @hidden
  45888. * Backing field
  45889. */
  45890. _debugLayer: DebugLayer;
  45891. /**
  45892. * Gets the debug layer (aka Inspector) associated with the scene
  45893. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45894. */
  45895. debugLayer: DebugLayer;
  45896. }
  45897. }
  45898. /**
  45899. * Enum of inspector action tab
  45900. */
  45901. export enum DebugLayerTab {
  45902. /**
  45903. * Properties tag (default)
  45904. */
  45905. Properties = 0,
  45906. /**
  45907. * Debug tab
  45908. */
  45909. Debug = 1,
  45910. /**
  45911. * Statistics tab
  45912. */
  45913. Statistics = 2,
  45914. /**
  45915. * Tools tab
  45916. */
  45917. Tools = 3,
  45918. /**
  45919. * Settings tab
  45920. */
  45921. Settings = 4
  45922. }
  45923. /**
  45924. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45925. * what is happening in your scene
  45926. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45927. */
  45928. export class DebugLayer {
  45929. /**
  45930. * Define the url to get the inspector script from.
  45931. * By default it uses the babylonjs CDN.
  45932. * @ignoreNaming
  45933. */
  45934. static InspectorURL: string;
  45935. private _scene;
  45936. private BJSINSPECTOR;
  45937. private _onPropertyChangedObservable?;
  45938. /**
  45939. * Observable triggered when a property is changed through the inspector.
  45940. */
  45941. readonly onPropertyChangedObservable: any;
  45942. /**
  45943. * Instantiates a new debug layer.
  45944. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45945. * what is happening in your scene
  45946. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45947. * @param scene Defines the scene to inspect
  45948. */
  45949. constructor(scene: Scene);
  45950. /** Creates the inspector window. */
  45951. private _createInspector;
  45952. /**
  45953. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  45954. * @param entity defines the entity to select
  45955. * @param lineContainerTitle defines the specific block to highlight
  45956. */
  45957. select(entity: any, lineContainerTitle?: string): void;
  45958. /** Get the inspector from bundle or global */
  45959. private _getGlobalInspector;
  45960. /**
  45961. * Get if the inspector is visible or not.
  45962. * @returns true if visible otherwise, false
  45963. */
  45964. isVisible(): boolean;
  45965. /**
  45966. * Hide the inspector and close its window.
  45967. */
  45968. hide(): void;
  45969. /**
  45970. * Launch the debugLayer.
  45971. * @param config Define the configuration of the inspector
  45972. * @return a promise fulfilled when the debug layer is visible
  45973. */
  45974. show(config?: IInspectorOptions): Promise<DebugLayer>;
  45975. }
  45976. }
  45977. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  45978. import { Nullable } from "babylonjs/types";
  45979. import { Scene } from "babylonjs/scene";
  45980. import { Vector4 } from "babylonjs/Maths/math.vector";
  45981. import { Color4 } from "babylonjs/Maths/math.color";
  45982. import { Mesh } from "babylonjs/Meshes/mesh";
  45983. /**
  45984. * Class containing static functions to help procedurally build meshes
  45985. */
  45986. export class BoxBuilder {
  45987. /**
  45988. * Creates a box mesh
  45989. * * The parameter `size` sets the size (float) of each box side (default 1)
  45990. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  45991. * * 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)
  45992. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  45993. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45994. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45995. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45996. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  45997. * @param name defines the name of the mesh
  45998. * @param options defines the options used to create the mesh
  45999. * @param scene defines the hosting scene
  46000. * @returns the box mesh
  46001. */
  46002. static CreateBox(name: string, options: {
  46003. size?: number;
  46004. width?: number;
  46005. height?: number;
  46006. depth?: number;
  46007. faceUV?: Vector4[];
  46008. faceColors?: Color4[];
  46009. sideOrientation?: number;
  46010. frontUVs?: Vector4;
  46011. backUVs?: Vector4;
  46012. wrap?: boolean;
  46013. topBaseAt?: number;
  46014. bottomBaseAt?: number;
  46015. updatable?: boolean;
  46016. }, scene?: Nullable<Scene>): Mesh;
  46017. }
  46018. }
  46019. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  46020. import { Vector4 } from "babylonjs/Maths/math.vector";
  46021. import { Mesh } from "babylonjs/Meshes/mesh";
  46022. import { Scene } from "babylonjs/scene";
  46023. import { Nullable } from "babylonjs/types";
  46024. /**
  46025. * Class containing static functions to help procedurally build meshes
  46026. */
  46027. export class SphereBuilder {
  46028. /**
  46029. * Creates a sphere mesh
  46030. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  46031. * * 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`)
  46032. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  46033. * * 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
  46034. * * 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)
  46035. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46036. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46037. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46038. * @param name defines the name of the mesh
  46039. * @param options defines the options used to create the mesh
  46040. * @param scene defines the hosting scene
  46041. * @returns the sphere mesh
  46042. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  46043. */
  46044. static CreateSphere(name: string, options: {
  46045. segments?: number;
  46046. diameter?: number;
  46047. diameterX?: number;
  46048. diameterY?: number;
  46049. diameterZ?: number;
  46050. arc?: number;
  46051. slice?: number;
  46052. sideOrientation?: number;
  46053. frontUVs?: Vector4;
  46054. backUVs?: Vector4;
  46055. updatable?: boolean;
  46056. }, scene?: Nullable<Scene>): Mesh;
  46057. }
  46058. }
  46059. declare module "babylonjs/Debug/physicsViewer" {
  46060. import { Nullable } from "babylonjs/types";
  46061. import { Scene } from "babylonjs/scene";
  46062. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46063. import { Mesh } from "babylonjs/Meshes/mesh";
  46064. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  46065. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  46066. /**
  46067. * Used to show the physics impostor around the specific mesh
  46068. */
  46069. export class PhysicsViewer {
  46070. /** @hidden */
  46071. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46072. /** @hidden */
  46073. protected _meshes: Array<Nullable<AbstractMesh>>;
  46074. /** @hidden */
  46075. protected _scene: Nullable<Scene>;
  46076. /** @hidden */
  46077. protected _numMeshes: number;
  46078. /** @hidden */
  46079. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46080. private _renderFunction;
  46081. private _utilityLayer;
  46082. private _debugBoxMesh;
  46083. private _debugSphereMesh;
  46084. private _debugCylinderMesh;
  46085. private _debugMaterial;
  46086. private _debugMeshMeshes;
  46087. /**
  46088. * Creates a new PhysicsViewer
  46089. * @param scene defines the hosting scene
  46090. */
  46091. constructor(scene: Scene);
  46092. /** @hidden */
  46093. protected _updateDebugMeshes(): void;
  46094. /**
  46095. * Renders a specified physic impostor
  46096. * @param impostor defines the impostor to render
  46097. * @param targetMesh defines the mesh represented by the impostor
  46098. * @returns the new debug mesh used to render the impostor
  46099. */
  46100. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46101. /**
  46102. * Hides a specified physic impostor
  46103. * @param impostor defines the impostor to hide
  46104. */
  46105. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46106. private _getDebugMaterial;
  46107. private _getDebugBoxMesh;
  46108. private _getDebugSphereMesh;
  46109. private _getDebugCylinderMesh;
  46110. private _getDebugMeshMesh;
  46111. private _getDebugMesh;
  46112. /** Releases all resources */
  46113. dispose(): void;
  46114. }
  46115. }
  46116. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  46117. import { Vector3 } from "babylonjs/Maths/math.vector";
  46118. import { Color4 } from "babylonjs/Maths/math.color";
  46119. import { Nullable } from "babylonjs/types";
  46120. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46121. import { Scene } from "babylonjs/scene";
  46122. /**
  46123. * Class containing static functions to help procedurally build meshes
  46124. */
  46125. export class LinesBuilder {
  46126. /**
  46127. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46128. * * 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
  46129. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46130. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46131. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46132. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46133. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46134. * * 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
  46135. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46136. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46137. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46138. * @param name defines the name of the new line system
  46139. * @param options defines the options used to create the line system
  46140. * @param scene defines the hosting scene
  46141. * @returns a new line system mesh
  46142. */
  46143. static CreateLineSystem(name: string, options: {
  46144. lines: Vector3[][];
  46145. updatable?: boolean;
  46146. instance?: Nullable<LinesMesh>;
  46147. colors?: Nullable<Color4[][]>;
  46148. useVertexAlpha?: boolean;
  46149. }, scene: Nullable<Scene>): LinesMesh;
  46150. /**
  46151. * Creates a line mesh
  46152. * 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
  46153. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46154. * * The parameter `points` is an array successive Vector3
  46155. * * 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
  46156. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46157. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46158. * * When updating an instance, remember that only point positions can change, not the number of points
  46159. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46160. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  46161. * @param name defines the name of the new line system
  46162. * @param options defines the options used to create the line system
  46163. * @param scene defines the hosting scene
  46164. * @returns a new line mesh
  46165. */
  46166. static CreateLines(name: string, options: {
  46167. points: Vector3[];
  46168. updatable?: boolean;
  46169. instance?: Nullable<LinesMesh>;
  46170. colors?: Color4[];
  46171. useVertexAlpha?: boolean;
  46172. }, scene?: Nullable<Scene>): LinesMesh;
  46173. /**
  46174. * Creates a dashed line mesh
  46175. * * 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
  46176. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46177. * * The parameter `points` is an array successive Vector3
  46178. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  46179. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  46180. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  46181. * * 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
  46182. * * When updating an instance, remember that only point positions can change, not the number of points
  46183. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46184. * @param name defines the name of the mesh
  46185. * @param options defines the options used to create the mesh
  46186. * @param scene defines the hosting scene
  46187. * @returns the dashed line mesh
  46188. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  46189. */
  46190. static CreateDashedLines(name: string, options: {
  46191. points: Vector3[];
  46192. dashSize?: number;
  46193. gapSize?: number;
  46194. dashNb?: number;
  46195. updatable?: boolean;
  46196. instance?: LinesMesh;
  46197. }, scene?: Nullable<Scene>): LinesMesh;
  46198. }
  46199. }
  46200. declare module "babylonjs/Debug/rayHelper" {
  46201. import { Nullable } from "babylonjs/types";
  46202. import { Ray } from "babylonjs/Culling/ray";
  46203. import { Vector3 } from "babylonjs/Maths/math.vector";
  46204. import { Color3 } from "babylonjs/Maths/math.color";
  46205. import { Scene } from "babylonjs/scene";
  46206. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46207. import "babylonjs/Meshes/Builders/linesBuilder";
  46208. /**
  46209. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46210. * in order to better appreciate the issue one might have.
  46211. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46212. */
  46213. export class RayHelper {
  46214. /**
  46215. * Defines the ray we are currently tryin to visualize.
  46216. */
  46217. ray: Nullable<Ray>;
  46218. private _renderPoints;
  46219. private _renderLine;
  46220. private _renderFunction;
  46221. private _scene;
  46222. private _updateToMeshFunction;
  46223. private _attachedToMesh;
  46224. private _meshSpaceDirection;
  46225. private _meshSpaceOrigin;
  46226. /**
  46227. * Helper function to create a colored helper in a scene in one line.
  46228. * @param ray Defines the ray we are currently tryin to visualize
  46229. * @param scene Defines the scene the ray is used in
  46230. * @param color Defines the color we want to see the ray in
  46231. * @returns The newly created ray helper.
  46232. */
  46233. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46234. /**
  46235. * Instantiate a new ray helper.
  46236. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46237. * in order to better appreciate the issue one might have.
  46238. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46239. * @param ray Defines the ray we are currently tryin to visualize
  46240. */
  46241. constructor(ray: Ray);
  46242. /**
  46243. * Shows the ray we are willing to debug.
  46244. * @param scene Defines the scene the ray needs to be rendered in
  46245. * @param color Defines the color the ray needs to be rendered in
  46246. */
  46247. show(scene: Scene, color?: Color3): void;
  46248. /**
  46249. * Hides the ray we are debugging.
  46250. */
  46251. hide(): void;
  46252. private _render;
  46253. /**
  46254. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46255. * @param mesh Defines the mesh we want the helper attached to
  46256. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46257. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46258. * @param length Defines the length of the ray
  46259. */
  46260. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46261. /**
  46262. * Detach the ray helper from the mesh it has previously been attached to.
  46263. */
  46264. detachFromMesh(): void;
  46265. private _updateToMesh;
  46266. /**
  46267. * Dispose the helper and release its associated resources.
  46268. */
  46269. dispose(): void;
  46270. }
  46271. }
  46272. declare module "babylonjs/Debug/skeletonViewer" {
  46273. import { Color3 } from "babylonjs/Maths/math.color";
  46274. import { Scene } from "babylonjs/scene";
  46275. import { Nullable } from "babylonjs/types";
  46276. import { Skeleton } from "babylonjs/Bones/skeleton";
  46277. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46278. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46279. /**
  46280. * Class used to render a debug view of a given skeleton
  46281. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46282. */
  46283. export class SkeletonViewer {
  46284. /** defines the skeleton to render */
  46285. skeleton: Skeleton;
  46286. /** defines the mesh attached to the skeleton */
  46287. mesh: AbstractMesh;
  46288. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46289. autoUpdateBonesMatrices: boolean;
  46290. /** defines the rendering group id to use with the viewer */
  46291. renderingGroupId: number;
  46292. /** Gets or sets the color used to render the skeleton */
  46293. color: Color3;
  46294. private _scene;
  46295. private _debugLines;
  46296. private _debugMesh;
  46297. private _isEnabled;
  46298. private _renderFunction;
  46299. private _utilityLayer;
  46300. /**
  46301. * Returns the mesh used to render the bones
  46302. */
  46303. readonly debugMesh: Nullable<LinesMesh>;
  46304. /**
  46305. * Creates a new SkeletonViewer
  46306. * @param skeleton defines the skeleton to render
  46307. * @param mesh defines the mesh attached to the skeleton
  46308. * @param scene defines the hosting scene
  46309. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46310. * @param renderingGroupId defines the rendering group id to use with the viewer
  46311. */
  46312. constructor(
  46313. /** defines the skeleton to render */
  46314. skeleton: Skeleton,
  46315. /** defines the mesh attached to the skeleton */
  46316. mesh: AbstractMesh, scene: Scene,
  46317. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46318. autoUpdateBonesMatrices?: boolean,
  46319. /** defines the rendering group id to use with the viewer */
  46320. renderingGroupId?: number);
  46321. /** Gets or sets a boolean indicating if the viewer is enabled */
  46322. isEnabled: boolean;
  46323. private _getBonePosition;
  46324. private _getLinesForBonesWithLength;
  46325. private _getLinesForBonesNoLength;
  46326. /** Update the viewer to sync with current skeleton state */
  46327. update(): void;
  46328. /** Release associated resources */
  46329. dispose(): void;
  46330. }
  46331. }
  46332. declare module "babylonjs/Debug/index" {
  46333. export * from "babylonjs/Debug/axesViewer";
  46334. export * from "babylonjs/Debug/boneAxesViewer";
  46335. export * from "babylonjs/Debug/debugLayer";
  46336. export * from "babylonjs/Debug/physicsViewer";
  46337. export * from "babylonjs/Debug/rayHelper";
  46338. export * from "babylonjs/Debug/skeletonViewer";
  46339. }
  46340. declare module "babylonjs/Engines/nullEngine" {
  46341. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  46342. import { Scene } from "babylonjs/scene";
  46343. import { Engine } from "babylonjs/Engines/engine";
  46344. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  46345. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  46346. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46347. import { Effect } from "babylonjs/Materials/effect";
  46348. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  46349. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46350. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  46351. /**
  46352. * Options to create the null engine
  46353. */
  46354. export class NullEngineOptions {
  46355. /**
  46356. * Render width (Default: 512)
  46357. */
  46358. renderWidth: number;
  46359. /**
  46360. * Render height (Default: 256)
  46361. */
  46362. renderHeight: number;
  46363. /**
  46364. * Texture size (Default: 512)
  46365. */
  46366. textureSize: number;
  46367. /**
  46368. * If delta time between frames should be constant
  46369. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46370. */
  46371. deterministicLockstep: boolean;
  46372. /**
  46373. * Maximum about of steps between frames (Default: 4)
  46374. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46375. */
  46376. lockstepMaxSteps: number;
  46377. }
  46378. /**
  46379. * The null engine class provides support for headless version of babylon.js.
  46380. * This can be used in server side scenario or for testing purposes
  46381. */
  46382. export class NullEngine extends Engine {
  46383. private _options;
  46384. /**
  46385. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  46386. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46387. * @returns true if engine is in deterministic lock step mode
  46388. */
  46389. isDeterministicLockStep(): boolean;
  46390. /**
  46391. * Gets the max steps when engine is running in deterministic lock step
  46392. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46393. * @returns the max steps
  46394. */
  46395. getLockstepMaxSteps(): number;
  46396. /**
  46397. * Gets the current hardware scaling level.
  46398. * By default the hardware scaling level is computed from the window device ratio.
  46399. * 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.
  46400. * @returns a number indicating the current hardware scaling level
  46401. */
  46402. getHardwareScalingLevel(): number;
  46403. constructor(options?: NullEngineOptions);
  46404. /**
  46405. * Creates a vertex buffer
  46406. * @param vertices the data for the vertex buffer
  46407. * @returns the new WebGL static buffer
  46408. */
  46409. createVertexBuffer(vertices: FloatArray): DataBuffer;
  46410. /**
  46411. * Creates a new index buffer
  46412. * @param indices defines the content of the index buffer
  46413. * @param updatable defines if the index buffer must be updatable
  46414. * @returns a new webGL buffer
  46415. */
  46416. createIndexBuffer(indices: IndicesArray): DataBuffer;
  46417. /**
  46418. * Clear the current render buffer or the current render target (if any is set up)
  46419. * @param color defines the color to use
  46420. * @param backBuffer defines if the back buffer must be cleared
  46421. * @param depth defines if the depth buffer must be cleared
  46422. * @param stencil defines if the stencil buffer must be cleared
  46423. */
  46424. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46425. /**
  46426. * Gets the current render width
  46427. * @param useScreen defines if screen size must be used (or the current render target if any)
  46428. * @returns a number defining the current render width
  46429. */
  46430. getRenderWidth(useScreen?: boolean): number;
  46431. /**
  46432. * Gets the current render height
  46433. * @param useScreen defines if screen size must be used (or the current render target if any)
  46434. * @returns a number defining the current render height
  46435. */
  46436. getRenderHeight(useScreen?: boolean): number;
  46437. /**
  46438. * Set the WebGL's viewport
  46439. * @param viewport defines the viewport element to be used
  46440. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  46441. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  46442. */
  46443. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  46444. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  46445. /**
  46446. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  46447. * @param pipelineContext defines the pipeline context to use
  46448. * @param uniformsNames defines the list of uniform names
  46449. * @returns an array of webGL uniform locations
  46450. */
  46451. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46452. /**
  46453. * Gets the lsit of active attributes for a given webGL program
  46454. * @param pipelineContext defines the pipeline context to use
  46455. * @param attributesNames defines the list of attribute names to get
  46456. * @returns an array of indices indicating the offset of each attribute
  46457. */
  46458. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46459. /**
  46460. * Binds an effect to the webGL context
  46461. * @param effect defines the effect to bind
  46462. */
  46463. bindSamplers(effect: Effect): void;
  46464. /**
  46465. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46466. * @param effect defines the effect to activate
  46467. */
  46468. enableEffect(effect: Effect): void;
  46469. /**
  46470. * Set various states to the webGL context
  46471. * @param culling defines backface culling state
  46472. * @param zOffset defines the value to apply to zOffset (0 by default)
  46473. * @param force defines if states must be applied even if cache is up to date
  46474. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46475. */
  46476. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46477. /**
  46478. * Set the value of an uniform to an array of int32
  46479. * @param uniform defines the webGL uniform location where to store the value
  46480. * @param array defines the array of int32 to store
  46481. */
  46482. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46483. /**
  46484. * Set the value of an uniform to an array of int32 (stored as vec2)
  46485. * @param uniform defines the webGL uniform location where to store the value
  46486. * @param array defines the array of int32 to store
  46487. */
  46488. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46489. /**
  46490. * Set the value of an uniform to an array of int32 (stored as vec3)
  46491. * @param uniform defines the webGL uniform location where to store the value
  46492. * @param array defines the array of int32 to store
  46493. */
  46494. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46495. /**
  46496. * Set the value of an uniform to an array of int32 (stored as vec4)
  46497. * @param uniform defines the webGL uniform location where to store the value
  46498. * @param array defines the array of int32 to store
  46499. */
  46500. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46501. /**
  46502. * Set the value of an uniform to an array of float32
  46503. * @param uniform defines the webGL uniform location where to store the value
  46504. * @param array defines the array of float32 to store
  46505. */
  46506. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46507. /**
  46508. * Set the value of an uniform to an array of float32 (stored as vec2)
  46509. * @param uniform defines the webGL uniform location where to store the value
  46510. * @param array defines the array of float32 to store
  46511. */
  46512. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46513. /**
  46514. * Set the value of an uniform to an array of float32 (stored as vec3)
  46515. * @param uniform defines the webGL uniform location where to store the value
  46516. * @param array defines the array of float32 to store
  46517. */
  46518. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46519. /**
  46520. * Set the value of an uniform to an array of float32 (stored as vec4)
  46521. * @param uniform defines the webGL uniform location where to store the value
  46522. * @param array defines the array of float32 to store
  46523. */
  46524. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46525. /**
  46526. * Set the value of an uniform to an array of number
  46527. * @param uniform defines the webGL uniform location where to store the value
  46528. * @param array defines the array of number to store
  46529. */
  46530. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46531. /**
  46532. * Set the value of an uniform to an array of number (stored as vec2)
  46533. * @param uniform defines the webGL uniform location where to store the value
  46534. * @param array defines the array of number to store
  46535. */
  46536. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46537. /**
  46538. * Set the value of an uniform to an array of number (stored as vec3)
  46539. * @param uniform defines the webGL uniform location where to store the value
  46540. * @param array defines the array of number to store
  46541. */
  46542. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46543. /**
  46544. * Set the value of an uniform to an array of number (stored as vec4)
  46545. * @param uniform defines the webGL uniform location where to store the value
  46546. * @param array defines the array of number to store
  46547. */
  46548. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46549. /**
  46550. * Set the value of an uniform to an array of float32 (stored as matrices)
  46551. * @param uniform defines the webGL uniform location where to store the value
  46552. * @param matrices defines the array of float32 to store
  46553. */
  46554. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46555. /**
  46556. * Set the value of an uniform to a matrix (3x3)
  46557. * @param uniform defines the webGL uniform location where to store the value
  46558. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  46559. */
  46560. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46561. /**
  46562. * Set the value of an uniform to a matrix (2x2)
  46563. * @param uniform defines the webGL uniform location where to store the value
  46564. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  46565. */
  46566. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46567. /**
  46568. * Set the value of an uniform to a number (float)
  46569. * @param uniform defines the webGL uniform location where to store the value
  46570. * @param value defines the float number to store
  46571. */
  46572. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46573. /**
  46574. * Set the value of an uniform to a vec2
  46575. * @param uniform defines the webGL uniform location where to store the value
  46576. * @param x defines the 1st component of the value
  46577. * @param y defines the 2nd component of the value
  46578. */
  46579. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46580. /**
  46581. * Set the value of an uniform to a vec3
  46582. * @param uniform defines the webGL uniform location where to store the value
  46583. * @param x defines the 1st component of the value
  46584. * @param y defines the 2nd component of the value
  46585. * @param z defines the 3rd component of the value
  46586. */
  46587. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46588. /**
  46589. * Set the value of an uniform to a boolean
  46590. * @param uniform defines the webGL uniform location where to store the value
  46591. * @param bool defines the boolean to store
  46592. */
  46593. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46594. /**
  46595. * Set the value of an uniform to a vec4
  46596. * @param uniform defines the webGL uniform location where to store the value
  46597. * @param x defines the 1st component of the value
  46598. * @param y defines the 2nd component of the value
  46599. * @param z defines the 3rd component of the value
  46600. * @param w defines the 4th component of the value
  46601. */
  46602. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46603. /**
  46604. * Sets the current alpha mode
  46605. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46606. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46607. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46608. */
  46609. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46610. /**
  46611. * Bind webGl buffers directly to the webGL context
  46612. * @param vertexBuffers defines the vertex buffer to bind
  46613. * @param indexBuffer defines the index buffer to bind
  46614. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  46615. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  46616. * @param effect defines the effect associated with the vertex buffer
  46617. */
  46618. bindBuffers(vertexBuffers: {
  46619. [key: string]: VertexBuffer;
  46620. }, indexBuffer: DataBuffer, effect: Effect): void;
  46621. /**
  46622. * Force the entire cache to be cleared
  46623. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  46624. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46625. */
  46626. wipeCaches(bruteForce?: boolean): void;
  46627. /**
  46628. * Send a draw order
  46629. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  46630. * @param indexStart defines the starting index
  46631. * @param indexCount defines the number of index to draw
  46632. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46633. */
  46634. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  46635. /**
  46636. * Draw a list of indexed primitives
  46637. * @param fillMode defines the primitive to use
  46638. * @param indexStart defines the starting index
  46639. * @param indexCount defines the number of index to draw
  46640. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46641. */
  46642. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46643. /**
  46644. * Draw a list of unindexed primitives
  46645. * @param fillMode defines the primitive to use
  46646. * @param verticesStart defines the index of first vertex to draw
  46647. * @param verticesCount defines the count of vertices to draw
  46648. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46649. */
  46650. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46651. /** @hidden */
  46652. _createTexture(): WebGLTexture;
  46653. /** @hidden */
  46654. _releaseTexture(texture: InternalTexture): void;
  46655. /**
  46656. * Usually called from Texture.ts.
  46657. * Passed information to create a WebGLTexture
  46658. * @param urlArg defines a value which contains one of the following:
  46659. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46660. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46661. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46662. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46663. * @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)
  46664. * @param scene needed for loading to the correct scene
  46665. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46666. * @param onLoad optional callback to be called upon successful completion
  46667. * @param onError optional callback to be called upon failure
  46668. * @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
  46669. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46670. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46671. * @param forcedExtension defines the extension to use to pick the right loader
  46672. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  46673. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46674. */
  46675. 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;
  46676. /**
  46677. * Creates a new render target texture
  46678. * @param size defines the size of the texture
  46679. * @param options defines the options used to create the texture
  46680. * @returns a new render target texture stored in an InternalTexture
  46681. */
  46682. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46683. /**
  46684. * Update the sampling mode of a given texture
  46685. * @param samplingMode defines the required sampling mode
  46686. * @param texture defines the texture to update
  46687. */
  46688. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46689. /**
  46690. * Binds the frame buffer to the specified texture.
  46691. * @param texture The texture to render to or null for the default canvas
  46692. * @param faceIndex The face of the texture to render to in case of cube texture
  46693. * @param requiredWidth The width of the target to render to
  46694. * @param requiredHeight The height of the target to render to
  46695. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46696. * @param depthStencilTexture The depth stencil texture to use to render
  46697. * @param lodLevel defines le lod level to bind to the frame buffer
  46698. */
  46699. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46700. /**
  46701. * Unbind the current render target texture from the webGL context
  46702. * @param texture defines the render target texture to unbind
  46703. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46704. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46705. */
  46706. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46707. /**
  46708. * Creates a dynamic vertex buffer
  46709. * @param vertices the data for the dynamic vertex buffer
  46710. * @returns the new WebGL dynamic buffer
  46711. */
  46712. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  46713. /**
  46714. * Update the content of a dynamic texture
  46715. * @param texture defines the texture to update
  46716. * @param canvas defines the canvas containing the source
  46717. * @param invertY defines if data must be stored with Y axis inverted
  46718. * @param premulAlpha defines if alpha is stored as premultiplied
  46719. * @param format defines the format of the data
  46720. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  46721. */
  46722. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  46723. /**
  46724. * Gets a boolean indicating if all created effects are ready
  46725. * @returns true if all effects are ready
  46726. */
  46727. areAllEffectsReady(): boolean;
  46728. /**
  46729. * @hidden
  46730. * Get the current error code of the webGL context
  46731. * @returns the error code
  46732. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  46733. */
  46734. getError(): number;
  46735. /** @hidden */
  46736. _getUnpackAlignement(): number;
  46737. /** @hidden */
  46738. _unpackFlipY(value: boolean): void;
  46739. /**
  46740. * Update a dynamic index buffer
  46741. * @param indexBuffer defines the target index buffer
  46742. * @param indices defines the data to update
  46743. * @param offset defines the offset in the target index buffer where update should start
  46744. */
  46745. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  46746. /**
  46747. * Updates a dynamic vertex buffer.
  46748. * @param vertexBuffer the vertex buffer to update
  46749. * @param vertices the data used to update the vertex buffer
  46750. * @param byteOffset the byte offset of the data (optional)
  46751. * @param byteLength the byte length of the data (optional)
  46752. */
  46753. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  46754. /** @hidden */
  46755. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  46756. /** @hidden */
  46757. _bindTexture(channel: number, texture: InternalTexture): void;
  46758. protected _deleteBuffer(buffer: WebGLBuffer): void;
  46759. /**
  46760. * 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
  46761. */
  46762. releaseEffects(): void;
  46763. displayLoadingUI(): void;
  46764. hideLoadingUI(): void;
  46765. /** @hidden */
  46766. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46767. /** @hidden */
  46768. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46769. /** @hidden */
  46770. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46771. /** @hidden */
  46772. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46773. }
  46774. }
  46775. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  46776. import { Nullable, int } from "babylonjs/types";
  46777. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  46778. /** @hidden */
  46779. export class _OcclusionDataStorage {
  46780. /** @hidden */
  46781. occlusionInternalRetryCounter: number;
  46782. /** @hidden */
  46783. isOcclusionQueryInProgress: boolean;
  46784. /** @hidden */
  46785. isOccluded: boolean;
  46786. /** @hidden */
  46787. occlusionRetryCount: number;
  46788. /** @hidden */
  46789. occlusionType: number;
  46790. /** @hidden */
  46791. occlusionQueryAlgorithmType: number;
  46792. }
  46793. module "babylonjs/Engines/engine" {
  46794. interface Engine {
  46795. /**
  46796. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  46797. * @return the new query
  46798. */
  46799. createQuery(): WebGLQuery;
  46800. /**
  46801. * Delete and release a webGL query
  46802. * @param query defines the query to delete
  46803. * @return the current engine
  46804. */
  46805. deleteQuery(query: WebGLQuery): Engine;
  46806. /**
  46807. * Check if a given query has resolved and got its value
  46808. * @param query defines the query to check
  46809. * @returns true if the query got its value
  46810. */
  46811. isQueryResultAvailable(query: WebGLQuery): boolean;
  46812. /**
  46813. * Gets the value of a given query
  46814. * @param query defines the query to check
  46815. * @returns the value of the query
  46816. */
  46817. getQueryResult(query: WebGLQuery): number;
  46818. /**
  46819. * Initiates an occlusion query
  46820. * @param algorithmType defines the algorithm to use
  46821. * @param query defines the query to use
  46822. * @returns the current engine
  46823. * @see http://doc.babylonjs.com/features/occlusionquery
  46824. */
  46825. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  46826. /**
  46827. * Ends an occlusion query
  46828. * @see http://doc.babylonjs.com/features/occlusionquery
  46829. * @param algorithmType defines the algorithm to use
  46830. * @returns the current engine
  46831. */
  46832. endOcclusionQuery(algorithmType: number): Engine;
  46833. /**
  46834. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  46835. * Please note that only one query can be issued at a time
  46836. * @returns a time token used to track the time span
  46837. */
  46838. startTimeQuery(): Nullable<_TimeToken>;
  46839. /**
  46840. * Ends a time query
  46841. * @param token defines the token used to measure the time span
  46842. * @returns the time spent (in ns)
  46843. */
  46844. endTimeQuery(token: _TimeToken): int;
  46845. /** @hidden */
  46846. _currentNonTimestampToken: Nullable<_TimeToken>;
  46847. /** @hidden */
  46848. _createTimeQuery(): WebGLQuery;
  46849. /** @hidden */
  46850. _deleteTimeQuery(query: WebGLQuery): void;
  46851. /** @hidden */
  46852. _getGlAlgorithmType(algorithmType: number): number;
  46853. /** @hidden */
  46854. _getTimeQueryResult(query: WebGLQuery): any;
  46855. /** @hidden */
  46856. _getTimeQueryAvailability(query: WebGLQuery): any;
  46857. }
  46858. }
  46859. module "babylonjs/Meshes/abstractMesh" {
  46860. interface AbstractMesh {
  46861. /**
  46862. * Backing filed
  46863. * @hidden
  46864. */
  46865. __occlusionDataStorage: _OcclusionDataStorage;
  46866. /**
  46867. * Access property
  46868. * @hidden
  46869. */
  46870. _occlusionDataStorage: _OcclusionDataStorage;
  46871. /**
  46872. * 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.
  46873. * The default value is -1 which means don't break the query and wait till the result
  46874. * @see http://doc.babylonjs.com/features/occlusionquery
  46875. */
  46876. occlusionRetryCount: number;
  46877. /**
  46878. * 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:
  46879. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  46880. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  46881. * * 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.
  46882. * @see http://doc.babylonjs.com/features/occlusionquery
  46883. */
  46884. occlusionType: number;
  46885. /**
  46886. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  46887. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  46888. * * 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.
  46889. * @see http://doc.babylonjs.com/features/occlusionquery
  46890. */
  46891. occlusionQueryAlgorithmType: number;
  46892. /**
  46893. * 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
  46894. * @see http://doc.babylonjs.com/features/occlusionquery
  46895. */
  46896. isOccluded: boolean;
  46897. /**
  46898. * Flag to check the progress status of the query
  46899. * @see http://doc.babylonjs.com/features/occlusionquery
  46900. */
  46901. isOcclusionQueryInProgress: boolean;
  46902. }
  46903. }
  46904. }
  46905. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  46906. import { Nullable } from "babylonjs/types";
  46907. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46908. /** @hidden */
  46909. export var _forceTransformFeedbackToBundle: boolean;
  46910. module "babylonjs/Engines/engine" {
  46911. interface Engine {
  46912. /**
  46913. * Creates a webGL transform feedback object
  46914. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  46915. * @returns the webGL transform feedback object
  46916. */
  46917. createTransformFeedback(): WebGLTransformFeedback;
  46918. /**
  46919. * Delete a webGL transform feedback object
  46920. * @param value defines the webGL transform feedback object to delete
  46921. */
  46922. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  46923. /**
  46924. * Bind a webGL transform feedback object to the webgl context
  46925. * @param value defines the webGL transform feedback object to bind
  46926. */
  46927. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  46928. /**
  46929. * Begins a transform feedback operation
  46930. * @param usePoints defines if points or triangles must be used
  46931. */
  46932. beginTransformFeedback(usePoints: boolean): void;
  46933. /**
  46934. * Ends a transform feedback operation
  46935. */
  46936. endTransformFeedback(): void;
  46937. /**
  46938. * Specify the varyings to use with transform feedback
  46939. * @param program defines the associated webGL program
  46940. * @param value defines the list of strings representing the varying names
  46941. */
  46942. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  46943. /**
  46944. * Bind a webGL buffer for a transform feedback operation
  46945. * @param value defines the webGL buffer to bind
  46946. */
  46947. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  46948. }
  46949. }
  46950. }
  46951. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  46952. import { Scene } from "babylonjs/scene";
  46953. import { Engine } from "babylonjs/Engines/engine";
  46954. import { Texture } from "babylonjs/Materials/Textures/texture";
  46955. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46956. import "babylonjs/Engines/Extensions/engine.multiRender";
  46957. /**
  46958. * Creation options of the multi render target texture.
  46959. */
  46960. export interface IMultiRenderTargetOptions {
  46961. /**
  46962. * Define if the texture needs to create mip maps after render.
  46963. */
  46964. generateMipMaps?: boolean;
  46965. /**
  46966. * Define the types of all the draw buffers we want to create
  46967. */
  46968. types?: number[];
  46969. /**
  46970. * Define the sampling modes of all the draw buffers we want to create
  46971. */
  46972. samplingModes?: number[];
  46973. /**
  46974. * Define if a depth buffer is required
  46975. */
  46976. generateDepthBuffer?: boolean;
  46977. /**
  46978. * Define if a stencil buffer is required
  46979. */
  46980. generateStencilBuffer?: boolean;
  46981. /**
  46982. * Define if a depth texture is required instead of a depth buffer
  46983. */
  46984. generateDepthTexture?: boolean;
  46985. /**
  46986. * Define the number of desired draw buffers
  46987. */
  46988. textureCount?: number;
  46989. /**
  46990. * Define if aspect ratio should be adapted to the texture or stay the scene one
  46991. */
  46992. doNotChangeAspectRatio?: boolean;
  46993. /**
  46994. * Define the default type of the buffers we are creating
  46995. */
  46996. defaultType?: number;
  46997. }
  46998. /**
  46999. * A multi render target, like a render target provides the ability to render to a texture.
  47000. * Unlike the render target, it can render to several draw buffers in one draw.
  47001. * This is specially interesting in deferred rendering or for any effects requiring more than
  47002. * just one color from a single pass.
  47003. */
  47004. export class MultiRenderTarget extends RenderTargetTexture {
  47005. private _internalTextures;
  47006. private _textures;
  47007. private _multiRenderTargetOptions;
  47008. /**
  47009. * Get if draw buffers are currently supported by the used hardware and browser.
  47010. */
  47011. readonly isSupported: boolean;
  47012. /**
  47013. * Get the list of textures generated by the multi render target.
  47014. */
  47015. readonly textures: Texture[];
  47016. /**
  47017. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47018. */
  47019. readonly depthTexture: Texture;
  47020. /**
  47021. * Set the wrapping mode on U of all the textures we are rendering to.
  47022. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47023. */
  47024. wrapU: number;
  47025. /**
  47026. * Set the wrapping mode on V of all the textures we are rendering to.
  47027. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47028. */
  47029. wrapV: number;
  47030. /**
  47031. * Instantiate a new multi render target texture.
  47032. * A multi render target, like a render target provides the ability to render to a texture.
  47033. * Unlike the render target, it can render to several draw buffers in one draw.
  47034. * This is specially interesting in deferred rendering or for any effects requiring more than
  47035. * just one color from a single pass.
  47036. * @param name Define the name of the texture
  47037. * @param size Define the size of the buffers to render to
  47038. * @param count Define the number of target we are rendering into
  47039. * @param scene Define the scene the texture belongs to
  47040. * @param options Define the options used to create the multi render target
  47041. */
  47042. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47043. /** @hidden */
  47044. _rebuild(): void;
  47045. private _createInternalTextures;
  47046. private _createTextures;
  47047. /**
  47048. * Define the number of samples used if MSAA is enabled.
  47049. */
  47050. samples: number;
  47051. /**
  47052. * Resize all the textures in the multi render target.
  47053. * Be carrefull as it will recreate all the data in the new texture.
  47054. * @param size Define the new size
  47055. */
  47056. resize(size: any): void;
  47057. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47058. /**
  47059. * Dispose the render targets and their associated resources
  47060. */
  47061. dispose(): void;
  47062. /**
  47063. * Release all the underlying texture used as draw buffers.
  47064. */
  47065. releaseInternalTextures(): void;
  47066. }
  47067. }
  47068. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  47069. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47070. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  47071. import { Nullable } from "babylonjs/types";
  47072. module "babylonjs/Engines/thinEngine" {
  47073. interface ThinEngine {
  47074. /**
  47075. * Unbind a list of render target textures from the webGL context
  47076. * This is used only when drawBuffer extension or webGL2 are active
  47077. * @param textures defines the render target textures to unbind
  47078. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47079. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47080. */
  47081. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47082. /**
  47083. * Create a multi render target texture
  47084. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47085. * @param size defines the size of the texture
  47086. * @param options defines the creation options
  47087. * @returns the cube texture as an InternalTexture
  47088. */
  47089. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47090. /**
  47091. * Update the sample count for a given multiple render target texture
  47092. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47093. * @param textures defines the textures to update
  47094. * @param samples defines the sample count to set
  47095. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47096. */
  47097. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47098. }
  47099. }
  47100. }
  47101. declare module "babylonjs/Engines/Extensions/engine.views" {
  47102. import { Camera } from "babylonjs/Cameras/camera";
  47103. import { Nullable } from "babylonjs/types";
  47104. /**
  47105. * Class used to define an additional view for the engine
  47106. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47107. */
  47108. export class EngineView {
  47109. /** Defines the canvas where to render the view */
  47110. target: HTMLCanvasElement;
  47111. /** Defines an optional camera used to render the view (will use active camera else) */
  47112. camera?: Camera;
  47113. }
  47114. module "babylonjs/Engines/engine" {
  47115. interface Engine {
  47116. /**
  47117. * Gets or sets the HTML element to use for attaching events
  47118. */
  47119. inputElement: Nullable<HTMLElement>;
  47120. /**
  47121. * Gets the current engine view
  47122. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47123. */
  47124. activeView: Nullable<EngineView>;
  47125. /** Gets or sets the list of views */
  47126. views: EngineView[];
  47127. /**
  47128. * Register a new child canvas
  47129. * @param canvas defines the canvas to register
  47130. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47131. * @returns the associated view
  47132. */
  47133. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47134. /**
  47135. * Remove a registered child canvas
  47136. * @param canvas defines the canvas to remove
  47137. * @returns the current engine
  47138. */
  47139. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47140. }
  47141. }
  47142. }
  47143. declare module "babylonjs/Engines/Extensions/index" {
  47144. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  47145. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  47146. export * from "babylonjs/Engines/Extensions/engine.multiview";
  47147. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  47148. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  47149. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  47150. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  47151. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  47152. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  47153. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  47154. export * from "babylonjs/Engines/Extensions/engine.webVR";
  47155. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  47156. export * from "babylonjs/Engines/Extensions/engine.views";
  47157. }
  47158. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  47159. import { Nullable } from "babylonjs/types";
  47160. /**
  47161. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47162. */
  47163. export interface CubeMapInfo {
  47164. /**
  47165. * The pixel array for the front face.
  47166. * This is stored in format, left to right, up to down format.
  47167. */
  47168. front: Nullable<ArrayBufferView>;
  47169. /**
  47170. * The pixel array for the back face.
  47171. * This is stored in format, left to right, up to down format.
  47172. */
  47173. back: Nullable<ArrayBufferView>;
  47174. /**
  47175. * The pixel array for the left face.
  47176. * This is stored in format, left to right, up to down format.
  47177. */
  47178. left: Nullable<ArrayBufferView>;
  47179. /**
  47180. * The pixel array for the right face.
  47181. * This is stored in format, left to right, up to down format.
  47182. */
  47183. right: Nullable<ArrayBufferView>;
  47184. /**
  47185. * The pixel array for the up face.
  47186. * This is stored in format, left to right, up to down format.
  47187. */
  47188. up: Nullable<ArrayBufferView>;
  47189. /**
  47190. * The pixel array for the down face.
  47191. * This is stored in format, left to right, up to down format.
  47192. */
  47193. down: Nullable<ArrayBufferView>;
  47194. /**
  47195. * The size of the cubemap stored.
  47196. *
  47197. * Each faces will be size * size pixels.
  47198. */
  47199. size: number;
  47200. /**
  47201. * The format of the texture.
  47202. *
  47203. * RGBA, RGB.
  47204. */
  47205. format: number;
  47206. /**
  47207. * The type of the texture data.
  47208. *
  47209. * UNSIGNED_INT, FLOAT.
  47210. */
  47211. type: number;
  47212. /**
  47213. * Specifies whether the texture is in gamma space.
  47214. */
  47215. gammaSpace: boolean;
  47216. }
  47217. /**
  47218. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47219. */
  47220. export class PanoramaToCubeMapTools {
  47221. private static FACE_FRONT;
  47222. private static FACE_BACK;
  47223. private static FACE_RIGHT;
  47224. private static FACE_LEFT;
  47225. private static FACE_DOWN;
  47226. private static FACE_UP;
  47227. /**
  47228. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47229. *
  47230. * @param float32Array The source data.
  47231. * @param inputWidth The width of the input panorama.
  47232. * @param inputHeight The height of the input panorama.
  47233. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47234. * @return The cubemap data
  47235. */
  47236. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47237. private static CreateCubemapTexture;
  47238. private static CalcProjectionSpherical;
  47239. }
  47240. }
  47241. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  47242. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47243. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47244. import { Nullable } from "babylonjs/types";
  47245. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  47246. /**
  47247. * Helper class dealing with the extraction of spherical polynomial dataArray
  47248. * from a cube map.
  47249. */
  47250. export class CubeMapToSphericalPolynomialTools {
  47251. private static FileFaces;
  47252. /**
  47253. * Converts a texture to the according Spherical Polynomial data.
  47254. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47255. *
  47256. * @param texture The texture to extract the information from.
  47257. * @return The Spherical Polynomial data.
  47258. */
  47259. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47260. /**
  47261. * Converts a cubemap to the according Spherical Polynomial data.
  47262. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47263. *
  47264. * @param cubeInfo The Cube map to extract the information from.
  47265. * @return The Spherical Polynomial data.
  47266. */
  47267. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47268. }
  47269. }
  47270. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  47271. import { Nullable } from "babylonjs/types";
  47272. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47273. module "babylonjs/Materials/Textures/baseTexture" {
  47274. interface BaseTexture {
  47275. /**
  47276. * Get the polynomial representation of the texture data.
  47277. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47278. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47279. */
  47280. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47281. }
  47282. }
  47283. }
  47284. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  47285. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47286. /** @hidden */
  47287. export var rgbdEncodePixelShader: {
  47288. name: string;
  47289. shader: string;
  47290. };
  47291. }
  47292. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  47293. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47294. /** @hidden */
  47295. export var rgbdDecodePixelShader: {
  47296. name: string;
  47297. shader: string;
  47298. };
  47299. }
  47300. declare module "babylonjs/Misc/environmentTextureTools" {
  47301. import { Nullable } from "babylonjs/types";
  47302. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47303. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47304. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  47305. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  47306. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  47307. import "babylonjs/Shaders/rgbdEncode.fragment";
  47308. import "babylonjs/Shaders/rgbdDecode.fragment";
  47309. /**
  47310. * Raw texture data and descriptor sufficient for WebGL texture upload
  47311. */
  47312. export interface EnvironmentTextureInfo {
  47313. /**
  47314. * Version of the environment map
  47315. */
  47316. version: number;
  47317. /**
  47318. * Width of image
  47319. */
  47320. width: number;
  47321. /**
  47322. * Irradiance information stored in the file.
  47323. */
  47324. irradiance: any;
  47325. /**
  47326. * Specular information stored in the file.
  47327. */
  47328. specular: any;
  47329. }
  47330. /**
  47331. * Defines One Image in the file. It requires only the position in the file
  47332. * as well as the length.
  47333. */
  47334. interface BufferImageData {
  47335. /**
  47336. * Length of the image data.
  47337. */
  47338. length: number;
  47339. /**
  47340. * Position of the data from the null terminator delimiting the end of the JSON.
  47341. */
  47342. position: number;
  47343. }
  47344. /**
  47345. * Defines the specular data enclosed in the file.
  47346. * This corresponds to the version 1 of the data.
  47347. */
  47348. export interface EnvironmentTextureSpecularInfoV1 {
  47349. /**
  47350. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  47351. */
  47352. specularDataPosition?: number;
  47353. /**
  47354. * This contains all the images data needed to reconstruct the cubemap.
  47355. */
  47356. mipmaps: Array<BufferImageData>;
  47357. /**
  47358. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  47359. */
  47360. lodGenerationScale: number;
  47361. }
  47362. /**
  47363. * Sets of helpers addressing the serialization and deserialization of environment texture
  47364. * stored in a BabylonJS env file.
  47365. * Those files are usually stored as .env files.
  47366. */
  47367. export class EnvironmentTextureTools {
  47368. /**
  47369. * Magic number identifying the env file.
  47370. */
  47371. private static _MagicBytes;
  47372. /**
  47373. * Gets the environment info from an env file.
  47374. * @param data The array buffer containing the .env bytes.
  47375. * @returns the environment file info (the json header) if successfully parsed.
  47376. */
  47377. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  47378. /**
  47379. * Creates an environment texture from a loaded cube texture.
  47380. * @param texture defines the cube texture to convert in env file
  47381. * @return a promise containing the environment data if succesfull.
  47382. */
  47383. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47384. /**
  47385. * Creates a JSON representation of the spherical data.
  47386. * @param texture defines the texture containing the polynomials
  47387. * @return the JSON representation of the spherical info
  47388. */
  47389. private static _CreateEnvTextureIrradiance;
  47390. /**
  47391. * Creates the ArrayBufferViews used for initializing environment texture image data.
  47392. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  47393. * @param info parameters that determine what views will be created for accessing the underlying buffer
  47394. * @return the views described by info providing access to the underlying buffer
  47395. */
  47396. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  47397. /**
  47398. * Uploads the texture info contained in the env file to the GPU.
  47399. * @param texture defines the internal texture to upload to
  47400. * @param arrayBuffer defines the buffer cotaining the data to load
  47401. * @param info defines the texture info retrieved through the GetEnvInfo method
  47402. * @returns a promise
  47403. */
  47404. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  47405. private static _OnImageReadyAsync;
  47406. /**
  47407. * Uploads the levels of image data to the GPU.
  47408. * @param texture defines the internal texture to upload to
  47409. * @param imageData defines the array buffer views of image data [mipmap][face]
  47410. * @returns a promise
  47411. */
  47412. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47413. /**
  47414. * Uploads spherical polynomials information to the texture.
  47415. * @param texture defines the texture we are trying to upload the information to
  47416. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47417. */
  47418. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47419. /** @hidden */
  47420. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47421. }
  47422. }
  47423. declare module "babylonjs/Maths/math.vertexFormat" {
  47424. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  47425. /**
  47426. * Contains position and normal vectors for a vertex
  47427. */
  47428. export class PositionNormalVertex {
  47429. /** the position of the vertex (defaut: 0,0,0) */
  47430. position: Vector3;
  47431. /** the normal of the vertex (defaut: 0,1,0) */
  47432. normal: Vector3;
  47433. /**
  47434. * Creates a PositionNormalVertex
  47435. * @param position the position of the vertex (defaut: 0,0,0)
  47436. * @param normal the normal of the vertex (defaut: 0,1,0)
  47437. */
  47438. constructor(
  47439. /** the position of the vertex (defaut: 0,0,0) */
  47440. position?: Vector3,
  47441. /** the normal of the vertex (defaut: 0,1,0) */
  47442. normal?: Vector3);
  47443. /**
  47444. * Clones the PositionNormalVertex
  47445. * @returns the cloned PositionNormalVertex
  47446. */
  47447. clone(): PositionNormalVertex;
  47448. }
  47449. /**
  47450. * Contains position, normal and uv vectors for a vertex
  47451. */
  47452. export class PositionNormalTextureVertex {
  47453. /** the position of the vertex (defaut: 0,0,0) */
  47454. position: Vector3;
  47455. /** the normal of the vertex (defaut: 0,1,0) */
  47456. normal: Vector3;
  47457. /** the uv of the vertex (default: 0,0) */
  47458. uv: Vector2;
  47459. /**
  47460. * Creates a PositionNormalTextureVertex
  47461. * @param position the position of the vertex (defaut: 0,0,0)
  47462. * @param normal the normal of the vertex (defaut: 0,1,0)
  47463. * @param uv the uv of the vertex (default: 0,0)
  47464. */
  47465. constructor(
  47466. /** the position of the vertex (defaut: 0,0,0) */
  47467. position?: Vector3,
  47468. /** the normal of the vertex (defaut: 0,1,0) */
  47469. normal?: Vector3,
  47470. /** the uv of the vertex (default: 0,0) */
  47471. uv?: Vector2);
  47472. /**
  47473. * Clones the PositionNormalTextureVertex
  47474. * @returns the cloned PositionNormalTextureVertex
  47475. */
  47476. clone(): PositionNormalTextureVertex;
  47477. }
  47478. }
  47479. declare module "babylonjs/Maths/math" {
  47480. export * from "babylonjs/Maths/math.axis";
  47481. export * from "babylonjs/Maths/math.color";
  47482. export * from "babylonjs/Maths/math.constants";
  47483. export * from "babylonjs/Maths/math.frustum";
  47484. export * from "babylonjs/Maths/math.path";
  47485. export * from "babylonjs/Maths/math.plane";
  47486. export * from "babylonjs/Maths/math.size";
  47487. export * from "babylonjs/Maths/math.vector";
  47488. export * from "babylonjs/Maths/math.vertexFormat";
  47489. export * from "babylonjs/Maths/math.viewport";
  47490. }
  47491. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  47492. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  47493. /** @hidden */
  47494. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  47495. private _genericAttributeLocation;
  47496. private _varyingLocationCount;
  47497. private _varyingLocationMap;
  47498. private _replacements;
  47499. private _textureCount;
  47500. private _uniforms;
  47501. lineProcessor(line: string): string;
  47502. attributeProcessor(attribute: string): string;
  47503. varyingProcessor(varying: string, isFragment: boolean): string;
  47504. uniformProcessor(uniform: string): string;
  47505. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  47506. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  47507. }
  47508. }
  47509. declare module "babylonjs/Engines/nativeEngine" {
  47510. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  47511. import { Engine } from "babylonjs/Engines/engine";
  47512. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  47513. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47514. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47515. import { Effect } from "babylonjs/Materials/effect";
  47516. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  47517. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  47518. import { IColor4Like } from "babylonjs/Maths/math.like";
  47519. import { Scene } from "babylonjs/scene";
  47520. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  47521. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  47522. /**
  47523. * Container for accessors for natively-stored mesh data buffers.
  47524. */
  47525. class NativeDataBuffer extends DataBuffer {
  47526. /**
  47527. * Accessor value used to identify/retrieve a natively-stored index buffer.
  47528. */
  47529. nativeIndexBuffer?: any;
  47530. /**
  47531. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  47532. */
  47533. nativeVertexBuffer?: any;
  47534. }
  47535. /** @hidden */
  47536. class NativeTexture extends InternalTexture {
  47537. getInternalTexture(): InternalTexture;
  47538. getViewCount(): number;
  47539. }
  47540. /** @hidden */
  47541. export class NativeEngine extends Engine {
  47542. private readonly _native;
  47543. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  47544. private readonly INVALID_HANDLE;
  47545. getHardwareScalingLevel(): number;
  47546. constructor();
  47547. /**
  47548. * Can be used to override the current requestAnimationFrame requester.
  47549. * @hidden
  47550. */
  47551. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  47552. /**
  47553. * Override default engine behavior.
  47554. * @param color
  47555. * @param backBuffer
  47556. * @param depth
  47557. * @param stencil
  47558. */
  47559. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  47560. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47561. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  47562. createVertexBuffer(data: DataArray): NativeDataBuffer;
  47563. recordVertexArrayObject(vertexBuffers: {
  47564. [key: string]: VertexBuffer;
  47565. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  47566. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47567. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47568. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47569. /**
  47570. * Draw a list of indexed primitives
  47571. * @param fillMode defines the primitive to use
  47572. * @param indexStart defines the starting index
  47573. * @param indexCount defines the number of index to draw
  47574. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47575. */
  47576. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47577. /**
  47578. * Draw a list of unindexed primitives
  47579. * @param fillMode defines the primitive to use
  47580. * @param verticesStart defines the index of first vertex to draw
  47581. * @param verticesCount defines the count of vertices to draw
  47582. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47583. */
  47584. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47585. createPipelineContext(): IPipelineContext;
  47586. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  47587. /** @hidden */
  47588. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  47589. /** @hidden */
  47590. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  47591. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47592. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47593. protected _setProgram(program: WebGLProgram): void;
  47594. _releaseEffect(effect: Effect): void;
  47595. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  47596. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  47597. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  47598. bindSamplers(effect: Effect): void;
  47599. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  47600. getRenderWidth(useScreen?: boolean): number;
  47601. getRenderHeight(useScreen?: boolean): number;
  47602. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  47603. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47604. /**
  47605. * Set the z offset to apply to current rendering
  47606. * @param value defines the offset to apply
  47607. */
  47608. setZOffset(value: number): void;
  47609. /**
  47610. * Gets the current value of the zOffset
  47611. * @returns the current zOffset state
  47612. */
  47613. getZOffset(): number;
  47614. /**
  47615. * Enable or disable depth buffering
  47616. * @param enable defines the state to set
  47617. */
  47618. setDepthBuffer(enable: boolean): void;
  47619. /**
  47620. * Gets a boolean indicating if depth writing is enabled
  47621. * @returns the current depth writing state
  47622. */
  47623. getDepthWrite(): boolean;
  47624. /**
  47625. * Enable or disable depth writing
  47626. * @param enable defines the state to set
  47627. */
  47628. setDepthWrite(enable: boolean): void;
  47629. /**
  47630. * Enable or disable color writing
  47631. * @param enable defines the state to set
  47632. */
  47633. setColorWrite(enable: boolean): void;
  47634. /**
  47635. * Gets a boolean indicating if color writing is enabled
  47636. * @returns the current color writing state
  47637. */
  47638. getColorWrite(): boolean;
  47639. /**
  47640. * Sets alpha constants used by some alpha blending modes
  47641. * @param r defines the red component
  47642. * @param g defines the green component
  47643. * @param b defines the blue component
  47644. * @param a defines the alpha component
  47645. */
  47646. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  47647. /**
  47648. * Sets the current alpha mode
  47649. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  47650. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47651. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47652. */
  47653. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47654. /**
  47655. * Gets the current alpha mode
  47656. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47657. * @returns the current alpha mode
  47658. */
  47659. getAlphaMode(): number;
  47660. setInt(uniform: WebGLUniformLocation, int: number): void;
  47661. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47662. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47663. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47664. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47665. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47666. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47667. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47668. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47669. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47670. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47671. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47672. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47673. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47674. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47675. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47676. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47677. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47678. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47679. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47680. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  47681. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  47682. wipeCaches(bruteForce?: boolean): void;
  47683. _createTexture(): WebGLTexture;
  47684. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  47685. /**
  47686. * Usually called from BABYLON.Texture.ts.
  47687. * Passed information to create a WebGLTexture
  47688. * @param urlArg defines a value which contains one of the following:
  47689. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47690. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47691. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47692. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47693. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  47694. * @param scene needed for loading to the correct scene
  47695. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  47696. * @param onLoad optional callback to be called upon successful completion
  47697. * @param onError optional callback to be called upon failure
  47698. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  47699. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47700. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47701. * @param forcedExtension defines the extension to use to pick the right loader
  47702. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47703. */
  47704. 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;
  47705. /**
  47706. * Creates a cube texture
  47707. * @param rootUrl defines the url where the files to load is located
  47708. * @param scene defines the current scene
  47709. * @param files defines the list of files to load (1 per face)
  47710. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  47711. * @param onLoad defines an optional callback raised when the texture is loaded
  47712. * @param onError defines an optional callback raised if there is an issue to load the texture
  47713. * @param format defines the format of the data
  47714. * @param forcedExtension defines the extension to use to pick the right loader
  47715. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  47716. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47717. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47718. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  47719. * @returns the cube texture as an InternalTexture
  47720. */
  47721. 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;
  47722. private _getSamplingFilter;
  47723. private static _GetNativeTextureFormat;
  47724. createRenderTargetTexture(size: number | {
  47725. width: number;
  47726. height: number;
  47727. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  47728. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47729. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47730. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47731. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  47732. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  47733. /**
  47734. * Updates a dynamic vertex buffer.
  47735. * @param vertexBuffer the vertex buffer to update
  47736. * @param data the data used to update the vertex buffer
  47737. * @param byteOffset the byte offset of the data (optional)
  47738. * @param byteLength the byte length of the data (optional)
  47739. */
  47740. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  47741. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  47742. private _updateAnisotropicLevel;
  47743. private _getAddressMode;
  47744. /** @hidden */
  47745. _bindTexture(channel: number, texture: InternalTexture): void;
  47746. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  47747. releaseEffects(): void;
  47748. /** @hidden */
  47749. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47750. /** @hidden */
  47751. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47752. /** @hidden */
  47753. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47754. /** @hidden */
  47755. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47756. }
  47757. }
  47758. declare module "babylonjs/Engines/index" {
  47759. export * from "babylonjs/Engines/constants";
  47760. export * from "babylonjs/Engines/engineCapabilities";
  47761. export * from "babylonjs/Engines/instancingAttributeInfo";
  47762. export * from "babylonjs/Engines/thinEngine";
  47763. export * from "babylonjs/Engines/engine";
  47764. export * from "babylonjs/Engines/engineStore";
  47765. export * from "babylonjs/Engines/nullEngine";
  47766. export * from "babylonjs/Engines/Extensions/index";
  47767. export * from "babylonjs/Engines/IPipelineContext";
  47768. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  47769. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  47770. export * from "babylonjs/Engines/nativeEngine";
  47771. }
  47772. declare module "babylonjs/Events/clipboardEvents" {
  47773. /**
  47774. * Gather the list of clipboard event types as constants.
  47775. */
  47776. export class ClipboardEventTypes {
  47777. /**
  47778. * The clipboard event is fired when a copy command is active (pressed).
  47779. */
  47780. static readonly COPY: number;
  47781. /**
  47782. * The clipboard event is fired when a cut command is active (pressed).
  47783. */
  47784. static readonly CUT: number;
  47785. /**
  47786. * The clipboard event is fired when a paste command is active (pressed).
  47787. */
  47788. static readonly PASTE: number;
  47789. }
  47790. /**
  47791. * This class is used to store clipboard related info for the onClipboardObservable event.
  47792. */
  47793. export class ClipboardInfo {
  47794. /**
  47795. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47796. */
  47797. type: number;
  47798. /**
  47799. * Defines the related dom event
  47800. */
  47801. event: ClipboardEvent;
  47802. /**
  47803. *Creates an instance of ClipboardInfo.
  47804. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  47805. * @param event Defines the related dom event
  47806. */
  47807. constructor(
  47808. /**
  47809. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47810. */
  47811. type: number,
  47812. /**
  47813. * Defines the related dom event
  47814. */
  47815. event: ClipboardEvent);
  47816. /**
  47817. * Get the clipboard event's type from the keycode.
  47818. * @param keyCode Defines the keyCode for the current keyboard event.
  47819. * @return {number}
  47820. */
  47821. static GetTypeFromCharacter(keyCode: number): number;
  47822. }
  47823. }
  47824. declare module "babylonjs/Events/index" {
  47825. export * from "babylonjs/Events/keyboardEvents";
  47826. export * from "babylonjs/Events/pointerEvents";
  47827. export * from "babylonjs/Events/clipboardEvents";
  47828. }
  47829. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  47830. import { Scene } from "babylonjs/scene";
  47831. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47832. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  47833. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47834. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47835. /**
  47836. * Google Daydream controller
  47837. */
  47838. export class DaydreamController extends WebVRController {
  47839. /**
  47840. * Base Url for the controller model.
  47841. */
  47842. static MODEL_BASE_URL: string;
  47843. /**
  47844. * File name for the controller model.
  47845. */
  47846. static MODEL_FILENAME: string;
  47847. /**
  47848. * Gamepad Id prefix used to identify Daydream Controller.
  47849. */
  47850. static readonly GAMEPAD_ID_PREFIX: string;
  47851. /**
  47852. * Creates a new DaydreamController from a gamepad
  47853. * @param vrGamepad the gamepad that the controller should be created from
  47854. */
  47855. constructor(vrGamepad: any);
  47856. /**
  47857. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47858. * @param scene scene in which to add meshes
  47859. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47860. */
  47861. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47862. /**
  47863. * Called once for each button that changed state since the last frame
  47864. * @param buttonIdx Which button index changed
  47865. * @param state New state of the button
  47866. * @param changes Which properties on the state changed since last frame
  47867. */
  47868. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47869. }
  47870. }
  47871. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  47872. import { Scene } from "babylonjs/scene";
  47873. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47874. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  47875. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47876. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47877. /**
  47878. * Gear VR Controller
  47879. */
  47880. export class GearVRController extends WebVRController {
  47881. /**
  47882. * Base Url for the controller model.
  47883. */
  47884. static MODEL_BASE_URL: string;
  47885. /**
  47886. * File name for the controller model.
  47887. */
  47888. static MODEL_FILENAME: string;
  47889. /**
  47890. * Gamepad Id prefix used to identify this controller.
  47891. */
  47892. static readonly GAMEPAD_ID_PREFIX: string;
  47893. private readonly _buttonIndexToObservableNameMap;
  47894. /**
  47895. * Creates a new GearVRController from a gamepad
  47896. * @param vrGamepad the gamepad that the controller should be created from
  47897. */
  47898. constructor(vrGamepad: any);
  47899. /**
  47900. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47901. * @param scene scene in which to add meshes
  47902. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47903. */
  47904. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47905. /**
  47906. * Called once for each button that changed state since the last frame
  47907. * @param buttonIdx Which button index changed
  47908. * @param state New state of the button
  47909. * @param changes Which properties on the state changed since last frame
  47910. */
  47911. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47912. }
  47913. }
  47914. declare module "babylonjs/Gamepads/Controllers/index" {
  47915. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  47916. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  47917. export * from "babylonjs/Gamepads/Controllers/genericController";
  47918. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  47919. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47920. export * from "babylonjs/Gamepads/Controllers/viveController";
  47921. export * from "babylonjs/Gamepads/Controllers/webVRController";
  47922. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  47923. }
  47924. declare module "babylonjs/Gamepads/index" {
  47925. export * from "babylonjs/Gamepads/Controllers/index";
  47926. export * from "babylonjs/Gamepads/gamepad";
  47927. export * from "babylonjs/Gamepads/gamepadManager";
  47928. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  47929. export * from "babylonjs/Gamepads/xboxGamepad";
  47930. export * from "babylonjs/Gamepads/dualShockGamepad";
  47931. }
  47932. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  47933. import { Scene } from "babylonjs/scene";
  47934. import { Vector4 } from "babylonjs/Maths/math.vector";
  47935. import { Color4 } from "babylonjs/Maths/math.color";
  47936. import { Mesh } from "babylonjs/Meshes/mesh";
  47937. import { Nullable } from "babylonjs/types";
  47938. /**
  47939. * Class containing static functions to help procedurally build meshes
  47940. */
  47941. export class PolyhedronBuilder {
  47942. /**
  47943. * Creates a polyhedron mesh
  47944. * * 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
  47945. * * The parameter `size` (positive float, default 1) sets the polygon size
  47946. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  47947. * * 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`
  47948. * * 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
  47949. * * 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)`)
  47950. * * 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
  47951. * * 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
  47952. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47953. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47954. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47955. * @param name defines the name of the mesh
  47956. * @param options defines the options used to create the mesh
  47957. * @param scene defines the hosting scene
  47958. * @returns the polyhedron mesh
  47959. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  47960. */
  47961. static CreatePolyhedron(name: string, options: {
  47962. type?: number;
  47963. size?: number;
  47964. sizeX?: number;
  47965. sizeY?: number;
  47966. sizeZ?: number;
  47967. custom?: any;
  47968. faceUV?: Vector4[];
  47969. faceColors?: Color4[];
  47970. flat?: boolean;
  47971. updatable?: boolean;
  47972. sideOrientation?: number;
  47973. frontUVs?: Vector4;
  47974. backUVs?: Vector4;
  47975. }, scene?: Nullable<Scene>): Mesh;
  47976. }
  47977. }
  47978. declare module "babylonjs/Gizmos/scaleGizmo" {
  47979. import { Observable } from "babylonjs/Misc/observable";
  47980. import { Nullable } from "babylonjs/types";
  47981. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47982. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47983. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  47984. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47985. /**
  47986. * Gizmo that enables scaling a mesh along 3 axis
  47987. */
  47988. export class ScaleGizmo extends Gizmo {
  47989. /**
  47990. * Internal gizmo used for interactions on the x axis
  47991. */
  47992. xGizmo: AxisScaleGizmo;
  47993. /**
  47994. * Internal gizmo used for interactions on the y axis
  47995. */
  47996. yGizmo: AxisScaleGizmo;
  47997. /**
  47998. * Internal gizmo used for interactions on the z axis
  47999. */
  48000. zGizmo: AxisScaleGizmo;
  48001. /**
  48002. * Internal gizmo used to scale all axis equally
  48003. */
  48004. uniformScaleGizmo: AxisScaleGizmo;
  48005. private _meshAttached;
  48006. private _updateGizmoRotationToMatchAttachedMesh;
  48007. private _snapDistance;
  48008. private _scaleRatio;
  48009. private _uniformScalingMesh;
  48010. private _octahedron;
  48011. private _sensitivity;
  48012. /** Fires an event when any of it's sub gizmos are dragged */
  48013. onDragStartObservable: Observable<unknown>;
  48014. /** Fires an event when any of it's sub gizmos are released from dragging */
  48015. onDragEndObservable: Observable<unknown>;
  48016. attachedMesh: Nullable<AbstractMesh>;
  48017. /**
  48018. * Creates a ScaleGizmo
  48019. * @param gizmoLayer The utility layer the gizmo will be added to
  48020. */
  48021. constructor(gizmoLayer?: UtilityLayerRenderer);
  48022. updateGizmoRotationToMatchAttachedMesh: boolean;
  48023. /**
  48024. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48025. */
  48026. snapDistance: number;
  48027. /**
  48028. * Ratio for the scale of the gizmo (Default: 1)
  48029. */
  48030. scaleRatio: number;
  48031. /**
  48032. * Sensitivity factor for dragging (Default: 1)
  48033. */
  48034. sensitivity: number;
  48035. /**
  48036. * Disposes of the gizmo
  48037. */
  48038. dispose(): void;
  48039. }
  48040. }
  48041. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  48042. import { Observable } from "babylonjs/Misc/observable";
  48043. import { Nullable } from "babylonjs/types";
  48044. import { Vector3 } from "babylonjs/Maths/math.vector";
  48045. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48046. import { Mesh } from "babylonjs/Meshes/mesh";
  48047. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48048. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48049. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48050. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  48051. import { Color3 } from "babylonjs/Maths/math.color";
  48052. /**
  48053. * Single axis scale gizmo
  48054. */
  48055. export class AxisScaleGizmo extends Gizmo {
  48056. /**
  48057. * Drag behavior responsible for the gizmos dragging interactions
  48058. */
  48059. dragBehavior: PointerDragBehavior;
  48060. private _pointerObserver;
  48061. /**
  48062. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48063. */
  48064. snapDistance: number;
  48065. /**
  48066. * Event that fires each time the gizmo snaps to a new location.
  48067. * * snapDistance is the the change in distance
  48068. */
  48069. onSnapObservable: Observable<{
  48070. snapDistance: number;
  48071. }>;
  48072. /**
  48073. * If the scaling operation should be done on all axis (default: false)
  48074. */
  48075. uniformScaling: boolean;
  48076. /**
  48077. * Custom sensitivity value for the drag strength
  48078. */
  48079. sensitivity: number;
  48080. private _isEnabled;
  48081. private _parent;
  48082. private _arrow;
  48083. private _coloredMaterial;
  48084. private _hoverMaterial;
  48085. /**
  48086. * Creates an AxisScaleGizmo
  48087. * @param gizmoLayer The utility layer the gizmo will be added to
  48088. * @param dragAxis The axis which the gizmo will be able to scale on
  48089. * @param color The color of the gizmo
  48090. */
  48091. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  48092. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48093. /**
  48094. * If the gizmo is enabled
  48095. */
  48096. isEnabled: boolean;
  48097. /**
  48098. * Disposes of the gizmo
  48099. */
  48100. dispose(): void;
  48101. /**
  48102. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48103. * @param mesh The mesh to replace the default mesh of the gizmo
  48104. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  48105. */
  48106. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  48107. }
  48108. }
  48109. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  48110. import { Observable } from "babylonjs/Misc/observable";
  48111. import { Nullable } from "babylonjs/types";
  48112. import { Vector3 } from "babylonjs/Maths/math.vector";
  48113. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48114. import { Mesh } from "babylonjs/Meshes/mesh";
  48115. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48116. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48117. import { Color3 } from "babylonjs/Maths/math.color";
  48118. import "babylonjs/Meshes/Builders/boxBuilder";
  48119. /**
  48120. * Bounding box gizmo
  48121. */
  48122. export class BoundingBoxGizmo extends Gizmo {
  48123. private _lineBoundingBox;
  48124. private _rotateSpheresParent;
  48125. private _scaleBoxesParent;
  48126. private _boundingDimensions;
  48127. private _renderObserver;
  48128. private _pointerObserver;
  48129. private _scaleDragSpeed;
  48130. private _tmpQuaternion;
  48131. private _tmpVector;
  48132. private _tmpRotationMatrix;
  48133. /**
  48134. * 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)
  48135. */
  48136. ignoreChildren: boolean;
  48137. /**
  48138. * 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)
  48139. */
  48140. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  48141. /**
  48142. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  48143. */
  48144. rotationSphereSize: number;
  48145. /**
  48146. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  48147. */
  48148. scaleBoxSize: number;
  48149. /**
  48150. * 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)
  48151. */
  48152. fixedDragMeshScreenSize: boolean;
  48153. /**
  48154. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  48155. */
  48156. fixedDragMeshScreenSizeDistanceFactor: number;
  48157. /**
  48158. * Fired when a rotation sphere or scale box is dragged
  48159. */
  48160. onDragStartObservable: Observable<{}>;
  48161. /**
  48162. * Fired when a scale box is dragged
  48163. */
  48164. onScaleBoxDragObservable: Observable<{}>;
  48165. /**
  48166. * Fired when a scale box drag is ended
  48167. */
  48168. onScaleBoxDragEndObservable: Observable<{}>;
  48169. /**
  48170. * Fired when a rotation sphere is dragged
  48171. */
  48172. onRotationSphereDragObservable: Observable<{}>;
  48173. /**
  48174. * Fired when a rotation sphere drag is ended
  48175. */
  48176. onRotationSphereDragEndObservable: Observable<{}>;
  48177. /**
  48178. * 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)
  48179. */
  48180. scalePivot: Nullable<Vector3>;
  48181. /**
  48182. * Mesh used as a pivot to rotate the attached mesh
  48183. */
  48184. private _anchorMesh;
  48185. private _existingMeshScale;
  48186. private _dragMesh;
  48187. private pointerDragBehavior;
  48188. private coloredMaterial;
  48189. private hoverColoredMaterial;
  48190. /**
  48191. * Sets the color of the bounding box gizmo
  48192. * @param color the color to set
  48193. */
  48194. setColor(color: Color3): void;
  48195. /**
  48196. * Creates an BoundingBoxGizmo
  48197. * @param gizmoLayer The utility layer the gizmo will be added to
  48198. * @param color The color of the gizmo
  48199. */
  48200. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  48201. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48202. private _selectNode;
  48203. /**
  48204. * Updates the bounding box information for the Gizmo
  48205. */
  48206. updateBoundingBox(): void;
  48207. private _updateRotationSpheres;
  48208. private _updateScaleBoxes;
  48209. /**
  48210. * Enables rotation on the specified axis and disables rotation on the others
  48211. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  48212. */
  48213. setEnabledRotationAxis(axis: string): void;
  48214. /**
  48215. * Enables/disables scaling
  48216. * @param enable if scaling should be enabled
  48217. */
  48218. setEnabledScaling(enable: boolean): void;
  48219. private _updateDummy;
  48220. /**
  48221. * Enables a pointer drag behavior on the bounding box of the gizmo
  48222. */
  48223. enableDragBehavior(): void;
  48224. /**
  48225. * Disposes of the gizmo
  48226. */
  48227. dispose(): void;
  48228. /**
  48229. * 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)
  48230. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  48231. * @returns the bounding box mesh with the passed in mesh as a child
  48232. */
  48233. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  48234. /**
  48235. * CustomMeshes are not supported by this gizmo
  48236. * @param mesh The mesh to replace the default mesh of the gizmo
  48237. */
  48238. setCustomMesh(mesh: Mesh): void;
  48239. }
  48240. }
  48241. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  48242. import { Observable } from "babylonjs/Misc/observable";
  48243. import { Nullable } from "babylonjs/types";
  48244. import { Vector3 } from "babylonjs/Maths/math.vector";
  48245. import { Color3 } from "babylonjs/Maths/math.color";
  48246. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48247. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48248. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48249. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48250. import "babylonjs/Meshes/Builders/linesBuilder";
  48251. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  48252. /**
  48253. * Single plane rotation gizmo
  48254. */
  48255. export class PlaneRotationGizmo extends Gizmo {
  48256. /**
  48257. * Drag behavior responsible for the gizmos dragging interactions
  48258. */
  48259. dragBehavior: PointerDragBehavior;
  48260. private _pointerObserver;
  48261. /**
  48262. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  48263. */
  48264. snapDistance: number;
  48265. /**
  48266. * Event that fires each time the gizmo snaps to a new location.
  48267. * * snapDistance is the the change in distance
  48268. */
  48269. onSnapObservable: Observable<{
  48270. snapDistance: number;
  48271. }>;
  48272. private _isEnabled;
  48273. private _parent;
  48274. /**
  48275. * Creates a PlaneRotationGizmo
  48276. * @param gizmoLayer The utility layer the gizmo will be added to
  48277. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  48278. * @param color The color of the gizmo
  48279. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48280. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48281. */
  48282. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  48283. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48284. /**
  48285. * If the gizmo is enabled
  48286. */
  48287. isEnabled: boolean;
  48288. /**
  48289. * Disposes of the gizmo
  48290. */
  48291. dispose(): void;
  48292. }
  48293. }
  48294. declare module "babylonjs/Gizmos/rotationGizmo" {
  48295. import { Observable } from "babylonjs/Misc/observable";
  48296. import { Nullable } from "babylonjs/types";
  48297. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48298. import { Mesh } from "babylonjs/Meshes/mesh";
  48299. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48300. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  48301. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48302. /**
  48303. * Gizmo that enables rotating a mesh along 3 axis
  48304. */
  48305. export class RotationGizmo extends Gizmo {
  48306. /**
  48307. * Internal gizmo used for interactions on the x axis
  48308. */
  48309. xGizmo: PlaneRotationGizmo;
  48310. /**
  48311. * Internal gizmo used for interactions on the y axis
  48312. */
  48313. yGizmo: PlaneRotationGizmo;
  48314. /**
  48315. * Internal gizmo used for interactions on the z axis
  48316. */
  48317. zGizmo: PlaneRotationGizmo;
  48318. /** Fires an event when any of it's sub gizmos are dragged */
  48319. onDragStartObservable: Observable<unknown>;
  48320. /** Fires an event when any of it's sub gizmos are released from dragging */
  48321. onDragEndObservable: Observable<unknown>;
  48322. private _meshAttached;
  48323. attachedMesh: Nullable<AbstractMesh>;
  48324. /**
  48325. * Creates a RotationGizmo
  48326. * @param gizmoLayer The utility layer the gizmo will be added to
  48327. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48328. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48329. */
  48330. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  48331. updateGizmoRotationToMatchAttachedMesh: boolean;
  48332. /**
  48333. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48334. */
  48335. snapDistance: number;
  48336. /**
  48337. * Ratio for the scale of the gizmo (Default: 1)
  48338. */
  48339. scaleRatio: number;
  48340. /**
  48341. * Disposes of the gizmo
  48342. */
  48343. dispose(): void;
  48344. /**
  48345. * CustomMeshes are not supported by this gizmo
  48346. * @param mesh The mesh to replace the default mesh of the gizmo
  48347. */
  48348. setCustomMesh(mesh: Mesh): void;
  48349. }
  48350. }
  48351. declare module "babylonjs/Gizmos/gizmoManager" {
  48352. import { Observable } from "babylonjs/Misc/observable";
  48353. import { Nullable } from "babylonjs/types";
  48354. import { Scene, IDisposable } from "babylonjs/scene";
  48355. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48356. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48357. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  48358. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  48359. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  48360. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  48361. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  48362. /**
  48363. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  48364. */
  48365. export class GizmoManager implements IDisposable {
  48366. private scene;
  48367. /**
  48368. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  48369. */
  48370. gizmos: {
  48371. positionGizmo: Nullable<PositionGizmo>;
  48372. rotationGizmo: Nullable<RotationGizmo>;
  48373. scaleGizmo: Nullable<ScaleGizmo>;
  48374. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  48375. };
  48376. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  48377. clearGizmoOnEmptyPointerEvent: boolean;
  48378. /** Fires an event when the manager is attached to a mesh */
  48379. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  48380. private _gizmosEnabled;
  48381. private _pointerObserver;
  48382. private _attachedMesh;
  48383. private _boundingBoxColor;
  48384. private _defaultUtilityLayer;
  48385. private _defaultKeepDepthUtilityLayer;
  48386. /**
  48387. * When bounding box gizmo is enabled, this can be used to track drag/end events
  48388. */
  48389. boundingBoxDragBehavior: SixDofDragBehavior;
  48390. /**
  48391. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  48392. */
  48393. attachableMeshes: Nullable<Array<AbstractMesh>>;
  48394. /**
  48395. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  48396. */
  48397. usePointerToAttachGizmos: boolean;
  48398. /**
  48399. * Utility layer that the bounding box gizmo belongs to
  48400. */
  48401. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  48402. /**
  48403. * Utility layer that all gizmos besides bounding box belong to
  48404. */
  48405. readonly utilityLayer: UtilityLayerRenderer;
  48406. /**
  48407. * Instatiates a gizmo manager
  48408. * @param scene the scene to overlay the gizmos on top of
  48409. */
  48410. constructor(scene: Scene);
  48411. /**
  48412. * Attaches a set of gizmos to the specified mesh
  48413. * @param mesh The mesh the gizmo's should be attached to
  48414. */
  48415. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48416. /**
  48417. * If the position gizmo is enabled
  48418. */
  48419. positionGizmoEnabled: boolean;
  48420. /**
  48421. * If the rotation gizmo is enabled
  48422. */
  48423. rotationGizmoEnabled: boolean;
  48424. /**
  48425. * If the scale gizmo is enabled
  48426. */
  48427. scaleGizmoEnabled: boolean;
  48428. /**
  48429. * If the boundingBox gizmo is enabled
  48430. */
  48431. boundingBoxGizmoEnabled: boolean;
  48432. /**
  48433. * Disposes of the gizmo manager
  48434. */
  48435. dispose(): void;
  48436. }
  48437. }
  48438. declare module "babylonjs/Lights/directionalLight" {
  48439. import { Camera } from "babylonjs/Cameras/camera";
  48440. import { Scene } from "babylonjs/scene";
  48441. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48442. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48443. import { Light } from "babylonjs/Lights/light";
  48444. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48445. import { Effect } from "babylonjs/Materials/effect";
  48446. /**
  48447. * A directional light is defined by a direction (what a surprise!).
  48448. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48449. * 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.
  48450. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48451. */
  48452. export class DirectionalLight extends ShadowLight {
  48453. private _shadowFrustumSize;
  48454. /**
  48455. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48456. */
  48457. /**
  48458. * Specifies a fix frustum size for the shadow generation.
  48459. */
  48460. shadowFrustumSize: number;
  48461. private _shadowOrthoScale;
  48462. /**
  48463. * Gets the shadow projection scale against the optimal computed one.
  48464. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48465. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48466. */
  48467. /**
  48468. * Sets the shadow projection scale against the optimal computed one.
  48469. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48470. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48471. */
  48472. shadowOrthoScale: number;
  48473. /**
  48474. * Automatically compute the projection matrix to best fit (including all the casters)
  48475. * on each frame.
  48476. */
  48477. autoUpdateExtends: boolean;
  48478. private _orthoLeft;
  48479. private _orthoRight;
  48480. private _orthoTop;
  48481. private _orthoBottom;
  48482. /**
  48483. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48484. * The directional light is emitted from everywhere in the given direction.
  48485. * It can cast shadows.
  48486. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48487. * @param name The friendly name of the light
  48488. * @param direction The direction of the light
  48489. * @param scene The scene the light belongs to
  48490. */
  48491. constructor(name: string, direction: Vector3, scene: Scene);
  48492. /**
  48493. * Returns the string "DirectionalLight".
  48494. * @return The class name
  48495. */
  48496. getClassName(): string;
  48497. /**
  48498. * Returns the integer 1.
  48499. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48500. */
  48501. getTypeID(): number;
  48502. /**
  48503. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48504. * Returns the DirectionalLight Shadow projection matrix.
  48505. */
  48506. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48507. /**
  48508. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48509. * Returns the DirectionalLight Shadow projection matrix.
  48510. */
  48511. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48512. /**
  48513. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48514. * Returns the DirectionalLight Shadow projection matrix.
  48515. */
  48516. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48517. protected _buildUniformLayout(): void;
  48518. /**
  48519. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48520. * @param effect The effect to update
  48521. * @param lightIndex The index of the light in the effect to update
  48522. * @returns The directional light
  48523. */
  48524. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48525. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  48526. /**
  48527. * Gets the minZ used for shadow according to both the scene and the light.
  48528. *
  48529. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48530. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48531. * @param activeCamera The camera we are returning the min for
  48532. * @returns the depth min z
  48533. */
  48534. getDepthMinZ(activeCamera: Camera): number;
  48535. /**
  48536. * Gets the maxZ used for shadow according to both the scene and the light.
  48537. *
  48538. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48539. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48540. * @param activeCamera The camera we are returning the max for
  48541. * @returns the depth max z
  48542. */
  48543. getDepthMaxZ(activeCamera: Camera): number;
  48544. /**
  48545. * Prepares the list of defines specific to the light type.
  48546. * @param defines the list of defines
  48547. * @param lightIndex defines the index of the light for the effect
  48548. */
  48549. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48550. }
  48551. }
  48552. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  48553. import { Mesh } from "babylonjs/Meshes/mesh";
  48554. /**
  48555. * Class containing static functions to help procedurally build meshes
  48556. */
  48557. export class HemisphereBuilder {
  48558. /**
  48559. * Creates a hemisphere mesh
  48560. * @param name defines the name of the mesh
  48561. * @param options defines the options used to create the mesh
  48562. * @param scene defines the hosting scene
  48563. * @returns the hemisphere mesh
  48564. */
  48565. static CreateHemisphere(name: string, options: {
  48566. segments?: number;
  48567. diameter?: number;
  48568. sideOrientation?: number;
  48569. }, scene: any): Mesh;
  48570. }
  48571. }
  48572. declare module "babylonjs/Lights/spotLight" {
  48573. import { Nullable } from "babylonjs/types";
  48574. import { Scene } from "babylonjs/scene";
  48575. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48576. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48577. import { Effect } from "babylonjs/Materials/effect";
  48578. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48579. import { Light } from "babylonjs/Lights/light";
  48580. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48581. /**
  48582. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48583. * These values define a cone of light starting from the position, emitting toward the direction.
  48584. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48585. * and the exponent defines the speed of the decay of the light with distance (reach).
  48586. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48587. */
  48588. export class SpotLight extends ShadowLight {
  48589. private _angle;
  48590. private _innerAngle;
  48591. private _cosHalfAngle;
  48592. private _lightAngleScale;
  48593. private _lightAngleOffset;
  48594. /**
  48595. * Gets the cone angle of the spot light in Radians.
  48596. */
  48597. /**
  48598. * Sets the cone angle of the spot light in Radians.
  48599. */
  48600. angle: number;
  48601. /**
  48602. * Only used in gltf falloff mode, this defines the angle where
  48603. * the directional falloff will start before cutting at angle which could be seen
  48604. * as outer angle.
  48605. */
  48606. /**
  48607. * Only used in gltf falloff mode, this defines the angle where
  48608. * the directional falloff will start before cutting at angle which could be seen
  48609. * as outer angle.
  48610. */
  48611. innerAngle: number;
  48612. private _shadowAngleScale;
  48613. /**
  48614. * Allows scaling the angle of the light for shadow generation only.
  48615. */
  48616. /**
  48617. * Allows scaling the angle of the light for shadow generation only.
  48618. */
  48619. shadowAngleScale: number;
  48620. /**
  48621. * The light decay speed with the distance from the emission spot.
  48622. */
  48623. exponent: number;
  48624. private _projectionTextureMatrix;
  48625. /**
  48626. * Allows reading the projecton texture
  48627. */
  48628. readonly projectionTextureMatrix: Matrix;
  48629. protected _projectionTextureLightNear: number;
  48630. /**
  48631. * Gets the near clip of the Spotlight for texture projection.
  48632. */
  48633. /**
  48634. * Sets the near clip of the Spotlight for texture projection.
  48635. */
  48636. projectionTextureLightNear: number;
  48637. protected _projectionTextureLightFar: number;
  48638. /**
  48639. * Gets the far clip of the Spotlight for texture projection.
  48640. */
  48641. /**
  48642. * Sets the far clip of the Spotlight for texture projection.
  48643. */
  48644. projectionTextureLightFar: number;
  48645. protected _projectionTextureUpDirection: Vector3;
  48646. /**
  48647. * Gets the Up vector of the Spotlight for texture projection.
  48648. */
  48649. /**
  48650. * Sets the Up vector of the Spotlight for texture projection.
  48651. */
  48652. projectionTextureUpDirection: Vector3;
  48653. private _projectionTexture;
  48654. /**
  48655. * Gets the projection texture of the light.
  48656. */
  48657. /**
  48658. * Sets the projection texture of the light.
  48659. */
  48660. projectionTexture: Nullable<BaseTexture>;
  48661. private _projectionTextureViewLightDirty;
  48662. private _projectionTextureProjectionLightDirty;
  48663. private _projectionTextureDirty;
  48664. private _projectionTextureViewTargetVector;
  48665. private _projectionTextureViewLightMatrix;
  48666. private _projectionTextureProjectionLightMatrix;
  48667. private _projectionTextureScalingMatrix;
  48668. /**
  48669. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48670. * It can cast shadows.
  48671. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48672. * @param name The light friendly name
  48673. * @param position The position of the spot light in the scene
  48674. * @param direction The direction of the light in the scene
  48675. * @param angle The cone angle of the light in Radians
  48676. * @param exponent The light decay speed with the distance from the emission spot
  48677. * @param scene The scene the lights belongs to
  48678. */
  48679. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  48680. /**
  48681. * Returns the string "SpotLight".
  48682. * @returns the class name
  48683. */
  48684. getClassName(): string;
  48685. /**
  48686. * Returns the integer 2.
  48687. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48688. */
  48689. getTypeID(): number;
  48690. /**
  48691. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48692. */
  48693. protected _setDirection(value: Vector3): void;
  48694. /**
  48695. * Overrides the position setter to recompute the projection texture view light Matrix.
  48696. */
  48697. protected _setPosition(value: Vector3): void;
  48698. /**
  48699. * 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.
  48700. * Returns the SpotLight.
  48701. */
  48702. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48703. protected _computeProjectionTextureViewLightMatrix(): void;
  48704. protected _computeProjectionTextureProjectionLightMatrix(): void;
  48705. /**
  48706. * Main function for light texture projection matrix computing.
  48707. */
  48708. protected _computeProjectionTextureMatrix(): void;
  48709. protected _buildUniformLayout(): void;
  48710. private _computeAngleValues;
  48711. /**
  48712. * Sets the passed Effect "effect" with the Light textures.
  48713. * @param effect The effect to update
  48714. * @param lightIndex The index of the light in the effect to update
  48715. * @returns The light
  48716. */
  48717. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  48718. /**
  48719. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48720. * @param effect The effect to update
  48721. * @param lightIndex The index of the light in the effect to update
  48722. * @returns The spot light
  48723. */
  48724. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  48725. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  48726. /**
  48727. * Disposes the light and the associated resources.
  48728. */
  48729. dispose(): void;
  48730. /**
  48731. * Prepares the list of defines specific to the light type.
  48732. * @param defines the list of defines
  48733. * @param lightIndex defines the index of the light for the effect
  48734. */
  48735. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48736. }
  48737. }
  48738. declare module "babylonjs/Gizmos/lightGizmo" {
  48739. import { Nullable } from "babylonjs/types";
  48740. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48741. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48742. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  48743. import { Light } from "babylonjs/Lights/light";
  48744. /**
  48745. * Gizmo that enables viewing a light
  48746. */
  48747. export class LightGizmo extends Gizmo {
  48748. private _lightMesh;
  48749. private _material;
  48750. private _cachedPosition;
  48751. private _cachedForward;
  48752. private _attachedMeshParent;
  48753. /**
  48754. * Creates a LightGizmo
  48755. * @param gizmoLayer The utility layer the gizmo will be added to
  48756. */
  48757. constructor(gizmoLayer?: UtilityLayerRenderer);
  48758. private _light;
  48759. /**
  48760. * The light that the gizmo is attached to
  48761. */
  48762. light: Nullable<Light>;
  48763. /**
  48764. * Gets the material used to render the light gizmo
  48765. */
  48766. readonly material: StandardMaterial;
  48767. /**
  48768. * @hidden
  48769. * Updates the gizmo to match the attached mesh's position/rotation
  48770. */
  48771. protected _update(): void;
  48772. private static _Scale;
  48773. /**
  48774. * Creates the lines for a light mesh
  48775. */
  48776. private static _CreateLightLines;
  48777. /**
  48778. * Disposes of the light gizmo
  48779. */
  48780. dispose(): void;
  48781. private static _CreateHemisphericLightMesh;
  48782. private static _CreatePointLightMesh;
  48783. private static _CreateSpotLightMesh;
  48784. private static _CreateDirectionalLightMesh;
  48785. }
  48786. }
  48787. declare module "babylonjs/Gizmos/index" {
  48788. export * from "babylonjs/Gizmos/axisDragGizmo";
  48789. export * from "babylonjs/Gizmos/axisScaleGizmo";
  48790. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  48791. export * from "babylonjs/Gizmos/gizmo";
  48792. export * from "babylonjs/Gizmos/gizmoManager";
  48793. export * from "babylonjs/Gizmos/planeRotationGizmo";
  48794. export * from "babylonjs/Gizmos/positionGizmo";
  48795. export * from "babylonjs/Gizmos/rotationGizmo";
  48796. export * from "babylonjs/Gizmos/scaleGizmo";
  48797. export * from "babylonjs/Gizmos/lightGizmo";
  48798. export * from "babylonjs/Gizmos/planeDragGizmo";
  48799. }
  48800. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  48801. /** @hidden */
  48802. export var backgroundFragmentDeclaration: {
  48803. name: string;
  48804. shader: string;
  48805. };
  48806. }
  48807. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  48808. /** @hidden */
  48809. export var backgroundUboDeclaration: {
  48810. name: string;
  48811. shader: string;
  48812. };
  48813. }
  48814. declare module "babylonjs/Shaders/background.fragment" {
  48815. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  48816. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  48817. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  48818. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  48819. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48820. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48821. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48822. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  48823. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  48824. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  48825. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  48826. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  48827. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  48828. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  48829. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  48830. /** @hidden */
  48831. export var backgroundPixelShader: {
  48832. name: string;
  48833. shader: string;
  48834. };
  48835. }
  48836. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  48837. /** @hidden */
  48838. export var backgroundVertexDeclaration: {
  48839. name: string;
  48840. shader: string;
  48841. };
  48842. }
  48843. declare module "babylonjs/Shaders/background.vertex" {
  48844. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  48845. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  48846. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48847. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48848. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48849. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  48850. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  48851. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48852. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48853. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48854. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48855. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  48856. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  48857. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  48858. /** @hidden */
  48859. export var backgroundVertexShader: {
  48860. name: string;
  48861. shader: string;
  48862. };
  48863. }
  48864. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  48865. import { Nullable, int, float } from "babylonjs/types";
  48866. import { Scene } from "babylonjs/scene";
  48867. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48868. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48869. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48870. import { Mesh } from "babylonjs/Meshes/mesh";
  48871. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  48872. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  48873. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  48874. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48875. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  48876. import { Color3 } from "babylonjs/Maths/math.color";
  48877. import "babylonjs/Shaders/background.fragment";
  48878. import "babylonjs/Shaders/background.vertex";
  48879. /**
  48880. * Background material used to create an efficient environement around your scene.
  48881. */
  48882. export class BackgroundMaterial extends PushMaterial {
  48883. /**
  48884. * Standard reflectance value at parallel view angle.
  48885. */
  48886. static StandardReflectance0: number;
  48887. /**
  48888. * Standard reflectance value at grazing angle.
  48889. */
  48890. static StandardReflectance90: number;
  48891. protected _primaryColor: Color3;
  48892. /**
  48893. * Key light Color (multiply against the environement texture)
  48894. */
  48895. primaryColor: Color3;
  48896. protected __perceptualColor: Nullable<Color3>;
  48897. /**
  48898. * Experimental Internal Use Only.
  48899. *
  48900. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  48901. * This acts as a helper to set the primary color to a more "human friendly" value.
  48902. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  48903. * output color as close as possible from the chosen value.
  48904. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  48905. * part of lighting setup.)
  48906. */
  48907. _perceptualColor: Nullable<Color3>;
  48908. protected _primaryColorShadowLevel: float;
  48909. /**
  48910. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  48911. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  48912. */
  48913. primaryColorShadowLevel: float;
  48914. protected _primaryColorHighlightLevel: float;
  48915. /**
  48916. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  48917. * The primary color is used at the level chosen to define what the white area would look.
  48918. */
  48919. primaryColorHighlightLevel: float;
  48920. protected _reflectionTexture: Nullable<BaseTexture>;
  48921. /**
  48922. * Reflection Texture used in the material.
  48923. * Should be author in a specific way for the best result (refer to the documentation).
  48924. */
  48925. reflectionTexture: Nullable<BaseTexture>;
  48926. protected _reflectionBlur: float;
  48927. /**
  48928. * Reflection Texture level of blur.
  48929. *
  48930. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  48931. * texture twice.
  48932. */
  48933. reflectionBlur: float;
  48934. protected _diffuseTexture: Nullable<BaseTexture>;
  48935. /**
  48936. * Diffuse Texture used in the material.
  48937. * Should be author in a specific way for the best result (refer to the documentation).
  48938. */
  48939. diffuseTexture: Nullable<BaseTexture>;
  48940. protected _shadowLights: Nullable<IShadowLight[]>;
  48941. /**
  48942. * Specify the list of lights casting shadow on the material.
  48943. * All scene shadow lights will be included if null.
  48944. */
  48945. shadowLights: Nullable<IShadowLight[]>;
  48946. protected _shadowLevel: float;
  48947. /**
  48948. * Helps adjusting the shadow to a softer level if required.
  48949. * 0 means black shadows and 1 means no shadows.
  48950. */
  48951. shadowLevel: float;
  48952. protected _sceneCenter: Vector3;
  48953. /**
  48954. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  48955. * It is usually zero but might be interesting to modify according to your setup.
  48956. */
  48957. sceneCenter: Vector3;
  48958. protected _opacityFresnel: boolean;
  48959. /**
  48960. * This helps specifying that the material is falling off to the sky box at grazing angle.
  48961. * This helps ensuring a nice transition when the camera goes under the ground.
  48962. */
  48963. opacityFresnel: boolean;
  48964. protected _reflectionFresnel: boolean;
  48965. /**
  48966. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  48967. * This helps adding a mirror texture on the ground.
  48968. */
  48969. reflectionFresnel: boolean;
  48970. protected _reflectionFalloffDistance: number;
  48971. /**
  48972. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  48973. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  48974. */
  48975. reflectionFalloffDistance: number;
  48976. protected _reflectionAmount: number;
  48977. /**
  48978. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  48979. */
  48980. reflectionAmount: number;
  48981. protected _reflectionReflectance0: number;
  48982. /**
  48983. * This specifies the weight of the reflection at grazing angle.
  48984. */
  48985. reflectionReflectance0: number;
  48986. protected _reflectionReflectance90: number;
  48987. /**
  48988. * This specifies the weight of the reflection at a perpendicular point of view.
  48989. */
  48990. reflectionReflectance90: number;
  48991. /**
  48992. * Sets the reflection reflectance fresnel values according to the default standard
  48993. * empirically know to work well :-)
  48994. */
  48995. reflectionStandardFresnelWeight: number;
  48996. protected _useRGBColor: boolean;
  48997. /**
  48998. * Helps to directly use the maps channels instead of their level.
  48999. */
  49000. useRGBColor: boolean;
  49001. protected _enableNoise: boolean;
  49002. /**
  49003. * This helps reducing the banding effect that could occur on the background.
  49004. */
  49005. enableNoise: boolean;
  49006. /**
  49007. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49008. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49009. * Recommended to be keep at 1.0 except for special cases.
  49010. */
  49011. fovMultiplier: number;
  49012. private _fovMultiplier;
  49013. /**
  49014. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49015. */
  49016. useEquirectangularFOV: boolean;
  49017. private _maxSimultaneousLights;
  49018. /**
  49019. * Number of Simultaneous lights allowed on the material.
  49020. */
  49021. maxSimultaneousLights: int;
  49022. /**
  49023. * Default configuration related to image processing available in the Background Material.
  49024. */
  49025. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49026. /**
  49027. * Keep track of the image processing observer to allow dispose and replace.
  49028. */
  49029. private _imageProcessingObserver;
  49030. /**
  49031. * Attaches a new image processing configuration to the PBR Material.
  49032. * @param configuration (if null the scene configuration will be use)
  49033. */
  49034. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49035. /**
  49036. * Gets the image processing configuration used either in this material.
  49037. */
  49038. /**
  49039. * Sets the Default image processing configuration used either in the this material.
  49040. *
  49041. * If sets to null, the scene one is in use.
  49042. */
  49043. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  49044. /**
  49045. * Gets wether the color curves effect is enabled.
  49046. */
  49047. /**
  49048. * Sets wether the color curves effect is enabled.
  49049. */
  49050. cameraColorCurvesEnabled: boolean;
  49051. /**
  49052. * Gets wether the color grading effect is enabled.
  49053. */
  49054. /**
  49055. * Gets wether the color grading effect is enabled.
  49056. */
  49057. cameraColorGradingEnabled: boolean;
  49058. /**
  49059. * Gets wether tonemapping is enabled or not.
  49060. */
  49061. /**
  49062. * Sets wether tonemapping is enabled or not
  49063. */
  49064. cameraToneMappingEnabled: boolean;
  49065. /**
  49066. * The camera exposure used on this material.
  49067. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49068. * This corresponds to a photographic exposure.
  49069. */
  49070. /**
  49071. * The camera exposure used on this material.
  49072. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49073. * This corresponds to a photographic exposure.
  49074. */
  49075. cameraExposure: float;
  49076. /**
  49077. * Gets The camera contrast used on this material.
  49078. */
  49079. /**
  49080. * Sets The camera contrast used on this material.
  49081. */
  49082. cameraContrast: float;
  49083. /**
  49084. * Gets the Color Grading 2D Lookup Texture.
  49085. */
  49086. /**
  49087. * Sets the Color Grading 2D Lookup Texture.
  49088. */
  49089. cameraColorGradingTexture: Nullable<BaseTexture>;
  49090. /**
  49091. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49092. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49093. * 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;
  49094. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49095. */
  49096. /**
  49097. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49098. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49099. * 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;
  49100. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49101. */
  49102. cameraColorCurves: Nullable<ColorCurves>;
  49103. /**
  49104. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49105. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49106. */
  49107. switchToBGR: boolean;
  49108. private _renderTargets;
  49109. private _reflectionControls;
  49110. private _white;
  49111. private _primaryShadowColor;
  49112. private _primaryHighlightColor;
  49113. /**
  49114. * Instantiates a Background Material in the given scene
  49115. * @param name The friendly name of the material
  49116. * @param scene The scene to add the material to
  49117. */
  49118. constructor(name: string, scene: Scene);
  49119. /**
  49120. * Gets a boolean indicating that current material needs to register RTT
  49121. */
  49122. readonly hasRenderTargetTextures: boolean;
  49123. /**
  49124. * The entire material has been created in order to prevent overdraw.
  49125. * @returns false
  49126. */
  49127. needAlphaTesting(): boolean;
  49128. /**
  49129. * The entire material has been created in order to prevent overdraw.
  49130. * @returns true if blending is enable
  49131. */
  49132. needAlphaBlending(): boolean;
  49133. /**
  49134. * Checks wether the material is ready to be rendered for a given mesh.
  49135. * @param mesh The mesh to render
  49136. * @param subMesh The submesh to check against
  49137. * @param useInstances Specify wether or not the material is used with instances
  49138. * @returns true if all the dependencies are ready (Textures, Effects...)
  49139. */
  49140. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49141. /**
  49142. * Compute the primary color according to the chosen perceptual color.
  49143. */
  49144. private _computePrimaryColorFromPerceptualColor;
  49145. /**
  49146. * Compute the highlights and shadow colors according to their chosen levels.
  49147. */
  49148. private _computePrimaryColors;
  49149. /**
  49150. * Build the uniform buffer used in the material.
  49151. */
  49152. buildUniformLayout(): void;
  49153. /**
  49154. * Unbind the material.
  49155. */
  49156. unbind(): void;
  49157. /**
  49158. * Bind only the world matrix to the material.
  49159. * @param world The world matrix to bind.
  49160. */
  49161. bindOnlyWorldMatrix(world: Matrix): void;
  49162. /**
  49163. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  49164. * @param world The world matrix to bind.
  49165. * @param subMesh The submesh to bind for.
  49166. */
  49167. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49168. /**
  49169. * Checks to see if a texture is used in the material.
  49170. * @param texture - Base texture to use.
  49171. * @returns - Boolean specifying if a texture is used in the material.
  49172. */
  49173. hasTexture(texture: BaseTexture): boolean;
  49174. /**
  49175. * Dispose the material.
  49176. * @param forceDisposeEffect Force disposal of the associated effect.
  49177. * @param forceDisposeTextures Force disposal of the associated textures.
  49178. */
  49179. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49180. /**
  49181. * Clones the material.
  49182. * @param name The cloned name.
  49183. * @returns The cloned material.
  49184. */
  49185. clone(name: string): BackgroundMaterial;
  49186. /**
  49187. * Serializes the current material to its JSON representation.
  49188. * @returns The JSON representation.
  49189. */
  49190. serialize(): any;
  49191. /**
  49192. * Gets the class name of the material
  49193. * @returns "BackgroundMaterial"
  49194. */
  49195. getClassName(): string;
  49196. /**
  49197. * Parse a JSON input to create back a background material.
  49198. * @param source The JSON data to parse
  49199. * @param scene The scene to create the parsed material in
  49200. * @param rootUrl The root url of the assets the material depends upon
  49201. * @returns the instantiated BackgroundMaterial.
  49202. */
  49203. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  49204. }
  49205. }
  49206. declare module "babylonjs/Helpers/environmentHelper" {
  49207. import { Observable } from "babylonjs/Misc/observable";
  49208. import { Nullable } from "babylonjs/types";
  49209. import { Scene } from "babylonjs/scene";
  49210. import { Vector3 } from "babylonjs/Maths/math.vector";
  49211. import { Color3 } from "babylonjs/Maths/math.color";
  49212. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49213. import { Mesh } from "babylonjs/Meshes/mesh";
  49214. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49215. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  49216. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  49217. import "babylonjs/Meshes/Builders/planeBuilder";
  49218. import "babylonjs/Meshes/Builders/boxBuilder";
  49219. /**
  49220. * Represents the different options available during the creation of
  49221. * a Environment helper.
  49222. *
  49223. * This can control the default ground, skybox and image processing setup of your scene.
  49224. */
  49225. export interface IEnvironmentHelperOptions {
  49226. /**
  49227. * Specifies wether or not to create a ground.
  49228. * True by default.
  49229. */
  49230. createGround: boolean;
  49231. /**
  49232. * Specifies the ground size.
  49233. * 15 by default.
  49234. */
  49235. groundSize: number;
  49236. /**
  49237. * The texture used on the ground for the main color.
  49238. * Comes from the BabylonJS CDN by default.
  49239. *
  49240. * Remarks: Can be either a texture or a url.
  49241. */
  49242. groundTexture: string | BaseTexture;
  49243. /**
  49244. * The color mixed in the ground texture by default.
  49245. * BabylonJS clearColor by default.
  49246. */
  49247. groundColor: Color3;
  49248. /**
  49249. * Specifies the ground opacity.
  49250. * 1 by default.
  49251. */
  49252. groundOpacity: number;
  49253. /**
  49254. * Enables the ground to receive shadows.
  49255. * True by default.
  49256. */
  49257. enableGroundShadow: boolean;
  49258. /**
  49259. * Helps preventing the shadow to be fully black on the ground.
  49260. * 0.5 by default.
  49261. */
  49262. groundShadowLevel: number;
  49263. /**
  49264. * Creates a mirror texture attach to the ground.
  49265. * false by default.
  49266. */
  49267. enableGroundMirror: boolean;
  49268. /**
  49269. * Specifies the ground mirror size ratio.
  49270. * 0.3 by default as the default kernel is 64.
  49271. */
  49272. groundMirrorSizeRatio: number;
  49273. /**
  49274. * Specifies the ground mirror blur kernel size.
  49275. * 64 by default.
  49276. */
  49277. groundMirrorBlurKernel: number;
  49278. /**
  49279. * Specifies the ground mirror visibility amount.
  49280. * 1 by default
  49281. */
  49282. groundMirrorAmount: number;
  49283. /**
  49284. * Specifies the ground mirror reflectance weight.
  49285. * This uses the standard weight of the background material to setup the fresnel effect
  49286. * of the mirror.
  49287. * 1 by default.
  49288. */
  49289. groundMirrorFresnelWeight: number;
  49290. /**
  49291. * Specifies the ground mirror Falloff distance.
  49292. * This can helps reducing the size of the reflection.
  49293. * 0 by Default.
  49294. */
  49295. groundMirrorFallOffDistance: number;
  49296. /**
  49297. * Specifies the ground mirror texture type.
  49298. * Unsigned Int by Default.
  49299. */
  49300. groundMirrorTextureType: number;
  49301. /**
  49302. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  49303. * the shown objects.
  49304. */
  49305. groundYBias: number;
  49306. /**
  49307. * Specifies wether or not to create a skybox.
  49308. * True by default.
  49309. */
  49310. createSkybox: boolean;
  49311. /**
  49312. * Specifies the skybox size.
  49313. * 20 by default.
  49314. */
  49315. skyboxSize: number;
  49316. /**
  49317. * The texture used on the skybox for the main color.
  49318. * Comes from the BabylonJS CDN by default.
  49319. *
  49320. * Remarks: Can be either a texture or a url.
  49321. */
  49322. skyboxTexture: string | BaseTexture;
  49323. /**
  49324. * The color mixed in the skybox texture by default.
  49325. * BabylonJS clearColor by default.
  49326. */
  49327. skyboxColor: Color3;
  49328. /**
  49329. * The background rotation around the Y axis of the scene.
  49330. * This helps aligning the key lights of your scene with the background.
  49331. * 0 by default.
  49332. */
  49333. backgroundYRotation: number;
  49334. /**
  49335. * Compute automatically the size of the elements to best fit with the scene.
  49336. */
  49337. sizeAuto: boolean;
  49338. /**
  49339. * Default position of the rootMesh if autoSize is not true.
  49340. */
  49341. rootPosition: Vector3;
  49342. /**
  49343. * Sets up the image processing in the scene.
  49344. * true by default.
  49345. */
  49346. setupImageProcessing: boolean;
  49347. /**
  49348. * The texture used as your environment texture in the scene.
  49349. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  49350. *
  49351. * Remarks: Can be either a texture or a url.
  49352. */
  49353. environmentTexture: string | BaseTexture;
  49354. /**
  49355. * The value of the exposure to apply to the scene.
  49356. * 0.6 by default if setupImageProcessing is true.
  49357. */
  49358. cameraExposure: number;
  49359. /**
  49360. * The value of the contrast to apply to the scene.
  49361. * 1.6 by default if setupImageProcessing is true.
  49362. */
  49363. cameraContrast: number;
  49364. /**
  49365. * Specifies wether or not tonemapping should be enabled in the scene.
  49366. * true by default if setupImageProcessing is true.
  49367. */
  49368. toneMappingEnabled: boolean;
  49369. }
  49370. /**
  49371. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  49372. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  49373. * It also helps with the default setup of your imageProcessing configuration.
  49374. */
  49375. export class EnvironmentHelper {
  49376. /**
  49377. * Default ground texture URL.
  49378. */
  49379. private static _groundTextureCDNUrl;
  49380. /**
  49381. * Default skybox texture URL.
  49382. */
  49383. private static _skyboxTextureCDNUrl;
  49384. /**
  49385. * Default environment texture URL.
  49386. */
  49387. private static _environmentTextureCDNUrl;
  49388. /**
  49389. * Creates the default options for the helper.
  49390. */
  49391. private static _getDefaultOptions;
  49392. private _rootMesh;
  49393. /**
  49394. * Gets the root mesh created by the helper.
  49395. */
  49396. readonly rootMesh: Mesh;
  49397. private _skybox;
  49398. /**
  49399. * Gets the skybox created by the helper.
  49400. */
  49401. readonly skybox: Nullable<Mesh>;
  49402. private _skyboxTexture;
  49403. /**
  49404. * Gets the skybox texture created by the helper.
  49405. */
  49406. readonly skyboxTexture: Nullable<BaseTexture>;
  49407. private _skyboxMaterial;
  49408. /**
  49409. * Gets the skybox material created by the helper.
  49410. */
  49411. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  49412. private _ground;
  49413. /**
  49414. * Gets the ground mesh created by the helper.
  49415. */
  49416. readonly ground: Nullable<Mesh>;
  49417. private _groundTexture;
  49418. /**
  49419. * Gets the ground texture created by the helper.
  49420. */
  49421. readonly groundTexture: Nullable<BaseTexture>;
  49422. private _groundMirror;
  49423. /**
  49424. * Gets the ground mirror created by the helper.
  49425. */
  49426. readonly groundMirror: Nullable<MirrorTexture>;
  49427. /**
  49428. * Gets the ground mirror render list to helps pushing the meshes
  49429. * you wish in the ground reflection.
  49430. */
  49431. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  49432. private _groundMaterial;
  49433. /**
  49434. * Gets the ground material created by the helper.
  49435. */
  49436. readonly groundMaterial: Nullable<BackgroundMaterial>;
  49437. /**
  49438. * Stores the creation options.
  49439. */
  49440. private readonly _scene;
  49441. private _options;
  49442. /**
  49443. * This observable will be notified with any error during the creation of the environment,
  49444. * mainly texture creation errors.
  49445. */
  49446. onErrorObservable: Observable<{
  49447. message?: string;
  49448. exception?: any;
  49449. }>;
  49450. /**
  49451. * constructor
  49452. * @param options Defines the options we want to customize the helper
  49453. * @param scene The scene to add the material to
  49454. */
  49455. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  49456. /**
  49457. * Updates the background according to the new options
  49458. * @param options
  49459. */
  49460. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  49461. /**
  49462. * Sets the primary color of all the available elements.
  49463. * @param color the main color to affect to the ground and the background
  49464. */
  49465. setMainColor(color: Color3): void;
  49466. /**
  49467. * Setup the image processing according to the specified options.
  49468. */
  49469. private _setupImageProcessing;
  49470. /**
  49471. * Setup the environment texture according to the specified options.
  49472. */
  49473. private _setupEnvironmentTexture;
  49474. /**
  49475. * Setup the background according to the specified options.
  49476. */
  49477. private _setupBackground;
  49478. /**
  49479. * Get the scene sizes according to the setup.
  49480. */
  49481. private _getSceneSize;
  49482. /**
  49483. * Setup the ground according to the specified options.
  49484. */
  49485. private _setupGround;
  49486. /**
  49487. * Setup the ground material according to the specified options.
  49488. */
  49489. private _setupGroundMaterial;
  49490. /**
  49491. * Setup the ground diffuse texture according to the specified options.
  49492. */
  49493. private _setupGroundDiffuseTexture;
  49494. /**
  49495. * Setup the ground mirror texture according to the specified options.
  49496. */
  49497. private _setupGroundMirrorTexture;
  49498. /**
  49499. * Setup the ground to receive the mirror texture.
  49500. */
  49501. private _setupMirrorInGroundMaterial;
  49502. /**
  49503. * Setup the skybox according to the specified options.
  49504. */
  49505. private _setupSkybox;
  49506. /**
  49507. * Setup the skybox material according to the specified options.
  49508. */
  49509. private _setupSkyboxMaterial;
  49510. /**
  49511. * Setup the skybox reflection texture according to the specified options.
  49512. */
  49513. private _setupSkyboxReflectionTexture;
  49514. private _errorHandler;
  49515. /**
  49516. * Dispose all the elements created by the Helper.
  49517. */
  49518. dispose(): void;
  49519. }
  49520. }
  49521. declare module "babylonjs/Helpers/photoDome" {
  49522. import { Observable } from "babylonjs/Misc/observable";
  49523. import { Nullable } from "babylonjs/types";
  49524. import { Scene } from "babylonjs/scene";
  49525. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49526. import { Mesh } from "babylonjs/Meshes/mesh";
  49527. import { Texture } from "babylonjs/Materials/Textures/texture";
  49528. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  49529. import "babylonjs/Meshes/Builders/sphereBuilder";
  49530. /**
  49531. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  49532. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  49533. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  49534. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49535. */
  49536. export class PhotoDome extends TransformNode {
  49537. /**
  49538. * Define the image as a Monoscopic panoramic 360 image.
  49539. */
  49540. static readonly MODE_MONOSCOPIC: number;
  49541. /**
  49542. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49543. */
  49544. static readonly MODE_TOPBOTTOM: number;
  49545. /**
  49546. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49547. */
  49548. static readonly MODE_SIDEBYSIDE: number;
  49549. private _useDirectMapping;
  49550. /**
  49551. * The texture being displayed on the sphere
  49552. */
  49553. protected _photoTexture: Texture;
  49554. /**
  49555. * Gets or sets the texture being displayed on the sphere
  49556. */
  49557. photoTexture: Texture;
  49558. /**
  49559. * Observable raised when an error occured while loading the 360 image
  49560. */
  49561. onLoadErrorObservable: Observable<string>;
  49562. /**
  49563. * The skybox material
  49564. */
  49565. protected _material: BackgroundMaterial;
  49566. /**
  49567. * The surface used for the skybox
  49568. */
  49569. protected _mesh: Mesh;
  49570. /**
  49571. * Gets the mesh used for the skybox.
  49572. */
  49573. readonly mesh: Mesh;
  49574. /**
  49575. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49576. * Also see the options.resolution property.
  49577. */
  49578. fovMultiplier: number;
  49579. private _imageMode;
  49580. /**
  49581. * Gets or set the current video mode for the video. It can be:
  49582. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  49583. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49584. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49585. */
  49586. imageMode: number;
  49587. /**
  49588. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  49589. * @param name Element's name, child elements will append suffixes for their own names.
  49590. * @param urlsOfPhoto defines the url of the photo to display
  49591. * @param options defines an object containing optional or exposed sub element properties
  49592. * @param onError defines a callback called when an error occured while loading the texture
  49593. */
  49594. constructor(name: string, urlOfPhoto: string, options: {
  49595. resolution?: number;
  49596. size?: number;
  49597. useDirectMapping?: boolean;
  49598. faceForward?: boolean;
  49599. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  49600. private _onBeforeCameraRenderObserver;
  49601. private _changeImageMode;
  49602. /**
  49603. * Releases resources associated with this node.
  49604. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49605. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49606. */
  49607. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49608. }
  49609. }
  49610. declare module "babylonjs/Misc/rgbdTextureTools" {
  49611. import "babylonjs/Shaders/rgbdDecode.fragment";
  49612. import "babylonjs/Engines/Extensions/engine.renderTarget";
  49613. import { Texture } from "babylonjs/Materials/Textures/texture";
  49614. /**
  49615. * Class used to host RGBD texture specific utilities
  49616. */
  49617. export class RGBDTextureTools {
  49618. /**
  49619. * Expand the RGBD Texture from RGBD to Half Float if possible.
  49620. * @param texture the texture to expand.
  49621. */
  49622. static ExpandRGBDTexture(texture: Texture): void;
  49623. }
  49624. }
  49625. declare module "babylonjs/Misc/brdfTextureTools" {
  49626. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49627. import { Scene } from "babylonjs/scene";
  49628. /**
  49629. * Class used to host texture specific utilities
  49630. */
  49631. export class BRDFTextureTools {
  49632. /**
  49633. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  49634. * @param scene defines the hosting scene
  49635. * @returns the environment BRDF texture
  49636. */
  49637. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  49638. private static _environmentBRDFBase64Texture;
  49639. }
  49640. }
  49641. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  49642. import { Nullable } from "babylonjs/types";
  49643. import { Color3 } from "babylonjs/Maths/math.color";
  49644. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49645. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49646. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49647. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49648. import { Engine } from "babylonjs/Engines/engine";
  49649. import { Scene } from "babylonjs/scene";
  49650. /**
  49651. * @hidden
  49652. */
  49653. export interface IMaterialClearCoatDefines {
  49654. CLEARCOAT: boolean;
  49655. CLEARCOAT_DEFAULTIOR: boolean;
  49656. CLEARCOAT_TEXTURE: boolean;
  49657. CLEARCOAT_TEXTUREDIRECTUV: number;
  49658. CLEARCOAT_BUMP: boolean;
  49659. CLEARCOAT_BUMPDIRECTUV: number;
  49660. CLEARCOAT_TINT: boolean;
  49661. CLEARCOAT_TINT_TEXTURE: boolean;
  49662. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49663. /** @hidden */
  49664. _areTexturesDirty: boolean;
  49665. }
  49666. /**
  49667. * Define the code related to the clear coat parameters of the pbr material.
  49668. */
  49669. export class PBRClearCoatConfiguration {
  49670. /**
  49671. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49672. * The default fits with a polyurethane material.
  49673. */
  49674. private static readonly _DefaultIndexOfRefraction;
  49675. private _isEnabled;
  49676. /**
  49677. * Defines if the clear coat is enabled in the material.
  49678. */
  49679. isEnabled: boolean;
  49680. /**
  49681. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  49682. */
  49683. intensity: number;
  49684. /**
  49685. * Defines the clear coat layer roughness.
  49686. */
  49687. roughness: number;
  49688. private _indexOfRefraction;
  49689. /**
  49690. * Defines the index of refraction of the clear coat.
  49691. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49692. * The default fits with a polyurethane material.
  49693. * Changing the default value is more performance intensive.
  49694. */
  49695. indexOfRefraction: number;
  49696. private _texture;
  49697. /**
  49698. * Stores the clear coat values in a texture.
  49699. */
  49700. texture: Nullable<BaseTexture>;
  49701. private _bumpTexture;
  49702. /**
  49703. * Define the clear coat specific bump texture.
  49704. */
  49705. bumpTexture: Nullable<BaseTexture>;
  49706. private _isTintEnabled;
  49707. /**
  49708. * Defines if the clear coat tint is enabled in the material.
  49709. */
  49710. isTintEnabled: boolean;
  49711. /**
  49712. * Defines the clear coat tint of the material.
  49713. * This is only use if tint is enabled
  49714. */
  49715. tintColor: Color3;
  49716. /**
  49717. * Defines the distance at which the tint color should be found in the
  49718. * clear coat media.
  49719. * This is only use if tint is enabled
  49720. */
  49721. tintColorAtDistance: number;
  49722. /**
  49723. * Defines the clear coat layer thickness.
  49724. * This is only use if tint is enabled
  49725. */
  49726. tintThickness: number;
  49727. private _tintTexture;
  49728. /**
  49729. * Stores the clear tint values in a texture.
  49730. * rgb is tint
  49731. * a is a thickness factor
  49732. */
  49733. tintTexture: Nullable<BaseTexture>;
  49734. /** @hidden */
  49735. private _internalMarkAllSubMeshesAsTexturesDirty;
  49736. /** @hidden */
  49737. _markAllSubMeshesAsTexturesDirty(): void;
  49738. /**
  49739. * Instantiate a new istance of clear coat configuration.
  49740. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49741. */
  49742. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49743. /**
  49744. * Gets wehter the submesh is ready to be used or not.
  49745. * @param defines the list of "defines" to update.
  49746. * @param scene defines the scene the material belongs to.
  49747. * @param engine defines the engine the material belongs to.
  49748. * @param disableBumpMap defines wether the material disables bump or not.
  49749. * @returns - boolean indicating that the submesh is ready or not.
  49750. */
  49751. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  49752. /**
  49753. * Checks to see if a texture is used in the material.
  49754. * @param defines the list of "defines" to update.
  49755. * @param scene defines the scene to the material belongs to.
  49756. */
  49757. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  49758. /**
  49759. * Binds the material data.
  49760. * @param uniformBuffer defines the Uniform buffer to fill in.
  49761. * @param scene defines the scene the material belongs to.
  49762. * @param engine defines the engine the material belongs to.
  49763. * @param disableBumpMap defines wether the material disables bump or not.
  49764. * @param isFrozen defines wether the material is frozen or not.
  49765. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49766. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49767. */
  49768. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  49769. /**
  49770. * Checks to see if a texture is used in the material.
  49771. * @param texture - Base texture to use.
  49772. * @returns - Boolean specifying if a texture is used in the material.
  49773. */
  49774. hasTexture(texture: BaseTexture): boolean;
  49775. /**
  49776. * Returns an array of the actively used textures.
  49777. * @param activeTextures Array of BaseTextures
  49778. */
  49779. getActiveTextures(activeTextures: BaseTexture[]): void;
  49780. /**
  49781. * Returns the animatable textures.
  49782. * @param animatables Array of animatable textures.
  49783. */
  49784. getAnimatables(animatables: IAnimatable[]): void;
  49785. /**
  49786. * Disposes the resources of the material.
  49787. * @param forceDisposeTextures - Forces the disposal of all textures.
  49788. */
  49789. dispose(forceDisposeTextures?: boolean): void;
  49790. /**
  49791. * Get the current class name of the texture useful for serialization or dynamic coding.
  49792. * @returns "PBRClearCoatConfiguration"
  49793. */
  49794. getClassName(): string;
  49795. /**
  49796. * Add fallbacks to the effect fallbacks list.
  49797. * @param defines defines the Base texture to use.
  49798. * @param fallbacks defines the current fallback list.
  49799. * @param currentRank defines the current fallback rank.
  49800. * @returns the new fallback rank.
  49801. */
  49802. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49803. /**
  49804. * Add the required uniforms to the current list.
  49805. * @param uniforms defines the current uniform list.
  49806. */
  49807. static AddUniforms(uniforms: string[]): void;
  49808. /**
  49809. * Add the required samplers to the current list.
  49810. * @param samplers defines the current sampler list.
  49811. */
  49812. static AddSamplers(samplers: string[]): void;
  49813. /**
  49814. * Add the required uniforms to the current buffer.
  49815. * @param uniformBuffer defines the current uniform buffer.
  49816. */
  49817. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49818. /**
  49819. * Makes a duplicate of the current configuration into another one.
  49820. * @param clearCoatConfiguration define the config where to copy the info
  49821. */
  49822. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  49823. /**
  49824. * Serializes this clear coat configuration.
  49825. * @returns - An object with the serialized config.
  49826. */
  49827. serialize(): any;
  49828. /**
  49829. * Parses a anisotropy Configuration from a serialized object.
  49830. * @param source - Serialized object.
  49831. * @param scene Defines the scene we are parsing for
  49832. * @param rootUrl Defines the rootUrl to load from
  49833. */
  49834. parse(source: any, scene: Scene, rootUrl: string): void;
  49835. }
  49836. }
  49837. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  49838. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49839. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49840. import { Vector2 } from "babylonjs/Maths/math.vector";
  49841. import { Scene } from "babylonjs/scene";
  49842. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49843. import { Nullable } from "babylonjs/types";
  49844. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49845. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49846. /**
  49847. * @hidden
  49848. */
  49849. export interface IMaterialAnisotropicDefines {
  49850. ANISOTROPIC: boolean;
  49851. ANISOTROPIC_TEXTURE: boolean;
  49852. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49853. MAINUV1: boolean;
  49854. _areTexturesDirty: boolean;
  49855. _needUVs: boolean;
  49856. }
  49857. /**
  49858. * Define the code related to the anisotropic parameters of the pbr material.
  49859. */
  49860. export class PBRAnisotropicConfiguration {
  49861. private _isEnabled;
  49862. /**
  49863. * Defines if the anisotropy is enabled in the material.
  49864. */
  49865. isEnabled: boolean;
  49866. /**
  49867. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  49868. */
  49869. intensity: number;
  49870. /**
  49871. * Defines if the effect is along the tangents, bitangents or in between.
  49872. * By default, the effect is "strectching" the highlights along the tangents.
  49873. */
  49874. direction: Vector2;
  49875. private _texture;
  49876. /**
  49877. * Stores the anisotropy values in a texture.
  49878. * rg is direction (like normal from -1 to 1)
  49879. * b is a intensity
  49880. */
  49881. texture: Nullable<BaseTexture>;
  49882. /** @hidden */
  49883. private _internalMarkAllSubMeshesAsTexturesDirty;
  49884. /** @hidden */
  49885. _markAllSubMeshesAsTexturesDirty(): void;
  49886. /**
  49887. * Instantiate a new istance of anisotropy configuration.
  49888. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49889. */
  49890. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49891. /**
  49892. * Specifies that the submesh is ready to be used.
  49893. * @param defines the list of "defines" to update.
  49894. * @param scene defines the scene the material belongs to.
  49895. * @returns - boolean indicating that the submesh is ready or not.
  49896. */
  49897. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  49898. /**
  49899. * Checks to see if a texture is used in the material.
  49900. * @param defines the list of "defines" to update.
  49901. * @param mesh the mesh we are preparing the defines for.
  49902. * @param scene defines the scene the material belongs to.
  49903. */
  49904. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  49905. /**
  49906. * Binds the material data.
  49907. * @param uniformBuffer defines the Uniform buffer to fill in.
  49908. * @param scene defines the scene the material belongs to.
  49909. * @param isFrozen defines wether the material is frozen or not.
  49910. */
  49911. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49912. /**
  49913. * Checks to see if a texture is used in the material.
  49914. * @param texture - Base texture to use.
  49915. * @returns - Boolean specifying if a texture is used in the material.
  49916. */
  49917. hasTexture(texture: BaseTexture): boolean;
  49918. /**
  49919. * Returns an array of the actively used textures.
  49920. * @param activeTextures Array of BaseTextures
  49921. */
  49922. getActiveTextures(activeTextures: BaseTexture[]): void;
  49923. /**
  49924. * Returns the animatable textures.
  49925. * @param animatables Array of animatable textures.
  49926. */
  49927. getAnimatables(animatables: IAnimatable[]): void;
  49928. /**
  49929. * Disposes the resources of the material.
  49930. * @param forceDisposeTextures - Forces the disposal of all textures.
  49931. */
  49932. dispose(forceDisposeTextures?: boolean): void;
  49933. /**
  49934. * Get the current class name of the texture useful for serialization or dynamic coding.
  49935. * @returns "PBRAnisotropicConfiguration"
  49936. */
  49937. getClassName(): string;
  49938. /**
  49939. * Add fallbacks to the effect fallbacks list.
  49940. * @param defines defines the Base texture to use.
  49941. * @param fallbacks defines the current fallback list.
  49942. * @param currentRank defines the current fallback rank.
  49943. * @returns the new fallback rank.
  49944. */
  49945. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49946. /**
  49947. * Add the required uniforms to the current list.
  49948. * @param uniforms defines the current uniform list.
  49949. */
  49950. static AddUniforms(uniforms: string[]): void;
  49951. /**
  49952. * Add the required uniforms to the current buffer.
  49953. * @param uniformBuffer defines the current uniform buffer.
  49954. */
  49955. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49956. /**
  49957. * Add the required samplers to the current list.
  49958. * @param samplers defines the current sampler list.
  49959. */
  49960. static AddSamplers(samplers: string[]): void;
  49961. /**
  49962. * Makes a duplicate of the current configuration into another one.
  49963. * @param anisotropicConfiguration define the config where to copy the info
  49964. */
  49965. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  49966. /**
  49967. * Serializes this anisotropy configuration.
  49968. * @returns - An object with the serialized config.
  49969. */
  49970. serialize(): any;
  49971. /**
  49972. * Parses a anisotropy Configuration from a serialized object.
  49973. * @param source - Serialized object.
  49974. * @param scene Defines the scene we are parsing for
  49975. * @param rootUrl Defines the rootUrl to load from
  49976. */
  49977. parse(source: any, scene: Scene, rootUrl: string): void;
  49978. }
  49979. }
  49980. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  49981. import { Scene } from "babylonjs/scene";
  49982. /**
  49983. * @hidden
  49984. */
  49985. export interface IMaterialBRDFDefines {
  49986. BRDF_V_HEIGHT_CORRELATED: boolean;
  49987. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49988. SPHERICAL_HARMONICS: boolean;
  49989. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49990. /** @hidden */
  49991. _areMiscDirty: boolean;
  49992. }
  49993. /**
  49994. * Define the code related to the BRDF parameters of the pbr material.
  49995. */
  49996. export class PBRBRDFConfiguration {
  49997. /**
  49998. * Default value used for the energy conservation.
  49999. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50000. */
  50001. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  50002. /**
  50003. * Default value used for the Smith Visibility Height Correlated mode.
  50004. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50005. */
  50006. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  50007. /**
  50008. * Default value used for the IBL diffuse part.
  50009. * This can help switching back to the polynomials mode globally which is a tiny bit
  50010. * less GPU intensive at the drawback of a lower quality.
  50011. */
  50012. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  50013. /**
  50014. * Default value used for activating energy conservation for the specular workflow.
  50015. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50016. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50017. */
  50018. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  50019. private _useEnergyConservation;
  50020. /**
  50021. * Defines if the material uses energy conservation.
  50022. */
  50023. useEnergyConservation: boolean;
  50024. private _useSmithVisibilityHeightCorrelated;
  50025. /**
  50026. * LEGACY Mode set to false
  50027. * Defines if the material uses height smith correlated visibility term.
  50028. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  50029. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  50030. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  50031. * Not relying on height correlated will also disable energy conservation.
  50032. */
  50033. useSmithVisibilityHeightCorrelated: boolean;
  50034. private _useSphericalHarmonics;
  50035. /**
  50036. * LEGACY Mode set to false
  50037. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  50038. * diffuse part of the IBL.
  50039. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  50040. * to the ground truth.
  50041. */
  50042. useSphericalHarmonics: boolean;
  50043. private _useSpecularGlossinessInputEnergyConservation;
  50044. /**
  50045. * Defines if the material uses energy conservation, when the specular workflow is active.
  50046. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50047. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50048. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  50049. */
  50050. useSpecularGlossinessInputEnergyConservation: boolean;
  50051. /** @hidden */
  50052. private _internalMarkAllSubMeshesAsMiscDirty;
  50053. /** @hidden */
  50054. _markAllSubMeshesAsMiscDirty(): void;
  50055. /**
  50056. * Instantiate a new istance of clear coat configuration.
  50057. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50058. */
  50059. constructor(markAllSubMeshesAsMiscDirty: () => void);
  50060. /**
  50061. * Checks to see if a texture is used in the material.
  50062. * @param defines the list of "defines" to update.
  50063. */
  50064. prepareDefines(defines: IMaterialBRDFDefines): void;
  50065. /**
  50066. * Get the current class name of the texture useful for serialization or dynamic coding.
  50067. * @returns "PBRClearCoatConfiguration"
  50068. */
  50069. getClassName(): string;
  50070. /**
  50071. * Makes a duplicate of the current configuration into another one.
  50072. * @param brdfConfiguration define the config where to copy the info
  50073. */
  50074. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  50075. /**
  50076. * Serializes this BRDF configuration.
  50077. * @returns - An object with the serialized config.
  50078. */
  50079. serialize(): any;
  50080. /**
  50081. * Parses a anisotropy Configuration from a serialized object.
  50082. * @param source - Serialized object.
  50083. * @param scene Defines the scene we are parsing for
  50084. * @param rootUrl Defines the rootUrl to load from
  50085. */
  50086. parse(source: any, scene: Scene, rootUrl: string): void;
  50087. }
  50088. }
  50089. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  50090. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  50091. import { Color3 } from "babylonjs/Maths/math.color";
  50092. import { Scene } from "babylonjs/scene";
  50093. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50094. import { Nullable } from "babylonjs/types";
  50095. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  50096. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  50097. /**
  50098. * @hidden
  50099. */
  50100. export interface IMaterialSheenDefines {
  50101. SHEEN: boolean;
  50102. SHEEN_TEXTURE: boolean;
  50103. SHEEN_TEXTUREDIRECTUV: number;
  50104. SHEEN_LINKWITHALBEDO: boolean;
  50105. /** @hidden */
  50106. _areTexturesDirty: boolean;
  50107. }
  50108. /**
  50109. * Define the code related to the Sheen parameters of the pbr material.
  50110. */
  50111. export class PBRSheenConfiguration {
  50112. private _isEnabled;
  50113. /**
  50114. * Defines if the material uses sheen.
  50115. */
  50116. isEnabled: boolean;
  50117. private _linkSheenWithAlbedo;
  50118. /**
  50119. * Defines if the sheen is linked to the sheen color.
  50120. */
  50121. linkSheenWithAlbedo: boolean;
  50122. /**
  50123. * Defines the sheen intensity.
  50124. */
  50125. intensity: number;
  50126. /**
  50127. * Defines the sheen color.
  50128. */
  50129. color: Color3;
  50130. private _texture;
  50131. /**
  50132. * Stores the sheen tint values in a texture.
  50133. * rgb is tint
  50134. * a is a intensity
  50135. */
  50136. texture: Nullable<BaseTexture>;
  50137. /** @hidden */
  50138. private _internalMarkAllSubMeshesAsTexturesDirty;
  50139. /** @hidden */
  50140. _markAllSubMeshesAsTexturesDirty(): void;
  50141. /**
  50142. * Instantiate a new istance of clear coat configuration.
  50143. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50144. */
  50145. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50146. /**
  50147. * Specifies that the submesh is ready to be used.
  50148. * @param defines the list of "defines" to update.
  50149. * @param scene defines the scene the material belongs to.
  50150. * @returns - boolean indicating that the submesh is ready or not.
  50151. */
  50152. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  50153. /**
  50154. * Checks to see if a texture is used in the material.
  50155. * @param defines the list of "defines" to update.
  50156. * @param scene defines the scene the material belongs to.
  50157. */
  50158. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  50159. /**
  50160. * Binds the material data.
  50161. * @param uniformBuffer defines the Uniform buffer to fill in.
  50162. * @param scene defines the scene the material belongs to.
  50163. * @param isFrozen defines wether the material is frozen or not.
  50164. */
  50165. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50166. /**
  50167. * Checks to see if a texture is used in the material.
  50168. * @param texture - Base texture to use.
  50169. * @returns - Boolean specifying if a texture is used in the material.
  50170. */
  50171. hasTexture(texture: BaseTexture): boolean;
  50172. /**
  50173. * Returns an array of the actively used textures.
  50174. * @param activeTextures Array of BaseTextures
  50175. */
  50176. getActiveTextures(activeTextures: BaseTexture[]): void;
  50177. /**
  50178. * Returns the animatable textures.
  50179. * @param animatables Array of animatable textures.
  50180. */
  50181. getAnimatables(animatables: IAnimatable[]): void;
  50182. /**
  50183. * Disposes the resources of the material.
  50184. * @param forceDisposeTextures - Forces the disposal of all textures.
  50185. */
  50186. dispose(forceDisposeTextures?: boolean): void;
  50187. /**
  50188. * Get the current class name of the texture useful for serialization or dynamic coding.
  50189. * @returns "PBRSheenConfiguration"
  50190. */
  50191. getClassName(): string;
  50192. /**
  50193. * Add fallbacks to the effect fallbacks list.
  50194. * @param defines defines the Base texture to use.
  50195. * @param fallbacks defines the current fallback list.
  50196. * @param currentRank defines the current fallback rank.
  50197. * @returns the new fallback rank.
  50198. */
  50199. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50200. /**
  50201. * Add the required uniforms to the current list.
  50202. * @param uniforms defines the current uniform list.
  50203. */
  50204. static AddUniforms(uniforms: string[]): void;
  50205. /**
  50206. * Add the required uniforms to the current buffer.
  50207. * @param uniformBuffer defines the current uniform buffer.
  50208. */
  50209. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50210. /**
  50211. * Add the required samplers to the current list.
  50212. * @param samplers defines the current sampler list.
  50213. */
  50214. static AddSamplers(samplers: string[]): void;
  50215. /**
  50216. * Makes a duplicate of the current configuration into another one.
  50217. * @param sheenConfiguration define the config where to copy the info
  50218. */
  50219. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  50220. /**
  50221. * Serializes this BRDF configuration.
  50222. * @returns - An object with the serialized config.
  50223. */
  50224. serialize(): any;
  50225. /**
  50226. * Parses a anisotropy Configuration from a serialized object.
  50227. * @param source - Serialized object.
  50228. * @param scene Defines the scene we are parsing for
  50229. * @param rootUrl Defines the rootUrl to load from
  50230. */
  50231. parse(source: any, scene: Scene, rootUrl: string): void;
  50232. }
  50233. }
  50234. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  50235. import { Nullable } from "babylonjs/types";
  50236. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  50237. import { Color3 } from "babylonjs/Maths/math.color";
  50238. import { SmartArray } from "babylonjs/Misc/smartArray";
  50239. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50240. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50241. import { Effect } from "babylonjs/Materials/effect";
  50242. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  50243. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  50244. import { Engine } from "babylonjs/Engines/engine";
  50245. import { Scene } from "babylonjs/scene";
  50246. /**
  50247. * @hidden
  50248. */
  50249. export interface IMaterialSubSurfaceDefines {
  50250. SUBSURFACE: boolean;
  50251. SS_REFRACTION: boolean;
  50252. SS_TRANSLUCENCY: boolean;
  50253. SS_SCATERRING: boolean;
  50254. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50255. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50256. SS_REFRACTIONMAP_3D: boolean;
  50257. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50258. SS_LODINREFRACTIONALPHA: boolean;
  50259. SS_GAMMAREFRACTION: boolean;
  50260. SS_RGBDREFRACTION: boolean;
  50261. SS_LINEARSPECULARREFRACTION: boolean;
  50262. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50263. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50264. /** @hidden */
  50265. _areTexturesDirty: boolean;
  50266. }
  50267. /**
  50268. * Define the code related to the sub surface parameters of the pbr material.
  50269. */
  50270. export class PBRSubSurfaceConfiguration {
  50271. private _isRefractionEnabled;
  50272. /**
  50273. * Defines if the refraction is enabled in the material.
  50274. */
  50275. isRefractionEnabled: boolean;
  50276. private _isTranslucencyEnabled;
  50277. /**
  50278. * Defines if the translucency is enabled in the material.
  50279. */
  50280. isTranslucencyEnabled: boolean;
  50281. private _isScatteringEnabled;
  50282. /**
  50283. * Defines the refraction intensity of the material.
  50284. * The refraction when enabled replaces the Diffuse part of the material.
  50285. * The intensity helps transitionning between diffuse and refraction.
  50286. */
  50287. refractionIntensity: number;
  50288. /**
  50289. * Defines the translucency intensity of the material.
  50290. * When translucency has been enabled, this defines how much of the "translucency"
  50291. * is addded to the diffuse part of the material.
  50292. */
  50293. translucencyIntensity: number;
  50294. /**
  50295. * Defines the scattering intensity of the material.
  50296. * When scattering has been enabled, this defines how much of the "scattered light"
  50297. * is addded to the diffuse part of the material.
  50298. */
  50299. scatteringIntensity: number;
  50300. private _thicknessTexture;
  50301. /**
  50302. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  50303. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  50304. * 0 would mean minimumThickness
  50305. * 1 would mean maximumThickness
  50306. * The other channels might be use as a mask to vary the different effects intensity.
  50307. */
  50308. thicknessTexture: Nullable<BaseTexture>;
  50309. private _refractionTexture;
  50310. /**
  50311. * Defines the texture to use for refraction.
  50312. */
  50313. refractionTexture: Nullable<BaseTexture>;
  50314. private _indexOfRefraction;
  50315. /**
  50316. * Defines the index of refraction used in the material.
  50317. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  50318. */
  50319. indexOfRefraction: number;
  50320. private _invertRefractionY;
  50321. /**
  50322. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50323. */
  50324. invertRefractionY: boolean;
  50325. private _linkRefractionWithTransparency;
  50326. /**
  50327. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50328. * Materials half opaque for instance using refraction could benefit from this control.
  50329. */
  50330. linkRefractionWithTransparency: boolean;
  50331. /**
  50332. * Defines the minimum thickness stored in the thickness map.
  50333. * If no thickness map is defined, this value will be used to simulate thickness.
  50334. */
  50335. minimumThickness: number;
  50336. /**
  50337. * Defines the maximum thickness stored in the thickness map.
  50338. */
  50339. maximumThickness: number;
  50340. /**
  50341. * Defines the volume tint of the material.
  50342. * This is used for both translucency and scattering.
  50343. */
  50344. tintColor: Color3;
  50345. /**
  50346. * Defines the distance at which the tint color should be found in the media.
  50347. * This is used for refraction only.
  50348. */
  50349. tintColorAtDistance: number;
  50350. /**
  50351. * Defines how far each channel transmit through the media.
  50352. * It is defined as a color to simplify it selection.
  50353. */
  50354. diffusionDistance: Color3;
  50355. private _useMaskFromThicknessTexture;
  50356. /**
  50357. * Stores the intensity of the different subsurface effects in the thickness texture.
  50358. * * the green channel is the translucency intensity.
  50359. * * the blue channel is the scattering intensity.
  50360. * * the alpha channel is the refraction intensity.
  50361. */
  50362. useMaskFromThicknessTexture: boolean;
  50363. /** @hidden */
  50364. private _internalMarkAllSubMeshesAsTexturesDirty;
  50365. /** @hidden */
  50366. _markAllSubMeshesAsTexturesDirty(): void;
  50367. /**
  50368. * Instantiate a new istance of sub surface configuration.
  50369. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50370. */
  50371. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50372. /**
  50373. * Gets wehter the submesh is ready to be used or not.
  50374. * @param defines the list of "defines" to update.
  50375. * @param scene defines the scene the material belongs to.
  50376. * @returns - boolean indicating that the submesh is ready or not.
  50377. */
  50378. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  50379. /**
  50380. * Checks to see if a texture is used in the material.
  50381. * @param defines the list of "defines" to update.
  50382. * @param scene defines the scene to the material belongs to.
  50383. */
  50384. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  50385. /**
  50386. * Binds the material data.
  50387. * @param uniformBuffer defines the Uniform buffer to fill in.
  50388. * @param scene defines the scene the material belongs to.
  50389. * @param engine defines the engine the material belongs to.
  50390. * @param isFrozen defines wether the material is frozen or not.
  50391. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  50392. */
  50393. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  50394. /**
  50395. * Unbinds the material from the mesh.
  50396. * @param activeEffect defines the effect that should be unbound from.
  50397. * @returns true if unbound, otherwise false
  50398. */
  50399. unbind(activeEffect: Effect): boolean;
  50400. /**
  50401. * Returns the texture used for refraction or null if none is used.
  50402. * @param scene defines the scene the material belongs to.
  50403. * @returns - Refraction texture if present. If no refraction texture and refraction
  50404. * is linked with transparency, returns environment texture. Otherwise, returns null.
  50405. */
  50406. private _getRefractionTexture;
  50407. /**
  50408. * Returns true if alpha blending should be disabled.
  50409. */
  50410. readonly disableAlphaBlending: boolean;
  50411. /**
  50412. * Fills the list of render target textures.
  50413. * @param renderTargets the list of render targets to update
  50414. */
  50415. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  50416. /**
  50417. * Checks to see if a texture is used in the material.
  50418. * @param texture - Base texture to use.
  50419. * @returns - Boolean specifying if a texture is used in the material.
  50420. */
  50421. hasTexture(texture: BaseTexture): boolean;
  50422. /**
  50423. * Gets a boolean indicating that current material needs to register RTT
  50424. * @returns true if this uses a render target otherwise false.
  50425. */
  50426. hasRenderTargetTextures(): boolean;
  50427. /**
  50428. * Returns an array of the actively used textures.
  50429. * @param activeTextures Array of BaseTextures
  50430. */
  50431. getActiveTextures(activeTextures: BaseTexture[]): void;
  50432. /**
  50433. * Returns the animatable textures.
  50434. * @param animatables Array of animatable textures.
  50435. */
  50436. getAnimatables(animatables: IAnimatable[]): void;
  50437. /**
  50438. * Disposes the resources of the material.
  50439. * @param forceDisposeTextures - Forces the disposal of all textures.
  50440. */
  50441. dispose(forceDisposeTextures?: boolean): void;
  50442. /**
  50443. * Get the current class name of the texture useful for serialization or dynamic coding.
  50444. * @returns "PBRSubSurfaceConfiguration"
  50445. */
  50446. getClassName(): string;
  50447. /**
  50448. * Add fallbacks to the effect fallbacks list.
  50449. * @param defines defines the Base texture to use.
  50450. * @param fallbacks defines the current fallback list.
  50451. * @param currentRank defines the current fallback rank.
  50452. * @returns the new fallback rank.
  50453. */
  50454. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50455. /**
  50456. * Add the required uniforms to the current list.
  50457. * @param uniforms defines the current uniform list.
  50458. */
  50459. static AddUniforms(uniforms: string[]): void;
  50460. /**
  50461. * Add the required samplers to the current list.
  50462. * @param samplers defines the current sampler list.
  50463. */
  50464. static AddSamplers(samplers: string[]): void;
  50465. /**
  50466. * Add the required uniforms to the current buffer.
  50467. * @param uniformBuffer defines the current uniform buffer.
  50468. */
  50469. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50470. /**
  50471. * Makes a duplicate of the current configuration into another one.
  50472. * @param configuration define the config where to copy the info
  50473. */
  50474. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  50475. /**
  50476. * Serializes this Sub Surface configuration.
  50477. * @returns - An object with the serialized config.
  50478. */
  50479. serialize(): any;
  50480. /**
  50481. * Parses a anisotropy Configuration from a serialized object.
  50482. * @param source - Serialized object.
  50483. * @param scene Defines the scene we are parsing for
  50484. * @param rootUrl Defines the rootUrl to load from
  50485. */
  50486. parse(source: any, scene: Scene, rootUrl: string): void;
  50487. }
  50488. }
  50489. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  50490. /** @hidden */
  50491. export var pbrFragmentDeclaration: {
  50492. name: string;
  50493. shader: string;
  50494. };
  50495. }
  50496. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  50497. /** @hidden */
  50498. export var pbrUboDeclaration: {
  50499. name: string;
  50500. shader: string;
  50501. };
  50502. }
  50503. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  50504. /** @hidden */
  50505. export var pbrFragmentExtraDeclaration: {
  50506. name: string;
  50507. shader: string;
  50508. };
  50509. }
  50510. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  50511. /** @hidden */
  50512. export var pbrFragmentSamplersDeclaration: {
  50513. name: string;
  50514. shader: string;
  50515. };
  50516. }
  50517. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  50518. /** @hidden */
  50519. export var pbrHelperFunctions: {
  50520. name: string;
  50521. shader: string;
  50522. };
  50523. }
  50524. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  50525. /** @hidden */
  50526. export var harmonicsFunctions: {
  50527. name: string;
  50528. shader: string;
  50529. };
  50530. }
  50531. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  50532. /** @hidden */
  50533. export var pbrDirectLightingSetupFunctions: {
  50534. name: string;
  50535. shader: string;
  50536. };
  50537. }
  50538. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  50539. /** @hidden */
  50540. export var pbrDirectLightingFalloffFunctions: {
  50541. name: string;
  50542. shader: string;
  50543. };
  50544. }
  50545. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  50546. /** @hidden */
  50547. export var pbrBRDFFunctions: {
  50548. name: string;
  50549. shader: string;
  50550. };
  50551. }
  50552. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  50553. /** @hidden */
  50554. export var pbrDirectLightingFunctions: {
  50555. name: string;
  50556. shader: string;
  50557. };
  50558. }
  50559. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  50560. /** @hidden */
  50561. export var pbrIBLFunctions: {
  50562. name: string;
  50563. shader: string;
  50564. };
  50565. }
  50566. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  50567. /** @hidden */
  50568. export var pbrDebug: {
  50569. name: string;
  50570. shader: string;
  50571. };
  50572. }
  50573. declare module "babylonjs/Shaders/pbr.fragment" {
  50574. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  50575. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  50576. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  50577. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50578. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50579. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  50580. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  50581. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  50582. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  50583. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  50584. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50585. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  50586. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  50587. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  50588. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  50589. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  50590. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  50591. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  50592. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  50593. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  50594. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  50595. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  50596. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  50597. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  50598. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  50599. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  50600. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  50601. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  50602. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  50603. /** @hidden */
  50604. export var pbrPixelShader: {
  50605. name: string;
  50606. shader: string;
  50607. };
  50608. }
  50609. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  50610. /** @hidden */
  50611. export var pbrVertexDeclaration: {
  50612. name: string;
  50613. shader: string;
  50614. };
  50615. }
  50616. declare module "babylonjs/Shaders/pbr.vertex" {
  50617. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  50618. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  50619. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50620. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50621. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50622. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  50623. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  50624. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  50625. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  50626. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50627. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50628. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  50629. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  50630. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  50631. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  50632. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50633. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50634. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  50635. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  50636. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  50637. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  50638. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  50639. /** @hidden */
  50640. export var pbrVertexShader: {
  50641. name: string;
  50642. shader: string;
  50643. };
  50644. }
  50645. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  50646. import { Nullable } from "babylonjs/types";
  50647. import { Scene } from "babylonjs/scene";
  50648. import { Matrix } from "babylonjs/Maths/math.vector";
  50649. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50650. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50651. import { Mesh } from "babylonjs/Meshes/mesh";
  50652. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  50653. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  50654. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  50655. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  50656. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  50657. import { Color3 } from "babylonjs/Maths/math.color";
  50658. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  50659. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  50660. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  50661. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  50662. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50663. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  50664. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  50665. import "babylonjs/Shaders/pbr.fragment";
  50666. import "babylonjs/Shaders/pbr.vertex";
  50667. /**
  50668. * Manages the defines for the PBR Material.
  50669. * @hidden
  50670. */
  50671. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  50672. PBR: boolean;
  50673. MAINUV1: boolean;
  50674. MAINUV2: boolean;
  50675. UV1: boolean;
  50676. UV2: boolean;
  50677. ALBEDO: boolean;
  50678. ALBEDODIRECTUV: number;
  50679. VERTEXCOLOR: boolean;
  50680. AMBIENT: boolean;
  50681. AMBIENTDIRECTUV: number;
  50682. AMBIENTINGRAYSCALE: boolean;
  50683. OPACITY: boolean;
  50684. VERTEXALPHA: boolean;
  50685. OPACITYDIRECTUV: number;
  50686. OPACITYRGB: boolean;
  50687. ALPHATEST: boolean;
  50688. DEPTHPREPASS: boolean;
  50689. ALPHABLEND: boolean;
  50690. ALPHAFROMALBEDO: boolean;
  50691. ALPHATESTVALUE: string;
  50692. SPECULAROVERALPHA: boolean;
  50693. RADIANCEOVERALPHA: boolean;
  50694. ALPHAFRESNEL: boolean;
  50695. LINEARALPHAFRESNEL: boolean;
  50696. PREMULTIPLYALPHA: boolean;
  50697. EMISSIVE: boolean;
  50698. EMISSIVEDIRECTUV: number;
  50699. REFLECTIVITY: boolean;
  50700. REFLECTIVITYDIRECTUV: number;
  50701. SPECULARTERM: boolean;
  50702. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  50703. MICROSURFACEAUTOMATIC: boolean;
  50704. LODBASEDMICROSFURACE: boolean;
  50705. MICROSURFACEMAP: boolean;
  50706. MICROSURFACEMAPDIRECTUV: number;
  50707. METALLICWORKFLOW: boolean;
  50708. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  50709. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  50710. METALLNESSSTOREINMETALMAPBLUE: boolean;
  50711. AOSTOREINMETALMAPRED: boolean;
  50712. METALLICF0FACTORFROMMETALLICMAP: boolean;
  50713. ENVIRONMENTBRDF: boolean;
  50714. ENVIRONMENTBRDF_RGBD: boolean;
  50715. NORMAL: boolean;
  50716. TANGENT: boolean;
  50717. BUMP: boolean;
  50718. BUMPDIRECTUV: number;
  50719. OBJECTSPACE_NORMALMAP: boolean;
  50720. PARALLAX: boolean;
  50721. PARALLAXOCCLUSION: boolean;
  50722. NORMALXYSCALE: boolean;
  50723. LIGHTMAP: boolean;
  50724. LIGHTMAPDIRECTUV: number;
  50725. USELIGHTMAPASSHADOWMAP: boolean;
  50726. GAMMALIGHTMAP: boolean;
  50727. RGBDLIGHTMAP: boolean;
  50728. REFLECTION: boolean;
  50729. REFLECTIONMAP_3D: boolean;
  50730. REFLECTIONMAP_SPHERICAL: boolean;
  50731. REFLECTIONMAP_PLANAR: boolean;
  50732. REFLECTIONMAP_CUBIC: boolean;
  50733. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  50734. REFLECTIONMAP_PROJECTION: boolean;
  50735. REFLECTIONMAP_SKYBOX: boolean;
  50736. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  50737. REFLECTIONMAP_EXPLICIT: boolean;
  50738. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  50739. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  50740. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  50741. INVERTCUBICMAP: boolean;
  50742. USESPHERICALFROMREFLECTIONMAP: boolean;
  50743. USEIRRADIANCEMAP: boolean;
  50744. SPHERICAL_HARMONICS: boolean;
  50745. USESPHERICALINVERTEX: boolean;
  50746. REFLECTIONMAP_OPPOSITEZ: boolean;
  50747. LODINREFLECTIONALPHA: boolean;
  50748. GAMMAREFLECTION: boolean;
  50749. RGBDREFLECTION: boolean;
  50750. LINEARSPECULARREFLECTION: boolean;
  50751. RADIANCEOCCLUSION: boolean;
  50752. HORIZONOCCLUSION: boolean;
  50753. INSTANCES: boolean;
  50754. NUM_BONE_INFLUENCERS: number;
  50755. BonesPerMesh: number;
  50756. BONETEXTURE: boolean;
  50757. NONUNIFORMSCALING: boolean;
  50758. MORPHTARGETS: boolean;
  50759. MORPHTARGETS_NORMAL: boolean;
  50760. MORPHTARGETS_TANGENT: boolean;
  50761. MORPHTARGETS_UV: boolean;
  50762. NUM_MORPH_INFLUENCERS: number;
  50763. IMAGEPROCESSING: boolean;
  50764. VIGNETTE: boolean;
  50765. VIGNETTEBLENDMODEMULTIPLY: boolean;
  50766. VIGNETTEBLENDMODEOPAQUE: boolean;
  50767. TONEMAPPING: boolean;
  50768. TONEMAPPING_ACES: boolean;
  50769. CONTRAST: boolean;
  50770. COLORCURVES: boolean;
  50771. COLORGRADING: boolean;
  50772. COLORGRADING3D: boolean;
  50773. SAMPLER3DGREENDEPTH: boolean;
  50774. SAMPLER3DBGRMAP: boolean;
  50775. IMAGEPROCESSINGPOSTPROCESS: boolean;
  50776. EXPOSURE: boolean;
  50777. MULTIVIEW: boolean;
  50778. USEPHYSICALLIGHTFALLOFF: boolean;
  50779. USEGLTFLIGHTFALLOFF: boolean;
  50780. TWOSIDEDLIGHTING: boolean;
  50781. SHADOWFLOAT: boolean;
  50782. CLIPPLANE: boolean;
  50783. CLIPPLANE2: boolean;
  50784. CLIPPLANE3: boolean;
  50785. CLIPPLANE4: boolean;
  50786. POINTSIZE: boolean;
  50787. FOG: boolean;
  50788. LOGARITHMICDEPTH: boolean;
  50789. FORCENORMALFORWARD: boolean;
  50790. SPECULARAA: boolean;
  50791. CLEARCOAT: boolean;
  50792. CLEARCOAT_DEFAULTIOR: boolean;
  50793. CLEARCOAT_TEXTURE: boolean;
  50794. CLEARCOAT_TEXTUREDIRECTUV: number;
  50795. CLEARCOAT_BUMP: boolean;
  50796. CLEARCOAT_BUMPDIRECTUV: number;
  50797. CLEARCOAT_TINT: boolean;
  50798. CLEARCOAT_TINT_TEXTURE: boolean;
  50799. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50800. ANISOTROPIC: boolean;
  50801. ANISOTROPIC_TEXTURE: boolean;
  50802. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50803. BRDF_V_HEIGHT_CORRELATED: boolean;
  50804. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50805. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50806. SHEEN: boolean;
  50807. SHEEN_TEXTURE: boolean;
  50808. SHEEN_TEXTUREDIRECTUV: number;
  50809. SHEEN_LINKWITHALBEDO: boolean;
  50810. SUBSURFACE: boolean;
  50811. SS_REFRACTION: boolean;
  50812. SS_TRANSLUCENCY: boolean;
  50813. SS_SCATERRING: boolean;
  50814. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50815. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50816. SS_REFRACTIONMAP_3D: boolean;
  50817. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50818. SS_LODINREFRACTIONALPHA: boolean;
  50819. SS_GAMMAREFRACTION: boolean;
  50820. SS_RGBDREFRACTION: boolean;
  50821. SS_LINEARSPECULARREFRACTION: boolean;
  50822. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50823. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50824. UNLIT: boolean;
  50825. DEBUGMODE: number;
  50826. /**
  50827. * Initializes the PBR Material defines.
  50828. */
  50829. constructor();
  50830. /**
  50831. * Resets the PBR Material defines.
  50832. */
  50833. reset(): void;
  50834. }
  50835. /**
  50836. * The Physically based material base class of BJS.
  50837. *
  50838. * This offers the main features of a standard PBR material.
  50839. * For more information, please refer to the documentation :
  50840. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50841. */
  50842. export abstract class PBRBaseMaterial extends PushMaterial {
  50843. /**
  50844. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50845. */
  50846. static readonly PBRMATERIAL_OPAQUE: number;
  50847. /**
  50848. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50849. */
  50850. static readonly PBRMATERIAL_ALPHATEST: number;
  50851. /**
  50852. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50853. */
  50854. static readonly PBRMATERIAL_ALPHABLEND: number;
  50855. /**
  50856. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50857. * They are also discarded below the alpha cutoff threshold to improve performances.
  50858. */
  50859. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50860. /**
  50861. * Defines the default value of how much AO map is occluding the analytical lights
  50862. * (point spot...).
  50863. */
  50864. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50865. /**
  50866. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  50867. */
  50868. static readonly LIGHTFALLOFF_PHYSICAL: number;
  50869. /**
  50870. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  50871. * to enhance interoperability with other engines.
  50872. */
  50873. static readonly LIGHTFALLOFF_GLTF: number;
  50874. /**
  50875. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  50876. * to enhance interoperability with other materials.
  50877. */
  50878. static readonly LIGHTFALLOFF_STANDARD: number;
  50879. /**
  50880. * Intensity of the direct lights e.g. the four lights available in your scene.
  50881. * This impacts both the direct diffuse and specular highlights.
  50882. */
  50883. protected _directIntensity: number;
  50884. /**
  50885. * Intensity of the emissive part of the material.
  50886. * This helps controlling the emissive effect without modifying the emissive color.
  50887. */
  50888. protected _emissiveIntensity: number;
  50889. /**
  50890. * Intensity of the environment e.g. how much the environment will light the object
  50891. * either through harmonics for rough material or through the refelction for shiny ones.
  50892. */
  50893. protected _environmentIntensity: number;
  50894. /**
  50895. * This is a special control allowing the reduction of the specular highlights coming from the
  50896. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50897. */
  50898. protected _specularIntensity: number;
  50899. /**
  50900. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  50901. */
  50902. private _lightingInfos;
  50903. /**
  50904. * Debug Control allowing disabling the bump map on this material.
  50905. */
  50906. protected _disableBumpMap: boolean;
  50907. /**
  50908. * AKA Diffuse Texture in standard nomenclature.
  50909. */
  50910. protected _albedoTexture: Nullable<BaseTexture>;
  50911. /**
  50912. * AKA Occlusion Texture in other nomenclature.
  50913. */
  50914. protected _ambientTexture: Nullable<BaseTexture>;
  50915. /**
  50916. * AKA Occlusion Texture Intensity in other nomenclature.
  50917. */
  50918. protected _ambientTextureStrength: number;
  50919. /**
  50920. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50921. * 1 means it completely occludes it
  50922. * 0 mean it has no impact
  50923. */
  50924. protected _ambientTextureImpactOnAnalyticalLights: number;
  50925. /**
  50926. * Stores the alpha values in a texture.
  50927. */
  50928. protected _opacityTexture: Nullable<BaseTexture>;
  50929. /**
  50930. * Stores the reflection values in a texture.
  50931. */
  50932. protected _reflectionTexture: Nullable<BaseTexture>;
  50933. /**
  50934. * Stores the emissive values in a texture.
  50935. */
  50936. protected _emissiveTexture: Nullable<BaseTexture>;
  50937. /**
  50938. * AKA Specular texture in other nomenclature.
  50939. */
  50940. protected _reflectivityTexture: Nullable<BaseTexture>;
  50941. /**
  50942. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50943. */
  50944. protected _metallicTexture: Nullable<BaseTexture>;
  50945. /**
  50946. * Specifies the metallic scalar of the metallic/roughness workflow.
  50947. * Can also be used to scale the metalness values of the metallic texture.
  50948. */
  50949. protected _metallic: Nullable<number>;
  50950. /**
  50951. * Specifies the roughness scalar of the metallic/roughness workflow.
  50952. * Can also be used to scale the roughness values of the metallic texture.
  50953. */
  50954. protected _roughness: Nullable<number>;
  50955. /**
  50956. * Specifies the an F0 factor to help configuring the material F0.
  50957. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  50958. * to 0.5 the previously hard coded value stays the same.
  50959. * Can also be used to scale the F0 values of the metallic texture.
  50960. */
  50961. protected _metallicF0Factor: number;
  50962. /**
  50963. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  50964. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  50965. * your expectation as it multiplies with the texture data.
  50966. */
  50967. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  50968. /**
  50969. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50970. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50971. */
  50972. protected _microSurfaceTexture: Nullable<BaseTexture>;
  50973. /**
  50974. * Stores surface normal data used to displace a mesh in a texture.
  50975. */
  50976. protected _bumpTexture: Nullable<BaseTexture>;
  50977. /**
  50978. * Stores the pre-calculated light information of a mesh in a texture.
  50979. */
  50980. protected _lightmapTexture: Nullable<BaseTexture>;
  50981. /**
  50982. * The color of a material in ambient lighting.
  50983. */
  50984. protected _ambientColor: Color3;
  50985. /**
  50986. * AKA Diffuse Color in other nomenclature.
  50987. */
  50988. protected _albedoColor: Color3;
  50989. /**
  50990. * AKA Specular Color in other nomenclature.
  50991. */
  50992. protected _reflectivityColor: Color3;
  50993. /**
  50994. * The color applied when light is reflected from a material.
  50995. */
  50996. protected _reflectionColor: Color3;
  50997. /**
  50998. * The color applied when light is emitted from a material.
  50999. */
  51000. protected _emissiveColor: Color3;
  51001. /**
  51002. * AKA Glossiness in other nomenclature.
  51003. */
  51004. protected _microSurface: number;
  51005. /**
  51006. * Specifies that the material will use the light map as a show map.
  51007. */
  51008. protected _useLightmapAsShadowmap: boolean;
  51009. /**
  51010. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51011. * makes the reflect vector face the model (under horizon).
  51012. */
  51013. protected _useHorizonOcclusion: boolean;
  51014. /**
  51015. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51016. * too much the area relying on ambient texture to define their ambient occlusion.
  51017. */
  51018. protected _useRadianceOcclusion: boolean;
  51019. /**
  51020. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51021. */
  51022. protected _useAlphaFromAlbedoTexture: boolean;
  51023. /**
  51024. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51025. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51026. */
  51027. protected _useSpecularOverAlpha: boolean;
  51028. /**
  51029. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51030. */
  51031. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51032. /**
  51033. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51034. */
  51035. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  51036. /**
  51037. * Specifies if the metallic texture contains the roughness information in its green channel.
  51038. */
  51039. protected _useRoughnessFromMetallicTextureGreen: boolean;
  51040. /**
  51041. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51042. */
  51043. protected _useMetallnessFromMetallicTextureBlue: boolean;
  51044. /**
  51045. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51046. */
  51047. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  51048. /**
  51049. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51050. */
  51051. protected _useAmbientInGrayScale: boolean;
  51052. /**
  51053. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51054. * The material will try to infer what glossiness each pixel should be.
  51055. */
  51056. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  51057. /**
  51058. * Defines the falloff type used in this material.
  51059. * It by default is Physical.
  51060. */
  51061. protected _lightFalloff: number;
  51062. /**
  51063. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51064. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51065. */
  51066. protected _useRadianceOverAlpha: boolean;
  51067. /**
  51068. * Allows using an object space normal map (instead of tangent space).
  51069. */
  51070. protected _useObjectSpaceNormalMap: boolean;
  51071. /**
  51072. * Allows using the bump map in parallax mode.
  51073. */
  51074. protected _useParallax: boolean;
  51075. /**
  51076. * Allows using the bump map in parallax occlusion mode.
  51077. */
  51078. protected _useParallaxOcclusion: boolean;
  51079. /**
  51080. * Controls the scale bias of the parallax mode.
  51081. */
  51082. protected _parallaxScaleBias: number;
  51083. /**
  51084. * If sets to true, disables all the lights affecting the material.
  51085. */
  51086. protected _disableLighting: boolean;
  51087. /**
  51088. * Number of Simultaneous lights allowed on the material.
  51089. */
  51090. protected _maxSimultaneousLights: number;
  51091. /**
  51092. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51093. */
  51094. protected _invertNormalMapX: boolean;
  51095. /**
  51096. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51097. */
  51098. protected _invertNormalMapY: boolean;
  51099. /**
  51100. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51101. */
  51102. protected _twoSidedLighting: boolean;
  51103. /**
  51104. * Defines the alpha limits in alpha test mode.
  51105. */
  51106. protected _alphaCutOff: number;
  51107. /**
  51108. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51109. */
  51110. protected _forceAlphaTest: boolean;
  51111. /**
  51112. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51113. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51114. */
  51115. protected _useAlphaFresnel: boolean;
  51116. /**
  51117. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51118. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51119. */
  51120. protected _useLinearAlphaFresnel: boolean;
  51121. /**
  51122. * The transparency mode of the material.
  51123. */
  51124. protected _transparencyMode: Nullable<number>;
  51125. /**
  51126. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  51127. * from cos thetav and roughness:
  51128. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  51129. */
  51130. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  51131. /**
  51132. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51133. */
  51134. protected _forceIrradianceInFragment: boolean;
  51135. /**
  51136. * Force normal to face away from face.
  51137. */
  51138. protected _forceNormalForward: boolean;
  51139. /**
  51140. * Enables specular anti aliasing in the PBR shader.
  51141. * It will both interacts on the Geometry for analytical and IBL lighting.
  51142. * It also prefilter the roughness map based on the bump values.
  51143. */
  51144. protected _enableSpecularAntiAliasing: boolean;
  51145. /**
  51146. * Default configuration related to image processing available in the PBR Material.
  51147. */
  51148. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51149. /**
  51150. * Keep track of the image processing observer to allow dispose and replace.
  51151. */
  51152. private _imageProcessingObserver;
  51153. /**
  51154. * Attaches a new image processing configuration to the PBR Material.
  51155. * @param configuration
  51156. */
  51157. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51158. /**
  51159. * Stores the available render targets.
  51160. */
  51161. private _renderTargets;
  51162. /**
  51163. * Sets the global ambient color for the material used in lighting calculations.
  51164. */
  51165. private _globalAmbientColor;
  51166. /**
  51167. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  51168. */
  51169. private _useLogarithmicDepth;
  51170. /**
  51171. * If set to true, no lighting calculations will be applied.
  51172. */
  51173. private _unlit;
  51174. private _debugMode;
  51175. /**
  51176. * @hidden
  51177. * This is reserved for the inspector.
  51178. * Defines the material debug mode.
  51179. * It helps seeing only some components of the material while troubleshooting.
  51180. */
  51181. debugMode: number;
  51182. /**
  51183. * @hidden
  51184. * This is reserved for the inspector.
  51185. * Specify from where on screen the debug mode should start.
  51186. * The value goes from -1 (full screen) to 1 (not visible)
  51187. * It helps with side by side comparison against the final render
  51188. * This defaults to -1
  51189. */
  51190. private debugLimit;
  51191. /**
  51192. * @hidden
  51193. * This is reserved for the inspector.
  51194. * As the default viewing range might not be enough (if the ambient is really small for instance)
  51195. * You can use the factor to better multiply the final value.
  51196. */
  51197. private debugFactor;
  51198. /**
  51199. * Defines the clear coat layer parameters for the material.
  51200. */
  51201. readonly clearCoat: PBRClearCoatConfiguration;
  51202. /**
  51203. * Defines the anisotropic parameters for the material.
  51204. */
  51205. readonly anisotropy: PBRAnisotropicConfiguration;
  51206. /**
  51207. * Defines the BRDF parameters for the material.
  51208. */
  51209. readonly brdf: PBRBRDFConfiguration;
  51210. /**
  51211. * Defines the Sheen parameters for the material.
  51212. */
  51213. readonly sheen: PBRSheenConfiguration;
  51214. /**
  51215. * Defines the SubSurface parameters for the material.
  51216. */
  51217. readonly subSurface: PBRSubSurfaceConfiguration;
  51218. /**
  51219. * Custom callback helping to override the default shader used in the material.
  51220. */
  51221. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  51222. protected _rebuildInParallel: boolean;
  51223. /**
  51224. * Instantiates a new PBRMaterial instance.
  51225. *
  51226. * @param name The material name
  51227. * @param scene The scene the material will be use in.
  51228. */
  51229. constructor(name: string, scene: Scene);
  51230. /**
  51231. * Gets a boolean indicating that current material needs to register RTT
  51232. */
  51233. readonly hasRenderTargetTextures: boolean;
  51234. /**
  51235. * Gets the name of the material class.
  51236. */
  51237. getClassName(): string;
  51238. /**
  51239. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51240. */
  51241. /**
  51242. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51243. */
  51244. useLogarithmicDepth: boolean;
  51245. /**
  51246. * Gets the current transparency mode.
  51247. */
  51248. /**
  51249. * Sets the transparency mode of the material.
  51250. *
  51251. * | Value | Type | Description |
  51252. * | ----- | ----------------------------------- | ----------- |
  51253. * | 0 | OPAQUE | |
  51254. * | 1 | ALPHATEST | |
  51255. * | 2 | ALPHABLEND | |
  51256. * | 3 | ALPHATESTANDBLEND | |
  51257. *
  51258. */
  51259. transparencyMode: Nullable<number>;
  51260. /**
  51261. * Returns true if alpha blending should be disabled.
  51262. */
  51263. private readonly _disableAlphaBlending;
  51264. /**
  51265. * Specifies whether or not this material should be rendered in alpha blend mode.
  51266. */
  51267. needAlphaBlending(): boolean;
  51268. /**
  51269. * Specifies if the mesh will require alpha blending.
  51270. * @param mesh - BJS mesh.
  51271. */
  51272. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  51273. /**
  51274. * Specifies whether or not this material should be rendered in alpha test mode.
  51275. */
  51276. needAlphaTesting(): boolean;
  51277. /**
  51278. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  51279. */
  51280. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  51281. /**
  51282. * Gets the texture used for the alpha test.
  51283. */
  51284. getAlphaTestTexture(): Nullable<BaseTexture>;
  51285. /**
  51286. * Specifies that the submesh is ready to be used.
  51287. * @param mesh - BJS mesh.
  51288. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  51289. * @param useInstances - Specifies that instances should be used.
  51290. * @returns - boolean indicating that the submesh is ready or not.
  51291. */
  51292. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51293. /**
  51294. * Specifies if the material uses metallic roughness workflow.
  51295. * @returns boolean specifiying if the material uses metallic roughness workflow.
  51296. */
  51297. isMetallicWorkflow(): boolean;
  51298. private _prepareEffect;
  51299. private _prepareDefines;
  51300. /**
  51301. * Force shader compilation
  51302. */
  51303. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  51304. /**
  51305. * Initializes the uniform buffer layout for the shader.
  51306. */
  51307. buildUniformLayout(): void;
  51308. /**
  51309. * Unbinds the material from the mesh
  51310. */
  51311. unbind(): void;
  51312. /**
  51313. * Binds the submesh data.
  51314. * @param world - The world matrix.
  51315. * @param mesh - The BJS mesh.
  51316. * @param subMesh - A submesh of the BJS mesh.
  51317. */
  51318. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51319. /**
  51320. * Returns the animatable textures.
  51321. * @returns - Array of animatable textures.
  51322. */
  51323. getAnimatables(): IAnimatable[];
  51324. /**
  51325. * Returns the texture used for reflections.
  51326. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  51327. */
  51328. private _getReflectionTexture;
  51329. /**
  51330. * Returns an array of the actively used textures.
  51331. * @returns - Array of BaseTextures
  51332. */
  51333. getActiveTextures(): BaseTexture[];
  51334. /**
  51335. * Checks to see if a texture is used in the material.
  51336. * @param texture - Base texture to use.
  51337. * @returns - Boolean specifying if a texture is used in the material.
  51338. */
  51339. hasTexture(texture: BaseTexture): boolean;
  51340. /**
  51341. * Disposes the resources of the material.
  51342. * @param forceDisposeEffect - Forces the disposal of effects.
  51343. * @param forceDisposeTextures - Forces the disposal of all textures.
  51344. */
  51345. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51346. }
  51347. }
  51348. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  51349. import { Nullable } from "babylonjs/types";
  51350. import { Scene } from "babylonjs/scene";
  51351. import { Color3 } from "babylonjs/Maths/math.color";
  51352. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51353. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51354. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51355. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51356. /**
  51357. * The Physically based material of BJS.
  51358. *
  51359. * This offers the main features of a standard PBR material.
  51360. * For more information, please refer to the documentation :
  51361. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51362. */
  51363. export class PBRMaterial extends PBRBaseMaterial {
  51364. /**
  51365. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51366. */
  51367. static readonly PBRMATERIAL_OPAQUE: number;
  51368. /**
  51369. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51370. */
  51371. static readonly PBRMATERIAL_ALPHATEST: number;
  51372. /**
  51373. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51374. */
  51375. static readonly PBRMATERIAL_ALPHABLEND: number;
  51376. /**
  51377. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51378. * They are also discarded below the alpha cutoff threshold to improve performances.
  51379. */
  51380. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51381. /**
  51382. * Defines the default value of how much AO map is occluding the analytical lights
  51383. * (point spot...).
  51384. */
  51385. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51386. /**
  51387. * Intensity of the direct lights e.g. the four lights available in your scene.
  51388. * This impacts both the direct diffuse and specular highlights.
  51389. */
  51390. directIntensity: number;
  51391. /**
  51392. * Intensity of the emissive part of the material.
  51393. * This helps controlling the emissive effect without modifying the emissive color.
  51394. */
  51395. emissiveIntensity: number;
  51396. /**
  51397. * Intensity of the environment e.g. how much the environment will light the object
  51398. * either through harmonics for rough material or through the refelction for shiny ones.
  51399. */
  51400. environmentIntensity: number;
  51401. /**
  51402. * This is a special control allowing the reduction of the specular highlights coming from the
  51403. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51404. */
  51405. specularIntensity: number;
  51406. /**
  51407. * Debug Control allowing disabling the bump map on this material.
  51408. */
  51409. disableBumpMap: boolean;
  51410. /**
  51411. * AKA Diffuse Texture in standard nomenclature.
  51412. */
  51413. albedoTexture: BaseTexture;
  51414. /**
  51415. * AKA Occlusion Texture in other nomenclature.
  51416. */
  51417. ambientTexture: BaseTexture;
  51418. /**
  51419. * AKA Occlusion Texture Intensity in other nomenclature.
  51420. */
  51421. ambientTextureStrength: number;
  51422. /**
  51423. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51424. * 1 means it completely occludes it
  51425. * 0 mean it has no impact
  51426. */
  51427. ambientTextureImpactOnAnalyticalLights: number;
  51428. /**
  51429. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  51430. */
  51431. opacityTexture: BaseTexture;
  51432. /**
  51433. * Stores the reflection values in a texture.
  51434. */
  51435. reflectionTexture: Nullable<BaseTexture>;
  51436. /**
  51437. * Stores the emissive values in a texture.
  51438. */
  51439. emissiveTexture: BaseTexture;
  51440. /**
  51441. * AKA Specular texture in other nomenclature.
  51442. */
  51443. reflectivityTexture: BaseTexture;
  51444. /**
  51445. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51446. */
  51447. metallicTexture: BaseTexture;
  51448. /**
  51449. * Specifies the metallic scalar of the metallic/roughness workflow.
  51450. * Can also be used to scale the metalness values of the metallic texture.
  51451. */
  51452. metallic: Nullable<number>;
  51453. /**
  51454. * Specifies the roughness scalar of the metallic/roughness workflow.
  51455. * Can also be used to scale the roughness values of the metallic texture.
  51456. */
  51457. roughness: Nullable<number>;
  51458. /**
  51459. * Specifies the an F0 factor to help configuring the material F0.
  51460. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51461. * to 0.5 the previously hard coded value stays the same.
  51462. * Can also be used to scale the F0 values of the metallic texture.
  51463. */
  51464. metallicF0Factor: number;
  51465. /**
  51466. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51467. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51468. * your expectation as it multiplies with the texture data.
  51469. */
  51470. useMetallicF0FactorFromMetallicTexture: boolean;
  51471. /**
  51472. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51473. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51474. */
  51475. microSurfaceTexture: BaseTexture;
  51476. /**
  51477. * Stores surface normal data used to displace a mesh in a texture.
  51478. */
  51479. bumpTexture: BaseTexture;
  51480. /**
  51481. * Stores the pre-calculated light information of a mesh in a texture.
  51482. */
  51483. lightmapTexture: BaseTexture;
  51484. /**
  51485. * Stores the refracted light information in a texture.
  51486. */
  51487. refractionTexture: Nullable<BaseTexture>;
  51488. /**
  51489. * The color of a material in ambient lighting.
  51490. */
  51491. ambientColor: Color3;
  51492. /**
  51493. * AKA Diffuse Color in other nomenclature.
  51494. */
  51495. albedoColor: Color3;
  51496. /**
  51497. * AKA Specular Color in other nomenclature.
  51498. */
  51499. reflectivityColor: Color3;
  51500. /**
  51501. * The color reflected from the material.
  51502. */
  51503. reflectionColor: Color3;
  51504. /**
  51505. * The color emitted from the material.
  51506. */
  51507. emissiveColor: Color3;
  51508. /**
  51509. * AKA Glossiness in other nomenclature.
  51510. */
  51511. microSurface: number;
  51512. /**
  51513. * source material index of refraction (IOR)' / 'destination material IOR.
  51514. */
  51515. indexOfRefraction: number;
  51516. /**
  51517. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51518. */
  51519. invertRefractionY: boolean;
  51520. /**
  51521. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51522. * Materials half opaque for instance using refraction could benefit from this control.
  51523. */
  51524. linkRefractionWithTransparency: boolean;
  51525. /**
  51526. * If true, the light map contains occlusion information instead of lighting info.
  51527. */
  51528. useLightmapAsShadowmap: boolean;
  51529. /**
  51530. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51531. */
  51532. useAlphaFromAlbedoTexture: boolean;
  51533. /**
  51534. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51535. */
  51536. forceAlphaTest: boolean;
  51537. /**
  51538. * Defines the alpha limits in alpha test mode.
  51539. */
  51540. alphaCutOff: number;
  51541. /**
  51542. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  51543. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51544. */
  51545. useSpecularOverAlpha: boolean;
  51546. /**
  51547. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51548. */
  51549. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51550. /**
  51551. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51552. */
  51553. useRoughnessFromMetallicTextureAlpha: boolean;
  51554. /**
  51555. * Specifies if the metallic texture contains the roughness information in its green channel.
  51556. */
  51557. useRoughnessFromMetallicTextureGreen: boolean;
  51558. /**
  51559. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51560. */
  51561. useMetallnessFromMetallicTextureBlue: boolean;
  51562. /**
  51563. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51564. */
  51565. useAmbientOcclusionFromMetallicTextureRed: boolean;
  51566. /**
  51567. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51568. */
  51569. useAmbientInGrayScale: boolean;
  51570. /**
  51571. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51572. * The material will try to infer what glossiness each pixel should be.
  51573. */
  51574. useAutoMicroSurfaceFromReflectivityMap: boolean;
  51575. /**
  51576. * BJS is using an harcoded light falloff based on a manually sets up range.
  51577. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51578. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51579. */
  51580. /**
  51581. * BJS is using an harcoded light falloff based on a manually sets up range.
  51582. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51583. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51584. */
  51585. usePhysicalLightFalloff: boolean;
  51586. /**
  51587. * In order to support the falloff compatibility with gltf, a special mode has been added
  51588. * to reproduce the gltf light falloff.
  51589. */
  51590. /**
  51591. * In order to support the falloff compatibility with gltf, a special mode has been added
  51592. * to reproduce the gltf light falloff.
  51593. */
  51594. useGLTFLightFalloff: boolean;
  51595. /**
  51596. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51597. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51598. */
  51599. useRadianceOverAlpha: boolean;
  51600. /**
  51601. * Allows using an object space normal map (instead of tangent space).
  51602. */
  51603. useObjectSpaceNormalMap: boolean;
  51604. /**
  51605. * Allows using the bump map in parallax mode.
  51606. */
  51607. useParallax: boolean;
  51608. /**
  51609. * Allows using the bump map in parallax occlusion mode.
  51610. */
  51611. useParallaxOcclusion: boolean;
  51612. /**
  51613. * Controls the scale bias of the parallax mode.
  51614. */
  51615. parallaxScaleBias: number;
  51616. /**
  51617. * If sets to true, disables all the lights affecting the material.
  51618. */
  51619. disableLighting: boolean;
  51620. /**
  51621. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51622. */
  51623. forceIrradianceInFragment: boolean;
  51624. /**
  51625. * Number of Simultaneous lights allowed on the material.
  51626. */
  51627. maxSimultaneousLights: number;
  51628. /**
  51629. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51630. */
  51631. invertNormalMapX: boolean;
  51632. /**
  51633. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51634. */
  51635. invertNormalMapY: boolean;
  51636. /**
  51637. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51638. */
  51639. twoSidedLighting: boolean;
  51640. /**
  51641. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51642. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51643. */
  51644. useAlphaFresnel: boolean;
  51645. /**
  51646. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51647. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51648. */
  51649. useLinearAlphaFresnel: boolean;
  51650. /**
  51651. * Let user defines the brdf lookup texture used for IBL.
  51652. * A default 8bit version is embedded but you could point at :
  51653. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  51654. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  51655. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  51656. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  51657. */
  51658. environmentBRDFTexture: Nullable<BaseTexture>;
  51659. /**
  51660. * Force normal to face away from face.
  51661. */
  51662. forceNormalForward: boolean;
  51663. /**
  51664. * Enables specular anti aliasing in the PBR shader.
  51665. * It will both interacts on the Geometry for analytical and IBL lighting.
  51666. * It also prefilter the roughness map based on the bump values.
  51667. */
  51668. enableSpecularAntiAliasing: boolean;
  51669. /**
  51670. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51671. * makes the reflect vector face the model (under horizon).
  51672. */
  51673. useHorizonOcclusion: boolean;
  51674. /**
  51675. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51676. * too much the area relying on ambient texture to define their ambient occlusion.
  51677. */
  51678. useRadianceOcclusion: boolean;
  51679. /**
  51680. * If set to true, no lighting calculations will be applied.
  51681. */
  51682. unlit: boolean;
  51683. /**
  51684. * Gets the image processing configuration used either in this material.
  51685. */
  51686. /**
  51687. * Sets the Default image processing configuration used either in the this material.
  51688. *
  51689. * If sets to null, the scene one is in use.
  51690. */
  51691. imageProcessingConfiguration: ImageProcessingConfiguration;
  51692. /**
  51693. * Gets wether the color curves effect is enabled.
  51694. */
  51695. /**
  51696. * Sets wether the color curves effect is enabled.
  51697. */
  51698. cameraColorCurvesEnabled: boolean;
  51699. /**
  51700. * Gets wether the color grading effect is enabled.
  51701. */
  51702. /**
  51703. * Gets wether the color grading effect is enabled.
  51704. */
  51705. cameraColorGradingEnabled: boolean;
  51706. /**
  51707. * Gets wether tonemapping is enabled or not.
  51708. */
  51709. /**
  51710. * Sets wether tonemapping is enabled or not
  51711. */
  51712. cameraToneMappingEnabled: boolean;
  51713. /**
  51714. * The camera exposure used on this material.
  51715. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51716. * This corresponds to a photographic exposure.
  51717. */
  51718. /**
  51719. * The camera exposure used on this material.
  51720. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51721. * This corresponds to a photographic exposure.
  51722. */
  51723. cameraExposure: number;
  51724. /**
  51725. * Gets The camera contrast used on this material.
  51726. */
  51727. /**
  51728. * Sets The camera contrast used on this material.
  51729. */
  51730. cameraContrast: number;
  51731. /**
  51732. * Gets the Color Grading 2D Lookup Texture.
  51733. */
  51734. /**
  51735. * Sets the Color Grading 2D Lookup Texture.
  51736. */
  51737. cameraColorGradingTexture: Nullable<BaseTexture>;
  51738. /**
  51739. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51740. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51741. * 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;
  51742. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51743. */
  51744. /**
  51745. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51746. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51747. * 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;
  51748. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51749. */
  51750. cameraColorCurves: Nullable<ColorCurves>;
  51751. /**
  51752. * Instantiates a new PBRMaterial instance.
  51753. *
  51754. * @param name The material name
  51755. * @param scene The scene the material will be use in.
  51756. */
  51757. constructor(name: string, scene: Scene);
  51758. /**
  51759. * Returns the name of this material class.
  51760. */
  51761. getClassName(): string;
  51762. /**
  51763. * Makes a duplicate of the current material.
  51764. * @param name - name to use for the new material.
  51765. */
  51766. clone(name: string): PBRMaterial;
  51767. /**
  51768. * Serializes this PBR Material.
  51769. * @returns - An object with the serialized material.
  51770. */
  51771. serialize(): any;
  51772. /**
  51773. * Parses a PBR Material from a serialized object.
  51774. * @param source - Serialized object.
  51775. * @param scene - BJS scene instance.
  51776. * @param rootUrl - url for the scene object
  51777. * @returns - PBRMaterial
  51778. */
  51779. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  51780. }
  51781. }
  51782. declare module "babylonjs/Misc/dds" {
  51783. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  51784. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51785. import { Nullable } from "babylonjs/types";
  51786. import { Scene } from "babylonjs/scene";
  51787. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  51788. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  51789. /**
  51790. * Direct draw surface info
  51791. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  51792. */
  51793. export interface DDSInfo {
  51794. /**
  51795. * Width of the texture
  51796. */
  51797. width: number;
  51798. /**
  51799. * Width of the texture
  51800. */
  51801. height: number;
  51802. /**
  51803. * Number of Mipmaps for the texture
  51804. * @see https://en.wikipedia.org/wiki/Mipmap
  51805. */
  51806. mipmapCount: number;
  51807. /**
  51808. * If the textures format is a known fourCC format
  51809. * @see https://www.fourcc.org/
  51810. */
  51811. isFourCC: boolean;
  51812. /**
  51813. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  51814. */
  51815. isRGB: boolean;
  51816. /**
  51817. * If the texture is a lumincance format
  51818. */
  51819. isLuminance: boolean;
  51820. /**
  51821. * If this is a cube texture
  51822. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  51823. */
  51824. isCube: boolean;
  51825. /**
  51826. * If the texture is a compressed format eg. FOURCC_DXT1
  51827. */
  51828. isCompressed: boolean;
  51829. /**
  51830. * The dxgiFormat of the texture
  51831. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  51832. */
  51833. dxgiFormat: number;
  51834. /**
  51835. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  51836. */
  51837. textureType: number;
  51838. /**
  51839. * Sphericle polynomial created for the dds texture
  51840. */
  51841. sphericalPolynomial?: SphericalPolynomial;
  51842. }
  51843. /**
  51844. * Class used to provide DDS decompression tools
  51845. */
  51846. export class DDSTools {
  51847. /**
  51848. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  51849. */
  51850. static StoreLODInAlphaChannel: boolean;
  51851. /**
  51852. * Gets DDS information from an array buffer
  51853. * @param arrayBuffer defines the array buffer to read data from
  51854. * @returns the DDS information
  51855. */
  51856. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  51857. private static _FloatView;
  51858. private static _Int32View;
  51859. private static _ToHalfFloat;
  51860. private static _FromHalfFloat;
  51861. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  51862. private static _GetHalfFloatRGBAArrayBuffer;
  51863. private static _GetFloatRGBAArrayBuffer;
  51864. private static _GetFloatAsUIntRGBAArrayBuffer;
  51865. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  51866. private static _GetRGBAArrayBuffer;
  51867. private static _ExtractLongWordOrder;
  51868. private static _GetRGBArrayBuffer;
  51869. private static _GetLuminanceArrayBuffer;
  51870. /**
  51871. * Uploads DDS Levels to a Babylon Texture
  51872. * @hidden
  51873. */
  51874. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  51875. }
  51876. module "babylonjs/Engines/thinEngine" {
  51877. interface ThinEngine {
  51878. /**
  51879. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  51880. * @param rootUrl defines the url where the file to load is located
  51881. * @param scene defines the current scene
  51882. * @param lodScale defines scale to apply to the mip map selection
  51883. * @param lodOffset defines offset to apply to the mip map selection
  51884. * @param onLoad defines an optional callback raised when the texture is loaded
  51885. * @param onError defines an optional callback raised if there is an issue to load the texture
  51886. * @param format defines the format of the data
  51887. * @param forcedExtension defines the extension to use to pick the right loader
  51888. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  51889. * @returns the cube texture as an InternalTexture
  51890. */
  51891. 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;
  51892. }
  51893. }
  51894. }
  51895. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  51896. import { Nullable } from "babylonjs/types";
  51897. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51898. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51899. /**
  51900. * Implementation of the DDS Texture Loader.
  51901. * @hidden
  51902. */
  51903. export class _DDSTextureLoader implements IInternalTextureLoader {
  51904. /**
  51905. * Defines wether the loader supports cascade loading the different faces.
  51906. */
  51907. readonly supportCascades: boolean;
  51908. /**
  51909. * This returns if the loader support the current file information.
  51910. * @param extension defines the file extension of the file being loaded
  51911. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51912. * @param fallback defines the fallback internal texture if any
  51913. * @param isBase64 defines whether the texture is encoded as a base64
  51914. * @param isBuffer defines whether the texture data are stored as a buffer
  51915. * @returns true if the loader can load the specified file
  51916. */
  51917. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51918. /**
  51919. * Transform the url before loading if required.
  51920. * @param rootUrl the url of the texture
  51921. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51922. * @returns the transformed texture
  51923. */
  51924. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51925. /**
  51926. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51927. * @param rootUrl the url of the texture
  51928. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51929. * @returns the fallback texture
  51930. */
  51931. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51932. /**
  51933. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51934. * @param data contains the texture data
  51935. * @param texture defines the BabylonJS internal texture
  51936. * @param createPolynomials will be true if polynomials have been requested
  51937. * @param onLoad defines the callback to trigger once the texture is ready
  51938. * @param onError defines the callback to trigger in case of error
  51939. */
  51940. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51941. /**
  51942. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51943. * @param data contains the texture data
  51944. * @param texture defines the BabylonJS internal texture
  51945. * @param callback defines the method to call once ready to upload
  51946. */
  51947. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51948. }
  51949. }
  51950. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  51951. import { Nullable } from "babylonjs/types";
  51952. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51953. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51954. /**
  51955. * Implementation of the ENV Texture Loader.
  51956. * @hidden
  51957. */
  51958. export class _ENVTextureLoader implements IInternalTextureLoader {
  51959. /**
  51960. * Defines wether the loader supports cascade loading the different faces.
  51961. */
  51962. readonly supportCascades: boolean;
  51963. /**
  51964. * This returns if the loader support the current file information.
  51965. * @param extension defines the file extension of the file being loaded
  51966. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51967. * @param fallback defines the fallback internal texture if any
  51968. * @param isBase64 defines whether the texture is encoded as a base64
  51969. * @param isBuffer defines whether the texture data are stored as a buffer
  51970. * @returns true if the loader can load the specified file
  51971. */
  51972. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51973. /**
  51974. * Transform the url before loading if required.
  51975. * @param rootUrl the url of the texture
  51976. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51977. * @returns the transformed texture
  51978. */
  51979. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51980. /**
  51981. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51982. * @param rootUrl the url of the texture
  51983. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51984. * @returns the fallback texture
  51985. */
  51986. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51987. /**
  51988. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51989. * @param data contains the texture data
  51990. * @param texture defines the BabylonJS internal texture
  51991. * @param createPolynomials will be true if polynomials have been requested
  51992. * @param onLoad defines the callback to trigger once the texture is ready
  51993. * @param onError defines the callback to trigger in case of error
  51994. */
  51995. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51996. /**
  51997. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51998. * @param data contains the texture data
  51999. * @param texture defines the BabylonJS internal texture
  52000. * @param callback defines the method to call once ready to upload
  52001. */
  52002. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52003. }
  52004. }
  52005. declare module "babylonjs/Misc/khronosTextureContainer" {
  52006. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52007. /**
  52008. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52009. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52010. */
  52011. export class KhronosTextureContainer {
  52012. /** contents of the KTX container file */
  52013. arrayBuffer: any;
  52014. private static HEADER_LEN;
  52015. private static COMPRESSED_2D;
  52016. private static COMPRESSED_3D;
  52017. private static TEX_2D;
  52018. private static TEX_3D;
  52019. /**
  52020. * Gets the openGL type
  52021. */
  52022. glType: number;
  52023. /**
  52024. * Gets the openGL type size
  52025. */
  52026. glTypeSize: number;
  52027. /**
  52028. * Gets the openGL format
  52029. */
  52030. glFormat: number;
  52031. /**
  52032. * Gets the openGL internal format
  52033. */
  52034. glInternalFormat: number;
  52035. /**
  52036. * Gets the base internal format
  52037. */
  52038. glBaseInternalFormat: number;
  52039. /**
  52040. * Gets image width in pixel
  52041. */
  52042. pixelWidth: number;
  52043. /**
  52044. * Gets image height in pixel
  52045. */
  52046. pixelHeight: number;
  52047. /**
  52048. * Gets image depth in pixels
  52049. */
  52050. pixelDepth: number;
  52051. /**
  52052. * Gets the number of array elements
  52053. */
  52054. numberOfArrayElements: number;
  52055. /**
  52056. * Gets the number of faces
  52057. */
  52058. numberOfFaces: number;
  52059. /**
  52060. * Gets the number of mipmap levels
  52061. */
  52062. numberOfMipmapLevels: number;
  52063. /**
  52064. * Gets the bytes of key value data
  52065. */
  52066. bytesOfKeyValueData: number;
  52067. /**
  52068. * Gets the load type
  52069. */
  52070. loadType: number;
  52071. /**
  52072. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  52073. */
  52074. isInvalid: boolean;
  52075. /**
  52076. * Creates a new KhronosTextureContainer
  52077. * @param arrayBuffer contents of the KTX container file
  52078. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  52079. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  52080. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  52081. */
  52082. constructor(
  52083. /** contents of the KTX container file */
  52084. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  52085. /**
  52086. * Uploads KTX content to a Babylon Texture.
  52087. * It is assumed that the texture has already been created & is currently bound
  52088. * @hidden
  52089. */
  52090. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  52091. private _upload2DCompressedLevels;
  52092. }
  52093. }
  52094. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  52095. import { Nullable } from "babylonjs/types";
  52096. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52097. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52098. /**
  52099. * Implementation of the KTX Texture Loader.
  52100. * @hidden
  52101. */
  52102. export class _KTXTextureLoader implements IInternalTextureLoader {
  52103. /**
  52104. * Defines wether the loader supports cascade loading the different faces.
  52105. */
  52106. readonly supportCascades: boolean;
  52107. /**
  52108. * This returns if the loader support the current file information.
  52109. * @param extension defines the file extension of the file being loaded
  52110. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52111. * @param fallback defines the fallback internal texture if any
  52112. * @param isBase64 defines whether the texture is encoded as a base64
  52113. * @param isBuffer defines whether the texture data are stored as a buffer
  52114. * @returns true if the loader can load the specified file
  52115. */
  52116. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52117. /**
  52118. * Transform the url before loading if required.
  52119. * @param rootUrl the url of the texture
  52120. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52121. * @returns the transformed texture
  52122. */
  52123. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52124. /**
  52125. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52126. * @param rootUrl the url of the texture
  52127. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52128. * @returns the fallback texture
  52129. */
  52130. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52131. /**
  52132. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52133. * @param data contains the texture data
  52134. * @param texture defines the BabylonJS internal texture
  52135. * @param createPolynomials will be true if polynomials have been requested
  52136. * @param onLoad defines the callback to trigger once the texture is ready
  52137. * @param onError defines the callback to trigger in case of error
  52138. */
  52139. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52140. /**
  52141. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52142. * @param data contains the texture data
  52143. * @param texture defines the BabylonJS internal texture
  52144. * @param callback defines the method to call once ready to upload
  52145. */
  52146. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  52147. }
  52148. }
  52149. declare module "babylonjs/Helpers/sceneHelpers" {
  52150. import { Nullable } from "babylonjs/types";
  52151. import { Mesh } from "babylonjs/Meshes/mesh";
  52152. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52153. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  52154. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  52155. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  52156. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  52157. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  52158. import "babylonjs/Meshes/Builders/boxBuilder";
  52159. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  52160. /** @hidden */
  52161. export var _forceSceneHelpersToBundle: boolean;
  52162. module "babylonjs/scene" {
  52163. interface Scene {
  52164. /**
  52165. * Creates a default light for the scene.
  52166. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  52167. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  52168. */
  52169. createDefaultLight(replace?: boolean): void;
  52170. /**
  52171. * Creates a default camera for the scene.
  52172. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  52173. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52174. * @param replace has default false, when true replaces the active camera in the scene
  52175. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  52176. */
  52177. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52178. /**
  52179. * Creates a default camera and a default light.
  52180. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  52181. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52182. * @param replace has the default false, when true replaces the active camera/light in the scene
  52183. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  52184. */
  52185. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52186. /**
  52187. * Creates a new sky box
  52188. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  52189. * @param environmentTexture defines the texture to use as environment texture
  52190. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  52191. * @param scale defines the overall scale of the skybox
  52192. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  52193. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  52194. * @returns a new mesh holding the sky box
  52195. */
  52196. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  52197. /**
  52198. * Creates a new environment
  52199. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  52200. * @param options defines the options you can use to configure the environment
  52201. * @returns the new EnvironmentHelper
  52202. */
  52203. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  52204. /**
  52205. * Creates a new VREXperienceHelper
  52206. * @see http://doc.babylonjs.com/how_to/webvr_helper
  52207. * @param webVROptions defines the options used to create the new VREXperienceHelper
  52208. * @returns a new VREXperienceHelper
  52209. */
  52210. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  52211. /**
  52212. * Creates a new WebXRDefaultExperience
  52213. * @see http://doc.babylonjs.com/how_to/webxr
  52214. * @param options experience options
  52215. * @returns a promise for a new WebXRDefaultExperience
  52216. */
  52217. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52218. }
  52219. }
  52220. }
  52221. declare module "babylonjs/Helpers/videoDome" {
  52222. import { Scene } from "babylonjs/scene";
  52223. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52224. import { Mesh } from "babylonjs/Meshes/mesh";
  52225. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  52226. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  52227. import "babylonjs/Meshes/Builders/sphereBuilder";
  52228. /**
  52229. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  52230. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  52231. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  52232. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52233. */
  52234. export class VideoDome extends TransformNode {
  52235. /**
  52236. * Define the video source as a Monoscopic panoramic 360 video.
  52237. */
  52238. static readonly MODE_MONOSCOPIC: number;
  52239. /**
  52240. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52241. */
  52242. static readonly MODE_TOPBOTTOM: number;
  52243. /**
  52244. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52245. */
  52246. static readonly MODE_SIDEBYSIDE: number;
  52247. private _halfDome;
  52248. private _useDirectMapping;
  52249. /**
  52250. * The video texture being displayed on the sphere
  52251. */
  52252. protected _videoTexture: VideoTexture;
  52253. /**
  52254. * Gets the video texture being displayed on the sphere
  52255. */
  52256. readonly videoTexture: VideoTexture;
  52257. /**
  52258. * The skybox material
  52259. */
  52260. protected _material: BackgroundMaterial;
  52261. /**
  52262. * The surface used for the skybox
  52263. */
  52264. protected _mesh: Mesh;
  52265. /**
  52266. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  52267. */
  52268. private _halfDomeMask;
  52269. /**
  52270. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52271. * Also see the options.resolution property.
  52272. */
  52273. fovMultiplier: number;
  52274. private _videoMode;
  52275. /**
  52276. * Gets or set the current video mode for the video. It can be:
  52277. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  52278. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52279. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52280. */
  52281. videoMode: number;
  52282. /**
  52283. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  52284. *
  52285. */
  52286. /**
  52287. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  52288. */
  52289. halfDome: boolean;
  52290. /**
  52291. * Oberserver used in Stereoscopic VR Mode.
  52292. */
  52293. private _onBeforeCameraRenderObserver;
  52294. /**
  52295. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  52296. * @param name Element's name, child elements will append suffixes for their own names.
  52297. * @param urlsOrVideo defines the url(s) or the video element to use
  52298. * @param options An object containing optional or exposed sub element properties
  52299. */
  52300. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  52301. resolution?: number;
  52302. clickToPlay?: boolean;
  52303. autoPlay?: boolean;
  52304. loop?: boolean;
  52305. size?: number;
  52306. poster?: string;
  52307. faceForward?: boolean;
  52308. useDirectMapping?: boolean;
  52309. halfDomeMode?: boolean;
  52310. }, scene: Scene);
  52311. private _changeVideoMode;
  52312. /**
  52313. * Releases resources associated with this node.
  52314. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52315. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52316. */
  52317. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52318. }
  52319. }
  52320. declare module "babylonjs/Helpers/index" {
  52321. export * from "babylonjs/Helpers/environmentHelper";
  52322. export * from "babylonjs/Helpers/photoDome";
  52323. export * from "babylonjs/Helpers/sceneHelpers";
  52324. export * from "babylonjs/Helpers/videoDome";
  52325. }
  52326. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  52327. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  52328. import { IDisposable } from "babylonjs/scene";
  52329. import { Engine } from "babylonjs/Engines/engine";
  52330. /**
  52331. * This class can be used to get instrumentation data from a Babylon engine
  52332. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52333. */
  52334. export class EngineInstrumentation implements IDisposable {
  52335. /**
  52336. * Define the instrumented engine.
  52337. */
  52338. engine: Engine;
  52339. private _captureGPUFrameTime;
  52340. private _gpuFrameTimeToken;
  52341. private _gpuFrameTime;
  52342. private _captureShaderCompilationTime;
  52343. private _shaderCompilationTime;
  52344. private _onBeginFrameObserver;
  52345. private _onEndFrameObserver;
  52346. private _onBeforeShaderCompilationObserver;
  52347. private _onAfterShaderCompilationObserver;
  52348. /**
  52349. * Gets the perf counter used for GPU frame time
  52350. */
  52351. readonly gpuFrameTimeCounter: PerfCounter;
  52352. /**
  52353. * Gets the GPU frame time capture status
  52354. */
  52355. /**
  52356. * Enable or disable the GPU frame time capture
  52357. */
  52358. captureGPUFrameTime: boolean;
  52359. /**
  52360. * Gets the perf counter used for shader compilation time
  52361. */
  52362. readonly shaderCompilationTimeCounter: PerfCounter;
  52363. /**
  52364. * Gets the shader compilation time capture status
  52365. */
  52366. /**
  52367. * Enable or disable the shader compilation time capture
  52368. */
  52369. captureShaderCompilationTime: boolean;
  52370. /**
  52371. * Instantiates a new engine instrumentation.
  52372. * This class can be used to get instrumentation data from a Babylon engine
  52373. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52374. * @param engine Defines the engine to instrument
  52375. */
  52376. constructor(
  52377. /**
  52378. * Define the instrumented engine.
  52379. */
  52380. engine: Engine);
  52381. /**
  52382. * Dispose and release associated resources.
  52383. */
  52384. dispose(): void;
  52385. }
  52386. }
  52387. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  52388. import { Scene, IDisposable } from "babylonjs/scene";
  52389. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  52390. /**
  52391. * This class can be used to get instrumentation data from a Babylon engine
  52392. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52393. */
  52394. export class SceneInstrumentation implements IDisposable {
  52395. /**
  52396. * Defines the scene to instrument
  52397. */
  52398. scene: Scene;
  52399. private _captureActiveMeshesEvaluationTime;
  52400. private _activeMeshesEvaluationTime;
  52401. private _captureRenderTargetsRenderTime;
  52402. private _renderTargetsRenderTime;
  52403. private _captureFrameTime;
  52404. private _frameTime;
  52405. private _captureRenderTime;
  52406. private _renderTime;
  52407. private _captureInterFrameTime;
  52408. private _interFrameTime;
  52409. private _captureParticlesRenderTime;
  52410. private _particlesRenderTime;
  52411. private _captureSpritesRenderTime;
  52412. private _spritesRenderTime;
  52413. private _capturePhysicsTime;
  52414. private _physicsTime;
  52415. private _captureAnimationsTime;
  52416. private _animationsTime;
  52417. private _captureCameraRenderTime;
  52418. private _cameraRenderTime;
  52419. private _onBeforeActiveMeshesEvaluationObserver;
  52420. private _onAfterActiveMeshesEvaluationObserver;
  52421. private _onBeforeRenderTargetsRenderObserver;
  52422. private _onAfterRenderTargetsRenderObserver;
  52423. private _onAfterRenderObserver;
  52424. private _onBeforeDrawPhaseObserver;
  52425. private _onAfterDrawPhaseObserver;
  52426. private _onBeforeAnimationsObserver;
  52427. private _onBeforeParticlesRenderingObserver;
  52428. private _onAfterParticlesRenderingObserver;
  52429. private _onBeforeSpritesRenderingObserver;
  52430. private _onAfterSpritesRenderingObserver;
  52431. private _onBeforePhysicsObserver;
  52432. private _onAfterPhysicsObserver;
  52433. private _onAfterAnimationsObserver;
  52434. private _onBeforeCameraRenderObserver;
  52435. private _onAfterCameraRenderObserver;
  52436. /**
  52437. * Gets the perf counter used for active meshes evaluation time
  52438. */
  52439. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  52440. /**
  52441. * Gets the active meshes evaluation time capture status
  52442. */
  52443. /**
  52444. * Enable or disable the active meshes evaluation time capture
  52445. */
  52446. captureActiveMeshesEvaluationTime: boolean;
  52447. /**
  52448. * Gets the perf counter used for render targets render time
  52449. */
  52450. readonly renderTargetsRenderTimeCounter: PerfCounter;
  52451. /**
  52452. * Gets the render targets render time capture status
  52453. */
  52454. /**
  52455. * Enable or disable the render targets render time capture
  52456. */
  52457. captureRenderTargetsRenderTime: boolean;
  52458. /**
  52459. * Gets the perf counter used for particles render time
  52460. */
  52461. readonly particlesRenderTimeCounter: PerfCounter;
  52462. /**
  52463. * Gets the particles render time capture status
  52464. */
  52465. /**
  52466. * Enable or disable the particles render time capture
  52467. */
  52468. captureParticlesRenderTime: boolean;
  52469. /**
  52470. * Gets the perf counter used for sprites render time
  52471. */
  52472. readonly spritesRenderTimeCounter: PerfCounter;
  52473. /**
  52474. * Gets the sprites render time capture status
  52475. */
  52476. /**
  52477. * Enable or disable the sprites render time capture
  52478. */
  52479. captureSpritesRenderTime: boolean;
  52480. /**
  52481. * Gets the perf counter used for physics time
  52482. */
  52483. readonly physicsTimeCounter: PerfCounter;
  52484. /**
  52485. * Gets the physics time capture status
  52486. */
  52487. /**
  52488. * Enable or disable the physics time capture
  52489. */
  52490. capturePhysicsTime: boolean;
  52491. /**
  52492. * Gets the perf counter used for animations time
  52493. */
  52494. readonly animationsTimeCounter: PerfCounter;
  52495. /**
  52496. * Gets the animations time capture status
  52497. */
  52498. /**
  52499. * Enable or disable the animations time capture
  52500. */
  52501. captureAnimationsTime: boolean;
  52502. /**
  52503. * Gets the perf counter used for frame time capture
  52504. */
  52505. readonly frameTimeCounter: PerfCounter;
  52506. /**
  52507. * Gets the frame time capture status
  52508. */
  52509. /**
  52510. * Enable or disable the frame time capture
  52511. */
  52512. captureFrameTime: boolean;
  52513. /**
  52514. * Gets the perf counter used for inter-frames time capture
  52515. */
  52516. readonly interFrameTimeCounter: PerfCounter;
  52517. /**
  52518. * Gets the inter-frames time capture status
  52519. */
  52520. /**
  52521. * Enable or disable the inter-frames time capture
  52522. */
  52523. captureInterFrameTime: boolean;
  52524. /**
  52525. * Gets the perf counter used for render time capture
  52526. */
  52527. readonly renderTimeCounter: PerfCounter;
  52528. /**
  52529. * Gets the render time capture status
  52530. */
  52531. /**
  52532. * Enable or disable the render time capture
  52533. */
  52534. captureRenderTime: boolean;
  52535. /**
  52536. * Gets the perf counter used for camera render time capture
  52537. */
  52538. readonly cameraRenderTimeCounter: PerfCounter;
  52539. /**
  52540. * Gets the camera render time capture status
  52541. */
  52542. /**
  52543. * Enable or disable the camera render time capture
  52544. */
  52545. captureCameraRenderTime: boolean;
  52546. /**
  52547. * Gets the perf counter used for draw calls
  52548. */
  52549. readonly drawCallsCounter: PerfCounter;
  52550. /**
  52551. * Instantiates a new scene instrumentation.
  52552. * This class can be used to get instrumentation data from a Babylon engine
  52553. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52554. * @param scene Defines the scene to instrument
  52555. */
  52556. constructor(
  52557. /**
  52558. * Defines the scene to instrument
  52559. */
  52560. scene: Scene);
  52561. /**
  52562. * Dispose and release associated resources.
  52563. */
  52564. dispose(): void;
  52565. }
  52566. }
  52567. declare module "babylonjs/Instrumentation/index" {
  52568. export * from "babylonjs/Instrumentation/engineInstrumentation";
  52569. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  52570. export * from "babylonjs/Instrumentation/timeToken";
  52571. }
  52572. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  52573. /** @hidden */
  52574. export var glowMapGenerationPixelShader: {
  52575. name: string;
  52576. shader: string;
  52577. };
  52578. }
  52579. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  52580. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52581. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  52582. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  52583. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52584. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  52585. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52586. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52587. /** @hidden */
  52588. export var glowMapGenerationVertexShader: {
  52589. name: string;
  52590. shader: string;
  52591. };
  52592. }
  52593. declare module "babylonjs/Layers/effectLayer" {
  52594. import { Observable } from "babylonjs/Misc/observable";
  52595. import { Nullable } from "babylonjs/types";
  52596. import { Camera } from "babylonjs/Cameras/camera";
  52597. import { Scene } from "babylonjs/scene";
  52598. import { ISize } from "babylonjs/Maths/math.size";
  52599. import { Color4 } from "babylonjs/Maths/math.color";
  52600. import { Engine } from "babylonjs/Engines/engine";
  52601. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52602. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52603. import { Mesh } from "babylonjs/Meshes/mesh";
  52604. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52605. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52606. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52607. import { Effect } from "babylonjs/Materials/effect";
  52608. import { Material } from "babylonjs/Materials/material";
  52609. import "babylonjs/Shaders/glowMapGeneration.fragment";
  52610. import "babylonjs/Shaders/glowMapGeneration.vertex";
  52611. /**
  52612. * Effect layer options. This helps customizing the behaviour
  52613. * of the effect layer.
  52614. */
  52615. export interface IEffectLayerOptions {
  52616. /**
  52617. * Multiplication factor apply to the canvas size to compute the render target size
  52618. * used to generated the objects (the smaller the faster).
  52619. */
  52620. mainTextureRatio: number;
  52621. /**
  52622. * Enforces a fixed size texture to ensure effect stability across devices.
  52623. */
  52624. mainTextureFixedSize?: number;
  52625. /**
  52626. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  52627. */
  52628. alphaBlendingMode: number;
  52629. /**
  52630. * The camera attached to the layer.
  52631. */
  52632. camera: Nullable<Camera>;
  52633. /**
  52634. * The rendering group to draw the layer in.
  52635. */
  52636. renderingGroupId: number;
  52637. }
  52638. /**
  52639. * The effect layer Helps adding post process effect blended with the main pass.
  52640. *
  52641. * This can be for instance use to generate glow or higlight effects on the scene.
  52642. *
  52643. * The effect layer class can not be used directly and is intented to inherited from to be
  52644. * customized per effects.
  52645. */
  52646. export abstract class EffectLayer {
  52647. private _vertexBuffers;
  52648. private _indexBuffer;
  52649. private _cachedDefines;
  52650. private _effectLayerMapGenerationEffect;
  52651. private _effectLayerOptions;
  52652. private _mergeEffect;
  52653. protected _scene: Scene;
  52654. protected _engine: Engine;
  52655. protected _maxSize: number;
  52656. protected _mainTextureDesiredSize: ISize;
  52657. protected _mainTexture: RenderTargetTexture;
  52658. protected _shouldRender: boolean;
  52659. protected _postProcesses: PostProcess[];
  52660. protected _textures: BaseTexture[];
  52661. protected _emissiveTextureAndColor: {
  52662. texture: Nullable<BaseTexture>;
  52663. color: Color4;
  52664. };
  52665. /**
  52666. * The name of the layer
  52667. */
  52668. name: string;
  52669. /**
  52670. * The clear color of the texture used to generate the glow map.
  52671. */
  52672. neutralColor: Color4;
  52673. /**
  52674. * Specifies wether the highlight layer is enabled or not.
  52675. */
  52676. isEnabled: boolean;
  52677. /**
  52678. * Gets the camera attached to the layer.
  52679. */
  52680. readonly camera: Nullable<Camera>;
  52681. /**
  52682. * Gets the rendering group id the layer should render in.
  52683. */
  52684. renderingGroupId: number;
  52685. /**
  52686. * An event triggered when the effect layer has been disposed.
  52687. */
  52688. onDisposeObservable: Observable<EffectLayer>;
  52689. /**
  52690. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  52691. */
  52692. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  52693. /**
  52694. * An event triggered when the generated texture is being merged in the scene.
  52695. */
  52696. onBeforeComposeObservable: Observable<EffectLayer>;
  52697. /**
  52698. * An event triggered when the mesh is rendered into the effect render target.
  52699. */
  52700. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  52701. /**
  52702. * An event triggered after the mesh has been rendered into the effect render target.
  52703. */
  52704. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  52705. /**
  52706. * An event triggered when the generated texture has been merged in the scene.
  52707. */
  52708. onAfterComposeObservable: Observable<EffectLayer>;
  52709. /**
  52710. * An event triggered when the efffect layer changes its size.
  52711. */
  52712. onSizeChangedObservable: Observable<EffectLayer>;
  52713. /** @hidden */
  52714. static _SceneComponentInitialization: (scene: Scene) => void;
  52715. /**
  52716. * Instantiates a new effect Layer and references it in the scene.
  52717. * @param name The name of the layer
  52718. * @param scene The scene to use the layer in
  52719. */
  52720. constructor(
  52721. /** The Friendly of the effect in the scene */
  52722. name: string, scene: Scene);
  52723. /**
  52724. * Get the effect name of the layer.
  52725. * @return The effect name
  52726. */
  52727. abstract getEffectName(): string;
  52728. /**
  52729. * Checks for the readiness of the element composing the layer.
  52730. * @param subMesh the mesh to check for
  52731. * @param useInstances specify wether or not to use instances to render the mesh
  52732. * @return true if ready otherwise, false
  52733. */
  52734. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52735. /**
  52736. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52737. * @returns true if the effect requires stencil during the main canvas render pass.
  52738. */
  52739. abstract needStencil(): boolean;
  52740. /**
  52741. * Create the merge effect. This is the shader use to blit the information back
  52742. * to the main canvas at the end of the scene rendering.
  52743. * @returns The effect containing the shader used to merge the effect on the main canvas
  52744. */
  52745. protected abstract _createMergeEffect(): Effect;
  52746. /**
  52747. * Creates the render target textures and post processes used in the effect layer.
  52748. */
  52749. protected abstract _createTextureAndPostProcesses(): void;
  52750. /**
  52751. * Implementation specific of rendering the generating effect on the main canvas.
  52752. * @param effect The effect used to render through
  52753. */
  52754. protected abstract _internalRender(effect: Effect): void;
  52755. /**
  52756. * Sets the required values for both the emissive texture and and the main color.
  52757. */
  52758. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52759. /**
  52760. * Free any resources and references associated to a mesh.
  52761. * Internal use
  52762. * @param mesh The mesh to free.
  52763. */
  52764. abstract _disposeMesh(mesh: Mesh): void;
  52765. /**
  52766. * Serializes this layer (Glow or Highlight for example)
  52767. * @returns a serialized layer object
  52768. */
  52769. abstract serialize?(): any;
  52770. /**
  52771. * Initializes the effect layer with the required options.
  52772. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  52773. */
  52774. protected _init(options: Partial<IEffectLayerOptions>): void;
  52775. /**
  52776. * Generates the index buffer of the full screen quad blending to the main canvas.
  52777. */
  52778. private _generateIndexBuffer;
  52779. /**
  52780. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  52781. */
  52782. private _generateVertexBuffer;
  52783. /**
  52784. * Sets the main texture desired size which is the closest power of two
  52785. * of the engine canvas size.
  52786. */
  52787. private _setMainTextureSize;
  52788. /**
  52789. * Creates the main texture for the effect layer.
  52790. */
  52791. protected _createMainTexture(): void;
  52792. /**
  52793. * Adds specific effects defines.
  52794. * @param defines The defines to add specifics to.
  52795. */
  52796. protected _addCustomEffectDefines(defines: string[]): void;
  52797. /**
  52798. * Checks for the readiness of the element composing the layer.
  52799. * @param subMesh the mesh to check for
  52800. * @param useInstances specify wether or not to use instances to render the mesh
  52801. * @param emissiveTexture the associated emissive texture used to generate the glow
  52802. * @return true if ready otherwise, false
  52803. */
  52804. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  52805. /**
  52806. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  52807. */
  52808. render(): void;
  52809. /**
  52810. * Determine if a given mesh will be used in the current effect.
  52811. * @param mesh mesh to test
  52812. * @returns true if the mesh will be used
  52813. */
  52814. hasMesh(mesh: AbstractMesh): boolean;
  52815. /**
  52816. * Returns true if the layer contains information to display, otherwise false.
  52817. * @returns true if the glow layer should be rendered
  52818. */
  52819. shouldRender(): boolean;
  52820. /**
  52821. * Returns true if the mesh should render, otherwise false.
  52822. * @param mesh The mesh to render
  52823. * @returns true if it should render otherwise false
  52824. */
  52825. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  52826. /**
  52827. * Returns true if the mesh can be rendered, otherwise false.
  52828. * @param mesh The mesh to render
  52829. * @param material The material used on the mesh
  52830. * @returns true if it can be rendered otherwise false
  52831. */
  52832. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52833. /**
  52834. * Returns true if the mesh should render, otherwise false.
  52835. * @param mesh The mesh to render
  52836. * @returns true if it should render otherwise false
  52837. */
  52838. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  52839. /**
  52840. * Renders the submesh passed in parameter to the generation map.
  52841. */
  52842. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  52843. /**
  52844. * Defines wether the current material of the mesh should be use to render the effect.
  52845. * @param mesh defines the current mesh to render
  52846. */
  52847. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52848. /**
  52849. * Rebuild the required buffers.
  52850. * @hidden Internal use only.
  52851. */
  52852. _rebuild(): void;
  52853. /**
  52854. * Dispose only the render target textures and post process.
  52855. */
  52856. private _disposeTextureAndPostProcesses;
  52857. /**
  52858. * Dispose the highlight layer and free resources.
  52859. */
  52860. dispose(): void;
  52861. /**
  52862. * Gets the class name of the effect layer
  52863. * @returns the string with the class name of the effect layer
  52864. */
  52865. getClassName(): string;
  52866. /**
  52867. * Creates an effect layer from parsed effect layer data
  52868. * @param parsedEffectLayer defines effect layer data
  52869. * @param scene defines the current scene
  52870. * @param rootUrl defines the root URL containing the effect layer information
  52871. * @returns a parsed effect Layer
  52872. */
  52873. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  52874. }
  52875. }
  52876. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  52877. import { Scene } from "babylonjs/scene";
  52878. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52879. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52880. import { AbstractScene } from "babylonjs/abstractScene";
  52881. module "babylonjs/abstractScene" {
  52882. interface AbstractScene {
  52883. /**
  52884. * The list of effect layers (highlights/glow) added to the scene
  52885. * @see http://doc.babylonjs.com/how_to/highlight_layer
  52886. * @see http://doc.babylonjs.com/how_to/glow_layer
  52887. */
  52888. effectLayers: Array<EffectLayer>;
  52889. /**
  52890. * Removes the given effect layer from this scene.
  52891. * @param toRemove defines the effect layer to remove
  52892. * @returns the index of the removed effect layer
  52893. */
  52894. removeEffectLayer(toRemove: EffectLayer): number;
  52895. /**
  52896. * Adds the given effect layer to this scene
  52897. * @param newEffectLayer defines the effect layer to add
  52898. */
  52899. addEffectLayer(newEffectLayer: EffectLayer): void;
  52900. }
  52901. }
  52902. /**
  52903. * Defines the layer scene component responsible to manage any effect layers
  52904. * in a given scene.
  52905. */
  52906. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  52907. /**
  52908. * The component name helpfull to identify the component in the list of scene components.
  52909. */
  52910. readonly name: string;
  52911. /**
  52912. * The scene the component belongs to.
  52913. */
  52914. scene: Scene;
  52915. private _engine;
  52916. private _renderEffects;
  52917. private _needStencil;
  52918. private _previousStencilState;
  52919. /**
  52920. * Creates a new instance of the component for the given scene
  52921. * @param scene Defines the scene to register the component in
  52922. */
  52923. constructor(scene: Scene);
  52924. /**
  52925. * Registers the component in a given scene
  52926. */
  52927. register(): void;
  52928. /**
  52929. * Rebuilds the elements related to this component in case of
  52930. * context lost for instance.
  52931. */
  52932. rebuild(): void;
  52933. /**
  52934. * Serializes the component data to the specified json object
  52935. * @param serializationObject The object to serialize to
  52936. */
  52937. serialize(serializationObject: any): void;
  52938. /**
  52939. * Adds all the elements from the container to the scene
  52940. * @param container the container holding the elements
  52941. */
  52942. addFromContainer(container: AbstractScene): void;
  52943. /**
  52944. * Removes all the elements in the container from the scene
  52945. * @param container contains the elements to remove
  52946. * @param dispose if the removed element should be disposed (default: false)
  52947. */
  52948. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52949. /**
  52950. * Disposes the component and the associated ressources.
  52951. */
  52952. dispose(): void;
  52953. private _isReadyForMesh;
  52954. private _renderMainTexture;
  52955. private _setStencil;
  52956. private _setStencilBack;
  52957. private _draw;
  52958. private _drawCamera;
  52959. private _drawRenderingGroup;
  52960. }
  52961. }
  52962. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  52963. /** @hidden */
  52964. export var glowMapMergePixelShader: {
  52965. name: string;
  52966. shader: string;
  52967. };
  52968. }
  52969. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  52970. /** @hidden */
  52971. export var glowMapMergeVertexShader: {
  52972. name: string;
  52973. shader: string;
  52974. };
  52975. }
  52976. declare module "babylonjs/Layers/glowLayer" {
  52977. import { Nullable } from "babylonjs/types";
  52978. import { Camera } from "babylonjs/Cameras/camera";
  52979. import { Scene } from "babylonjs/scene";
  52980. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52981. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52982. import { Mesh } from "babylonjs/Meshes/mesh";
  52983. import { Texture } from "babylonjs/Materials/Textures/texture";
  52984. import { Effect } from "babylonjs/Materials/effect";
  52985. import { Material } from "babylonjs/Materials/material";
  52986. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52987. import { Color4 } from "babylonjs/Maths/math.color";
  52988. import "babylonjs/Shaders/glowMapMerge.fragment";
  52989. import "babylonjs/Shaders/glowMapMerge.vertex";
  52990. import "babylonjs/Layers/effectLayerSceneComponent";
  52991. module "babylonjs/abstractScene" {
  52992. interface AbstractScene {
  52993. /**
  52994. * Return a the first highlight layer of the scene with a given name.
  52995. * @param name The name of the highlight layer to look for.
  52996. * @return The highlight layer if found otherwise null.
  52997. */
  52998. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  52999. }
  53000. }
  53001. /**
  53002. * Glow layer options. This helps customizing the behaviour
  53003. * of the glow layer.
  53004. */
  53005. export interface IGlowLayerOptions {
  53006. /**
  53007. * Multiplication factor apply to the canvas size to compute the render target size
  53008. * used to generated the glowing objects (the smaller the faster).
  53009. */
  53010. mainTextureRatio: number;
  53011. /**
  53012. * Enforces a fixed size texture to ensure resize independant blur.
  53013. */
  53014. mainTextureFixedSize?: number;
  53015. /**
  53016. * How big is the kernel of the blur texture.
  53017. */
  53018. blurKernelSize: number;
  53019. /**
  53020. * The camera attached to the layer.
  53021. */
  53022. camera: Nullable<Camera>;
  53023. /**
  53024. * Enable MSAA by chosing the number of samples.
  53025. */
  53026. mainTextureSamples?: number;
  53027. /**
  53028. * The rendering group to draw the layer in.
  53029. */
  53030. renderingGroupId: number;
  53031. }
  53032. /**
  53033. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53034. *
  53035. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53036. *
  53037. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53038. */
  53039. export class GlowLayer extends EffectLayer {
  53040. /**
  53041. * Effect Name of the layer.
  53042. */
  53043. static readonly EffectName: string;
  53044. /**
  53045. * The default blur kernel size used for the glow.
  53046. */
  53047. static DefaultBlurKernelSize: number;
  53048. /**
  53049. * The default texture size ratio used for the glow.
  53050. */
  53051. static DefaultTextureRatio: number;
  53052. /**
  53053. * Sets the kernel size of the blur.
  53054. */
  53055. /**
  53056. * Gets the kernel size of the blur.
  53057. */
  53058. blurKernelSize: number;
  53059. /**
  53060. * Sets the glow intensity.
  53061. */
  53062. /**
  53063. * Gets the glow intensity.
  53064. */
  53065. intensity: number;
  53066. private _options;
  53067. private _intensity;
  53068. private _horizontalBlurPostprocess1;
  53069. private _verticalBlurPostprocess1;
  53070. private _horizontalBlurPostprocess2;
  53071. private _verticalBlurPostprocess2;
  53072. private _blurTexture1;
  53073. private _blurTexture2;
  53074. private _postProcesses1;
  53075. private _postProcesses2;
  53076. private _includedOnlyMeshes;
  53077. private _excludedMeshes;
  53078. private _meshesUsingTheirOwnMaterials;
  53079. /**
  53080. * Callback used to let the user override the color selection on a per mesh basis
  53081. */
  53082. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53083. /**
  53084. * Callback used to let the user override the texture selection on a per mesh basis
  53085. */
  53086. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53087. /**
  53088. * Instantiates a new glow Layer and references it to the scene.
  53089. * @param name The name of the layer
  53090. * @param scene The scene to use the layer in
  53091. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53092. */
  53093. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53094. /**
  53095. * Get the effect name of the layer.
  53096. * @return The effect name
  53097. */
  53098. getEffectName(): string;
  53099. /**
  53100. * Create the merge effect. This is the shader use to blit the information back
  53101. * to the main canvas at the end of the scene rendering.
  53102. */
  53103. protected _createMergeEffect(): Effect;
  53104. /**
  53105. * Creates the render target textures and post processes used in the glow layer.
  53106. */
  53107. protected _createTextureAndPostProcesses(): void;
  53108. /**
  53109. * Checks for the readiness of the element composing the layer.
  53110. * @param subMesh the mesh to check for
  53111. * @param useInstances specify wether or not to use instances to render the mesh
  53112. * @param emissiveTexture the associated emissive texture used to generate the glow
  53113. * @return true if ready otherwise, false
  53114. */
  53115. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53116. /**
  53117. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53118. */
  53119. needStencil(): boolean;
  53120. /**
  53121. * Returns true if the mesh can be rendered, otherwise false.
  53122. * @param mesh The mesh to render
  53123. * @param material The material used on the mesh
  53124. * @returns true if it can be rendered otherwise false
  53125. */
  53126. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53127. /**
  53128. * Implementation specific of rendering the generating effect on the main canvas.
  53129. * @param effect The effect used to render through
  53130. */
  53131. protected _internalRender(effect: Effect): void;
  53132. /**
  53133. * Sets the required values for both the emissive texture and and the main color.
  53134. */
  53135. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53136. /**
  53137. * Returns true if the mesh should render, otherwise false.
  53138. * @param mesh The mesh to render
  53139. * @returns true if it should render otherwise false
  53140. */
  53141. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53142. /**
  53143. * Adds specific effects defines.
  53144. * @param defines The defines to add specifics to.
  53145. */
  53146. protected _addCustomEffectDefines(defines: string[]): void;
  53147. /**
  53148. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  53149. * @param mesh The mesh to exclude from the glow layer
  53150. */
  53151. addExcludedMesh(mesh: Mesh): void;
  53152. /**
  53153. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  53154. * @param mesh The mesh to remove
  53155. */
  53156. removeExcludedMesh(mesh: Mesh): void;
  53157. /**
  53158. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  53159. * @param mesh The mesh to include in the glow layer
  53160. */
  53161. addIncludedOnlyMesh(mesh: Mesh): void;
  53162. /**
  53163. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  53164. * @param mesh The mesh to remove
  53165. */
  53166. removeIncludedOnlyMesh(mesh: Mesh): void;
  53167. /**
  53168. * Determine if a given mesh will be used in the glow layer
  53169. * @param mesh The mesh to test
  53170. * @returns true if the mesh will be highlighted by the current glow layer
  53171. */
  53172. hasMesh(mesh: AbstractMesh): boolean;
  53173. /**
  53174. * Defines wether the current material of the mesh should be use to render the effect.
  53175. * @param mesh defines the current mesh to render
  53176. */
  53177. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53178. /**
  53179. * Add a mesh to be rendered through its own material and not with emissive only.
  53180. * @param mesh The mesh for which we need to use its material
  53181. */
  53182. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  53183. /**
  53184. * Remove a mesh from being rendered through its own material and not with emissive only.
  53185. * @param mesh The mesh for which we need to not use its material
  53186. */
  53187. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  53188. /**
  53189. * Free any resources and references associated to a mesh.
  53190. * Internal use
  53191. * @param mesh The mesh to free.
  53192. * @hidden
  53193. */
  53194. _disposeMesh(mesh: Mesh): void;
  53195. /**
  53196. * Gets the class name of the effect layer
  53197. * @returns the string with the class name of the effect layer
  53198. */
  53199. getClassName(): string;
  53200. /**
  53201. * Serializes this glow layer
  53202. * @returns a serialized glow layer object
  53203. */
  53204. serialize(): any;
  53205. /**
  53206. * Creates a Glow Layer from parsed glow layer data
  53207. * @param parsedGlowLayer defines glow layer data
  53208. * @param scene defines the current scene
  53209. * @param rootUrl defines the root URL containing the glow layer information
  53210. * @returns a parsed Glow Layer
  53211. */
  53212. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  53213. }
  53214. }
  53215. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  53216. /** @hidden */
  53217. export var glowBlurPostProcessPixelShader: {
  53218. name: string;
  53219. shader: string;
  53220. };
  53221. }
  53222. declare module "babylonjs/Layers/highlightLayer" {
  53223. import { Observable } from "babylonjs/Misc/observable";
  53224. import { Nullable } from "babylonjs/types";
  53225. import { Camera } from "babylonjs/Cameras/camera";
  53226. import { Scene } from "babylonjs/scene";
  53227. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53228. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53229. import { Mesh } from "babylonjs/Meshes/mesh";
  53230. import { Effect } from "babylonjs/Materials/effect";
  53231. import { Material } from "babylonjs/Materials/material";
  53232. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  53233. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  53234. import "babylonjs/Shaders/glowMapMerge.fragment";
  53235. import "babylonjs/Shaders/glowMapMerge.vertex";
  53236. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  53237. module "babylonjs/abstractScene" {
  53238. interface AbstractScene {
  53239. /**
  53240. * Return a the first highlight layer of the scene with a given name.
  53241. * @param name The name of the highlight layer to look for.
  53242. * @return The highlight layer if found otherwise null.
  53243. */
  53244. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  53245. }
  53246. }
  53247. /**
  53248. * Highlight layer options. This helps customizing the behaviour
  53249. * of the highlight layer.
  53250. */
  53251. export interface IHighlightLayerOptions {
  53252. /**
  53253. * Multiplication factor apply to the canvas size to compute the render target size
  53254. * used to generated the glowing objects (the smaller the faster).
  53255. */
  53256. mainTextureRatio: number;
  53257. /**
  53258. * Enforces a fixed size texture to ensure resize independant blur.
  53259. */
  53260. mainTextureFixedSize?: number;
  53261. /**
  53262. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  53263. * of the picture to blur (the smaller the faster).
  53264. */
  53265. blurTextureSizeRatio: number;
  53266. /**
  53267. * How big in texel of the blur texture is the vertical blur.
  53268. */
  53269. blurVerticalSize: number;
  53270. /**
  53271. * How big in texel of the blur texture is the horizontal blur.
  53272. */
  53273. blurHorizontalSize: number;
  53274. /**
  53275. * Alpha blending mode used to apply the blur. Default is combine.
  53276. */
  53277. alphaBlendingMode: number;
  53278. /**
  53279. * The camera attached to the layer.
  53280. */
  53281. camera: Nullable<Camera>;
  53282. /**
  53283. * Should we display highlight as a solid stroke?
  53284. */
  53285. isStroke?: boolean;
  53286. /**
  53287. * The rendering group to draw the layer in.
  53288. */
  53289. renderingGroupId: number;
  53290. }
  53291. /**
  53292. * The highlight layer Helps adding a glow effect around a mesh.
  53293. *
  53294. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  53295. * glowy meshes to your scene.
  53296. *
  53297. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  53298. */
  53299. export class HighlightLayer extends EffectLayer {
  53300. name: string;
  53301. /**
  53302. * Effect Name of the highlight layer.
  53303. */
  53304. static readonly EffectName: string;
  53305. /**
  53306. * The neutral color used during the preparation of the glow effect.
  53307. * This is black by default as the blend operation is a blend operation.
  53308. */
  53309. static NeutralColor: Color4;
  53310. /**
  53311. * Stencil value used for glowing meshes.
  53312. */
  53313. static GlowingMeshStencilReference: number;
  53314. /**
  53315. * Stencil value used for the other meshes in the scene.
  53316. */
  53317. static NormalMeshStencilReference: number;
  53318. /**
  53319. * Specifies whether or not the inner glow is ACTIVE in the layer.
  53320. */
  53321. innerGlow: boolean;
  53322. /**
  53323. * Specifies whether or not the outer glow is ACTIVE in the layer.
  53324. */
  53325. outerGlow: boolean;
  53326. /**
  53327. * Specifies the horizontal size of the blur.
  53328. */
  53329. /**
  53330. * Gets the horizontal size of the blur.
  53331. */
  53332. blurHorizontalSize: number;
  53333. /**
  53334. * Specifies the vertical size of the blur.
  53335. */
  53336. /**
  53337. * Gets the vertical size of the blur.
  53338. */
  53339. blurVerticalSize: number;
  53340. /**
  53341. * An event triggered when the highlight layer is being blurred.
  53342. */
  53343. onBeforeBlurObservable: Observable<HighlightLayer>;
  53344. /**
  53345. * An event triggered when the highlight layer has been blurred.
  53346. */
  53347. onAfterBlurObservable: Observable<HighlightLayer>;
  53348. private _instanceGlowingMeshStencilReference;
  53349. private _options;
  53350. private _downSamplePostprocess;
  53351. private _horizontalBlurPostprocess;
  53352. private _verticalBlurPostprocess;
  53353. private _blurTexture;
  53354. private _meshes;
  53355. private _excludedMeshes;
  53356. /**
  53357. * Instantiates a new highlight Layer and references it to the scene..
  53358. * @param name The name of the layer
  53359. * @param scene The scene to use the layer in
  53360. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  53361. */
  53362. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  53363. /**
  53364. * Get the effect name of the layer.
  53365. * @return The effect name
  53366. */
  53367. getEffectName(): string;
  53368. /**
  53369. * Create the merge effect. This is the shader use to blit the information back
  53370. * to the main canvas at the end of the scene rendering.
  53371. */
  53372. protected _createMergeEffect(): Effect;
  53373. /**
  53374. * Creates the render target textures and post processes used in the highlight layer.
  53375. */
  53376. protected _createTextureAndPostProcesses(): void;
  53377. /**
  53378. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53379. */
  53380. needStencil(): boolean;
  53381. /**
  53382. * Checks for the readiness of the element composing the layer.
  53383. * @param subMesh the mesh to check for
  53384. * @param useInstances specify wether or not to use instances to render the mesh
  53385. * @param emissiveTexture the associated emissive texture used to generate the glow
  53386. * @return true if ready otherwise, false
  53387. */
  53388. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53389. /**
  53390. * Implementation specific of rendering the generating effect on the main canvas.
  53391. * @param effect The effect used to render through
  53392. */
  53393. protected _internalRender(effect: Effect): void;
  53394. /**
  53395. * Returns true if the layer contains information to display, otherwise false.
  53396. */
  53397. shouldRender(): boolean;
  53398. /**
  53399. * Returns true if the mesh should render, otherwise false.
  53400. * @param mesh The mesh to render
  53401. * @returns true if it should render otherwise false
  53402. */
  53403. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53404. /**
  53405. * Sets the required values for both the emissive texture and and the main color.
  53406. */
  53407. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53408. /**
  53409. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  53410. * @param mesh The mesh to exclude from the highlight layer
  53411. */
  53412. addExcludedMesh(mesh: Mesh): void;
  53413. /**
  53414. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  53415. * @param mesh The mesh to highlight
  53416. */
  53417. removeExcludedMesh(mesh: Mesh): void;
  53418. /**
  53419. * Determine if a given mesh will be highlighted by the current HighlightLayer
  53420. * @param mesh mesh to test
  53421. * @returns true if the mesh will be highlighted by the current HighlightLayer
  53422. */
  53423. hasMesh(mesh: AbstractMesh): boolean;
  53424. /**
  53425. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  53426. * @param mesh The mesh to highlight
  53427. * @param color The color of the highlight
  53428. * @param glowEmissiveOnly Extract the glow from the emissive texture
  53429. */
  53430. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  53431. /**
  53432. * Remove a mesh from the highlight layer in order to make it stop glowing.
  53433. * @param mesh The mesh to highlight
  53434. */
  53435. removeMesh(mesh: Mesh): void;
  53436. /**
  53437. * Force the stencil to the normal expected value for none glowing parts
  53438. */
  53439. private _defaultStencilReference;
  53440. /**
  53441. * Free any resources and references associated to a mesh.
  53442. * Internal use
  53443. * @param mesh The mesh to free.
  53444. * @hidden
  53445. */
  53446. _disposeMesh(mesh: Mesh): void;
  53447. /**
  53448. * Dispose the highlight layer and free resources.
  53449. */
  53450. dispose(): void;
  53451. /**
  53452. * Gets the class name of the effect layer
  53453. * @returns the string with the class name of the effect layer
  53454. */
  53455. getClassName(): string;
  53456. /**
  53457. * Serializes this Highlight layer
  53458. * @returns a serialized Highlight layer object
  53459. */
  53460. serialize(): any;
  53461. /**
  53462. * Creates a Highlight layer from parsed Highlight layer data
  53463. * @param parsedHightlightLayer defines the Highlight layer data
  53464. * @param scene defines the current scene
  53465. * @param rootUrl defines the root URL containing the Highlight layer information
  53466. * @returns a parsed Highlight layer
  53467. */
  53468. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  53469. }
  53470. }
  53471. declare module "babylonjs/Layers/layerSceneComponent" {
  53472. import { Scene } from "babylonjs/scene";
  53473. import { ISceneComponent } from "babylonjs/sceneComponent";
  53474. import { Layer } from "babylonjs/Layers/layer";
  53475. import { AbstractScene } from "babylonjs/abstractScene";
  53476. module "babylonjs/abstractScene" {
  53477. interface AbstractScene {
  53478. /**
  53479. * The list of layers (background and foreground) of the scene
  53480. */
  53481. layers: Array<Layer>;
  53482. }
  53483. }
  53484. /**
  53485. * Defines the layer scene component responsible to manage any layers
  53486. * in a given scene.
  53487. */
  53488. export class LayerSceneComponent implements ISceneComponent {
  53489. /**
  53490. * The component name helpfull to identify the component in the list of scene components.
  53491. */
  53492. readonly name: string;
  53493. /**
  53494. * The scene the component belongs to.
  53495. */
  53496. scene: Scene;
  53497. private _engine;
  53498. /**
  53499. * Creates a new instance of the component for the given scene
  53500. * @param scene Defines the scene to register the component in
  53501. */
  53502. constructor(scene: Scene);
  53503. /**
  53504. * Registers the component in a given scene
  53505. */
  53506. register(): void;
  53507. /**
  53508. * Rebuilds the elements related to this component in case of
  53509. * context lost for instance.
  53510. */
  53511. rebuild(): void;
  53512. /**
  53513. * Disposes the component and the associated ressources.
  53514. */
  53515. dispose(): void;
  53516. private _draw;
  53517. private _drawCameraPredicate;
  53518. private _drawCameraBackground;
  53519. private _drawCameraForeground;
  53520. private _drawRenderTargetPredicate;
  53521. private _drawRenderTargetBackground;
  53522. private _drawRenderTargetForeground;
  53523. /**
  53524. * Adds all the elements from the container to the scene
  53525. * @param container the container holding the elements
  53526. */
  53527. addFromContainer(container: AbstractScene): void;
  53528. /**
  53529. * Removes all the elements in the container from the scene
  53530. * @param container contains the elements to remove
  53531. * @param dispose if the removed element should be disposed (default: false)
  53532. */
  53533. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53534. }
  53535. }
  53536. declare module "babylonjs/Shaders/layer.fragment" {
  53537. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53538. /** @hidden */
  53539. export var layerPixelShader: {
  53540. name: string;
  53541. shader: string;
  53542. };
  53543. }
  53544. declare module "babylonjs/Shaders/layer.vertex" {
  53545. /** @hidden */
  53546. export var layerVertexShader: {
  53547. name: string;
  53548. shader: string;
  53549. };
  53550. }
  53551. declare module "babylonjs/Layers/layer" {
  53552. import { Observable } from "babylonjs/Misc/observable";
  53553. import { Nullable } from "babylonjs/types";
  53554. import { Scene } from "babylonjs/scene";
  53555. import { Vector2 } from "babylonjs/Maths/math.vector";
  53556. import { Color4 } from "babylonjs/Maths/math.color";
  53557. import { Texture } from "babylonjs/Materials/Textures/texture";
  53558. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53559. import "babylonjs/Shaders/layer.fragment";
  53560. import "babylonjs/Shaders/layer.vertex";
  53561. /**
  53562. * This represents a full screen 2d layer.
  53563. * This can be useful to display a picture in the background of your scene for instance.
  53564. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53565. */
  53566. export class Layer {
  53567. /**
  53568. * Define the name of the layer.
  53569. */
  53570. name: string;
  53571. /**
  53572. * Define the texture the layer should display.
  53573. */
  53574. texture: Nullable<Texture>;
  53575. /**
  53576. * Is the layer in background or foreground.
  53577. */
  53578. isBackground: boolean;
  53579. /**
  53580. * Define the color of the layer (instead of texture).
  53581. */
  53582. color: Color4;
  53583. /**
  53584. * Define the scale of the layer in order to zoom in out of the texture.
  53585. */
  53586. scale: Vector2;
  53587. /**
  53588. * Define an offset for the layer in order to shift the texture.
  53589. */
  53590. offset: Vector2;
  53591. /**
  53592. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  53593. */
  53594. alphaBlendingMode: number;
  53595. /**
  53596. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  53597. * Alpha test will not mix with the background color in case of transparency.
  53598. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  53599. */
  53600. alphaTest: boolean;
  53601. /**
  53602. * Define a mask to restrict the layer to only some of the scene cameras.
  53603. */
  53604. layerMask: number;
  53605. /**
  53606. * Define the list of render target the layer is visible into.
  53607. */
  53608. renderTargetTextures: RenderTargetTexture[];
  53609. /**
  53610. * Define if the layer is only used in renderTarget or if it also
  53611. * renders in the main frame buffer of the canvas.
  53612. */
  53613. renderOnlyInRenderTargetTextures: boolean;
  53614. private _scene;
  53615. private _vertexBuffers;
  53616. private _indexBuffer;
  53617. private _effect;
  53618. private _previousDefines;
  53619. /**
  53620. * An event triggered when the layer is disposed.
  53621. */
  53622. onDisposeObservable: Observable<Layer>;
  53623. private _onDisposeObserver;
  53624. /**
  53625. * Back compatibility with callback before the onDisposeObservable existed.
  53626. * The set callback will be triggered when the layer has been disposed.
  53627. */
  53628. onDispose: () => void;
  53629. /**
  53630. * An event triggered before rendering the scene
  53631. */
  53632. onBeforeRenderObservable: Observable<Layer>;
  53633. private _onBeforeRenderObserver;
  53634. /**
  53635. * Back compatibility with callback before the onBeforeRenderObservable existed.
  53636. * The set callback will be triggered just before rendering the layer.
  53637. */
  53638. onBeforeRender: () => void;
  53639. /**
  53640. * An event triggered after rendering the scene
  53641. */
  53642. onAfterRenderObservable: Observable<Layer>;
  53643. private _onAfterRenderObserver;
  53644. /**
  53645. * Back compatibility with callback before the onAfterRenderObservable existed.
  53646. * The set callback will be triggered just after rendering the layer.
  53647. */
  53648. onAfterRender: () => void;
  53649. /**
  53650. * Instantiates a new layer.
  53651. * This represents a full screen 2d layer.
  53652. * This can be useful to display a picture in the background of your scene for instance.
  53653. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53654. * @param name Define the name of the layer in the scene
  53655. * @param imgUrl Define the url of the texture to display in the layer
  53656. * @param scene Define the scene the layer belongs to
  53657. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  53658. * @param color Defines a color for the layer
  53659. */
  53660. constructor(
  53661. /**
  53662. * Define the name of the layer.
  53663. */
  53664. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  53665. private _createIndexBuffer;
  53666. /** @hidden */
  53667. _rebuild(): void;
  53668. /**
  53669. * Renders the layer in the scene.
  53670. */
  53671. render(): void;
  53672. /**
  53673. * Disposes and releases the associated ressources.
  53674. */
  53675. dispose(): void;
  53676. }
  53677. }
  53678. declare module "babylonjs/Layers/index" {
  53679. export * from "babylonjs/Layers/effectLayer";
  53680. export * from "babylonjs/Layers/effectLayerSceneComponent";
  53681. export * from "babylonjs/Layers/glowLayer";
  53682. export * from "babylonjs/Layers/highlightLayer";
  53683. export * from "babylonjs/Layers/layer";
  53684. export * from "babylonjs/Layers/layerSceneComponent";
  53685. }
  53686. declare module "babylonjs/Shaders/lensFlare.fragment" {
  53687. /** @hidden */
  53688. export var lensFlarePixelShader: {
  53689. name: string;
  53690. shader: string;
  53691. };
  53692. }
  53693. declare module "babylonjs/Shaders/lensFlare.vertex" {
  53694. /** @hidden */
  53695. export var lensFlareVertexShader: {
  53696. name: string;
  53697. shader: string;
  53698. };
  53699. }
  53700. declare module "babylonjs/LensFlares/lensFlareSystem" {
  53701. import { Scene } from "babylonjs/scene";
  53702. import { Vector3 } from "babylonjs/Maths/math.vector";
  53703. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53704. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  53705. import "babylonjs/Shaders/lensFlare.fragment";
  53706. import "babylonjs/Shaders/lensFlare.vertex";
  53707. import { Viewport } from "babylonjs/Maths/math.viewport";
  53708. /**
  53709. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53710. * It is usually composed of several `lensFlare`.
  53711. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53712. */
  53713. export class LensFlareSystem {
  53714. /**
  53715. * Define the name of the lens flare system
  53716. */
  53717. name: string;
  53718. /**
  53719. * List of lens flares used in this system.
  53720. */
  53721. lensFlares: LensFlare[];
  53722. /**
  53723. * Define a limit from the border the lens flare can be visible.
  53724. */
  53725. borderLimit: number;
  53726. /**
  53727. * Define a viewport border we do not want to see the lens flare in.
  53728. */
  53729. viewportBorder: number;
  53730. /**
  53731. * Define a predicate which could limit the list of meshes able to occlude the effect.
  53732. */
  53733. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53734. /**
  53735. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  53736. */
  53737. layerMask: number;
  53738. /**
  53739. * Define the id of the lens flare system in the scene.
  53740. * (equal to name by default)
  53741. */
  53742. id: string;
  53743. private _scene;
  53744. private _emitter;
  53745. private _vertexBuffers;
  53746. private _indexBuffer;
  53747. private _effect;
  53748. private _positionX;
  53749. private _positionY;
  53750. private _isEnabled;
  53751. /** @hidden */
  53752. static _SceneComponentInitialization: (scene: Scene) => void;
  53753. /**
  53754. * Instantiates a lens flare system.
  53755. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53756. * It is usually composed of several `lensFlare`.
  53757. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53758. * @param name Define the name of the lens flare system in the scene
  53759. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  53760. * @param scene Define the scene the lens flare system belongs to
  53761. */
  53762. constructor(
  53763. /**
  53764. * Define the name of the lens flare system
  53765. */
  53766. name: string, emitter: any, scene: Scene);
  53767. /**
  53768. * Define if the lens flare system is enabled.
  53769. */
  53770. isEnabled: boolean;
  53771. /**
  53772. * Get the scene the effects belongs to.
  53773. * @returns the scene holding the lens flare system
  53774. */
  53775. getScene(): Scene;
  53776. /**
  53777. * Get the emitter of the lens flare system.
  53778. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53779. * @returns the emitter of the lens flare system
  53780. */
  53781. getEmitter(): any;
  53782. /**
  53783. * Set the emitter of the lens flare system.
  53784. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53785. * @param newEmitter Define the new emitter of the system
  53786. */
  53787. setEmitter(newEmitter: any): void;
  53788. /**
  53789. * Get the lens flare system emitter position.
  53790. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  53791. * @returns the position
  53792. */
  53793. getEmitterPosition(): Vector3;
  53794. /**
  53795. * @hidden
  53796. */
  53797. computeEffectivePosition(globalViewport: Viewport): boolean;
  53798. /** @hidden */
  53799. _isVisible(): boolean;
  53800. /**
  53801. * @hidden
  53802. */
  53803. render(): boolean;
  53804. /**
  53805. * Dispose and release the lens flare with its associated resources.
  53806. */
  53807. dispose(): void;
  53808. /**
  53809. * Parse a lens flare system from a JSON repressentation
  53810. * @param parsedLensFlareSystem Define the JSON to parse
  53811. * @param scene Define the scene the parsed system should be instantiated in
  53812. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  53813. * @returns the parsed system
  53814. */
  53815. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  53816. /**
  53817. * Serialize the current Lens Flare System into a JSON representation.
  53818. * @returns the serialized JSON
  53819. */
  53820. serialize(): any;
  53821. }
  53822. }
  53823. declare module "babylonjs/LensFlares/lensFlare" {
  53824. import { Nullable } from "babylonjs/types";
  53825. import { Color3 } from "babylonjs/Maths/math.color";
  53826. import { Texture } from "babylonjs/Materials/Textures/texture";
  53827. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  53828. /**
  53829. * This represents one of the lens effect in a `lensFlareSystem`.
  53830. * It controls one of the indiviual texture used in the effect.
  53831. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53832. */
  53833. export class LensFlare {
  53834. /**
  53835. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53836. */
  53837. size: number;
  53838. /**
  53839. * 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.
  53840. */
  53841. position: number;
  53842. /**
  53843. * Define the lens color.
  53844. */
  53845. color: Color3;
  53846. /**
  53847. * Define the lens texture.
  53848. */
  53849. texture: Nullable<Texture>;
  53850. /**
  53851. * Define the alpha mode to render this particular lens.
  53852. */
  53853. alphaMode: number;
  53854. private _system;
  53855. /**
  53856. * Creates a new Lens Flare.
  53857. * This represents one of the lens effect in a `lensFlareSystem`.
  53858. * It controls one of the indiviual texture used in the effect.
  53859. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53860. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  53861. * @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.
  53862. * @param color Define the lens color
  53863. * @param imgUrl Define the lens texture url
  53864. * @param system Define the `lensFlareSystem` this flare is part of
  53865. * @returns The newly created Lens Flare
  53866. */
  53867. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  53868. /**
  53869. * Instantiates a new Lens Flare.
  53870. * This represents one of the lens effect in a `lensFlareSystem`.
  53871. * It controls one of the indiviual texture used in the effect.
  53872. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53873. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  53874. * @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.
  53875. * @param color Define the lens color
  53876. * @param imgUrl Define the lens texture url
  53877. * @param system Define the `lensFlareSystem` this flare is part of
  53878. */
  53879. constructor(
  53880. /**
  53881. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53882. */
  53883. size: number,
  53884. /**
  53885. * 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.
  53886. */
  53887. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  53888. /**
  53889. * Dispose and release the lens flare with its associated resources.
  53890. */
  53891. dispose(): void;
  53892. }
  53893. }
  53894. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  53895. import { Nullable } from "babylonjs/types";
  53896. import { Scene } from "babylonjs/scene";
  53897. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  53898. import { AbstractScene } from "babylonjs/abstractScene";
  53899. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  53900. module "babylonjs/abstractScene" {
  53901. interface AbstractScene {
  53902. /**
  53903. * The list of lens flare system added to the scene
  53904. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53905. */
  53906. lensFlareSystems: Array<LensFlareSystem>;
  53907. /**
  53908. * Removes the given lens flare system from this scene.
  53909. * @param toRemove The lens flare system to remove
  53910. * @returns The index of the removed lens flare system
  53911. */
  53912. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  53913. /**
  53914. * Adds the given lens flare system to this scene
  53915. * @param newLensFlareSystem The lens flare system to add
  53916. */
  53917. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  53918. /**
  53919. * Gets a lens flare system using its name
  53920. * @param name defines the name to look for
  53921. * @returns the lens flare system or null if not found
  53922. */
  53923. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  53924. /**
  53925. * Gets a lens flare system using its id
  53926. * @param id defines the id to look for
  53927. * @returns the lens flare system or null if not found
  53928. */
  53929. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  53930. }
  53931. }
  53932. /**
  53933. * Defines the lens flare scene component responsible to manage any lens flares
  53934. * in a given scene.
  53935. */
  53936. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  53937. /**
  53938. * The component name helpfull to identify the component in the list of scene components.
  53939. */
  53940. readonly name: string;
  53941. /**
  53942. * The scene the component belongs to.
  53943. */
  53944. scene: Scene;
  53945. /**
  53946. * Creates a new instance of the component for the given scene
  53947. * @param scene Defines the scene to register the component in
  53948. */
  53949. constructor(scene: Scene);
  53950. /**
  53951. * Registers the component in a given scene
  53952. */
  53953. register(): void;
  53954. /**
  53955. * Rebuilds the elements related to this component in case of
  53956. * context lost for instance.
  53957. */
  53958. rebuild(): void;
  53959. /**
  53960. * Adds all the elements from the container to the scene
  53961. * @param container the container holding the elements
  53962. */
  53963. addFromContainer(container: AbstractScene): void;
  53964. /**
  53965. * Removes all the elements in the container from the scene
  53966. * @param container contains the elements to remove
  53967. * @param dispose if the removed element should be disposed (default: false)
  53968. */
  53969. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53970. /**
  53971. * Serializes the component data to the specified json object
  53972. * @param serializationObject The object to serialize to
  53973. */
  53974. serialize(serializationObject: any): void;
  53975. /**
  53976. * Disposes the component and the associated ressources.
  53977. */
  53978. dispose(): void;
  53979. private _draw;
  53980. }
  53981. }
  53982. declare module "babylonjs/LensFlares/index" {
  53983. export * from "babylonjs/LensFlares/lensFlare";
  53984. export * from "babylonjs/LensFlares/lensFlareSystem";
  53985. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  53986. }
  53987. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  53988. import { Scene } from "babylonjs/scene";
  53989. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  53990. import { AbstractScene } from "babylonjs/abstractScene";
  53991. /**
  53992. * Defines the shadow generator component responsible to manage any shadow generators
  53993. * in a given scene.
  53994. */
  53995. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  53996. /**
  53997. * The component name helpfull to identify the component in the list of scene components.
  53998. */
  53999. readonly name: string;
  54000. /**
  54001. * The scene the component belongs to.
  54002. */
  54003. scene: Scene;
  54004. /**
  54005. * Creates a new instance of the component for the given scene
  54006. * @param scene Defines the scene to register the component in
  54007. */
  54008. constructor(scene: Scene);
  54009. /**
  54010. * Registers the component in a given scene
  54011. */
  54012. register(): void;
  54013. /**
  54014. * Rebuilds the elements related to this component in case of
  54015. * context lost for instance.
  54016. */
  54017. rebuild(): void;
  54018. /**
  54019. * Serializes the component data to the specified json object
  54020. * @param serializationObject The object to serialize to
  54021. */
  54022. serialize(serializationObject: any): void;
  54023. /**
  54024. * Adds all the elements from the container to the scene
  54025. * @param container the container holding the elements
  54026. */
  54027. addFromContainer(container: AbstractScene): void;
  54028. /**
  54029. * Removes all the elements in the container from the scene
  54030. * @param container contains the elements to remove
  54031. * @param dispose if the removed element should be disposed (default: false)
  54032. */
  54033. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54034. /**
  54035. * Rebuilds the elements related to this component in case of
  54036. * context lost for instance.
  54037. */
  54038. dispose(): void;
  54039. private _gatherRenderTargets;
  54040. }
  54041. }
  54042. declare module "babylonjs/Lights/Shadows/index" {
  54043. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  54044. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  54045. }
  54046. declare module "babylonjs/Lights/pointLight" {
  54047. import { Scene } from "babylonjs/scene";
  54048. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  54049. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54050. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  54051. import { Effect } from "babylonjs/Materials/effect";
  54052. /**
  54053. * A point light is a light defined by an unique point in world space.
  54054. * The light is emitted in every direction from this point.
  54055. * A good example of a point light is a standard light bulb.
  54056. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54057. */
  54058. export class PointLight extends ShadowLight {
  54059. private _shadowAngle;
  54060. /**
  54061. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54062. * This specifies what angle the shadow will use to be created.
  54063. *
  54064. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54065. */
  54066. /**
  54067. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54068. * This specifies what angle the shadow will use to be created.
  54069. *
  54070. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54071. */
  54072. shadowAngle: number;
  54073. /**
  54074. * Gets the direction if it has been set.
  54075. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54076. */
  54077. /**
  54078. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54079. */
  54080. direction: Vector3;
  54081. /**
  54082. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  54083. * A PointLight emits the light in every direction.
  54084. * It can cast shadows.
  54085. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  54086. * ```javascript
  54087. * var pointLight = new PointLight("pl", camera.position, scene);
  54088. * ```
  54089. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54090. * @param name The light friendly name
  54091. * @param position The position of the point light in the scene
  54092. * @param scene The scene the lights belongs to
  54093. */
  54094. constructor(name: string, position: Vector3, scene: Scene);
  54095. /**
  54096. * Returns the string "PointLight"
  54097. * @returns the class name
  54098. */
  54099. getClassName(): string;
  54100. /**
  54101. * Returns the integer 0.
  54102. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54103. */
  54104. getTypeID(): number;
  54105. /**
  54106. * Specifies wether or not the shadowmap should be a cube texture.
  54107. * @returns true if the shadowmap needs to be a cube texture.
  54108. */
  54109. needCube(): boolean;
  54110. /**
  54111. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  54112. * @param faceIndex The index of the face we are computed the direction to generate shadow
  54113. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  54114. */
  54115. getShadowDirection(faceIndex?: number): Vector3;
  54116. /**
  54117. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  54118. * - fov = PI / 2
  54119. * - aspect ratio : 1.0
  54120. * - z-near and far equal to the active camera minZ and maxZ.
  54121. * Returns the PointLight.
  54122. */
  54123. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54124. protected _buildUniformLayout(): void;
  54125. /**
  54126. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  54127. * @param effect The effect to update
  54128. * @param lightIndex The index of the light in the effect to update
  54129. * @returns The point light
  54130. */
  54131. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  54132. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54133. /**
  54134. * Prepares the list of defines specific to the light type.
  54135. * @param defines the list of defines
  54136. * @param lightIndex defines the index of the light for the effect
  54137. */
  54138. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54139. }
  54140. }
  54141. declare module "babylonjs/Lights/index" {
  54142. export * from "babylonjs/Lights/light";
  54143. export * from "babylonjs/Lights/shadowLight";
  54144. export * from "babylonjs/Lights/Shadows/index";
  54145. export * from "babylonjs/Lights/directionalLight";
  54146. export * from "babylonjs/Lights/hemisphericLight";
  54147. export * from "babylonjs/Lights/pointLight";
  54148. export * from "babylonjs/Lights/spotLight";
  54149. }
  54150. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  54151. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  54152. /**
  54153. * Header information of HDR texture files.
  54154. */
  54155. export interface HDRInfo {
  54156. /**
  54157. * The height of the texture in pixels.
  54158. */
  54159. height: number;
  54160. /**
  54161. * The width of the texture in pixels.
  54162. */
  54163. width: number;
  54164. /**
  54165. * The index of the beginning of the data in the binary file.
  54166. */
  54167. dataPosition: number;
  54168. }
  54169. /**
  54170. * This groups tools to convert HDR texture to native colors array.
  54171. */
  54172. export class HDRTools {
  54173. private static Ldexp;
  54174. private static Rgbe2float;
  54175. private static readStringLine;
  54176. /**
  54177. * Reads header information from an RGBE texture stored in a native array.
  54178. * More information on this format are available here:
  54179. * https://en.wikipedia.org/wiki/RGBE_image_format
  54180. *
  54181. * @param uint8array The binary file stored in native array.
  54182. * @return The header information.
  54183. */
  54184. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  54185. /**
  54186. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  54187. * This RGBE texture needs to store the information as a panorama.
  54188. *
  54189. * More information on this format are available here:
  54190. * https://en.wikipedia.org/wiki/RGBE_image_format
  54191. *
  54192. * @param buffer The binary file stored in an array buffer.
  54193. * @param size The expected size of the extracted cubemap.
  54194. * @return The Cube Map information.
  54195. */
  54196. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  54197. /**
  54198. * Returns the pixels data extracted from an RGBE texture.
  54199. * This pixels will be stored left to right up to down in the R G B order in one array.
  54200. *
  54201. * More information on this format are available here:
  54202. * https://en.wikipedia.org/wiki/RGBE_image_format
  54203. *
  54204. * @param uint8array The binary file stored in an array buffer.
  54205. * @param hdrInfo The header information of the file.
  54206. * @return The pixels data in RGB right to left up to down order.
  54207. */
  54208. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  54209. private static RGBE_ReadPixels_RLE;
  54210. }
  54211. }
  54212. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  54213. import { Nullable } from "babylonjs/types";
  54214. import { Scene } from "babylonjs/scene";
  54215. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  54216. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54217. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54218. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  54219. /**
  54220. * This represents a texture coming from an HDR input.
  54221. *
  54222. * The only supported format is currently panorama picture stored in RGBE format.
  54223. * Example of such files can be found on HDRLib: http://hdrlib.com/
  54224. */
  54225. export class HDRCubeTexture extends BaseTexture {
  54226. private static _facesMapping;
  54227. private _generateHarmonics;
  54228. private _noMipmap;
  54229. private _textureMatrix;
  54230. private _size;
  54231. private _onLoad;
  54232. private _onError;
  54233. /**
  54234. * The texture URL.
  54235. */
  54236. url: string;
  54237. /**
  54238. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  54239. */
  54240. coordinatesMode: number;
  54241. protected _isBlocking: boolean;
  54242. /**
  54243. * Sets wether or not the texture is blocking during loading.
  54244. */
  54245. /**
  54246. * Gets wether or not the texture is blocking during loading.
  54247. */
  54248. isBlocking: boolean;
  54249. protected _rotationY: number;
  54250. /**
  54251. * Sets texture matrix rotation angle around Y axis in radians.
  54252. */
  54253. /**
  54254. * Gets texture matrix rotation angle around Y axis radians.
  54255. */
  54256. rotationY: number;
  54257. /**
  54258. * Gets or sets the center of the bounding box associated with the cube texture
  54259. * It must define where the camera used to render the texture was set
  54260. */
  54261. boundingBoxPosition: Vector3;
  54262. private _boundingBoxSize;
  54263. /**
  54264. * Gets or sets the size of the bounding box associated with the cube texture
  54265. * When defined, the cubemap will switch to local mode
  54266. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  54267. * @example https://www.babylonjs-playground.com/#RNASML
  54268. */
  54269. boundingBoxSize: Vector3;
  54270. /**
  54271. * Instantiates an HDRTexture from the following parameters.
  54272. *
  54273. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  54274. * @param scene The scene the texture will be used in
  54275. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54276. * @param noMipmap Forces to not generate the mipmap if true
  54277. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  54278. * @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)
  54279. * @param reserved Reserved flag for internal use.
  54280. */
  54281. 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>);
  54282. /**
  54283. * Get the current class name of the texture useful for serialization or dynamic coding.
  54284. * @returns "HDRCubeTexture"
  54285. */
  54286. getClassName(): string;
  54287. /**
  54288. * Occurs when the file is raw .hdr file.
  54289. */
  54290. private loadTexture;
  54291. clone(): HDRCubeTexture;
  54292. delayLoad(): void;
  54293. /**
  54294. * Get the texture reflection matrix used to rotate/transform the reflection.
  54295. * @returns the reflection matrix
  54296. */
  54297. getReflectionTextureMatrix(): Matrix;
  54298. /**
  54299. * Set the texture reflection matrix used to rotate/transform the reflection.
  54300. * @param value Define the reflection matrix to set
  54301. */
  54302. setReflectionTextureMatrix(value: Matrix): void;
  54303. /**
  54304. * Parses a JSON representation of an HDR Texture in order to create the texture
  54305. * @param parsedTexture Define the JSON representation
  54306. * @param scene Define the scene the texture should be created in
  54307. * @param rootUrl Define the root url in case we need to load relative dependencies
  54308. * @returns the newly created texture after parsing
  54309. */
  54310. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  54311. serialize(): any;
  54312. }
  54313. }
  54314. declare module "babylonjs/Physics/physicsEngine" {
  54315. import { Nullable } from "babylonjs/types";
  54316. import { Vector3 } from "babylonjs/Maths/math.vector";
  54317. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  54318. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  54319. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  54320. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54321. /**
  54322. * Class used to control physics engine
  54323. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  54324. */
  54325. export class PhysicsEngine implements IPhysicsEngine {
  54326. private _physicsPlugin;
  54327. /**
  54328. * Global value used to control the smallest number supported by the simulation
  54329. */
  54330. static Epsilon: number;
  54331. private _impostors;
  54332. private _joints;
  54333. private _subTimeStep;
  54334. /**
  54335. * Gets the gravity vector used by the simulation
  54336. */
  54337. gravity: Vector3;
  54338. /**
  54339. * Factory used to create the default physics plugin.
  54340. * @returns The default physics plugin
  54341. */
  54342. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  54343. /**
  54344. * Creates a new Physics Engine
  54345. * @param gravity defines the gravity vector used by the simulation
  54346. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  54347. */
  54348. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  54349. /**
  54350. * Sets the gravity vector used by the simulation
  54351. * @param gravity defines the gravity vector to use
  54352. */
  54353. setGravity(gravity: Vector3): void;
  54354. /**
  54355. * Set the time step of the physics engine.
  54356. * Default is 1/60.
  54357. * To slow it down, enter 1/600 for example.
  54358. * To speed it up, 1/30
  54359. * @param newTimeStep defines the new timestep to apply to this world.
  54360. */
  54361. setTimeStep(newTimeStep?: number): void;
  54362. /**
  54363. * Get the time step of the physics engine.
  54364. * @returns the current time step
  54365. */
  54366. getTimeStep(): number;
  54367. /**
  54368. * Set the sub time step of the physics engine.
  54369. * Default is 0 meaning there is no sub steps
  54370. * To increase physics resolution precision, set a small value (like 1 ms)
  54371. * @param subTimeStep defines the new sub timestep used for physics resolution.
  54372. */
  54373. setSubTimeStep(subTimeStep?: number): void;
  54374. /**
  54375. * Get the sub time step of the physics engine.
  54376. * @returns the current sub time step
  54377. */
  54378. getSubTimeStep(): number;
  54379. /**
  54380. * Release all resources
  54381. */
  54382. dispose(): void;
  54383. /**
  54384. * Gets the name of the current physics plugin
  54385. * @returns the name of the plugin
  54386. */
  54387. getPhysicsPluginName(): string;
  54388. /**
  54389. * Adding a new impostor for the impostor tracking.
  54390. * This will be done by the impostor itself.
  54391. * @param impostor the impostor to add
  54392. */
  54393. addImpostor(impostor: PhysicsImpostor): void;
  54394. /**
  54395. * Remove an impostor from the engine.
  54396. * This impostor and its mesh will not longer be updated by the physics engine.
  54397. * @param impostor the impostor to remove
  54398. */
  54399. removeImpostor(impostor: PhysicsImpostor): void;
  54400. /**
  54401. * Add a joint to the physics engine
  54402. * @param mainImpostor defines the main impostor to which the joint is added.
  54403. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  54404. * @param joint defines the joint that will connect both impostors.
  54405. */
  54406. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54407. /**
  54408. * Removes a joint from the simulation
  54409. * @param mainImpostor defines the impostor used with the joint
  54410. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  54411. * @param joint defines the joint to remove
  54412. */
  54413. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54414. /**
  54415. * Called by the scene. No need to call it.
  54416. * @param delta defines the timespam between frames
  54417. */
  54418. _step(delta: number): void;
  54419. /**
  54420. * Gets the current plugin used to run the simulation
  54421. * @returns current plugin
  54422. */
  54423. getPhysicsPlugin(): IPhysicsEnginePlugin;
  54424. /**
  54425. * Gets the list of physic impostors
  54426. * @returns an array of PhysicsImpostor
  54427. */
  54428. getImpostors(): Array<PhysicsImpostor>;
  54429. /**
  54430. * Gets the impostor for a physics enabled object
  54431. * @param object defines the object impersonated by the impostor
  54432. * @returns the PhysicsImpostor or null if not found
  54433. */
  54434. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  54435. /**
  54436. * Gets the impostor for a physics body object
  54437. * @param body defines physics body used by the impostor
  54438. * @returns the PhysicsImpostor or null if not found
  54439. */
  54440. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  54441. /**
  54442. * Does a raycast in the physics world
  54443. * @param from when should the ray start?
  54444. * @param to when should the ray end?
  54445. * @returns PhysicsRaycastResult
  54446. */
  54447. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54448. }
  54449. }
  54450. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  54451. import { Nullable } from "babylonjs/types";
  54452. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  54453. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54454. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54455. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54456. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54457. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54458. /** @hidden */
  54459. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  54460. private _useDeltaForWorldStep;
  54461. world: any;
  54462. name: string;
  54463. private _physicsMaterials;
  54464. private _fixedTimeStep;
  54465. private _cannonRaycastResult;
  54466. private _raycastResult;
  54467. private _physicsBodysToRemoveAfterStep;
  54468. BJSCANNON: any;
  54469. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  54470. setGravity(gravity: Vector3): void;
  54471. setTimeStep(timeStep: number): void;
  54472. getTimeStep(): number;
  54473. executeStep(delta: number): void;
  54474. private _removeMarkedPhysicsBodiesFromWorld;
  54475. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54476. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54477. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54478. private _processChildMeshes;
  54479. removePhysicsBody(impostor: PhysicsImpostor): void;
  54480. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54481. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54482. private _addMaterial;
  54483. private _checkWithEpsilon;
  54484. private _createShape;
  54485. private _createHeightmap;
  54486. private _minus90X;
  54487. private _plus90X;
  54488. private _tmpPosition;
  54489. private _tmpDeltaPosition;
  54490. private _tmpUnityRotation;
  54491. private _updatePhysicsBodyTransformation;
  54492. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54493. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54494. isSupported(): boolean;
  54495. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54496. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54497. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54498. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54499. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54500. getBodyMass(impostor: PhysicsImpostor): number;
  54501. getBodyFriction(impostor: PhysicsImpostor): number;
  54502. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54503. getBodyRestitution(impostor: PhysicsImpostor): number;
  54504. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54505. sleepBody(impostor: PhysicsImpostor): void;
  54506. wakeUpBody(impostor: PhysicsImpostor): void;
  54507. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  54508. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54509. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54510. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54511. getRadius(impostor: PhysicsImpostor): number;
  54512. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54513. dispose(): void;
  54514. private _extendNamespace;
  54515. /**
  54516. * Does a raycast in the physics world
  54517. * @param from when should the ray start?
  54518. * @param to when should the ray end?
  54519. * @returns PhysicsRaycastResult
  54520. */
  54521. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54522. }
  54523. }
  54524. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  54525. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54526. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54527. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54528. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54529. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  54530. import { Nullable } from "babylonjs/types";
  54531. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54532. /** @hidden */
  54533. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  54534. world: any;
  54535. name: string;
  54536. BJSOIMO: any;
  54537. private _raycastResult;
  54538. constructor(iterations?: number, oimoInjection?: any);
  54539. setGravity(gravity: Vector3): void;
  54540. setTimeStep(timeStep: number): void;
  54541. getTimeStep(): number;
  54542. private _tmpImpostorsArray;
  54543. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54544. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54545. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54546. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54547. private _tmpPositionVector;
  54548. removePhysicsBody(impostor: PhysicsImpostor): void;
  54549. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54550. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54551. isSupported(): boolean;
  54552. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54553. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54554. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54555. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54556. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54557. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54558. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54559. getBodyMass(impostor: PhysicsImpostor): number;
  54560. getBodyFriction(impostor: PhysicsImpostor): number;
  54561. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54562. getBodyRestitution(impostor: PhysicsImpostor): number;
  54563. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54564. sleepBody(impostor: PhysicsImpostor): void;
  54565. wakeUpBody(impostor: PhysicsImpostor): void;
  54566. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54567. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  54568. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  54569. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54570. getRadius(impostor: PhysicsImpostor): number;
  54571. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54572. dispose(): void;
  54573. /**
  54574. * Does a raycast in the physics world
  54575. * @param from when should the ray start?
  54576. * @param to when should the ray end?
  54577. * @returns PhysicsRaycastResult
  54578. */
  54579. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54580. }
  54581. }
  54582. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  54583. import { Nullable } from "babylonjs/types";
  54584. import { Scene } from "babylonjs/scene";
  54585. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  54586. import { Color4 } from "babylonjs/Maths/math.color";
  54587. import { Mesh } from "babylonjs/Meshes/mesh";
  54588. /**
  54589. * Class containing static functions to help procedurally build meshes
  54590. */
  54591. export class RibbonBuilder {
  54592. /**
  54593. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54594. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54595. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54596. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54597. * * 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
  54598. * * 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
  54599. * * 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
  54600. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54601. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54602. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54603. * * 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
  54604. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54605. * * 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
  54606. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54607. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54608. * @param name defines the name of the mesh
  54609. * @param options defines the options used to create the mesh
  54610. * @param scene defines the hosting scene
  54611. * @returns the ribbon mesh
  54612. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54613. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54614. */
  54615. static CreateRibbon(name: string, options: {
  54616. pathArray: Vector3[][];
  54617. closeArray?: boolean;
  54618. closePath?: boolean;
  54619. offset?: number;
  54620. updatable?: boolean;
  54621. sideOrientation?: number;
  54622. frontUVs?: Vector4;
  54623. backUVs?: Vector4;
  54624. instance?: Mesh;
  54625. invertUV?: boolean;
  54626. uvs?: Vector2[];
  54627. colors?: Color4[];
  54628. }, scene?: Nullable<Scene>): Mesh;
  54629. }
  54630. }
  54631. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  54632. import { Nullable } from "babylonjs/types";
  54633. import { Scene } from "babylonjs/scene";
  54634. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  54635. import { Mesh } from "babylonjs/Meshes/mesh";
  54636. /**
  54637. * Class containing static functions to help procedurally build meshes
  54638. */
  54639. export class ShapeBuilder {
  54640. /**
  54641. * 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.
  54642. * * 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.
  54643. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54644. * * 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.
  54645. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54646. * * 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
  54647. * * 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
  54648. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54649. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54650. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54651. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54652. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54653. * @param name defines the name of the mesh
  54654. * @param options defines the options used to create the mesh
  54655. * @param scene defines the hosting scene
  54656. * @returns the extruded shape mesh
  54657. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54658. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54659. */
  54660. static ExtrudeShape(name: string, options: {
  54661. shape: Vector3[];
  54662. path: Vector3[];
  54663. scale?: number;
  54664. rotation?: number;
  54665. cap?: number;
  54666. updatable?: boolean;
  54667. sideOrientation?: number;
  54668. frontUVs?: Vector4;
  54669. backUVs?: Vector4;
  54670. instance?: Mesh;
  54671. invertUV?: boolean;
  54672. }, scene?: Nullable<Scene>): Mesh;
  54673. /**
  54674. * Creates an custom extruded shape mesh.
  54675. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  54676. * * 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.
  54677. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54678. * * 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
  54679. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  54680. * * 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
  54681. * * It must returns a float value that will be the scale value applied to the shape on each path point
  54682. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  54683. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  54684. * * 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
  54685. * * 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
  54686. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  54687. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54688. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54689. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54690. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54691. * @param name defines the name of the mesh
  54692. * @param options defines the options used to create the mesh
  54693. * @param scene defines the hosting scene
  54694. * @returns the custom extruded shape mesh
  54695. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  54696. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54697. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54698. */
  54699. static ExtrudeShapeCustom(name: string, options: {
  54700. shape: Vector3[];
  54701. path: Vector3[];
  54702. scaleFunction?: any;
  54703. rotationFunction?: any;
  54704. ribbonCloseArray?: boolean;
  54705. ribbonClosePath?: boolean;
  54706. cap?: number;
  54707. updatable?: boolean;
  54708. sideOrientation?: number;
  54709. frontUVs?: Vector4;
  54710. backUVs?: Vector4;
  54711. instance?: Mesh;
  54712. invertUV?: boolean;
  54713. }, scene?: Nullable<Scene>): Mesh;
  54714. private static _ExtrudeShapeGeneric;
  54715. }
  54716. }
  54717. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  54718. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  54719. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54720. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54721. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54722. import { Nullable } from "babylonjs/types";
  54723. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54724. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54725. /**
  54726. * AmmoJS Physics plugin
  54727. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  54728. * @see https://github.com/kripken/ammo.js/
  54729. */
  54730. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  54731. private _useDeltaForWorldStep;
  54732. /**
  54733. * Reference to the Ammo library
  54734. */
  54735. bjsAMMO: any;
  54736. /**
  54737. * Created ammoJS world which physics bodies are added to
  54738. */
  54739. world: any;
  54740. /**
  54741. * Name of the plugin
  54742. */
  54743. name: string;
  54744. private _timeStep;
  54745. private _fixedTimeStep;
  54746. private _maxSteps;
  54747. private _tmpQuaternion;
  54748. private _tmpAmmoTransform;
  54749. private _tmpAmmoQuaternion;
  54750. private _tmpAmmoConcreteContactResultCallback;
  54751. private _collisionConfiguration;
  54752. private _dispatcher;
  54753. private _overlappingPairCache;
  54754. private _solver;
  54755. private _softBodySolver;
  54756. private _tmpAmmoVectorA;
  54757. private _tmpAmmoVectorB;
  54758. private _tmpAmmoVectorC;
  54759. private _tmpAmmoVectorD;
  54760. private _tmpContactCallbackResult;
  54761. private _tmpAmmoVectorRCA;
  54762. private _tmpAmmoVectorRCB;
  54763. private _raycastResult;
  54764. private static readonly DISABLE_COLLISION_FLAG;
  54765. private static readonly KINEMATIC_FLAG;
  54766. private static readonly DISABLE_DEACTIVATION_FLAG;
  54767. /**
  54768. * Initializes the ammoJS plugin
  54769. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  54770. * @param ammoInjection can be used to inject your own ammo reference
  54771. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  54772. */
  54773. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  54774. /**
  54775. * Sets the gravity of the physics world (m/(s^2))
  54776. * @param gravity Gravity to set
  54777. */
  54778. setGravity(gravity: Vector3): void;
  54779. /**
  54780. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  54781. * @param timeStep timestep to use in seconds
  54782. */
  54783. setTimeStep(timeStep: number): void;
  54784. /**
  54785. * 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)
  54786. * @param fixedTimeStep fixedTimeStep to use in seconds
  54787. */
  54788. setFixedTimeStep(fixedTimeStep: number): void;
  54789. /**
  54790. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  54791. * @param maxSteps the maximum number of steps by the physics engine per frame
  54792. */
  54793. setMaxSteps(maxSteps: number): void;
  54794. /**
  54795. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  54796. * @returns the current timestep in seconds
  54797. */
  54798. getTimeStep(): number;
  54799. /**
  54800. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  54801. */
  54802. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  54803. private _isImpostorInContact;
  54804. private _isImpostorPairInContact;
  54805. private _stepSimulation;
  54806. /**
  54807. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  54808. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  54809. * After the step the babylon meshes are set to the position of the physics imposters
  54810. * @param delta amount of time to step forward
  54811. * @param impostors array of imposters to update before/after the step
  54812. */
  54813. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54814. /**
  54815. * Update babylon mesh to match physics world object
  54816. * @param impostor imposter to match
  54817. */
  54818. private _afterSoftStep;
  54819. /**
  54820. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  54821. * @param impostor imposter to match
  54822. */
  54823. private _ropeStep;
  54824. /**
  54825. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  54826. * @param impostor imposter to match
  54827. */
  54828. private _softbodyOrClothStep;
  54829. private _tmpVector;
  54830. private _tmpMatrix;
  54831. /**
  54832. * Applies an impulse on the imposter
  54833. * @param impostor imposter to apply impulse to
  54834. * @param force amount of force to be applied to the imposter
  54835. * @param contactPoint the location to apply the impulse on the imposter
  54836. */
  54837. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54838. /**
  54839. * Applies a force on the imposter
  54840. * @param impostor imposter to apply force
  54841. * @param force amount of force to be applied to the imposter
  54842. * @param contactPoint the location to apply the force on the imposter
  54843. */
  54844. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54845. /**
  54846. * Creates a physics body using the plugin
  54847. * @param impostor the imposter to create the physics body on
  54848. */
  54849. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54850. /**
  54851. * Removes the physics body from the imposter and disposes of the body's memory
  54852. * @param impostor imposter to remove the physics body from
  54853. */
  54854. removePhysicsBody(impostor: PhysicsImpostor): void;
  54855. /**
  54856. * Generates a joint
  54857. * @param impostorJoint the imposter joint to create the joint with
  54858. */
  54859. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54860. /**
  54861. * Removes a joint
  54862. * @param impostorJoint the imposter joint to remove the joint from
  54863. */
  54864. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54865. private _addMeshVerts;
  54866. /**
  54867. * Initialise the soft body vertices to match its object's (mesh) vertices
  54868. * Softbody vertices (nodes) are in world space and to match this
  54869. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  54870. * @param impostor to create the softbody for
  54871. */
  54872. private _softVertexData;
  54873. /**
  54874. * Create an impostor's soft body
  54875. * @param impostor to create the softbody for
  54876. */
  54877. private _createSoftbody;
  54878. /**
  54879. * Create cloth for an impostor
  54880. * @param impostor to create the softbody for
  54881. */
  54882. private _createCloth;
  54883. /**
  54884. * Create rope for an impostor
  54885. * @param impostor to create the softbody for
  54886. */
  54887. private _createRope;
  54888. /**
  54889. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  54890. * @param impostor to create the custom physics shape for
  54891. */
  54892. private _createCustom;
  54893. private _addHullVerts;
  54894. private _createShape;
  54895. /**
  54896. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  54897. * @param impostor imposter containing the physics body and babylon object
  54898. */
  54899. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54900. /**
  54901. * Sets the babylon object's position/rotation from the physics body's position/rotation
  54902. * @param impostor imposter containing the physics body and babylon object
  54903. * @param newPosition new position
  54904. * @param newRotation new rotation
  54905. */
  54906. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54907. /**
  54908. * If this plugin is supported
  54909. * @returns true if its supported
  54910. */
  54911. isSupported(): boolean;
  54912. /**
  54913. * Sets the linear velocity of the physics body
  54914. * @param impostor imposter to set the velocity on
  54915. * @param velocity velocity to set
  54916. */
  54917. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54918. /**
  54919. * Sets the angular velocity of the physics body
  54920. * @param impostor imposter to set the velocity on
  54921. * @param velocity velocity to set
  54922. */
  54923. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54924. /**
  54925. * gets the linear velocity
  54926. * @param impostor imposter to get linear velocity from
  54927. * @returns linear velocity
  54928. */
  54929. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54930. /**
  54931. * gets the angular velocity
  54932. * @param impostor imposter to get angular velocity from
  54933. * @returns angular velocity
  54934. */
  54935. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54936. /**
  54937. * Sets the mass of physics body
  54938. * @param impostor imposter to set the mass on
  54939. * @param mass mass to set
  54940. */
  54941. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54942. /**
  54943. * Gets the mass of the physics body
  54944. * @param impostor imposter to get the mass from
  54945. * @returns mass
  54946. */
  54947. getBodyMass(impostor: PhysicsImpostor): number;
  54948. /**
  54949. * Gets friction of the impostor
  54950. * @param impostor impostor to get friction from
  54951. * @returns friction value
  54952. */
  54953. getBodyFriction(impostor: PhysicsImpostor): number;
  54954. /**
  54955. * Sets friction of the impostor
  54956. * @param impostor impostor to set friction on
  54957. * @param friction friction value
  54958. */
  54959. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54960. /**
  54961. * Gets restitution of the impostor
  54962. * @param impostor impostor to get restitution from
  54963. * @returns restitution value
  54964. */
  54965. getBodyRestitution(impostor: PhysicsImpostor): number;
  54966. /**
  54967. * Sets resitution of the impostor
  54968. * @param impostor impostor to set resitution on
  54969. * @param restitution resitution value
  54970. */
  54971. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54972. /**
  54973. * Gets pressure inside the impostor
  54974. * @param impostor impostor to get pressure from
  54975. * @returns pressure value
  54976. */
  54977. getBodyPressure(impostor: PhysicsImpostor): number;
  54978. /**
  54979. * Sets pressure inside a soft body impostor
  54980. * Cloth and rope must remain 0 pressure
  54981. * @param impostor impostor to set pressure on
  54982. * @param pressure pressure value
  54983. */
  54984. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  54985. /**
  54986. * Gets stiffness of the impostor
  54987. * @param impostor impostor to get stiffness from
  54988. * @returns pressure value
  54989. */
  54990. getBodyStiffness(impostor: PhysicsImpostor): number;
  54991. /**
  54992. * Sets stiffness of the impostor
  54993. * @param impostor impostor to set stiffness on
  54994. * @param stiffness stiffness value from 0 to 1
  54995. */
  54996. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  54997. /**
  54998. * Gets velocityIterations of the impostor
  54999. * @param impostor impostor to get velocity iterations from
  55000. * @returns velocityIterations value
  55001. */
  55002. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  55003. /**
  55004. * Sets velocityIterations of the impostor
  55005. * @param impostor impostor to set velocity iterations on
  55006. * @param velocityIterations velocityIterations value
  55007. */
  55008. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  55009. /**
  55010. * Gets positionIterations of the impostor
  55011. * @param impostor impostor to get position iterations from
  55012. * @returns positionIterations value
  55013. */
  55014. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  55015. /**
  55016. * Sets positionIterations of the impostor
  55017. * @param impostor impostor to set position on
  55018. * @param positionIterations positionIterations value
  55019. */
  55020. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  55021. /**
  55022. * Append an anchor to a cloth object
  55023. * @param impostor is the cloth impostor to add anchor to
  55024. * @param otherImpostor is the rigid impostor to anchor to
  55025. * @param width ratio across width from 0 to 1
  55026. * @param height ratio up height from 0 to 1
  55027. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  55028. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55029. */
  55030. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55031. /**
  55032. * Append an hook to a rope object
  55033. * @param impostor is the rope impostor to add hook to
  55034. * @param otherImpostor is the rigid impostor to hook to
  55035. * @param length ratio along the rope from 0 to 1
  55036. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  55037. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55038. */
  55039. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55040. /**
  55041. * Sleeps the physics body and stops it from being active
  55042. * @param impostor impostor to sleep
  55043. */
  55044. sleepBody(impostor: PhysicsImpostor): void;
  55045. /**
  55046. * Activates the physics body
  55047. * @param impostor impostor to activate
  55048. */
  55049. wakeUpBody(impostor: PhysicsImpostor): void;
  55050. /**
  55051. * Updates the distance parameters of the joint
  55052. * @param joint joint to update
  55053. * @param maxDistance maximum distance of the joint
  55054. * @param minDistance minimum distance of the joint
  55055. */
  55056. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55057. /**
  55058. * Sets a motor on the joint
  55059. * @param joint joint to set motor on
  55060. * @param speed speed of the motor
  55061. * @param maxForce maximum force of the motor
  55062. * @param motorIndex index of the motor
  55063. */
  55064. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55065. /**
  55066. * Sets the motors limit
  55067. * @param joint joint to set limit on
  55068. * @param upperLimit upper limit
  55069. * @param lowerLimit lower limit
  55070. */
  55071. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55072. /**
  55073. * Syncs the position and rotation of a mesh with the impostor
  55074. * @param mesh mesh to sync
  55075. * @param impostor impostor to update the mesh with
  55076. */
  55077. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55078. /**
  55079. * Gets the radius of the impostor
  55080. * @param impostor impostor to get radius from
  55081. * @returns the radius
  55082. */
  55083. getRadius(impostor: PhysicsImpostor): number;
  55084. /**
  55085. * Gets the box size of the impostor
  55086. * @param impostor impostor to get box size from
  55087. * @param result the resulting box size
  55088. */
  55089. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55090. /**
  55091. * Disposes of the impostor
  55092. */
  55093. dispose(): void;
  55094. /**
  55095. * Does a raycast in the physics world
  55096. * @param from when should the ray start?
  55097. * @param to when should the ray end?
  55098. * @returns PhysicsRaycastResult
  55099. */
  55100. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55101. }
  55102. }
  55103. declare module "babylonjs/Probes/reflectionProbe" {
  55104. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55105. import { Vector3 } from "babylonjs/Maths/math.vector";
  55106. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55107. import { Nullable } from "babylonjs/types";
  55108. import { Scene } from "babylonjs/scene";
  55109. module "babylonjs/abstractScene" {
  55110. interface AbstractScene {
  55111. /**
  55112. * The list of reflection probes added to the scene
  55113. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55114. */
  55115. reflectionProbes: Array<ReflectionProbe>;
  55116. /**
  55117. * Removes the given reflection probe from this scene.
  55118. * @param toRemove The reflection probe to remove
  55119. * @returns The index of the removed reflection probe
  55120. */
  55121. removeReflectionProbe(toRemove: ReflectionProbe): number;
  55122. /**
  55123. * Adds the given reflection probe to this scene.
  55124. * @param newReflectionProbe The reflection probe to add
  55125. */
  55126. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  55127. }
  55128. }
  55129. /**
  55130. * Class used to generate realtime reflection / refraction cube textures
  55131. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55132. */
  55133. export class ReflectionProbe {
  55134. /** defines the name of the probe */
  55135. name: string;
  55136. private _scene;
  55137. private _renderTargetTexture;
  55138. private _projectionMatrix;
  55139. private _viewMatrix;
  55140. private _target;
  55141. private _add;
  55142. private _attachedMesh;
  55143. private _invertYAxis;
  55144. /** Gets or sets probe position (center of the cube map) */
  55145. position: Vector3;
  55146. /**
  55147. * Creates a new reflection probe
  55148. * @param name defines the name of the probe
  55149. * @param size defines the texture resolution (for each face)
  55150. * @param scene defines the hosting scene
  55151. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  55152. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  55153. */
  55154. constructor(
  55155. /** defines the name of the probe */
  55156. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  55157. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  55158. samples: number;
  55159. /** Gets or sets the refresh rate to use (on every frame by default) */
  55160. refreshRate: number;
  55161. /**
  55162. * Gets the hosting scene
  55163. * @returns a Scene
  55164. */
  55165. getScene(): Scene;
  55166. /** Gets the internal CubeTexture used to render to */
  55167. readonly cubeTexture: RenderTargetTexture;
  55168. /** Gets the list of meshes to render */
  55169. readonly renderList: Nullable<AbstractMesh[]>;
  55170. /**
  55171. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  55172. * @param mesh defines the mesh to attach to
  55173. */
  55174. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55175. /**
  55176. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  55177. * @param renderingGroupId The rendering group id corresponding to its index
  55178. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  55179. */
  55180. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  55181. /**
  55182. * Clean all associated resources
  55183. */
  55184. dispose(): void;
  55185. /**
  55186. * Converts the reflection probe information to a readable string for debug purpose.
  55187. * @param fullDetails Supports for multiple levels of logging within scene loading
  55188. * @returns the human readable reflection probe info
  55189. */
  55190. toString(fullDetails?: boolean): string;
  55191. /**
  55192. * Get the class name of the relfection probe.
  55193. * @returns "ReflectionProbe"
  55194. */
  55195. getClassName(): string;
  55196. /**
  55197. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  55198. * @returns The JSON representation of the texture
  55199. */
  55200. serialize(): any;
  55201. /**
  55202. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  55203. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  55204. * @param scene Define the scene the parsed reflection probe should be instantiated in
  55205. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  55206. * @returns The parsed reflection probe if successful
  55207. */
  55208. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  55209. }
  55210. }
  55211. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  55212. /** @hidden */
  55213. export var _BabylonLoaderRegistered: boolean;
  55214. /**
  55215. * Helps setting up some configuration for the babylon file loader.
  55216. */
  55217. export class BabylonFileLoaderConfiguration {
  55218. /**
  55219. * The loader does not allow injecting custom physix engine into the plugins.
  55220. * Unfortunately in ES6, we need to manually inject them into the plugin.
  55221. * So you could set this variable to your engine import to make it work.
  55222. */
  55223. static LoaderInjectedPhysicsEngine: any;
  55224. }
  55225. }
  55226. declare module "babylonjs/Loading/Plugins/index" {
  55227. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  55228. }
  55229. declare module "babylonjs/Loading/index" {
  55230. export * from "babylonjs/Loading/loadingScreen";
  55231. export * from "babylonjs/Loading/Plugins/index";
  55232. export * from "babylonjs/Loading/sceneLoader";
  55233. export * from "babylonjs/Loading/sceneLoaderFlags";
  55234. }
  55235. declare module "babylonjs/Materials/Background/index" {
  55236. export * from "babylonjs/Materials/Background/backgroundMaterial";
  55237. }
  55238. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  55239. import { Scene } from "babylonjs/scene";
  55240. import { Color3 } from "babylonjs/Maths/math.color";
  55241. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  55242. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55243. /**
  55244. * The Physically based simple base material of BJS.
  55245. *
  55246. * This enables better naming and convention enforcements on top of the pbrMaterial.
  55247. * It is used as the base class for both the specGloss and metalRough conventions.
  55248. */
  55249. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  55250. /**
  55251. * Number of Simultaneous lights allowed on the material.
  55252. */
  55253. maxSimultaneousLights: number;
  55254. /**
  55255. * If sets to true, disables all the lights affecting the material.
  55256. */
  55257. disableLighting: boolean;
  55258. /**
  55259. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  55260. */
  55261. environmentTexture: BaseTexture;
  55262. /**
  55263. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55264. */
  55265. invertNormalMapX: boolean;
  55266. /**
  55267. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55268. */
  55269. invertNormalMapY: boolean;
  55270. /**
  55271. * Normal map used in the model.
  55272. */
  55273. normalTexture: BaseTexture;
  55274. /**
  55275. * Emissivie color used to self-illuminate the model.
  55276. */
  55277. emissiveColor: Color3;
  55278. /**
  55279. * Emissivie texture used to self-illuminate the model.
  55280. */
  55281. emissiveTexture: BaseTexture;
  55282. /**
  55283. * Occlusion Channel Strenght.
  55284. */
  55285. occlusionStrength: number;
  55286. /**
  55287. * Occlusion Texture of the material (adding extra occlusion effects).
  55288. */
  55289. occlusionTexture: BaseTexture;
  55290. /**
  55291. * Defines the alpha limits in alpha test mode.
  55292. */
  55293. alphaCutOff: number;
  55294. /**
  55295. * Gets the current double sided mode.
  55296. */
  55297. /**
  55298. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55299. */
  55300. doubleSided: boolean;
  55301. /**
  55302. * Stores the pre-calculated light information of a mesh in a texture.
  55303. */
  55304. lightmapTexture: BaseTexture;
  55305. /**
  55306. * If true, the light map contains occlusion information instead of lighting info.
  55307. */
  55308. useLightmapAsShadowmap: boolean;
  55309. /**
  55310. * Instantiates a new PBRMaterial instance.
  55311. *
  55312. * @param name The material name
  55313. * @param scene The scene the material will be use in.
  55314. */
  55315. constructor(name: string, scene: Scene);
  55316. getClassName(): string;
  55317. }
  55318. }
  55319. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  55320. import { Scene } from "babylonjs/scene";
  55321. import { Color3 } from "babylonjs/Maths/math.color";
  55322. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55323. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  55324. /**
  55325. * The PBR material of BJS following the metal roughness convention.
  55326. *
  55327. * This fits to the PBR convention in the GLTF definition:
  55328. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  55329. */
  55330. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  55331. /**
  55332. * The base color has two different interpretations depending on the value of metalness.
  55333. * When the material is a metal, the base color is the specific measured reflectance value
  55334. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  55335. * of the material.
  55336. */
  55337. baseColor: Color3;
  55338. /**
  55339. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  55340. * well as opacity information in the alpha channel.
  55341. */
  55342. baseTexture: BaseTexture;
  55343. /**
  55344. * Specifies the metallic scalar value of the material.
  55345. * Can also be used to scale the metalness values of the metallic texture.
  55346. */
  55347. metallic: number;
  55348. /**
  55349. * Specifies the roughness scalar value of the material.
  55350. * Can also be used to scale the roughness values of the metallic texture.
  55351. */
  55352. roughness: number;
  55353. /**
  55354. * Texture containing both the metallic value in the B channel and the
  55355. * roughness value in the G channel to keep better precision.
  55356. */
  55357. metallicRoughnessTexture: BaseTexture;
  55358. /**
  55359. * Instantiates a new PBRMetalRoughnessMaterial instance.
  55360. *
  55361. * @param name The material name
  55362. * @param scene The scene the material will be use in.
  55363. */
  55364. constructor(name: string, scene: Scene);
  55365. /**
  55366. * Return the currrent class name of the material.
  55367. */
  55368. getClassName(): string;
  55369. /**
  55370. * Makes a duplicate of the current material.
  55371. * @param name - name to use for the new material.
  55372. */
  55373. clone(name: string): PBRMetallicRoughnessMaterial;
  55374. /**
  55375. * Serialize the material to a parsable JSON object.
  55376. */
  55377. serialize(): any;
  55378. /**
  55379. * Parses a JSON object correponding to the serialize function.
  55380. */
  55381. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  55382. }
  55383. }
  55384. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  55385. import { Scene } from "babylonjs/scene";
  55386. import { Color3 } from "babylonjs/Maths/math.color";
  55387. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55388. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  55389. /**
  55390. * The PBR material of BJS following the specular glossiness convention.
  55391. *
  55392. * This fits to the PBR convention in the GLTF definition:
  55393. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  55394. */
  55395. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  55396. /**
  55397. * Specifies the diffuse color of the material.
  55398. */
  55399. diffuseColor: Color3;
  55400. /**
  55401. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  55402. * channel.
  55403. */
  55404. diffuseTexture: BaseTexture;
  55405. /**
  55406. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  55407. */
  55408. specularColor: Color3;
  55409. /**
  55410. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  55411. */
  55412. glossiness: number;
  55413. /**
  55414. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  55415. */
  55416. specularGlossinessTexture: BaseTexture;
  55417. /**
  55418. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  55419. *
  55420. * @param name The material name
  55421. * @param scene The scene the material will be use in.
  55422. */
  55423. constructor(name: string, scene: Scene);
  55424. /**
  55425. * Return the currrent class name of the material.
  55426. */
  55427. getClassName(): string;
  55428. /**
  55429. * Makes a duplicate of the current material.
  55430. * @param name - name to use for the new material.
  55431. */
  55432. clone(name: string): PBRSpecularGlossinessMaterial;
  55433. /**
  55434. * Serialize the material to a parsable JSON object.
  55435. */
  55436. serialize(): any;
  55437. /**
  55438. * Parses a JSON object correponding to the serialize function.
  55439. */
  55440. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  55441. }
  55442. }
  55443. declare module "babylonjs/Materials/PBR/index" {
  55444. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  55445. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  55446. export * from "babylonjs/Materials/PBR/pbrMaterial";
  55447. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  55448. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  55449. }
  55450. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  55451. import { Nullable } from "babylonjs/types";
  55452. import { Scene } from "babylonjs/scene";
  55453. import { Matrix } from "babylonjs/Maths/math.vector";
  55454. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55455. /**
  55456. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  55457. * It can help converting any input color in a desired output one. This can then be used to create effects
  55458. * from sepia, black and white to sixties or futuristic rendering...
  55459. *
  55460. * The only supported format is currently 3dl.
  55461. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  55462. */
  55463. export class ColorGradingTexture extends BaseTexture {
  55464. /**
  55465. * The current texture matrix. (will always be identity in color grading texture)
  55466. */
  55467. private _textureMatrix;
  55468. /**
  55469. * The texture URL.
  55470. */
  55471. url: string;
  55472. /**
  55473. * Empty line regex stored for GC.
  55474. */
  55475. private static _noneEmptyLineRegex;
  55476. private _engine;
  55477. /**
  55478. * Instantiates a ColorGradingTexture from the following parameters.
  55479. *
  55480. * @param url The location of the color gradind data (currently only supporting 3dl)
  55481. * @param scene The scene the texture will be used in
  55482. */
  55483. constructor(url: string, scene: Scene);
  55484. /**
  55485. * Returns the texture matrix used in most of the material.
  55486. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  55487. */
  55488. getTextureMatrix(): Matrix;
  55489. /**
  55490. * Occurs when the file being loaded is a .3dl LUT file.
  55491. */
  55492. private load3dlTexture;
  55493. /**
  55494. * Starts the loading process of the texture.
  55495. */
  55496. private loadTexture;
  55497. /**
  55498. * Clones the color gradind texture.
  55499. */
  55500. clone(): ColorGradingTexture;
  55501. /**
  55502. * Called during delayed load for textures.
  55503. */
  55504. delayLoad(): void;
  55505. /**
  55506. * Parses a color grading texture serialized by Babylon.
  55507. * @param parsedTexture The texture information being parsedTexture
  55508. * @param scene The scene to load the texture in
  55509. * @param rootUrl The root url of the data assets to load
  55510. * @return A color gradind texture
  55511. */
  55512. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  55513. /**
  55514. * Serializes the LUT texture to json format.
  55515. */
  55516. serialize(): any;
  55517. }
  55518. }
  55519. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  55520. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55521. import { Scene } from "babylonjs/scene";
  55522. import { Nullable } from "babylonjs/types";
  55523. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55524. /**
  55525. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  55526. */
  55527. export class EquiRectangularCubeTexture extends BaseTexture {
  55528. /** The six faces of the cube. */
  55529. private static _FacesMapping;
  55530. private _noMipmap;
  55531. private _onLoad;
  55532. private _onError;
  55533. /** The size of the cubemap. */
  55534. private _size;
  55535. /** The buffer of the image. */
  55536. private _buffer;
  55537. /** The width of the input image. */
  55538. private _width;
  55539. /** The height of the input image. */
  55540. private _height;
  55541. /** The URL to the image. */
  55542. url: string;
  55543. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  55544. coordinatesMode: number;
  55545. /**
  55546. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  55547. * @param url The location of the image
  55548. * @param scene The scene the texture will be used in
  55549. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55550. * @param noMipmap Forces to not generate the mipmap if true
  55551. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  55552. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  55553. * @param onLoad — defines a callback called when texture is loaded
  55554. * @param onError — defines a callback called if there is an error
  55555. */
  55556. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  55557. /**
  55558. * Load the image data, by putting the image on a canvas and extracting its buffer.
  55559. */
  55560. private loadImage;
  55561. /**
  55562. * Convert the image buffer into a cubemap and create a CubeTexture.
  55563. */
  55564. private loadTexture;
  55565. /**
  55566. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  55567. * @param buffer The ArrayBuffer that should be converted.
  55568. * @returns The buffer as Float32Array.
  55569. */
  55570. private getFloat32ArrayFromArrayBuffer;
  55571. /**
  55572. * Get the current class name of the texture useful for serialization or dynamic coding.
  55573. * @returns "EquiRectangularCubeTexture"
  55574. */
  55575. getClassName(): string;
  55576. /**
  55577. * Create a clone of the current EquiRectangularCubeTexture and return it.
  55578. * @returns A clone of the current EquiRectangularCubeTexture.
  55579. */
  55580. clone(): EquiRectangularCubeTexture;
  55581. }
  55582. }
  55583. declare module "babylonjs/Misc/tga" {
  55584. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55585. /**
  55586. * Based on jsTGALoader - Javascript loader for TGA file
  55587. * By Vincent Thibault
  55588. * @see http://blog.robrowser.com/javascript-tga-loader.html
  55589. */
  55590. export class TGATools {
  55591. private static _TYPE_INDEXED;
  55592. private static _TYPE_RGB;
  55593. private static _TYPE_GREY;
  55594. private static _TYPE_RLE_INDEXED;
  55595. private static _TYPE_RLE_RGB;
  55596. private static _TYPE_RLE_GREY;
  55597. private static _ORIGIN_MASK;
  55598. private static _ORIGIN_SHIFT;
  55599. private static _ORIGIN_BL;
  55600. private static _ORIGIN_BR;
  55601. private static _ORIGIN_UL;
  55602. private static _ORIGIN_UR;
  55603. /**
  55604. * Gets the header of a TGA file
  55605. * @param data defines the TGA data
  55606. * @returns the header
  55607. */
  55608. static GetTGAHeader(data: Uint8Array): any;
  55609. /**
  55610. * Uploads TGA content to a Babylon Texture
  55611. * @hidden
  55612. */
  55613. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  55614. /** @hidden */
  55615. 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;
  55616. /** @hidden */
  55617. 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;
  55618. /** @hidden */
  55619. 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;
  55620. /** @hidden */
  55621. 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;
  55622. /** @hidden */
  55623. 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;
  55624. /** @hidden */
  55625. 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;
  55626. }
  55627. }
  55628. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  55629. import { Nullable } from "babylonjs/types";
  55630. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55631. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55632. /**
  55633. * Implementation of the TGA Texture Loader.
  55634. * @hidden
  55635. */
  55636. export class _TGATextureLoader implements IInternalTextureLoader {
  55637. /**
  55638. * Defines wether the loader supports cascade loading the different faces.
  55639. */
  55640. readonly supportCascades: boolean;
  55641. /**
  55642. * This returns if the loader support the current file information.
  55643. * @param extension defines the file extension of the file being loaded
  55644. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55645. * @param fallback defines the fallback internal texture if any
  55646. * @param isBase64 defines whether the texture is encoded as a base64
  55647. * @param isBuffer defines whether the texture data are stored as a buffer
  55648. * @returns true if the loader can load the specified file
  55649. */
  55650. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55651. /**
  55652. * Transform the url before loading if required.
  55653. * @param rootUrl the url of the texture
  55654. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55655. * @returns the transformed texture
  55656. */
  55657. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  55658. /**
  55659. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55660. * @param rootUrl the url of the texture
  55661. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55662. * @returns the fallback texture
  55663. */
  55664. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  55665. /**
  55666. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  55667. * @param data contains the texture data
  55668. * @param texture defines the BabylonJS internal texture
  55669. * @param createPolynomials will be true if polynomials have been requested
  55670. * @param onLoad defines the callback to trigger once the texture is ready
  55671. * @param onError defines the callback to trigger in case of error
  55672. */
  55673. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55674. /**
  55675. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55676. * @param data contains the texture data
  55677. * @param texture defines the BabylonJS internal texture
  55678. * @param callback defines the method to call once ready to upload
  55679. */
  55680. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55681. }
  55682. }
  55683. declare module "babylonjs/Misc/basis" {
  55684. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55685. /**
  55686. * Info about the .basis files
  55687. */
  55688. class BasisFileInfo {
  55689. /**
  55690. * If the file has alpha
  55691. */
  55692. hasAlpha: boolean;
  55693. /**
  55694. * Info about each image of the basis file
  55695. */
  55696. images: Array<{
  55697. levels: Array<{
  55698. width: number;
  55699. height: number;
  55700. transcodedPixels: ArrayBufferView;
  55701. }>;
  55702. }>;
  55703. }
  55704. /**
  55705. * Result of transcoding a basis file
  55706. */
  55707. class TranscodeResult {
  55708. /**
  55709. * Info about the .basis file
  55710. */
  55711. fileInfo: BasisFileInfo;
  55712. /**
  55713. * Format to use when loading the file
  55714. */
  55715. format: number;
  55716. }
  55717. /**
  55718. * Configuration options for the Basis transcoder
  55719. */
  55720. export class BasisTranscodeConfiguration {
  55721. /**
  55722. * Supported compression formats used to determine the supported output format of the transcoder
  55723. */
  55724. supportedCompressionFormats?: {
  55725. /**
  55726. * etc1 compression format
  55727. */
  55728. etc1?: boolean;
  55729. /**
  55730. * s3tc compression format
  55731. */
  55732. s3tc?: boolean;
  55733. /**
  55734. * pvrtc compression format
  55735. */
  55736. pvrtc?: boolean;
  55737. /**
  55738. * etc2 compression format
  55739. */
  55740. etc2?: boolean;
  55741. };
  55742. /**
  55743. * If mipmap levels should be loaded for transcoded images (Default: true)
  55744. */
  55745. loadMipmapLevels?: boolean;
  55746. /**
  55747. * Index of a single image to load (Default: all images)
  55748. */
  55749. loadSingleImage?: number;
  55750. }
  55751. /**
  55752. * Used to load .Basis files
  55753. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  55754. */
  55755. export class BasisTools {
  55756. private static _IgnoreSupportedFormats;
  55757. /**
  55758. * URL to use when loading the basis transcoder
  55759. */
  55760. static JSModuleURL: string;
  55761. /**
  55762. * URL to use when loading the wasm module for the transcoder
  55763. */
  55764. static WasmModuleURL: string;
  55765. /**
  55766. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  55767. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  55768. * @returns internal format corresponding to the Basis format
  55769. */
  55770. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  55771. private static _WorkerPromise;
  55772. private static _Worker;
  55773. private static _actionId;
  55774. private static _CreateWorkerAsync;
  55775. /**
  55776. * Transcodes a loaded image file to compressed pixel data
  55777. * @param imageData image data to transcode
  55778. * @param config configuration options for the transcoding
  55779. * @returns a promise resulting in the transcoded image
  55780. */
  55781. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  55782. /**
  55783. * Loads a texture from the transcode result
  55784. * @param texture texture load to
  55785. * @param transcodeResult the result of transcoding the basis file to load from
  55786. */
  55787. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  55788. }
  55789. }
  55790. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  55791. import { Nullable } from "babylonjs/types";
  55792. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55793. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55794. /**
  55795. * Loader for .basis file format
  55796. */
  55797. export class _BasisTextureLoader implements IInternalTextureLoader {
  55798. /**
  55799. * Defines whether the loader supports cascade loading the different faces.
  55800. */
  55801. readonly supportCascades: boolean;
  55802. /**
  55803. * This returns if the loader support the current file information.
  55804. * @param extension defines the file extension of the file being loaded
  55805. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55806. * @param fallback defines the fallback internal texture if any
  55807. * @param isBase64 defines whether the texture is encoded as a base64
  55808. * @param isBuffer defines whether the texture data are stored as a buffer
  55809. * @returns true if the loader can load the specified file
  55810. */
  55811. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55812. /**
  55813. * Transform the url before loading if required.
  55814. * @param rootUrl the url of the texture
  55815. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55816. * @returns the transformed texture
  55817. */
  55818. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  55819. /**
  55820. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55821. * @param rootUrl the url of the texture
  55822. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55823. * @returns the fallback texture
  55824. */
  55825. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  55826. /**
  55827. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  55828. * @param data contains the texture data
  55829. * @param texture defines the BabylonJS internal texture
  55830. * @param createPolynomials will be true if polynomials have been requested
  55831. * @param onLoad defines the callback to trigger once the texture is ready
  55832. * @param onError defines the callback to trigger in case of error
  55833. */
  55834. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55835. /**
  55836. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55837. * @param data contains the texture data
  55838. * @param texture defines the BabylonJS internal texture
  55839. * @param callback defines the method to call once ready to upload
  55840. */
  55841. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55842. }
  55843. }
  55844. declare module "babylonjs/Materials/Textures/Loaders/index" {
  55845. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  55846. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  55847. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  55848. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  55849. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  55850. }
  55851. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  55852. import { Scene } from "babylonjs/scene";
  55853. import { Texture } from "babylonjs/Materials/Textures/texture";
  55854. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55855. /**
  55856. * 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.
  55857. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55858. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55859. */
  55860. export class CustomProceduralTexture extends ProceduralTexture {
  55861. private _animate;
  55862. private _time;
  55863. private _config;
  55864. private _texturePath;
  55865. /**
  55866. * Instantiates a new Custom Procedural Texture.
  55867. * 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.
  55868. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55869. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55870. * @param name Define the name of the texture
  55871. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  55872. * @param size Define the size of the texture to create
  55873. * @param scene Define the scene the texture belongs to
  55874. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  55875. * @param generateMipMaps Define if the texture should creates mip maps or not
  55876. */
  55877. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  55878. private _loadJson;
  55879. /**
  55880. * Is the texture ready to be used ? (rendered at least once)
  55881. * @returns true if ready, otherwise, false.
  55882. */
  55883. isReady(): boolean;
  55884. /**
  55885. * Render the texture to its associated render target.
  55886. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  55887. */
  55888. render(useCameraPostProcess?: boolean): void;
  55889. /**
  55890. * Update the list of dependant textures samplers in the shader.
  55891. */
  55892. updateTextures(): void;
  55893. /**
  55894. * Update the uniform values of the procedural texture in the shader.
  55895. */
  55896. updateShaderUniforms(): void;
  55897. /**
  55898. * Define if the texture animates or not.
  55899. */
  55900. animate: boolean;
  55901. }
  55902. }
  55903. declare module "babylonjs/Shaders/noise.fragment" {
  55904. /** @hidden */
  55905. export var noisePixelShader: {
  55906. name: string;
  55907. shader: string;
  55908. };
  55909. }
  55910. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  55911. import { Nullable } from "babylonjs/types";
  55912. import { Scene } from "babylonjs/scene";
  55913. import { Texture } from "babylonjs/Materials/Textures/texture";
  55914. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55915. import "babylonjs/Shaders/noise.fragment";
  55916. /**
  55917. * Class used to generate noise procedural textures
  55918. */
  55919. export class NoiseProceduralTexture extends ProceduralTexture {
  55920. private _time;
  55921. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  55922. brightness: number;
  55923. /** Defines the number of octaves to process */
  55924. octaves: number;
  55925. /** Defines the level of persistence (0.8 by default) */
  55926. persistence: number;
  55927. /** Gets or sets animation speed factor (default is 1) */
  55928. animationSpeedFactor: number;
  55929. /**
  55930. * Creates a new NoiseProceduralTexture
  55931. * @param name defines the name fo the texture
  55932. * @param size defines the size of the texture (default is 256)
  55933. * @param scene defines the hosting scene
  55934. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  55935. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  55936. */
  55937. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  55938. private _updateShaderUniforms;
  55939. protected _getDefines(): string;
  55940. /** Generate the current state of the procedural texture */
  55941. render(useCameraPostProcess?: boolean): void;
  55942. /**
  55943. * Serializes this noise procedural texture
  55944. * @returns a serialized noise procedural texture object
  55945. */
  55946. serialize(): any;
  55947. /**
  55948. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  55949. * @param parsedTexture defines parsed texture data
  55950. * @param scene defines the current scene
  55951. * @param rootUrl defines the root URL containing noise procedural texture information
  55952. * @returns a parsed NoiseProceduralTexture
  55953. */
  55954. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  55955. }
  55956. }
  55957. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  55958. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  55959. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  55960. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55961. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  55962. }
  55963. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  55964. import { Nullable } from "babylonjs/types";
  55965. import { Scene } from "babylonjs/scene";
  55966. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  55967. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55968. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  55969. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55970. /**
  55971. * Raw cube texture where the raw buffers are passed in
  55972. */
  55973. export class RawCubeTexture extends CubeTexture {
  55974. /**
  55975. * Creates a cube texture where the raw buffers are passed in.
  55976. * @param scene defines the scene the texture is attached to
  55977. * @param data defines the array of data to use to create each face
  55978. * @param size defines the size of the textures
  55979. * @param format defines the format of the data
  55980. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  55981. * @param generateMipMaps defines if the engine should generate the mip levels
  55982. * @param invertY defines if data must be stored with Y axis inverted
  55983. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  55984. * @param compression defines the compression used (null by default)
  55985. */
  55986. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  55987. /**
  55988. * Updates the raw cube texture.
  55989. * @param data defines the data to store
  55990. * @param format defines the data format
  55991. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  55992. * @param invertY defines if data must be stored with Y axis inverted
  55993. * @param compression defines the compression used (null by default)
  55994. * @param level defines which level of the texture to update
  55995. */
  55996. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  55997. /**
  55998. * Updates a raw cube texture with RGBD encoded data.
  55999. * @param data defines the array of data [mipmap][face] to use to create each face
  56000. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  56001. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56002. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56003. * @returns a promsie that resolves when the operation is complete
  56004. */
  56005. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  56006. /**
  56007. * Clones the raw cube texture.
  56008. * @return a new cube texture
  56009. */
  56010. clone(): CubeTexture;
  56011. /** @hidden */
  56012. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56013. }
  56014. }
  56015. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  56016. import { Scene } from "babylonjs/scene";
  56017. import { Texture } from "babylonjs/Materials/Textures/texture";
  56018. import "babylonjs/Engines/Extensions/engine.rawTexture";
  56019. /**
  56020. * Class used to store 3D textures containing user data
  56021. */
  56022. export class RawTexture3D extends Texture {
  56023. /** Gets or sets the texture format to use */
  56024. format: number;
  56025. private _engine;
  56026. /**
  56027. * Create a new RawTexture3D
  56028. * @param data defines the data of the texture
  56029. * @param width defines the width of the texture
  56030. * @param height defines the height of the texture
  56031. * @param depth defines the depth of the texture
  56032. * @param format defines the texture format to use
  56033. * @param scene defines the hosting scene
  56034. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56035. * @param invertY defines if texture must be stored with Y axis inverted
  56036. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56037. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56038. */
  56039. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56040. /** Gets or sets the texture format to use */
  56041. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56042. /**
  56043. * Update the texture with new data
  56044. * @param data defines the data to store in the texture
  56045. */
  56046. update(data: ArrayBufferView): void;
  56047. }
  56048. }
  56049. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  56050. import { Scene } from "babylonjs/scene";
  56051. import { Texture } from "babylonjs/Materials/Textures/texture";
  56052. import "babylonjs/Engines/Extensions/engine.rawTexture";
  56053. /**
  56054. * Class used to store 2D array textures containing user data
  56055. */
  56056. export class RawTexture2DArray extends Texture {
  56057. /** Gets or sets the texture format to use */
  56058. format: number;
  56059. private _engine;
  56060. /**
  56061. * Create a new RawTexture2DArray
  56062. * @param data defines the data of the texture
  56063. * @param width defines the width of the texture
  56064. * @param height defines the height of the texture
  56065. * @param depth defines the number of layers of the texture
  56066. * @param format defines the texture format to use
  56067. * @param scene defines the hosting scene
  56068. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56069. * @param invertY defines if texture must be stored with Y axis inverted
  56070. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56071. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56072. */
  56073. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56074. /** Gets or sets the texture format to use */
  56075. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56076. /**
  56077. * Update the texture with new data
  56078. * @param data defines the data to store in the texture
  56079. */
  56080. update(data: ArrayBufferView): void;
  56081. }
  56082. }
  56083. declare module "babylonjs/Materials/Textures/refractionTexture" {
  56084. import { Scene } from "babylonjs/scene";
  56085. import { Plane } from "babylonjs/Maths/math.plane";
  56086. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56087. /**
  56088. * Creates a refraction texture used by refraction channel of the standard material.
  56089. * It is like a mirror but to see through a material.
  56090. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56091. */
  56092. export class RefractionTexture extends RenderTargetTexture {
  56093. /**
  56094. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  56095. * 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.
  56096. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56097. */
  56098. refractionPlane: Plane;
  56099. /**
  56100. * Define how deep under the surface we should see.
  56101. */
  56102. depth: number;
  56103. /**
  56104. * Creates a refraction texture used by refraction channel of the standard material.
  56105. * It is like a mirror but to see through a material.
  56106. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56107. * @param name Define the texture name
  56108. * @param size Define the size of the underlying texture
  56109. * @param scene Define the scene the refraction belongs to
  56110. * @param generateMipMaps Define if we need to generate mips level for the refraction
  56111. */
  56112. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  56113. /**
  56114. * Clone the refraction texture.
  56115. * @returns the cloned texture
  56116. */
  56117. clone(): RefractionTexture;
  56118. /**
  56119. * Serialize the texture to a JSON representation you could use in Parse later on
  56120. * @returns the serialized JSON representation
  56121. */
  56122. serialize(): any;
  56123. }
  56124. }
  56125. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  56126. import { Nullable } from "babylonjs/types";
  56127. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56128. import { Matrix } from "babylonjs/Maths/math.vector";
  56129. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  56130. import "babylonjs/Engines/Extensions/engine.videoTexture";
  56131. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  56132. import { Scene } from "babylonjs/scene";
  56133. /**
  56134. * Defines the options related to the creation of an HtmlElementTexture
  56135. */
  56136. export interface IHtmlElementTextureOptions {
  56137. /**
  56138. * Defines wether mip maps should be created or not.
  56139. */
  56140. generateMipMaps?: boolean;
  56141. /**
  56142. * Defines the sampling mode of the texture.
  56143. */
  56144. samplingMode?: number;
  56145. /**
  56146. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  56147. */
  56148. engine: Nullable<ThinEngine>;
  56149. /**
  56150. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  56151. */
  56152. scene: Nullable<Scene>;
  56153. }
  56154. /**
  56155. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  56156. * To be as efficient as possible depending on your constraints nothing aside the first upload
  56157. * is automatically managed.
  56158. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  56159. * in your application.
  56160. *
  56161. * As the update is not automatic, you need to call them manually.
  56162. */
  56163. export class HtmlElementTexture extends BaseTexture {
  56164. /**
  56165. * The texture URL.
  56166. */
  56167. element: HTMLVideoElement | HTMLCanvasElement;
  56168. private static readonly DefaultOptions;
  56169. private _textureMatrix;
  56170. private _engine;
  56171. private _isVideo;
  56172. private _generateMipMaps;
  56173. private _samplingMode;
  56174. /**
  56175. * Instantiates a HtmlElementTexture from the following parameters.
  56176. *
  56177. * @param name Defines the name of the texture
  56178. * @param element Defines the video or canvas the texture is filled with
  56179. * @param options Defines the other none mandatory texture creation options
  56180. */
  56181. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  56182. private _createInternalTexture;
  56183. /**
  56184. * Returns the texture matrix used in most of the material.
  56185. */
  56186. getTextureMatrix(): Matrix;
  56187. /**
  56188. * Updates the content of the texture.
  56189. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  56190. */
  56191. update(invertY?: Nullable<boolean>): void;
  56192. }
  56193. }
  56194. declare module "babylonjs/Materials/Textures/index" {
  56195. export * from "babylonjs/Materials/Textures/baseTexture";
  56196. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  56197. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  56198. export * from "babylonjs/Materials/Textures/cubeTexture";
  56199. export * from "babylonjs/Materials/Textures/dynamicTexture";
  56200. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  56201. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  56202. export * from "babylonjs/Materials/Textures/internalTexture";
  56203. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  56204. export * from "babylonjs/Materials/Textures/Loaders/index";
  56205. export * from "babylonjs/Materials/Textures/mirrorTexture";
  56206. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  56207. export * from "babylonjs/Materials/Textures/Procedurals/index";
  56208. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  56209. export * from "babylonjs/Materials/Textures/rawTexture";
  56210. export * from "babylonjs/Materials/Textures/rawTexture3D";
  56211. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  56212. export * from "babylonjs/Materials/Textures/refractionTexture";
  56213. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  56214. export * from "babylonjs/Materials/Textures/texture";
  56215. export * from "babylonjs/Materials/Textures/videoTexture";
  56216. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  56217. }
  56218. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  56219. /**
  56220. * Enum used to define the target of a block
  56221. */
  56222. export enum NodeMaterialBlockTargets {
  56223. /** Vertex shader */
  56224. Vertex = 1,
  56225. /** Fragment shader */
  56226. Fragment = 2,
  56227. /** Neutral */
  56228. Neutral = 4,
  56229. /** Vertex and Fragment */
  56230. VertexAndFragment = 3
  56231. }
  56232. }
  56233. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  56234. /**
  56235. * Defines the kind of connection point for node based material
  56236. */
  56237. export enum NodeMaterialBlockConnectionPointTypes {
  56238. /** Float */
  56239. Float = 1,
  56240. /** Int */
  56241. Int = 2,
  56242. /** Vector2 */
  56243. Vector2 = 4,
  56244. /** Vector3 */
  56245. Vector3 = 8,
  56246. /** Vector4 */
  56247. Vector4 = 16,
  56248. /** Color3 */
  56249. Color3 = 32,
  56250. /** Color4 */
  56251. Color4 = 64,
  56252. /** Matrix */
  56253. Matrix = 128,
  56254. /** Detect type based on connection */
  56255. AutoDetect = 1024,
  56256. /** Output type that will be defined by input type */
  56257. BasedOnInput = 2048
  56258. }
  56259. }
  56260. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  56261. /**
  56262. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  56263. */
  56264. export enum NodeMaterialBlockConnectionPointMode {
  56265. /** Value is an uniform */
  56266. Uniform = 0,
  56267. /** Value is a mesh attribute */
  56268. Attribute = 1,
  56269. /** Value is a varying between vertex and fragment shaders */
  56270. Varying = 2,
  56271. /** Mode is undefined */
  56272. Undefined = 3
  56273. }
  56274. }
  56275. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  56276. /**
  56277. * Enum used to define system values e.g. values automatically provided by the system
  56278. */
  56279. export enum NodeMaterialSystemValues {
  56280. /** World */
  56281. World = 1,
  56282. /** View */
  56283. View = 2,
  56284. /** Projection */
  56285. Projection = 3,
  56286. /** ViewProjection */
  56287. ViewProjection = 4,
  56288. /** WorldView */
  56289. WorldView = 5,
  56290. /** WorldViewProjection */
  56291. WorldViewProjection = 6,
  56292. /** CameraPosition */
  56293. CameraPosition = 7,
  56294. /** Fog Color */
  56295. FogColor = 8,
  56296. /** Delta time */
  56297. DeltaTime = 9
  56298. }
  56299. }
  56300. declare module "babylonjs/Materials/Node/Enums/index" {
  56301. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56302. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56303. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  56304. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  56305. }
  56306. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  56307. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56308. /**
  56309. * Root class for all node material optimizers
  56310. */
  56311. export class NodeMaterialOptimizer {
  56312. /**
  56313. * Function used to optimize a NodeMaterial graph
  56314. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  56315. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  56316. */
  56317. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  56318. }
  56319. }
  56320. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  56321. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56322. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56323. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56324. import { Scene } from "babylonjs/scene";
  56325. /**
  56326. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  56327. */
  56328. export class TransformBlock extends NodeMaterialBlock {
  56329. /**
  56330. * Defines the value to use to complement W value to transform it to a Vector4
  56331. */
  56332. complementW: number;
  56333. /**
  56334. * Defines the value to use to complement z value to transform it to a Vector4
  56335. */
  56336. complementZ: number;
  56337. /**
  56338. * Creates a new TransformBlock
  56339. * @param name defines the block name
  56340. */
  56341. constructor(name: string);
  56342. /**
  56343. * Gets the current class name
  56344. * @returns the class name
  56345. */
  56346. getClassName(): string;
  56347. /**
  56348. * Gets the vector input
  56349. */
  56350. readonly vector: NodeMaterialConnectionPoint;
  56351. /**
  56352. * Gets the output component
  56353. */
  56354. readonly output: NodeMaterialConnectionPoint;
  56355. /**
  56356. * Gets the matrix transform input
  56357. */
  56358. readonly transform: NodeMaterialConnectionPoint;
  56359. protected _buildBlock(state: NodeMaterialBuildState): this;
  56360. serialize(): any;
  56361. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56362. protected _dumpPropertiesCode(): string;
  56363. }
  56364. }
  56365. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  56366. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56367. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56368. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56369. /**
  56370. * Block used to output the vertex position
  56371. */
  56372. export class VertexOutputBlock extends NodeMaterialBlock {
  56373. /**
  56374. * Creates a new VertexOutputBlock
  56375. * @param name defines the block name
  56376. */
  56377. constructor(name: string);
  56378. /**
  56379. * Gets the current class name
  56380. * @returns the class name
  56381. */
  56382. getClassName(): string;
  56383. /**
  56384. * Gets the vector input component
  56385. */
  56386. readonly vector: NodeMaterialConnectionPoint;
  56387. protected _buildBlock(state: NodeMaterialBuildState): this;
  56388. }
  56389. }
  56390. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  56391. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56392. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56393. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56394. /**
  56395. * Block used to output the final color
  56396. */
  56397. export class FragmentOutputBlock extends NodeMaterialBlock {
  56398. /**
  56399. * Create a new FragmentOutputBlock
  56400. * @param name defines the block name
  56401. */
  56402. constructor(name: string);
  56403. /**
  56404. * Gets the current class name
  56405. * @returns the class name
  56406. */
  56407. getClassName(): string;
  56408. /**
  56409. * Gets the rgba input component
  56410. */
  56411. readonly rgba: NodeMaterialConnectionPoint;
  56412. /**
  56413. * Gets the rgb input component
  56414. */
  56415. readonly rgb: NodeMaterialConnectionPoint;
  56416. /**
  56417. * Gets the a input component
  56418. */
  56419. readonly a: NodeMaterialConnectionPoint;
  56420. protected _buildBlock(state: NodeMaterialBuildState): this;
  56421. }
  56422. }
  56423. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  56424. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56425. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56426. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56427. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56428. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56429. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56430. import { Effect } from "babylonjs/Materials/effect";
  56431. import { Mesh } from "babylonjs/Meshes/mesh";
  56432. import { Nullable } from "babylonjs/types";
  56433. import { Scene } from "babylonjs/scene";
  56434. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  56435. /**
  56436. * Block used to read a reflection texture from a sampler
  56437. */
  56438. export class ReflectionTextureBlock extends NodeMaterialBlock {
  56439. private _define3DName;
  56440. private _defineCubicName;
  56441. private _defineExplicitName;
  56442. private _defineProjectionName;
  56443. private _defineLocalCubicName;
  56444. private _defineSphericalName;
  56445. private _definePlanarName;
  56446. private _defineEquirectangularName;
  56447. private _defineMirroredEquirectangularFixedName;
  56448. private _defineEquirectangularFixedName;
  56449. private _defineSkyboxName;
  56450. private _cubeSamplerName;
  56451. private _2DSamplerName;
  56452. private _positionUVWName;
  56453. private _directionWName;
  56454. private _reflectionCoordsName;
  56455. private _reflection2DCoordsName;
  56456. private _reflectionColorName;
  56457. private _reflectionMatrixName;
  56458. /**
  56459. * Gets or sets the texture associated with the node
  56460. */
  56461. texture: Nullable<BaseTexture>;
  56462. /**
  56463. * Create a new TextureBlock
  56464. * @param name defines the block name
  56465. */
  56466. constructor(name: string);
  56467. /**
  56468. * Gets the current class name
  56469. * @returns the class name
  56470. */
  56471. getClassName(): string;
  56472. /**
  56473. * Gets the world position input component
  56474. */
  56475. readonly position: NodeMaterialConnectionPoint;
  56476. /**
  56477. * Gets the world position input component
  56478. */
  56479. readonly worldPosition: NodeMaterialConnectionPoint;
  56480. /**
  56481. * Gets the world normal input component
  56482. */
  56483. readonly worldNormal: NodeMaterialConnectionPoint;
  56484. /**
  56485. * Gets the world input component
  56486. */
  56487. readonly world: NodeMaterialConnectionPoint;
  56488. /**
  56489. * Gets the camera (or eye) position component
  56490. */
  56491. readonly cameraPosition: NodeMaterialConnectionPoint;
  56492. /**
  56493. * Gets the view input component
  56494. */
  56495. readonly view: NodeMaterialConnectionPoint;
  56496. /**
  56497. * Gets the rgb output component
  56498. */
  56499. readonly rgb: NodeMaterialConnectionPoint;
  56500. /**
  56501. * Gets the r output component
  56502. */
  56503. readonly r: NodeMaterialConnectionPoint;
  56504. /**
  56505. * Gets the g output component
  56506. */
  56507. readonly g: NodeMaterialConnectionPoint;
  56508. /**
  56509. * Gets the b output component
  56510. */
  56511. readonly b: NodeMaterialConnectionPoint;
  56512. autoConfigure(material: NodeMaterial): void;
  56513. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56514. isReady(): boolean;
  56515. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56516. private _injectVertexCode;
  56517. private _writeOutput;
  56518. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56519. protected _dumpPropertiesCode(): string;
  56520. serialize(): any;
  56521. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56522. }
  56523. }
  56524. declare module "babylonjs/Materials/Node/nodeMaterial" {
  56525. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56526. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  56527. import { Scene } from "babylonjs/scene";
  56528. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56529. import { Matrix } from "babylonjs/Maths/math.vector";
  56530. import { Mesh } from "babylonjs/Meshes/mesh";
  56531. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56532. import { Observable } from "babylonjs/Misc/observable";
  56533. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56534. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  56535. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  56536. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  56537. import { Nullable } from "babylonjs/types";
  56538. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56539. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56540. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56541. /**
  56542. * Interface used to configure the node material editor
  56543. */
  56544. export interface INodeMaterialEditorOptions {
  56545. /** Define the URl to load node editor script */
  56546. editorURL?: string;
  56547. }
  56548. /** @hidden */
  56549. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  56550. /** BONES */
  56551. NUM_BONE_INFLUENCERS: number;
  56552. BonesPerMesh: number;
  56553. BONETEXTURE: boolean;
  56554. /** MORPH TARGETS */
  56555. MORPHTARGETS: boolean;
  56556. MORPHTARGETS_NORMAL: boolean;
  56557. MORPHTARGETS_TANGENT: boolean;
  56558. MORPHTARGETS_UV: boolean;
  56559. NUM_MORPH_INFLUENCERS: number;
  56560. /** IMAGE PROCESSING */
  56561. IMAGEPROCESSING: boolean;
  56562. VIGNETTE: boolean;
  56563. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56564. VIGNETTEBLENDMODEOPAQUE: boolean;
  56565. TONEMAPPING: boolean;
  56566. TONEMAPPING_ACES: boolean;
  56567. CONTRAST: boolean;
  56568. EXPOSURE: boolean;
  56569. COLORCURVES: boolean;
  56570. COLORGRADING: boolean;
  56571. COLORGRADING3D: boolean;
  56572. SAMPLER3DGREENDEPTH: boolean;
  56573. SAMPLER3DBGRMAP: boolean;
  56574. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56575. /** MISC. */
  56576. BUMPDIRECTUV: number;
  56577. constructor();
  56578. setValue(name: string, value: boolean): void;
  56579. }
  56580. /**
  56581. * Class used to configure NodeMaterial
  56582. */
  56583. export interface INodeMaterialOptions {
  56584. /**
  56585. * Defines if blocks should emit comments
  56586. */
  56587. emitComments: boolean;
  56588. }
  56589. /**
  56590. * Class used to create a node based material built by assembling shader blocks
  56591. */
  56592. export class NodeMaterial extends PushMaterial {
  56593. private static _BuildIdGenerator;
  56594. private _options;
  56595. private _vertexCompilationState;
  56596. private _fragmentCompilationState;
  56597. private _sharedData;
  56598. private _buildId;
  56599. private _buildWasSuccessful;
  56600. private _cachedWorldViewMatrix;
  56601. private _cachedWorldViewProjectionMatrix;
  56602. private _optimizers;
  56603. private _animationFrame;
  56604. /** Define the URl to load node editor script */
  56605. static EditorURL: string;
  56606. private BJSNODEMATERIALEDITOR;
  56607. /** Get the inspector from bundle or global */
  56608. private _getGlobalNodeMaterialEditor;
  56609. /**
  56610. * Gets or sets data used by visual editor
  56611. * @see https://nme.babylonjs.com
  56612. */
  56613. editorData: any;
  56614. /**
  56615. * 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)
  56616. */
  56617. ignoreAlpha: boolean;
  56618. /**
  56619. * Defines the maximum number of lights that can be used in the material
  56620. */
  56621. maxSimultaneousLights: number;
  56622. /**
  56623. * Observable raised when the material is built
  56624. */
  56625. onBuildObservable: Observable<NodeMaterial>;
  56626. /**
  56627. * Gets or sets the root nodes of the material vertex shader
  56628. */
  56629. _vertexOutputNodes: NodeMaterialBlock[];
  56630. /**
  56631. * Gets or sets the root nodes of the material fragment (pixel) shader
  56632. */
  56633. _fragmentOutputNodes: NodeMaterialBlock[];
  56634. /** Gets or sets options to control the node material overall behavior */
  56635. options: INodeMaterialOptions;
  56636. /**
  56637. * Default configuration related to image processing available in the standard Material.
  56638. */
  56639. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56640. /**
  56641. * Gets the image processing configuration used either in this material.
  56642. */
  56643. /**
  56644. * Sets the Default image processing configuration used either in the this material.
  56645. *
  56646. * If sets to null, the scene one is in use.
  56647. */
  56648. imageProcessingConfiguration: ImageProcessingConfiguration;
  56649. /**
  56650. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  56651. */
  56652. attachedBlocks: NodeMaterialBlock[];
  56653. /**
  56654. * Create a new node based material
  56655. * @param name defines the material name
  56656. * @param scene defines the hosting scene
  56657. * @param options defines creation option
  56658. */
  56659. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  56660. /**
  56661. * Gets the current class name of the material e.g. "NodeMaterial"
  56662. * @returns the class name
  56663. */
  56664. getClassName(): string;
  56665. /**
  56666. * Keep track of the image processing observer to allow dispose and replace.
  56667. */
  56668. private _imageProcessingObserver;
  56669. /**
  56670. * Attaches a new image processing configuration to the Standard Material.
  56671. * @param configuration
  56672. */
  56673. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56674. /**
  56675. * Get a block by its name
  56676. * @param name defines the name of the block to retrieve
  56677. * @returns the required block or null if not found
  56678. */
  56679. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  56680. /**
  56681. * Get a block by its name
  56682. * @param predicate defines the predicate used to find the good candidate
  56683. * @returns the required block or null if not found
  56684. */
  56685. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  56686. /**
  56687. * Get an input block by its name
  56688. * @param predicate defines the predicate used to find the good candidate
  56689. * @returns the required input block or null if not found
  56690. */
  56691. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  56692. /**
  56693. * Gets the list of input blocks attached to this material
  56694. * @returns an array of InputBlocks
  56695. */
  56696. getInputBlocks(): InputBlock[];
  56697. /**
  56698. * Adds a new optimizer to the list of optimizers
  56699. * @param optimizer defines the optimizers to add
  56700. * @returns the current material
  56701. */
  56702. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  56703. /**
  56704. * Remove an optimizer from the list of optimizers
  56705. * @param optimizer defines the optimizers to remove
  56706. * @returns the current material
  56707. */
  56708. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  56709. /**
  56710. * Add a new block to the list of output nodes
  56711. * @param node defines the node to add
  56712. * @returns the current material
  56713. */
  56714. addOutputNode(node: NodeMaterialBlock): this;
  56715. /**
  56716. * Remove a block from the list of root nodes
  56717. * @param node defines the node to remove
  56718. * @returns the current material
  56719. */
  56720. removeOutputNode(node: NodeMaterialBlock): this;
  56721. private _addVertexOutputNode;
  56722. private _removeVertexOutputNode;
  56723. private _addFragmentOutputNode;
  56724. private _removeFragmentOutputNode;
  56725. /**
  56726. * Specifies if the material will require alpha blending
  56727. * @returns a boolean specifying if alpha blending is needed
  56728. */
  56729. needAlphaBlending(): boolean;
  56730. /**
  56731. * Specifies if this material should be rendered in alpha test mode
  56732. * @returns a boolean specifying if an alpha test is needed.
  56733. */
  56734. needAlphaTesting(): boolean;
  56735. private _initializeBlock;
  56736. private _resetDualBlocks;
  56737. /**
  56738. * Remove a block from the current node material
  56739. * @param block defines the block to remove
  56740. */
  56741. removeBlock(block: NodeMaterialBlock): void;
  56742. /**
  56743. * Build the material and generates the inner effect
  56744. * @param verbose defines if the build should log activity
  56745. */
  56746. build(verbose?: boolean): void;
  56747. /**
  56748. * Runs an otpimization phase to try to improve the shader code
  56749. */
  56750. optimize(): void;
  56751. private _prepareDefinesForAttributes;
  56752. /**
  56753. * Get if the submesh is ready to be used and all its information available.
  56754. * Child classes can use it to update shaders
  56755. * @param mesh defines the mesh to check
  56756. * @param subMesh defines which submesh to check
  56757. * @param useInstances specifies that instances should be used
  56758. * @returns a boolean indicating that the submesh is ready or not
  56759. */
  56760. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56761. /**
  56762. * Get a string representing the shaders built by the current node graph
  56763. */
  56764. readonly compiledShaders: string;
  56765. /**
  56766. * Binds the world matrix to the material
  56767. * @param world defines the world transformation matrix
  56768. */
  56769. bindOnlyWorldMatrix(world: Matrix): void;
  56770. /**
  56771. * Binds the submesh to this material by preparing the effect and shader to draw
  56772. * @param world defines the world transformation matrix
  56773. * @param mesh defines the mesh containing the submesh
  56774. * @param subMesh defines the submesh to bind the material to
  56775. */
  56776. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56777. /**
  56778. * Gets the active textures from the material
  56779. * @returns an array of textures
  56780. */
  56781. getActiveTextures(): BaseTexture[];
  56782. /**
  56783. * Gets the list of texture blocks
  56784. * @returns an array of texture blocks
  56785. */
  56786. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  56787. /**
  56788. * Specifies if the material uses a texture
  56789. * @param texture defines the texture to check against the material
  56790. * @returns a boolean specifying if the material uses the texture
  56791. */
  56792. hasTexture(texture: BaseTexture): boolean;
  56793. /**
  56794. * Disposes the material
  56795. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  56796. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  56797. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  56798. */
  56799. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  56800. /** Creates the node editor window. */
  56801. private _createNodeEditor;
  56802. /**
  56803. * Launch the node material editor
  56804. * @param config Define the configuration of the editor
  56805. * @return a promise fulfilled when the node editor is visible
  56806. */
  56807. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  56808. /**
  56809. * Clear the current material
  56810. */
  56811. clear(): void;
  56812. /**
  56813. * Clear the current material and set it to a default state
  56814. */
  56815. setToDefault(): void;
  56816. /**
  56817. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  56818. * @param url defines the url to load from
  56819. * @returns a promise that will fullfil when the material is fully loaded
  56820. */
  56821. loadAsync(url: string): Promise<void>;
  56822. private _gatherBlocks;
  56823. /**
  56824. * Generate a string containing the code declaration required to create an equivalent of this material
  56825. * @returns a string
  56826. */
  56827. generateCode(): string;
  56828. /**
  56829. * Serializes this material in a JSON representation
  56830. * @returns the serialized material object
  56831. */
  56832. serialize(): any;
  56833. private _restoreConnections;
  56834. /**
  56835. * Clear the current graph and load a new one from a serialization object
  56836. * @param source defines the JSON representation of the material
  56837. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56838. */
  56839. loadFromSerialization(source: any, rootUrl?: string): void;
  56840. /**
  56841. * Creates a node material from parsed material data
  56842. * @param source defines the JSON representation of the material
  56843. * @param scene defines the hosting scene
  56844. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56845. * @returns a new node material
  56846. */
  56847. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  56848. /**
  56849. * Creates a new node material set to default basic configuration
  56850. * @param name defines the name of the material
  56851. * @param scene defines the hosting scene
  56852. * @returns a new NodeMaterial
  56853. */
  56854. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  56855. }
  56856. }
  56857. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  56858. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56859. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56860. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56861. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56862. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56863. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56864. import { Effect } from "babylonjs/Materials/effect";
  56865. import { Mesh } from "babylonjs/Meshes/mesh";
  56866. import { Nullable } from "babylonjs/types";
  56867. import { Texture } from "babylonjs/Materials/Textures/texture";
  56868. import { Scene } from "babylonjs/scene";
  56869. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56870. /**
  56871. * Block used to read a texture from a sampler
  56872. */
  56873. export class TextureBlock extends NodeMaterialBlock {
  56874. private _defineName;
  56875. private _linearDefineName;
  56876. private _tempTextureRead;
  56877. private _samplerName;
  56878. private _transformedUVName;
  56879. private _textureTransformName;
  56880. private _textureInfoName;
  56881. private _mainUVName;
  56882. private _mainUVDefineName;
  56883. /**
  56884. * Gets or sets the texture associated with the node
  56885. */
  56886. texture: Nullable<Texture>;
  56887. /**
  56888. * Create a new TextureBlock
  56889. * @param name defines the block name
  56890. */
  56891. constructor(name: string);
  56892. /**
  56893. * Gets the current class name
  56894. * @returns the class name
  56895. */
  56896. getClassName(): string;
  56897. /**
  56898. * Gets the uv input component
  56899. */
  56900. readonly uv: NodeMaterialConnectionPoint;
  56901. /**
  56902. * Gets the rgba output component
  56903. */
  56904. readonly rgba: NodeMaterialConnectionPoint;
  56905. /**
  56906. * Gets the rgb output component
  56907. */
  56908. readonly rgb: NodeMaterialConnectionPoint;
  56909. /**
  56910. * Gets the r output component
  56911. */
  56912. readonly r: NodeMaterialConnectionPoint;
  56913. /**
  56914. * Gets the g output component
  56915. */
  56916. readonly g: NodeMaterialConnectionPoint;
  56917. /**
  56918. * Gets the b output component
  56919. */
  56920. readonly b: NodeMaterialConnectionPoint;
  56921. /**
  56922. * Gets the a output component
  56923. */
  56924. readonly a: NodeMaterialConnectionPoint;
  56925. readonly target: NodeMaterialBlockTargets;
  56926. autoConfigure(material: NodeMaterial): void;
  56927. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56928. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56929. private _getTextureBase;
  56930. isReady(): boolean;
  56931. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56932. private readonly _isMixed;
  56933. private _injectVertexCode;
  56934. private _writeTextureRead;
  56935. private _writeOutput;
  56936. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56937. protected _dumpPropertiesCode(): string;
  56938. serialize(): any;
  56939. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56940. }
  56941. }
  56942. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  56943. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56944. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56945. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56946. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56947. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56948. import { Scene } from "babylonjs/scene";
  56949. /**
  56950. * Class used to store shared data between 2 NodeMaterialBuildState
  56951. */
  56952. export class NodeMaterialBuildStateSharedData {
  56953. /**
  56954. * Gets the list of emitted varyings
  56955. */
  56956. temps: string[];
  56957. /**
  56958. * Gets the list of emitted varyings
  56959. */
  56960. varyings: string[];
  56961. /**
  56962. * Gets the varying declaration string
  56963. */
  56964. varyingDeclaration: string;
  56965. /**
  56966. * Input blocks
  56967. */
  56968. inputBlocks: InputBlock[];
  56969. /**
  56970. * Input blocks
  56971. */
  56972. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  56973. /**
  56974. * Bindable blocks (Blocks that need to set data to the effect)
  56975. */
  56976. bindableBlocks: NodeMaterialBlock[];
  56977. /**
  56978. * List of blocks that can provide a compilation fallback
  56979. */
  56980. blocksWithFallbacks: NodeMaterialBlock[];
  56981. /**
  56982. * List of blocks that can provide a define update
  56983. */
  56984. blocksWithDefines: NodeMaterialBlock[];
  56985. /**
  56986. * List of blocks that can provide a repeatable content
  56987. */
  56988. repeatableContentBlocks: NodeMaterialBlock[];
  56989. /**
  56990. * List of blocks that can provide a dynamic list of uniforms
  56991. */
  56992. dynamicUniformBlocks: NodeMaterialBlock[];
  56993. /**
  56994. * List of blocks that can block the isReady function for the material
  56995. */
  56996. blockingBlocks: NodeMaterialBlock[];
  56997. /**
  56998. * Gets the list of animated inputs
  56999. */
  57000. animatedInputs: InputBlock[];
  57001. /**
  57002. * Build Id used to avoid multiple recompilations
  57003. */
  57004. buildId: number;
  57005. /** List of emitted variables */
  57006. variableNames: {
  57007. [key: string]: number;
  57008. };
  57009. /** List of emitted defines */
  57010. defineNames: {
  57011. [key: string]: number;
  57012. };
  57013. /** Should emit comments? */
  57014. emitComments: boolean;
  57015. /** Emit build activity */
  57016. verbose: boolean;
  57017. /** Gets or sets the hosting scene */
  57018. scene: Scene;
  57019. /**
  57020. * Gets the compilation hints emitted at compilation time
  57021. */
  57022. hints: {
  57023. needWorldViewMatrix: boolean;
  57024. needWorldViewProjectionMatrix: boolean;
  57025. needAlphaBlending: boolean;
  57026. needAlphaTesting: boolean;
  57027. };
  57028. /**
  57029. * List of compilation checks
  57030. */
  57031. checks: {
  57032. emitVertex: boolean;
  57033. emitFragment: boolean;
  57034. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  57035. };
  57036. /** Creates a new shared data */
  57037. constructor();
  57038. /**
  57039. * Emits console errors and exceptions if there is a failing check
  57040. */
  57041. emitErrors(): void;
  57042. }
  57043. }
  57044. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  57045. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57046. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57047. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  57048. /**
  57049. * Class used to store node based material build state
  57050. */
  57051. export class NodeMaterialBuildState {
  57052. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  57053. supportUniformBuffers: boolean;
  57054. /**
  57055. * Gets the list of emitted attributes
  57056. */
  57057. attributes: string[];
  57058. /**
  57059. * Gets the list of emitted uniforms
  57060. */
  57061. uniforms: string[];
  57062. /**
  57063. * Gets the list of emitted constants
  57064. */
  57065. constants: string[];
  57066. /**
  57067. * Gets the list of emitted samplers
  57068. */
  57069. samplers: string[];
  57070. /**
  57071. * Gets the list of emitted functions
  57072. */
  57073. functions: {
  57074. [key: string]: string;
  57075. };
  57076. /**
  57077. * Gets the list of emitted extensions
  57078. */
  57079. extensions: {
  57080. [key: string]: string;
  57081. };
  57082. /**
  57083. * Gets the target of the compilation state
  57084. */
  57085. target: NodeMaterialBlockTargets;
  57086. /**
  57087. * Gets the list of emitted counters
  57088. */
  57089. counters: {
  57090. [key: string]: number;
  57091. };
  57092. /**
  57093. * Shared data between multiple NodeMaterialBuildState instances
  57094. */
  57095. sharedData: NodeMaterialBuildStateSharedData;
  57096. /** @hidden */
  57097. _vertexState: NodeMaterialBuildState;
  57098. /** @hidden */
  57099. _attributeDeclaration: string;
  57100. /** @hidden */
  57101. _uniformDeclaration: string;
  57102. /** @hidden */
  57103. _constantDeclaration: string;
  57104. /** @hidden */
  57105. _samplerDeclaration: string;
  57106. /** @hidden */
  57107. _varyingTransfer: string;
  57108. private _repeatableContentAnchorIndex;
  57109. /** @hidden */
  57110. _builtCompilationString: string;
  57111. /**
  57112. * Gets the emitted compilation strings
  57113. */
  57114. compilationString: string;
  57115. /**
  57116. * Finalize the compilation strings
  57117. * @param state defines the current compilation state
  57118. */
  57119. finalize(state: NodeMaterialBuildState): void;
  57120. /** @hidden */
  57121. readonly _repeatableContentAnchor: string;
  57122. /** @hidden */
  57123. _getFreeVariableName(prefix: string): string;
  57124. /** @hidden */
  57125. _getFreeDefineName(prefix: string): string;
  57126. /** @hidden */
  57127. _excludeVariableName(name: string): void;
  57128. /** @hidden */
  57129. _emit2DSampler(name: string): void;
  57130. /** @hidden */
  57131. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  57132. /** @hidden */
  57133. _emitExtension(name: string, extension: string): void;
  57134. /** @hidden */
  57135. _emitFunction(name: string, code: string, comments: string): void;
  57136. /** @hidden */
  57137. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  57138. replaceStrings?: {
  57139. search: RegExp;
  57140. replace: string;
  57141. }[];
  57142. repeatKey?: string;
  57143. }): string;
  57144. /** @hidden */
  57145. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  57146. repeatKey?: string;
  57147. removeAttributes?: boolean;
  57148. removeUniforms?: boolean;
  57149. removeVaryings?: boolean;
  57150. removeIfDef?: boolean;
  57151. replaceStrings?: {
  57152. search: RegExp;
  57153. replace: string;
  57154. }[];
  57155. }, storeKey?: string): void;
  57156. /** @hidden */
  57157. _registerTempVariable(name: string): boolean;
  57158. /** @hidden */
  57159. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  57160. /** @hidden */
  57161. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  57162. /** @hidden */
  57163. _emitFloat(value: number): string;
  57164. }
  57165. }
  57166. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  57167. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57168. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57169. import { Nullable } from "babylonjs/types";
  57170. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57171. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57172. import { Effect } from "babylonjs/Materials/effect";
  57173. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57174. import { Mesh } from "babylonjs/Meshes/mesh";
  57175. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57176. import { Scene } from "babylonjs/scene";
  57177. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57178. /**
  57179. * Defines a block that can be used inside a node based material
  57180. */
  57181. export class NodeMaterialBlock {
  57182. private _buildId;
  57183. private _buildTarget;
  57184. private _target;
  57185. private _isFinalMerger;
  57186. private _isInput;
  57187. protected _isUnique: boolean;
  57188. /** @hidden */
  57189. _codeVariableName: string;
  57190. /** @hidden */
  57191. _inputs: NodeMaterialConnectionPoint[];
  57192. /** @hidden */
  57193. _outputs: NodeMaterialConnectionPoint[];
  57194. /** @hidden */
  57195. _preparationId: number;
  57196. /**
  57197. * Gets or sets the name of the block
  57198. */
  57199. name: string;
  57200. /**
  57201. * Gets or sets the unique id of the node
  57202. */
  57203. uniqueId: number;
  57204. /**
  57205. * Gets or sets the comments associated with this block
  57206. */
  57207. comments: string;
  57208. /**
  57209. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  57210. */
  57211. readonly isUnique: boolean;
  57212. /**
  57213. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  57214. */
  57215. readonly isFinalMerger: boolean;
  57216. /**
  57217. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  57218. */
  57219. readonly isInput: boolean;
  57220. /**
  57221. * Gets or sets the build Id
  57222. */
  57223. buildId: number;
  57224. /**
  57225. * Gets or sets the target of the block
  57226. */
  57227. target: NodeMaterialBlockTargets;
  57228. /**
  57229. * Gets the list of input points
  57230. */
  57231. readonly inputs: NodeMaterialConnectionPoint[];
  57232. /** Gets the list of output points */
  57233. readonly outputs: NodeMaterialConnectionPoint[];
  57234. /**
  57235. * Find an input by its name
  57236. * @param name defines the name of the input to look for
  57237. * @returns the input or null if not found
  57238. */
  57239. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57240. /**
  57241. * Find an output by its name
  57242. * @param name defines the name of the outputto look for
  57243. * @returns the output or null if not found
  57244. */
  57245. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57246. /**
  57247. * Creates a new NodeMaterialBlock
  57248. * @param name defines the block name
  57249. * @param target defines the target of that block (Vertex by default)
  57250. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  57251. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  57252. */
  57253. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  57254. /**
  57255. * Initialize the block and prepare the context for build
  57256. * @param state defines the state that will be used for the build
  57257. */
  57258. initialize(state: NodeMaterialBuildState): void;
  57259. /**
  57260. * Bind data to effect. Will only be called for blocks with isBindable === true
  57261. * @param effect defines the effect to bind data to
  57262. * @param nodeMaterial defines the hosting NodeMaterial
  57263. * @param mesh defines the mesh that will be rendered
  57264. */
  57265. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57266. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  57267. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  57268. protected _writeFloat(value: number): string;
  57269. /**
  57270. * Gets the current class name e.g. "NodeMaterialBlock"
  57271. * @returns the class name
  57272. */
  57273. getClassName(): string;
  57274. /**
  57275. * Register a new input. Must be called inside a block constructor
  57276. * @param name defines the connection point name
  57277. * @param type defines the connection point type
  57278. * @param isOptional defines a boolean indicating that this input can be omitted
  57279. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57280. * @returns the current block
  57281. */
  57282. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  57283. /**
  57284. * Register a new output. Must be called inside a block constructor
  57285. * @param name defines the connection point name
  57286. * @param type defines the connection point type
  57287. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57288. * @returns the current block
  57289. */
  57290. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  57291. /**
  57292. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  57293. * @param forOutput defines an optional connection point to check compatibility with
  57294. * @returns the first available input or null
  57295. */
  57296. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  57297. /**
  57298. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  57299. * @param forBlock defines an optional block to check compatibility with
  57300. * @returns the first available input or null
  57301. */
  57302. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  57303. /**
  57304. * Gets the sibling of the given output
  57305. * @param current defines the current output
  57306. * @returns the next output in the list or null
  57307. */
  57308. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  57309. /**
  57310. * Connect current block with another block
  57311. * @param other defines the block to connect with
  57312. * @param options define the various options to help pick the right connections
  57313. * @returns the current block
  57314. */
  57315. connectTo(other: NodeMaterialBlock, options?: {
  57316. input?: string;
  57317. output?: string;
  57318. outputSwizzle?: string;
  57319. }): this | undefined;
  57320. protected _buildBlock(state: NodeMaterialBuildState): void;
  57321. /**
  57322. * Add uniforms, samplers and uniform buffers at compilation time
  57323. * @param state defines the state to update
  57324. * @param nodeMaterial defines the node material requesting the update
  57325. * @param defines defines the material defines to update
  57326. * @param uniformBuffers defines the list of uniform buffer names
  57327. */
  57328. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57329. /**
  57330. * Add potential fallbacks if shader compilation fails
  57331. * @param mesh defines the mesh to be rendered
  57332. * @param fallbacks defines the current prioritized list of fallbacks
  57333. */
  57334. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57335. /**
  57336. * Initialize defines for shader compilation
  57337. * @param mesh defines the mesh to be rendered
  57338. * @param nodeMaterial defines the node material requesting the update
  57339. * @param defines defines the material defines to update
  57340. * @param useInstances specifies that instances should be used
  57341. */
  57342. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57343. /**
  57344. * Update defines for shader compilation
  57345. * @param mesh defines the mesh to be rendered
  57346. * @param nodeMaterial defines the node material requesting the update
  57347. * @param defines defines the material defines to update
  57348. * @param useInstances specifies that instances should be used
  57349. */
  57350. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57351. /**
  57352. * Lets the block try to connect some inputs automatically
  57353. * @param material defines the hosting NodeMaterial
  57354. */
  57355. autoConfigure(material: NodeMaterial): void;
  57356. /**
  57357. * Function called when a block is declared as repeatable content generator
  57358. * @param vertexShaderState defines the current compilation state for the vertex shader
  57359. * @param fragmentShaderState defines the current compilation state for the fragment shader
  57360. * @param mesh defines the mesh to be rendered
  57361. * @param defines defines the material defines to update
  57362. */
  57363. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57364. /**
  57365. * Checks if the block is ready
  57366. * @param mesh defines the mesh to be rendered
  57367. * @param nodeMaterial defines the node material requesting the update
  57368. * @param defines defines the material defines to update
  57369. * @param useInstances specifies that instances should be used
  57370. * @returns true if the block is ready
  57371. */
  57372. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  57373. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  57374. private _processBuild;
  57375. /**
  57376. * Compile the current node and generate the shader code
  57377. * @param state defines the current compilation state (uniforms, samplers, current string)
  57378. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  57379. * @returns true if already built
  57380. */
  57381. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  57382. protected _inputRename(name: string): string;
  57383. protected _outputRename(name: string): string;
  57384. protected _dumpPropertiesCode(): string;
  57385. /** @hidden */
  57386. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  57387. /** @hidden */
  57388. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  57389. /**
  57390. * Clone the current block to a new identical block
  57391. * @param scene defines the hosting scene
  57392. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57393. * @returns a copy of the current block
  57394. */
  57395. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  57396. /**
  57397. * Serializes this block in a JSON representation
  57398. * @returns the serialized block object
  57399. */
  57400. serialize(): any;
  57401. /** @hidden */
  57402. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57403. /**
  57404. * Release resources
  57405. */
  57406. dispose(): void;
  57407. }
  57408. }
  57409. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  57410. /**
  57411. * Enum defining the type of animations supported by InputBlock
  57412. */
  57413. export enum AnimatedInputBlockTypes {
  57414. /** No animation */
  57415. None = 0,
  57416. /** Time based animation. Will only work for floats */
  57417. Time = 1
  57418. }
  57419. }
  57420. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  57421. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57422. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57423. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  57424. import { Nullable } from "babylonjs/types";
  57425. import { Effect } from "babylonjs/Materials/effect";
  57426. import { Matrix } from "babylonjs/Maths/math.vector";
  57427. import { Scene } from "babylonjs/scene";
  57428. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57429. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57430. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57431. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  57432. /**
  57433. * Block used to expose an input value
  57434. */
  57435. export class InputBlock extends NodeMaterialBlock {
  57436. private _mode;
  57437. private _associatedVariableName;
  57438. private _storedValue;
  57439. private _valueCallback;
  57440. private _type;
  57441. private _animationType;
  57442. /** Gets or set a value used to limit the range of float values */
  57443. min: number;
  57444. /** Gets or set a value used to limit the range of float values */
  57445. max: number;
  57446. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  57447. matrixMode: number;
  57448. /** @hidden */
  57449. _systemValue: Nullable<NodeMaterialSystemValues>;
  57450. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  57451. visibleInInspector: boolean;
  57452. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  57453. isConstant: boolean;
  57454. /** Gets or sets the group to use to display this block in the Inspector */
  57455. groupInInspector: string;
  57456. /**
  57457. * Gets or sets the connection point type (default is float)
  57458. */
  57459. readonly type: NodeMaterialBlockConnectionPointTypes;
  57460. /**
  57461. * Creates a new InputBlock
  57462. * @param name defines the block name
  57463. * @param target defines the target of that block (Vertex by default)
  57464. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  57465. */
  57466. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  57467. /**
  57468. * Gets the output component
  57469. */
  57470. readonly output: NodeMaterialConnectionPoint;
  57471. /**
  57472. * Set the source of this connection point to a vertex attribute
  57473. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  57474. * @returns the current connection point
  57475. */
  57476. setAsAttribute(attributeName?: string): InputBlock;
  57477. /**
  57478. * Set the source of this connection point to a system value
  57479. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  57480. * @returns the current connection point
  57481. */
  57482. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  57483. /**
  57484. * Gets or sets the value of that point.
  57485. * Please note that this value will be ignored if valueCallback is defined
  57486. */
  57487. value: any;
  57488. /**
  57489. * Gets or sets a callback used to get the value of that point.
  57490. * Please note that setting this value will force the connection point to ignore the value property
  57491. */
  57492. valueCallback: () => any;
  57493. /**
  57494. * Gets or sets the associated variable name in the shader
  57495. */
  57496. associatedVariableName: string;
  57497. /** Gets or sets the type of animation applied to the input */
  57498. animationType: AnimatedInputBlockTypes;
  57499. /**
  57500. * Gets a boolean indicating that this connection point not defined yet
  57501. */
  57502. readonly isUndefined: boolean;
  57503. /**
  57504. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  57505. * In this case the connection point name must be the name of the uniform to use.
  57506. * Can only be set on inputs
  57507. */
  57508. isUniform: boolean;
  57509. /**
  57510. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  57511. * In this case the connection point name must be the name of the attribute to use
  57512. * Can only be set on inputs
  57513. */
  57514. isAttribute: boolean;
  57515. /**
  57516. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  57517. * Can only be set on exit points
  57518. */
  57519. isVarying: boolean;
  57520. /**
  57521. * Gets a boolean indicating that the current connection point is a system value
  57522. */
  57523. readonly isSystemValue: boolean;
  57524. /**
  57525. * Gets or sets the current well known value or null if not defined as a system value
  57526. */
  57527. systemValue: Nullable<NodeMaterialSystemValues>;
  57528. /**
  57529. * Gets the current class name
  57530. * @returns the class name
  57531. */
  57532. getClassName(): string;
  57533. /**
  57534. * Animate the input if animationType !== None
  57535. * @param scene defines the rendering scene
  57536. */
  57537. animate(scene: Scene): void;
  57538. private _emitDefine;
  57539. initialize(state: NodeMaterialBuildState): void;
  57540. /**
  57541. * Set the input block to its default value (based on its type)
  57542. */
  57543. setDefaultValue(): void;
  57544. private _emitConstant;
  57545. private _emit;
  57546. /** @hidden */
  57547. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  57548. /** @hidden */
  57549. _transmit(effect: Effect, scene: Scene): void;
  57550. protected _buildBlock(state: NodeMaterialBuildState): void;
  57551. protected _dumpPropertiesCode(): string;
  57552. serialize(): any;
  57553. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57554. }
  57555. }
  57556. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  57557. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57558. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57559. import { Nullable } from "babylonjs/types";
  57560. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  57561. import { Observable } from "babylonjs/Misc/observable";
  57562. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57563. /**
  57564. * Enum used to define the compatibility state between two connection points
  57565. */
  57566. export enum NodeMaterialConnectionPointCompatibilityStates {
  57567. /** Points are compatibles */
  57568. Compatible = 0,
  57569. /** Points are incompatible because of their types */
  57570. TypeIncompatible = 1,
  57571. /** Points are incompatible because of their targets (vertex vs fragment) */
  57572. TargetIncompatible = 2
  57573. }
  57574. /**
  57575. * Defines the direction of a connection point
  57576. */
  57577. export enum NodeMaterialConnectionPointDirection {
  57578. /** Input */
  57579. Input = 0,
  57580. /** Output */
  57581. Output = 1
  57582. }
  57583. /**
  57584. * Defines a connection point for a block
  57585. */
  57586. export class NodeMaterialConnectionPoint {
  57587. /** @hidden */
  57588. _ownerBlock: NodeMaterialBlock;
  57589. /** @hidden */
  57590. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  57591. private _endpoints;
  57592. private _associatedVariableName;
  57593. private _direction;
  57594. /** @hidden */
  57595. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57596. /** @hidden */
  57597. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57598. private _type;
  57599. /** @hidden */
  57600. _enforceAssociatedVariableName: boolean;
  57601. /** Gets the direction of the point */
  57602. readonly direction: NodeMaterialConnectionPointDirection;
  57603. /**
  57604. * Gets or sets the additional types supported by this connection point
  57605. */
  57606. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  57607. /**
  57608. * Gets or sets the additional types excluded by this connection point
  57609. */
  57610. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  57611. /**
  57612. * Observable triggered when this point is connected
  57613. */
  57614. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  57615. /**
  57616. * Gets or sets the associated variable name in the shader
  57617. */
  57618. associatedVariableName: string;
  57619. /**
  57620. * Gets or sets the connection point type (default is float)
  57621. */
  57622. type: NodeMaterialBlockConnectionPointTypes;
  57623. /**
  57624. * Gets or sets the connection point name
  57625. */
  57626. name: string;
  57627. /**
  57628. * Gets or sets a boolean indicating that this connection point can be omitted
  57629. */
  57630. isOptional: boolean;
  57631. /**
  57632. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  57633. */
  57634. define: string;
  57635. /** @hidden */
  57636. _prioritizeVertex: boolean;
  57637. private _target;
  57638. /** Gets or sets the target of that connection point */
  57639. target: NodeMaterialBlockTargets;
  57640. /**
  57641. * Gets a boolean indicating that the current point is connected
  57642. */
  57643. readonly isConnected: boolean;
  57644. /**
  57645. * Gets a boolean indicating that the current point is connected to an input block
  57646. */
  57647. readonly isConnectedToInputBlock: boolean;
  57648. /**
  57649. * Gets a the connected input block (if any)
  57650. */
  57651. readonly connectInputBlock: Nullable<InputBlock>;
  57652. /** Get the other side of the connection (if any) */
  57653. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  57654. /** Get the block that owns this connection point */
  57655. readonly ownerBlock: NodeMaterialBlock;
  57656. /** Get the block connected on the other side of this connection (if any) */
  57657. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  57658. /** Get the block connected on the endpoints of this connection (if any) */
  57659. readonly connectedBlocks: Array<NodeMaterialBlock>;
  57660. /** Gets the list of connected endpoints */
  57661. readonly endpoints: NodeMaterialConnectionPoint[];
  57662. /** Gets a boolean indicating if that output point is connected to at least one input */
  57663. readonly hasEndpoints: boolean;
  57664. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  57665. readonly isConnectedInVertexShader: boolean;
  57666. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  57667. readonly isConnectedInFragmentShader: boolean;
  57668. /**
  57669. * Creates a new connection point
  57670. * @param name defines the connection point name
  57671. * @param ownerBlock defines the block hosting this connection point
  57672. * @param direction defines the direction of the connection point
  57673. */
  57674. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  57675. /**
  57676. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  57677. * @returns the class name
  57678. */
  57679. getClassName(): string;
  57680. /**
  57681. * Gets a boolean indicating if the current point can be connected to another point
  57682. * @param connectionPoint defines the other connection point
  57683. * @returns a boolean
  57684. */
  57685. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  57686. /**
  57687. * Gets a number indicating if the current point can be connected to another point
  57688. * @param connectionPoint defines the other connection point
  57689. * @returns a number defining the compatibility state
  57690. */
  57691. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  57692. /**
  57693. * Connect this point to another connection point
  57694. * @param connectionPoint defines the other connection point
  57695. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  57696. * @returns the current connection point
  57697. */
  57698. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  57699. /**
  57700. * Disconnect this point from one of his endpoint
  57701. * @param endpoint defines the other connection point
  57702. * @returns the current connection point
  57703. */
  57704. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  57705. /**
  57706. * Serializes this point in a JSON representation
  57707. * @returns the serialized point object
  57708. */
  57709. serialize(): any;
  57710. /**
  57711. * Release resources
  57712. */
  57713. dispose(): void;
  57714. }
  57715. }
  57716. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  57717. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57718. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57719. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57720. import { Mesh } from "babylonjs/Meshes/mesh";
  57721. import { Effect } from "babylonjs/Materials/effect";
  57722. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57723. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57724. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57725. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57726. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57727. /**
  57728. * Block used to add support for vertex skinning (bones)
  57729. */
  57730. export class BonesBlock extends NodeMaterialBlock {
  57731. /**
  57732. * Creates a new BonesBlock
  57733. * @param name defines the block name
  57734. */
  57735. constructor(name: string);
  57736. /**
  57737. * Initialize the block and prepare the context for build
  57738. * @param state defines the state that will be used for the build
  57739. */
  57740. initialize(state: NodeMaterialBuildState): void;
  57741. /**
  57742. * Gets the current class name
  57743. * @returns the class name
  57744. */
  57745. getClassName(): string;
  57746. /**
  57747. * Gets the matrix indices input component
  57748. */
  57749. readonly matricesIndices: NodeMaterialConnectionPoint;
  57750. /**
  57751. * Gets the matrix weights input component
  57752. */
  57753. readonly matricesWeights: NodeMaterialConnectionPoint;
  57754. /**
  57755. * Gets the extra matrix indices input component
  57756. */
  57757. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  57758. /**
  57759. * Gets the extra matrix weights input component
  57760. */
  57761. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  57762. /**
  57763. * Gets the world input component
  57764. */
  57765. readonly world: NodeMaterialConnectionPoint;
  57766. /**
  57767. * Gets the output component
  57768. */
  57769. readonly output: NodeMaterialConnectionPoint;
  57770. autoConfigure(material: NodeMaterial): void;
  57771. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57772. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57773. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57774. protected _buildBlock(state: NodeMaterialBuildState): this;
  57775. }
  57776. }
  57777. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  57778. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57779. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57780. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57781. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57782. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57783. /**
  57784. * Block used to add support for instances
  57785. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  57786. */
  57787. export class InstancesBlock extends NodeMaterialBlock {
  57788. /**
  57789. * Creates a new InstancesBlock
  57790. * @param name defines the block name
  57791. */
  57792. constructor(name: string);
  57793. /**
  57794. * Gets the current class name
  57795. * @returns the class name
  57796. */
  57797. getClassName(): string;
  57798. /**
  57799. * Gets the first world row input component
  57800. */
  57801. readonly world0: NodeMaterialConnectionPoint;
  57802. /**
  57803. * Gets the second world row input component
  57804. */
  57805. readonly world1: NodeMaterialConnectionPoint;
  57806. /**
  57807. * Gets the third world row input component
  57808. */
  57809. readonly world2: NodeMaterialConnectionPoint;
  57810. /**
  57811. * Gets the forth world row input component
  57812. */
  57813. readonly world3: NodeMaterialConnectionPoint;
  57814. /**
  57815. * Gets the world input component
  57816. */
  57817. readonly world: NodeMaterialConnectionPoint;
  57818. /**
  57819. * Gets the output component
  57820. */
  57821. readonly output: NodeMaterialConnectionPoint;
  57822. autoConfigure(material: NodeMaterial): void;
  57823. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57824. protected _buildBlock(state: NodeMaterialBuildState): this;
  57825. }
  57826. }
  57827. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  57828. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57829. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57830. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57831. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57832. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57833. import { Effect } from "babylonjs/Materials/effect";
  57834. import { Mesh } from "babylonjs/Meshes/mesh";
  57835. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  57836. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  57837. /**
  57838. * Block used to add morph targets support to vertex shader
  57839. */
  57840. export class MorphTargetsBlock extends NodeMaterialBlock {
  57841. private _repeatableContentAnchor;
  57842. private _repeatebleContentGenerated;
  57843. /**
  57844. * Create a new MorphTargetsBlock
  57845. * @param name defines the block name
  57846. */
  57847. constructor(name: string);
  57848. /**
  57849. * Gets the current class name
  57850. * @returns the class name
  57851. */
  57852. getClassName(): string;
  57853. /**
  57854. * Gets the position input component
  57855. */
  57856. readonly position: NodeMaterialConnectionPoint;
  57857. /**
  57858. * Gets the normal input component
  57859. */
  57860. readonly normal: NodeMaterialConnectionPoint;
  57861. /**
  57862. * Gets the tangent input component
  57863. */
  57864. readonly tangent: NodeMaterialConnectionPoint;
  57865. /**
  57866. * Gets the tangent input component
  57867. */
  57868. readonly uv: NodeMaterialConnectionPoint;
  57869. /**
  57870. * Gets the position output component
  57871. */
  57872. readonly positionOutput: NodeMaterialConnectionPoint;
  57873. /**
  57874. * Gets the normal output component
  57875. */
  57876. readonly normalOutput: NodeMaterialConnectionPoint;
  57877. /**
  57878. * Gets the tangent output component
  57879. */
  57880. readonly tangentOutput: NodeMaterialConnectionPoint;
  57881. /**
  57882. * Gets the tangent output component
  57883. */
  57884. readonly uvOutput: NodeMaterialConnectionPoint;
  57885. initialize(state: NodeMaterialBuildState): void;
  57886. autoConfigure(material: NodeMaterial): void;
  57887. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57888. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57889. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57890. protected _buildBlock(state: NodeMaterialBuildState): this;
  57891. }
  57892. }
  57893. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  57894. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57895. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57896. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57897. import { Nullable } from "babylonjs/types";
  57898. import { Scene } from "babylonjs/scene";
  57899. import { Effect } from "babylonjs/Materials/effect";
  57900. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57901. import { Mesh } from "babylonjs/Meshes/mesh";
  57902. import { Light } from "babylonjs/Lights/light";
  57903. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57904. /**
  57905. * Block used to get data information from a light
  57906. */
  57907. export class LightInformationBlock extends NodeMaterialBlock {
  57908. private _lightDataUniformName;
  57909. private _lightColorUniformName;
  57910. private _lightTypeDefineName;
  57911. /**
  57912. * Gets or sets the light associated with this block
  57913. */
  57914. light: Nullable<Light>;
  57915. /**
  57916. * Creates a new LightInformationBlock
  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 world position input component
  57927. */
  57928. readonly worldPosition: NodeMaterialConnectionPoint;
  57929. /**
  57930. * Gets the direction output component
  57931. */
  57932. readonly direction: NodeMaterialConnectionPoint;
  57933. /**
  57934. * Gets the direction output component
  57935. */
  57936. readonly color: NodeMaterialConnectionPoint;
  57937. /**
  57938. * Gets the direction output component
  57939. */
  57940. readonly intensity: NodeMaterialConnectionPoint;
  57941. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57942. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57943. protected _buildBlock(state: NodeMaterialBuildState): this;
  57944. serialize(): any;
  57945. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57946. }
  57947. }
  57948. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  57949. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  57950. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  57951. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  57952. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  57953. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  57954. }
  57955. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  57956. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57957. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57958. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57959. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57960. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57961. import { Effect } from "babylonjs/Materials/effect";
  57962. import { Mesh } from "babylonjs/Meshes/mesh";
  57963. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57964. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  57965. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  57966. /**
  57967. * Block used to add image processing support to fragment shader
  57968. */
  57969. export class ImageProcessingBlock extends NodeMaterialBlock {
  57970. /**
  57971. * Create a new ImageProcessingBlock
  57972. * @param name defines the block name
  57973. */
  57974. constructor(name: string);
  57975. /**
  57976. * Gets the current class name
  57977. * @returns the class name
  57978. */
  57979. getClassName(): string;
  57980. /**
  57981. * Gets the color input component
  57982. */
  57983. readonly color: NodeMaterialConnectionPoint;
  57984. /**
  57985. * Gets the output component
  57986. */
  57987. readonly output: NodeMaterialConnectionPoint;
  57988. /**
  57989. * Initialize the block and prepare the context for build
  57990. * @param state defines the state that will be used for the build
  57991. */
  57992. initialize(state: NodeMaterialBuildState): void;
  57993. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  57994. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57995. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57996. protected _buildBlock(state: NodeMaterialBuildState): this;
  57997. }
  57998. }
  57999. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  58000. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58001. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58002. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58003. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58004. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58005. import { Effect } from "babylonjs/Materials/effect";
  58006. import { Mesh } from "babylonjs/Meshes/mesh";
  58007. import { Scene } from "babylonjs/scene";
  58008. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  58009. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  58010. /**
  58011. * Block used to pertub normals based on a normal map
  58012. */
  58013. export class PerturbNormalBlock extends NodeMaterialBlock {
  58014. private _tangentSpaceParameterName;
  58015. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  58016. invertX: boolean;
  58017. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  58018. invertY: boolean;
  58019. /**
  58020. * Create a new PerturbNormalBlock
  58021. * @param name defines the block name
  58022. */
  58023. constructor(name: string);
  58024. /**
  58025. * Gets the current class name
  58026. * @returns the class name
  58027. */
  58028. getClassName(): string;
  58029. /**
  58030. * Gets the world position input component
  58031. */
  58032. readonly worldPosition: NodeMaterialConnectionPoint;
  58033. /**
  58034. * Gets the world normal input component
  58035. */
  58036. readonly worldNormal: NodeMaterialConnectionPoint;
  58037. /**
  58038. * Gets the uv input component
  58039. */
  58040. readonly uv: NodeMaterialConnectionPoint;
  58041. /**
  58042. * Gets the normal map color input component
  58043. */
  58044. readonly normalMapColor: NodeMaterialConnectionPoint;
  58045. /**
  58046. * Gets the strength input component
  58047. */
  58048. readonly strength: NodeMaterialConnectionPoint;
  58049. /**
  58050. * Gets the output component
  58051. */
  58052. readonly output: NodeMaterialConnectionPoint;
  58053. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58054. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58055. autoConfigure(material: NodeMaterial): void;
  58056. protected _buildBlock(state: NodeMaterialBuildState): this;
  58057. protected _dumpPropertiesCode(): string;
  58058. serialize(): any;
  58059. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58060. }
  58061. }
  58062. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  58063. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58064. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58065. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58066. /**
  58067. * Block used to discard a pixel if a value is smaller than a cutoff
  58068. */
  58069. export class DiscardBlock extends NodeMaterialBlock {
  58070. /**
  58071. * Create a new DiscardBlock
  58072. * @param name defines the block name
  58073. */
  58074. constructor(name: string);
  58075. /**
  58076. * Gets the current class name
  58077. * @returns the class name
  58078. */
  58079. getClassName(): string;
  58080. /**
  58081. * Gets the color input component
  58082. */
  58083. readonly value: NodeMaterialConnectionPoint;
  58084. /**
  58085. * Gets the cutoff input component
  58086. */
  58087. readonly cutoff: NodeMaterialConnectionPoint;
  58088. protected _buildBlock(state: NodeMaterialBuildState): this;
  58089. }
  58090. }
  58091. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  58092. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58093. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58094. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58095. /**
  58096. * Block used to test if the fragment shader is front facing
  58097. */
  58098. export class FrontFacingBlock extends NodeMaterialBlock {
  58099. /**
  58100. * Creates a new FrontFacingBlock
  58101. * @param name defines the block name
  58102. */
  58103. constructor(name: string);
  58104. /**
  58105. * Gets the current class name
  58106. * @returns the class name
  58107. */
  58108. getClassName(): string;
  58109. /**
  58110. * Gets the output component
  58111. */
  58112. readonly output: NodeMaterialConnectionPoint;
  58113. protected _buildBlock(state: NodeMaterialBuildState): this;
  58114. }
  58115. }
  58116. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  58117. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58118. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58119. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58120. /**
  58121. * Block used to get the derivative value on x and y of a given input
  58122. */
  58123. export class DerivativeBlock extends NodeMaterialBlock {
  58124. /**
  58125. * Create a new DerivativeBlock
  58126. * @param name defines the block name
  58127. */
  58128. constructor(name: string);
  58129. /**
  58130. * Gets the current class name
  58131. * @returns the class name
  58132. */
  58133. getClassName(): string;
  58134. /**
  58135. * Gets the input component
  58136. */
  58137. readonly input: NodeMaterialConnectionPoint;
  58138. /**
  58139. * Gets the derivative output on x
  58140. */
  58141. readonly dx: NodeMaterialConnectionPoint;
  58142. /**
  58143. * Gets the derivative output on y
  58144. */
  58145. readonly dy: NodeMaterialConnectionPoint;
  58146. protected _buildBlock(state: NodeMaterialBuildState): this;
  58147. }
  58148. }
  58149. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  58150. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  58151. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  58152. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  58153. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  58154. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  58155. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  58156. }
  58157. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  58158. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58159. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58160. import { Mesh } from "babylonjs/Meshes/mesh";
  58161. import { Effect } from "babylonjs/Materials/effect";
  58162. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58163. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58164. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58165. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  58166. /**
  58167. * Block used to add support for scene fog
  58168. */
  58169. export class FogBlock extends NodeMaterialBlock {
  58170. private _fogDistanceName;
  58171. private _fogParameters;
  58172. /**
  58173. * Create a new FogBlock
  58174. * @param name defines the block name
  58175. */
  58176. constructor(name: string);
  58177. /**
  58178. * Gets the current class name
  58179. * @returns the class name
  58180. */
  58181. getClassName(): string;
  58182. /**
  58183. * Gets the world position input component
  58184. */
  58185. readonly worldPosition: NodeMaterialConnectionPoint;
  58186. /**
  58187. * Gets the view input component
  58188. */
  58189. readonly view: NodeMaterialConnectionPoint;
  58190. /**
  58191. * Gets the color input component
  58192. */
  58193. readonly input: NodeMaterialConnectionPoint;
  58194. /**
  58195. * Gets the fog color input component
  58196. */
  58197. readonly fogColor: NodeMaterialConnectionPoint;
  58198. /**
  58199. * Gets the output component
  58200. */
  58201. readonly output: NodeMaterialConnectionPoint;
  58202. autoConfigure(material: NodeMaterial): void;
  58203. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58204. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58205. protected _buildBlock(state: NodeMaterialBuildState): this;
  58206. }
  58207. }
  58208. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  58209. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58210. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58211. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58212. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58213. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58214. import { Effect } from "babylonjs/Materials/effect";
  58215. import { Mesh } from "babylonjs/Meshes/mesh";
  58216. import { Light } from "babylonjs/Lights/light";
  58217. import { Nullable } from "babylonjs/types";
  58218. import { Scene } from "babylonjs/scene";
  58219. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58220. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58221. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  58222. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58223. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  58224. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  58225. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  58226. /**
  58227. * Block used to add light in the fragment shader
  58228. */
  58229. export class LightBlock extends NodeMaterialBlock {
  58230. private _lightId;
  58231. /**
  58232. * Gets or sets the light associated with this block
  58233. */
  58234. light: Nullable<Light>;
  58235. /**
  58236. * Create a new LightBlock
  58237. * @param name defines the block name
  58238. */
  58239. constructor(name: string);
  58240. /**
  58241. * Gets the current class name
  58242. * @returns the class name
  58243. */
  58244. getClassName(): string;
  58245. /**
  58246. * Gets the world position input component
  58247. */
  58248. readonly worldPosition: NodeMaterialConnectionPoint;
  58249. /**
  58250. * Gets the world normal input component
  58251. */
  58252. readonly worldNormal: NodeMaterialConnectionPoint;
  58253. /**
  58254. * Gets the camera (or eye) position component
  58255. */
  58256. readonly cameraPosition: NodeMaterialConnectionPoint;
  58257. /**
  58258. * Gets the glossiness component
  58259. */
  58260. readonly glossiness: NodeMaterialConnectionPoint;
  58261. /**
  58262. * Gets the glossinness power component
  58263. */
  58264. readonly glossPower: NodeMaterialConnectionPoint;
  58265. /**
  58266. * Gets the diffuse color component
  58267. */
  58268. readonly diffuseColor: NodeMaterialConnectionPoint;
  58269. /**
  58270. * Gets the specular color component
  58271. */
  58272. readonly specularColor: NodeMaterialConnectionPoint;
  58273. /**
  58274. * Gets the diffuse output component
  58275. */
  58276. readonly diffuseOutput: NodeMaterialConnectionPoint;
  58277. /**
  58278. * Gets the specular output component
  58279. */
  58280. readonly specularOutput: NodeMaterialConnectionPoint;
  58281. autoConfigure(material: NodeMaterial): void;
  58282. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58283. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58284. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58285. private _injectVertexCode;
  58286. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58287. serialize(): any;
  58288. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58289. }
  58290. }
  58291. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  58292. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  58293. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  58294. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  58295. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  58296. }
  58297. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  58298. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  58299. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  58300. }
  58301. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  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 multiply 2 values
  58307. */
  58308. export class MultiplyBlock extends NodeMaterialBlock {
  58309. /**
  58310. * Creates a new MultiplyBlock
  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 left operand input component
  58321. */
  58322. readonly left: NodeMaterialConnectionPoint;
  58323. /**
  58324. * Gets the right operand input component
  58325. */
  58326. readonly right: 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/addBlock" {
  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 add 2 vectors
  58340. */
  58341. export class AddBlock extends NodeMaterialBlock {
  58342. /**
  58343. * Creates a new AddBlock
  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 left operand input component
  58354. */
  58355. readonly left: NodeMaterialConnectionPoint;
  58356. /**
  58357. * Gets the right operand input component
  58358. */
  58359. readonly right: NodeMaterialConnectionPoint;
  58360. /**
  58361. * Gets the output component
  58362. */
  58363. readonly output: NodeMaterialConnectionPoint;
  58364. protected _buildBlock(state: NodeMaterialBuildState): this;
  58365. }
  58366. }
  58367. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  58368. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58369. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58370. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58371. /**
  58372. * Block used to scale a vector by a float
  58373. */
  58374. export class ScaleBlock extends NodeMaterialBlock {
  58375. /**
  58376. * Creates a new ScaleBlock
  58377. * @param name defines the block name
  58378. */
  58379. constructor(name: string);
  58380. /**
  58381. * Gets the current class name
  58382. * @returns the class name
  58383. */
  58384. getClassName(): string;
  58385. /**
  58386. * Gets the input component
  58387. */
  58388. readonly input: NodeMaterialConnectionPoint;
  58389. /**
  58390. * Gets the factor input component
  58391. */
  58392. readonly factor: 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/clampBlock" {
  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. import { Scene } from "babylonjs/scene";
  58405. /**
  58406. * Block used to clamp a float
  58407. */
  58408. export class ClampBlock extends NodeMaterialBlock {
  58409. /** Gets or sets the minimum range */
  58410. minimum: number;
  58411. /** Gets or sets the maximum range */
  58412. maximum: number;
  58413. /**
  58414. * Creates a new ClampBlock
  58415. * @param name defines the block name
  58416. */
  58417. constructor(name: string);
  58418. /**
  58419. * Gets the current class name
  58420. * @returns the class name
  58421. */
  58422. getClassName(): string;
  58423. /**
  58424. * Gets the value input component
  58425. */
  58426. readonly value: NodeMaterialConnectionPoint;
  58427. /**
  58428. * Gets the output component
  58429. */
  58430. readonly output: NodeMaterialConnectionPoint;
  58431. protected _buildBlock(state: NodeMaterialBuildState): this;
  58432. protected _dumpPropertiesCode(): string;
  58433. serialize(): any;
  58434. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58435. }
  58436. }
  58437. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  58438. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58439. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58440. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58441. /**
  58442. * Block used to apply a cross product between 2 vectors
  58443. */
  58444. export class CrossBlock extends NodeMaterialBlock {
  58445. /**
  58446. * Creates a new CrossBlock
  58447. * @param name defines the block name
  58448. */
  58449. constructor(name: string);
  58450. /**
  58451. * Gets the current class name
  58452. * @returns the class name
  58453. */
  58454. getClassName(): string;
  58455. /**
  58456. * Gets the left operand input component
  58457. */
  58458. readonly left: NodeMaterialConnectionPoint;
  58459. /**
  58460. * Gets the right operand input component
  58461. */
  58462. readonly right: NodeMaterialConnectionPoint;
  58463. /**
  58464. * Gets the output component
  58465. */
  58466. readonly output: NodeMaterialConnectionPoint;
  58467. protected _buildBlock(state: NodeMaterialBuildState): this;
  58468. }
  58469. }
  58470. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  58471. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58472. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58473. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58474. /**
  58475. * Block used to apply a dot product between 2 vectors
  58476. */
  58477. export class DotBlock extends NodeMaterialBlock {
  58478. /**
  58479. * Creates a new DotBlock
  58480. * @param name defines the block name
  58481. */
  58482. constructor(name: string);
  58483. /**
  58484. * Gets the current class name
  58485. * @returns the class name
  58486. */
  58487. getClassName(): string;
  58488. /**
  58489. * Gets the left operand input component
  58490. */
  58491. readonly left: NodeMaterialConnectionPoint;
  58492. /**
  58493. * Gets the right operand input component
  58494. */
  58495. readonly right: NodeMaterialConnectionPoint;
  58496. /**
  58497. * Gets the output component
  58498. */
  58499. readonly output: NodeMaterialConnectionPoint;
  58500. protected _buildBlock(state: NodeMaterialBuildState): this;
  58501. }
  58502. }
  58503. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  58504. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58505. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58506. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58507. import { Vector2 } from "babylonjs/Maths/math.vector";
  58508. import { Scene } from "babylonjs/scene";
  58509. /**
  58510. * Block used to remap a float from a range to a new one
  58511. */
  58512. export class RemapBlock extends NodeMaterialBlock {
  58513. /**
  58514. * Gets or sets the source range
  58515. */
  58516. sourceRange: Vector2;
  58517. /**
  58518. * Gets or sets the target range
  58519. */
  58520. targetRange: Vector2;
  58521. /**
  58522. * Creates a new RemapBlock
  58523. * @param name defines the block name
  58524. */
  58525. constructor(name: string);
  58526. /**
  58527. * Gets the current class name
  58528. * @returns the class name
  58529. */
  58530. getClassName(): string;
  58531. /**
  58532. * Gets the input component
  58533. */
  58534. readonly input: NodeMaterialConnectionPoint;
  58535. /**
  58536. * Gets the source min input component
  58537. */
  58538. readonly sourceMin: NodeMaterialConnectionPoint;
  58539. /**
  58540. * Gets the source max input component
  58541. */
  58542. readonly sourceMax: NodeMaterialConnectionPoint;
  58543. /**
  58544. * Gets the target min input component
  58545. */
  58546. readonly targetMin: NodeMaterialConnectionPoint;
  58547. /**
  58548. * Gets the target max input component
  58549. */
  58550. readonly targetMax: NodeMaterialConnectionPoint;
  58551. /**
  58552. * Gets the output component
  58553. */
  58554. readonly output: NodeMaterialConnectionPoint;
  58555. protected _buildBlock(state: NodeMaterialBuildState): this;
  58556. protected _dumpPropertiesCode(): string;
  58557. serialize(): any;
  58558. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58559. }
  58560. }
  58561. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  58562. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58563. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58564. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58565. /**
  58566. * Block used to normalize a vector
  58567. */
  58568. export class NormalizeBlock extends NodeMaterialBlock {
  58569. /**
  58570. * Creates a new NormalizeBlock
  58571. * @param name defines the block name
  58572. */
  58573. constructor(name: string);
  58574. /**
  58575. * Gets the current class name
  58576. * @returns the class name
  58577. */
  58578. getClassName(): string;
  58579. /**
  58580. * Gets the input component
  58581. */
  58582. readonly input: NodeMaterialConnectionPoint;
  58583. /**
  58584. * Gets the output component
  58585. */
  58586. readonly output: NodeMaterialConnectionPoint;
  58587. protected _buildBlock(state: NodeMaterialBuildState): this;
  58588. }
  58589. }
  58590. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  58591. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58592. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58593. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58594. import { Scene } from "babylonjs/scene";
  58595. /**
  58596. * Operations supported by the Trigonometry block
  58597. */
  58598. export enum TrigonometryBlockOperations {
  58599. /** Cos */
  58600. Cos = 0,
  58601. /** Sin */
  58602. Sin = 1,
  58603. /** Abs */
  58604. Abs = 2,
  58605. /** Exp */
  58606. Exp = 3,
  58607. /** Exp2 */
  58608. Exp2 = 4,
  58609. /** Round */
  58610. Round = 5,
  58611. /** Floor */
  58612. Floor = 6,
  58613. /** Ceiling */
  58614. Ceiling = 7,
  58615. /** Square root */
  58616. Sqrt = 8,
  58617. /** Log */
  58618. Log = 9,
  58619. /** Tangent */
  58620. Tan = 10,
  58621. /** Arc tangent */
  58622. ArcTan = 11,
  58623. /** Arc cosinus */
  58624. ArcCos = 12,
  58625. /** Arc sinus */
  58626. ArcSin = 13,
  58627. /** Fraction */
  58628. Fract = 14,
  58629. /** Sign */
  58630. Sign = 15,
  58631. /** To radians (from degrees) */
  58632. Radians = 16,
  58633. /** To degrees (from radians) */
  58634. Degrees = 17
  58635. }
  58636. /**
  58637. * Block used to apply trigonometry operation to floats
  58638. */
  58639. export class TrigonometryBlock extends NodeMaterialBlock {
  58640. /**
  58641. * Gets or sets the operation applied by the block
  58642. */
  58643. operation: TrigonometryBlockOperations;
  58644. /**
  58645. * Creates a new TrigonometryBlock
  58646. * @param name defines the block name
  58647. */
  58648. constructor(name: string);
  58649. /**
  58650. * Gets the current class name
  58651. * @returns the class name
  58652. */
  58653. getClassName(): string;
  58654. /**
  58655. * Gets the input component
  58656. */
  58657. readonly input: NodeMaterialConnectionPoint;
  58658. /**
  58659. * Gets the output component
  58660. */
  58661. readonly output: NodeMaterialConnectionPoint;
  58662. protected _buildBlock(state: NodeMaterialBuildState): this;
  58663. serialize(): any;
  58664. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58665. protected _dumpPropertiesCode(): string;
  58666. }
  58667. }
  58668. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  58669. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58670. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58671. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58672. /**
  58673. * Block used to create a Color3/4 out of individual inputs (one for each component)
  58674. */
  58675. export class ColorMergerBlock extends NodeMaterialBlock {
  58676. /**
  58677. * Create a new ColorMergerBlock
  58678. * @param name defines the block name
  58679. */
  58680. constructor(name: string);
  58681. /**
  58682. * Gets the current class name
  58683. * @returns the class name
  58684. */
  58685. getClassName(): string;
  58686. /**
  58687. * Gets the rgb component (input)
  58688. */
  58689. readonly rgbIn: NodeMaterialConnectionPoint;
  58690. /**
  58691. * Gets the r component (input)
  58692. */
  58693. readonly r: NodeMaterialConnectionPoint;
  58694. /**
  58695. * Gets the g component (input)
  58696. */
  58697. readonly g: NodeMaterialConnectionPoint;
  58698. /**
  58699. * Gets the b component (input)
  58700. */
  58701. readonly b: NodeMaterialConnectionPoint;
  58702. /**
  58703. * Gets the a component (input)
  58704. */
  58705. readonly a: NodeMaterialConnectionPoint;
  58706. /**
  58707. * Gets the rgba component (output)
  58708. */
  58709. readonly rgba: NodeMaterialConnectionPoint;
  58710. /**
  58711. * Gets the rgb component (output)
  58712. */
  58713. readonly rgbOut: NodeMaterialConnectionPoint;
  58714. /**
  58715. * Gets the rgb component (output)
  58716. * @deprecated Please use rgbOut instead.
  58717. */
  58718. readonly rgb: NodeMaterialConnectionPoint;
  58719. protected _buildBlock(state: NodeMaterialBuildState): this;
  58720. }
  58721. }
  58722. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  58723. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58724. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58725. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58726. /**
  58727. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  58728. */
  58729. export class VectorMergerBlock extends NodeMaterialBlock {
  58730. /**
  58731. * Create a new VectorMergerBlock
  58732. * @param name defines the block name
  58733. */
  58734. constructor(name: string);
  58735. /**
  58736. * Gets the current class name
  58737. * @returns the class name
  58738. */
  58739. getClassName(): string;
  58740. /**
  58741. * Gets the xyz component (input)
  58742. */
  58743. readonly xyzIn: NodeMaterialConnectionPoint;
  58744. /**
  58745. * Gets the xy component (input)
  58746. */
  58747. readonly xyIn: NodeMaterialConnectionPoint;
  58748. /**
  58749. * Gets the x component (input)
  58750. */
  58751. readonly x: NodeMaterialConnectionPoint;
  58752. /**
  58753. * Gets the y component (input)
  58754. */
  58755. readonly y: NodeMaterialConnectionPoint;
  58756. /**
  58757. * Gets the z component (input)
  58758. */
  58759. readonly z: NodeMaterialConnectionPoint;
  58760. /**
  58761. * Gets the w component (input)
  58762. */
  58763. readonly w: NodeMaterialConnectionPoint;
  58764. /**
  58765. * Gets the xyzw component (output)
  58766. */
  58767. readonly xyzw: NodeMaterialConnectionPoint;
  58768. /**
  58769. * Gets the xyz component (output)
  58770. */
  58771. readonly xyzOut: NodeMaterialConnectionPoint;
  58772. /**
  58773. * Gets the xy component (output)
  58774. */
  58775. readonly xyOut: NodeMaterialConnectionPoint;
  58776. /**
  58777. * Gets the xy component (output)
  58778. * @deprecated Please use xyOut instead.
  58779. */
  58780. readonly xy: NodeMaterialConnectionPoint;
  58781. /**
  58782. * Gets the xyz component (output)
  58783. * @deprecated Please use xyzOut instead.
  58784. */
  58785. readonly xyz: NodeMaterialConnectionPoint;
  58786. protected _buildBlock(state: NodeMaterialBuildState): this;
  58787. }
  58788. }
  58789. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  58790. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58791. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58792. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58793. /**
  58794. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  58795. */
  58796. export class ColorSplitterBlock extends NodeMaterialBlock {
  58797. /**
  58798. * Create a new ColorSplitterBlock
  58799. * @param name defines the block name
  58800. */
  58801. constructor(name: string);
  58802. /**
  58803. * Gets the current class name
  58804. * @returns the class name
  58805. */
  58806. getClassName(): string;
  58807. /**
  58808. * Gets the rgba component (input)
  58809. */
  58810. readonly rgba: NodeMaterialConnectionPoint;
  58811. /**
  58812. * Gets the rgb component (input)
  58813. */
  58814. readonly rgbIn: NodeMaterialConnectionPoint;
  58815. /**
  58816. * Gets the rgb component (output)
  58817. */
  58818. readonly rgbOut: NodeMaterialConnectionPoint;
  58819. /**
  58820. * Gets the r component (output)
  58821. */
  58822. readonly r: NodeMaterialConnectionPoint;
  58823. /**
  58824. * Gets the g component (output)
  58825. */
  58826. readonly g: NodeMaterialConnectionPoint;
  58827. /**
  58828. * Gets the b component (output)
  58829. */
  58830. readonly b: NodeMaterialConnectionPoint;
  58831. /**
  58832. * Gets the a component (output)
  58833. */
  58834. readonly a: NodeMaterialConnectionPoint;
  58835. protected _inputRename(name: string): string;
  58836. protected _outputRename(name: string): string;
  58837. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58838. }
  58839. }
  58840. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  58841. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58842. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58843. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58844. /**
  58845. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  58846. */
  58847. export class VectorSplitterBlock extends NodeMaterialBlock {
  58848. /**
  58849. * Create a new VectorSplitterBlock
  58850. * @param name defines the block name
  58851. */
  58852. constructor(name: string);
  58853. /**
  58854. * Gets the current class name
  58855. * @returns the class name
  58856. */
  58857. getClassName(): string;
  58858. /**
  58859. * Gets the xyzw component (input)
  58860. */
  58861. readonly xyzw: NodeMaterialConnectionPoint;
  58862. /**
  58863. * Gets the xyz component (input)
  58864. */
  58865. readonly xyzIn: NodeMaterialConnectionPoint;
  58866. /**
  58867. * Gets the xy component (input)
  58868. */
  58869. readonly xyIn: NodeMaterialConnectionPoint;
  58870. /**
  58871. * Gets the xyz component (output)
  58872. */
  58873. readonly xyzOut: NodeMaterialConnectionPoint;
  58874. /**
  58875. * Gets the xy component (output)
  58876. */
  58877. readonly xyOut: NodeMaterialConnectionPoint;
  58878. /**
  58879. * Gets the x component (output)
  58880. */
  58881. readonly x: NodeMaterialConnectionPoint;
  58882. /**
  58883. * Gets the y component (output)
  58884. */
  58885. readonly y: NodeMaterialConnectionPoint;
  58886. /**
  58887. * Gets the z component (output)
  58888. */
  58889. readonly z: NodeMaterialConnectionPoint;
  58890. /**
  58891. * Gets the w component (output)
  58892. */
  58893. readonly w: NodeMaterialConnectionPoint;
  58894. protected _inputRename(name: string): string;
  58895. protected _outputRename(name: string): string;
  58896. protected _buildBlock(state: NodeMaterialBuildState): this;
  58897. }
  58898. }
  58899. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  58900. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58901. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58902. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58903. /**
  58904. * Block used to lerp between 2 values
  58905. */
  58906. export class LerpBlock extends NodeMaterialBlock {
  58907. /**
  58908. * Creates a new LerpBlock
  58909. * @param name defines the block name
  58910. */
  58911. constructor(name: string);
  58912. /**
  58913. * Gets the current class name
  58914. * @returns the class name
  58915. */
  58916. getClassName(): string;
  58917. /**
  58918. * Gets the left operand input component
  58919. */
  58920. readonly left: NodeMaterialConnectionPoint;
  58921. /**
  58922. * Gets the right operand input component
  58923. */
  58924. readonly right: NodeMaterialConnectionPoint;
  58925. /**
  58926. * Gets the gradient operand input component
  58927. */
  58928. readonly gradient: NodeMaterialConnectionPoint;
  58929. /**
  58930. * Gets the output component
  58931. */
  58932. readonly output: NodeMaterialConnectionPoint;
  58933. protected _buildBlock(state: NodeMaterialBuildState): this;
  58934. }
  58935. }
  58936. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  58937. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58938. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58939. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58940. /**
  58941. * Block used to divide 2 vectors
  58942. */
  58943. export class DivideBlock extends NodeMaterialBlock {
  58944. /**
  58945. * Creates a new DivideBlock
  58946. * @param name defines the block name
  58947. */
  58948. constructor(name: string);
  58949. /**
  58950. * Gets the current class name
  58951. * @returns the class name
  58952. */
  58953. getClassName(): string;
  58954. /**
  58955. * Gets the left operand input component
  58956. */
  58957. readonly left: NodeMaterialConnectionPoint;
  58958. /**
  58959. * Gets the right operand input component
  58960. */
  58961. readonly right: NodeMaterialConnectionPoint;
  58962. /**
  58963. * Gets the output component
  58964. */
  58965. readonly output: NodeMaterialConnectionPoint;
  58966. protected _buildBlock(state: NodeMaterialBuildState): this;
  58967. }
  58968. }
  58969. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  58970. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58971. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58972. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58973. /**
  58974. * Block used to subtract 2 vectors
  58975. */
  58976. export class SubtractBlock extends NodeMaterialBlock {
  58977. /**
  58978. * Creates a new SubtractBlock
  58979. * @param name defines the block name
  58980. */
  58981. constructor(name: string);
  58982. /**
  58983. * Gets the current class name
  58984. * @returns the class name
  58985. */
  58986. getClassName(): string;
  58987. /**
  58988. * Gets the left operand input component
  58989. */
  58990. readonly left: NodeMaterialConnectionPoint;
  58991. /**
  58992. * Gets the right operand input component
  58993. */
  58994. readonly right: NodeMaterialConnectionPoint;
  58995. /**
  58996. * Gets the output component
  58997. */
  58998. readonly output: NodeMaterialConnectionPoint;
  58999. protected _buildBlock(state: NodeMaterialBuildState): this;
  59000. }
  59001. }
  59002. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  59003. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59004. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59005. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59006. /**
  59007. * Block used to step a value
  59008. */
  59009. export class StepBlock extends NodeMaterialBlock {
  59010. /**
  59011. * Creates a new StepBlock
  59012. * @param name defines the block name
  59013. */
  59014. constructor(name: string);
  59015. /**
  59016. * Gets the current class name
  59017. * @returns the class name
  59018. */
  59019. getClassName(): string;
  59020. /**
  59021. * Gets the value operand input component
  59022. */
  59023. readonly value: NodeMaterialConnectionPoint;
  59024. /**
  59025. * Gets the edge operand input component
  59026. */
  59027. readonly edge: NodeMaterialConnectionPoint;
  59028. /**
  59029. * Gets the output component
  59030. */
  59031. readonly output: NodeMaterialConnectionPoint;
  59032. protected _buildBlock(state: NodeMaterialBuildState): this;
  59033. }
  59034. }
  59035. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  59036. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59037. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59038. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59039. /**
  59040. * Block used to get the opposite (1 - x) of a value
  59041. */
  59042. export class OneMinusBlock extends NodeMaterialBlock {
  59043. /**
  59044. * Creates a new OneMinusBlock
  59045. * @param name defines the block name
  59046. */
  59047. constructor(name: string);
  59048. /**
  59049. * Gets the current class name
  59050. * @returns the class name
  59051. */
  59052. getClassName(): string;
  59053. /**
  59054. * Gets the input component
  59055. */
  59056. readonly input: NodeMaterialConnectionPoint;
  59057. /**
  59058. * Gets the output component
  59059. */
  59060. readonly output: NodeMaterialConnectionPoint;
  59061. protected _buildBlock(state: NodeMaterialBuildState): this;
  59062. }
  59063. }
  59064. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  59065. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59066. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59067. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59068. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  59069. /**
  59070. * Block used to get the view direction
  59071. */
  59072. export class ViewDirectionBlock extends NodeMaterialBlock {
  59073. /**
  59074. * Creates a new ViewDirectionBlock
  59075. * @param name defines the block name
  59076. */
  59077. constructor(name: string);
  59078. /**
  59079. * Gets the current class name
  59080. * @returns the class name
  59081. */
  59082. getClassName(): string;
  59083. /**
  59084. * Gets the world position component
  59085. */
  59086. readonly worldPosition: NodeMaterialConnectionPoint;
  59087. /**
  59088. * Gets the camera position component
  59089. */
  59090. readonly cameraPosition: NodeMaterialConnectionPoint;
  59091. /**
  59092. * Gets the output component
  59093. */
  59094. readonly output: NodeMaterialConnectionPoint;
  59095. autoConfigure(material: NodeMaterial): void;
  59096. protected _buildBlock(state: NodeMaterialBuildState): this;
  59097. }
  59098. }
  59099. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  59100. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59101. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59102. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59103. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  59104. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  59105. /**
  59106. * Block used to compute fresnel value
  59107. */
  59108. export class FresnelBlock extends NodeMaterialBlock {
  59109. /**
  59110. * Create a new FresnelBlock
  59111. * @param name defines the block name
  59112. */
  59113. constructor(name: string);
  59114. /**
  59115. * Gets the current class name
  59116. * @returns the class name
  59117. */
  59118. getClassName(): string;
  59119. /**
  59120. * Gets the world normal input component
  59121. */
  59122. readonly worldNormal: NodeMaterialConnectionPoint;
  59123. /**
  59124. * Gets the view direction input component
  59125. */
  59126. readonly viewDirection: NodeMaterialConnectionPoint;
  59127. /**
  59128. * Gets the bias input component
  59129. */
  59130. readonly bias: NodeMaterialConnectionPoint;
  59131. /**
  59132. * Gets the camera (or eye) position component
  59133. */
  59134. readonly power: NodeMaterialConnectionPoint;
  59135. /**
  59136. * Gets the fresnel output component
  59137. */
  59138. readonly fresnel: NodeMaterialConnectionPoint;
  59139. autoConfigure(material: NodeMaterial): void;
  59140. protected _buildBlock(state: NodeMaterialBuildState): this;
  59141. }
  59142. }
  59143. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  59144. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59145. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59146. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59147. /**
  59148. * Block used to get the max of 2 values
  59149. */
  59150. export class MaxBlock extends NodeMaterialBlock {
  59151. /**
  59152. * Creates a new MaxBlock
  59153. * @param name defines the block name
  59154. */
  59155. constructor(name: string);
  59156. /**
  59157. * Gets the current class name
  59158. * @returns the class name
  59159. */
  59160. getClassName(): string;
  59161. /**
  59162. * Gets the left operand input component
  59163. */
  59164. readonly left: NodeMaterialConnectionPoint;
  59165. /**
  59166. * Gets the right operand input component
  59167. */
  59168. readonly right: NodeMaterialConnectionPoint;
  59169. /**
  59170. * Gets the output component
  59171. */
  59172. readonly output: NodeMaterialConnectionPoint;
  59173. protected _buildBlock(state: NodeMaterialBuildState): this;
  59174. }
  59175. }
  59176. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  59177. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59178. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59179. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59180. /**
  59181. * Block used to get the min of 2 values
  59182. */
  59183. export class MinBlock extends NodeMaterialBlock {
  59184. /**
  59185. * Creates a new MinBlock
  59186. * @param name defines the block name
  59187. */
  59188. constructor(name: string);
  59189. /**
  59190. * Gets the current class name
  59191. * @returns the class name
  59192. */
  59193. getClassName(): string;
  59194. /**
  59195. * Gets the left operand input component
  59196. */
  59197. readonly left: NodeMaterialConnectionPoint;
  59198. /**
  59199. * Gets the right operand input component
  59200. */
  59201. readonly right: NodeMaterialConnectionPoint;
  59202. /**
  59203. * Gets the output component
  59204. */
  59205. readonly output: NodeMaterialConnectionPoint;
  59206. protected _buildBlock(state: NodeMaterialBuildState): this;
  59207. }
  59208. }
  59209. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  59210. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59211. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59212. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59213. /**
  59214. * Block used to get the distance between 2 values
  59215. */
  59216. export class DistanceBlock extends NodeMaterialBlock {
  59217. /**
  59218. * Creates a new DistanceBlock
  59219. * @param name defines the block name
  59220. */
  59221. constructor(name: string);
  59222. /**
  59223. * Gets the current class name
  59224. * @returns the class name
  59225. */
  59226. getClassName(): string;
  59227. /**
  59228. * Gets the left operand input component
  59229. */
  59230. readonly left: NodeMaterialConnectionPoint;
  59231. /**
  59232. * Gets the right operand input component
  59233. */
  59234. readonly right: NodeMaterialConnectionPoint;
  59235. /**
  59236. * Gets the output component
  59237. */
  59238. readonly output: NodeMaterialConnectionPoint;
  59239. protected _buildBlock(state: NodeMaterialBuildState): this;
  59240. }
  59241. }
  59242. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  59243. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59244. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59245. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59246. /**
  59247. * Block used to get the length of a vector
  59248. */
  59249. export class LengthBlock extends NodeMaterialBlock {
  59250. /**
  59251. * Creates a new LengthBlock
  59252. * @param name defines the block name
  59253. */
  59254. constructor(name: string);
  59255. /**
  59256. * Gets the current class name
  59257. * @returns the class name
  59258. */
  59259. getClassName(): string;
  59260. /**
  59261. * Gets the value input component
  59262. */
  59263. readonly value: NodeMaterialConnectionPoint;
  59264. /**
  59265. * Gets the output component
  59266. */
  59267. readonly output: NodeMaterialConnectionPoint;
  59268. protected _buildBlock(state: NodeMaterialBuildState): this;
  59269. }
  59270. }
  59271. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  59272. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59273. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59274. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59275. /**
  59276. * Block used to get negative version of a value (i.e. x * -1)
  59277. */
  59278. export class NegateBlock extends NodeMaterialBlock {
  59279. /**
  59280. * Creates a new NegateBlock
  59281. * @param name defines the block name
  59282. */
  59283. constructor(name: string);
  59284. /**
  59285. * Gets the current class name
  59286. * @returns the class name
  59287. */
  59288. getClassName(): string;
  59289. /**
  59290. * Gets the value input component
  59291. */
  59292. readonly value: NodeMaterialConnectionPoint;
  59293. /**
  59294. * Gets the output component
  59295. */
  59296. readonly output: NodeMaterialConnectionPoint;
  59297. protected _buildBlock(state: NodeMaterialBuildState): this;
  59298. }
  59299. }
  59300. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  59301. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59302. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59303. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59304. /**
  59305. * Block used to get the value of the first parameter raised to the power of the second
  59306. */
  59307. export class PowBlock extends NodeMaterialBlock {
  59308. /**
  59309. * Creates a new PowBlock
  59310. * @param name defines the block name
  59311. */
  59312. constructor(name: string);
  59313. /**
  59314. * Gets the current class name
  59315. * @returns the class name
  59316. */
  59317. getClassName(): string;
  59318. /**
  59319. * Gets the value operand input component
  59320. */
  59321. readonly value: NodeMaterialConnectionPoint;
  59322. /**
  59323. * Gets the power operand input component
  59324. */
  59325. readonly power: NodeMaterialConnectionPoint;
  59326. /**
  59327. * Gets the output component
  59328. */
  59329. readonly output: NodeMaterialConnectionPoint;
  59330. protected _buildBlock(state: NodeMaterialBuildState): this;
  59331. }
  59332. }
  59333. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  59334. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59335. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59336. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59337. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59338. /**
  59339. * Block used to get a random number
  59340. */
  59341. export class RandomNumberBlock extends NodeMaterialBlock {
  59342. /**
  59343. * Creates a new RandomNumberBlock
  59344. * @param name defines the block name
  59345. */
  59346. constructor(name: string);
  59347. /**
  59348. * Gets the current class name
  59349. * @returns the class name
  59350. */
  59351. getClassName(): string;
  59352. /**
  59353. * Gets the seed input component
  59354. */
  59355. readonly seed: NodeMaterialConnectionPoint;
  59356. /**
  59357. * Gets the output component
  59358. */
  59359. readonly output: NodeMaterialConnectionPoint;
  59360. protected _buildBlock(state: NodeMaterialBuildState): this;
  59361. }
  59362. }
  59363. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  59364. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59365. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59366. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59367. /**
  59368. * Block used to compute arc tangent of 2 values
  59369. */
  59370. export class ArcTan2Block extends NodeMaterialBlock {
  59371. /**
  59372. * Creates a new ArcTan2Block
  59373. * @param name defines the block name
  59374. */
  59375. constructor(name: string);
  59376. /**
  59377. * Gets the current class name
  59378. * @returns the class name
  59379. */
  59380. getClassName(): string;
  59381. /**
  59382. * Gets the x operand input component
  59383. */
  59384. readonly x: NodeMaterialConnectionPoint;
  59385. /**
  59386. * Gets the y operand input component
  59387. */
  59388. readonly y: NodeMaterialConnectionPoint;
  59389. /**
  59390. * Gets the output component
  59391. */
  59392. readonly output: NodeMaterialConnectionPoint;
  59393. protected _buildBlock(state: NodeMaterialBuildState): this;
  59394. }
  59395. }
  59396. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  59397. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59398. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59399. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59400. /**
  59401. * Block used to smooth step a value
  59402. */
  59403. export class SmoothStepBlock extends NodeMaterialBlock {
  59404. /**
  59405. * Creates a new SmoothStepBlock
  59406. * @param name defines the block name
  59407. */
  59408. constructor(name: string);
  59409. /**
  59410. * Gets the current class name
  59411. * @returns the class name
  59412. */
  59413. getClassName(): string;
  59414. /**
  59415. * Gets the value operand input component
  59416. */
  59417. readonly value: NodeMaterialConnectionPoint;
  59418. /**
  59419. * Gets the first edge operand input component
  59420. */
  59421. readonly edge0: NodeMaterialConnectionPoint;
  59422. /**
  59423. * Gets the second edge operand input component
  59424. */
  59425. readonly edge1: NodeMaterialConnectionPoint;
  59426. /**
  59427. * Gets the output component
  59428. */
  59429. readonly output: NodeMaterialConnectionPoint;
  59430. protected _buildBlock(state: NodeMaterialBuildState): this;
  59431. }
  59432. }
  59433. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  59434. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59435. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59436. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59437. /**
  59438. * Block used to get the reciprocal (1 / x) of a value
  59439. */
  59440. export class ReciprocalBlock extends NodeMaterialBlock {
  59441. /**
  59442. * Creates a new ReciprocalBlock
  59443. * @param name defines the block name
  59444. */
  59445. constructor(name: string);
  59446. /**
  59447. * Gets the current class name
  59448. * @returns the class name
  59449. */
  59450. getClassName(): string;
  59451. /**
  59452. * Gets the input component
  59453. */
  59454. readonly input: NodeMaterialConnectionPoint;
  59455. /**
  59456. * Gets the output component
  59457. */
  59458. readonly output: NodeMaterialConnectionPoint;
  59459. protected _buildBlock(state: NodeMaterialBuildState): this;
  59460. }
  59461. }
  59462. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  59463. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59464. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59465. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59466. /**
  59467. * Block used to replace a color by another one
  59468. */
  59469. export class ReplaceColorBlock extends NodeMaterialBlock {
  59470. /**
  59471. * Creates a new ReplaceColorBlock
  59472. * @param name defines the block name
  59473. */
  59474. constructor(name: string);
  59475. /**
  59476. * Gets the current class name
  59477. * @returns the class name
  59478. */
  59479. getClassName(): string;
  59480. /**
  59481. * Gets the value input component
  59482. */
  59483. readonly value: NodeMaterialConnectionPoint;
  59484. /**
  59485. * Gets the reference input component
  59486. */
  59487. readonly reference: NodeMaterialConnectionPoint;
  59488. /**
  59489. * Gets the distance input component
  59490. */
  59491. readonly distance: NodeMaterialConnectionPoint;
  59492. /**
  59493. * Gets the replacement input component
  59494. */
  59495. readonly replacement: NodeMaterialConnectionPoint;
  59496. /**
  59497. * Gets the output component
  59498. */
  59499. readonly output: NodeMaterialConnectionPoint;
  59500. protected _buildBlock(state: NodeMaterialBuildState): this;
  59501. }
  59502. }
  59503. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  59504. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59505. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59506. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59507. /**
  59508. * Block used to posterize a value
  59509. * @see https://en.wikipedia.org/wiki/Posterization
  59510. */
  59511. export class PosterizeBlock extends NodeMaterialBlock {
  59512. /**
  59513. * Creates a new PosterizeBlock
  59514. * @param name defines the block name
  59515. */
  59516. constructor(name: string);
  59517. /**
  59518. * Gets the current class name
  59519. * @returns the class name
  59520. */
  59521. getClassName(): string;
  59522. /**
  59523. * Gets the value input component
  59524. */
  59525. readonly value: NodeMaterialConnectionPoint;
  59526. /**
  59527. * Gets the steps input component
  59528. */
  59529. readonly steps: NodeMaterialConnectionPoint;
  59530. /**
  59531. * Gets the output component
  59532. */
  59533. readonly output: NodeMaterialConnectionPoint;
  59534. protected _buildBlock(state: NodeMaterialBuildState): this;
  59535. }
  59536. }
  59537. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  59538. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59539. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59540. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59541. import { Scene } from "babylonjs/scene";
  59542. /**
  59543. * Operations supported by the Wave block
  59544. */
  59545. export enum WaveBlockKind {
  59546. /** SawTooth */
  59547. SawTooth = 0,
  59548. /** Square */
  59549. Square = 1,
  59550. /** Triangle */
  59551. Triangle = 2
  59552. }
  59553. /**
  59554. * Block used to apply wave operation to floats
  59555. */
  59556. export class WaveBlock extends NodeMaterialBlock {
  59557. /**
  59558. * Gets or sets the kibnd of wave to be applied by the block
  59559. */
  59560. kind: WaveBlockKind;
  59561. /**
  59562. * Creates a new WaveBlock
  59563. * @param name defines the block name
  59564. */
  59565. constructor(name: string);
  59566. /**
  59567. * Gets the current class name
  59568. * @returns the class name
  59569. */
  59570. getClassName(): string;
  59571. /**
  59572. * Gets the input component
  59573. */
  59574. readonly input: NodeMaterialConnectionPoint;
  59575. /**
  59576. * Gets the output component
  59577. */
  59578. readonly output: NodeMaterialConnectionPoint;
  59579. protected _buildBlock(state: NodeMaterialBuildState): this;
  59580. serialize(): any;
  59581. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59582. }
  59583. }
  59584. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  59585. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59586. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59587. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59588. import { Color3 } from "babylonjs/Maths/math.color";
  59589. import { Scene } from "babylonjs/scene";
  59590. /**
  59591. * Class used to store a color step for the GradientBlock
  59592. */
  59593. export class GradientBlockColorStep {
  59594. /**
  59595. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59596. */
  59597. step: number;
  59598. /**
  59599. * Gets or sets the color associated with this step
  59600. */
  59601. color: Color3;
  59602. /**
  59603. * Creates a new GradientBlockColorStep
  59604. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  59605. * @param color defines the color associated with this step
  59606. */
  59607. constructor(
  59608. /**
  59609. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59610. */
  59611. step: number,
  59612. /**
  59613. * Gets or sets the color associated with this step
  59614. */
  59615. color: Color3);
  59616. }
  59617. /**
  59618. * Block used to return a color from a gradient based on an input value between 0 and 1
  59619. */
  59620. export class GradientBlock extends NodeMaterialBlock {
  59621. /**
  59622. * Gets or sets the list of color steps
  59623. */
  59624. colorSteps: GradientBlockColorStep[];
  59625. /**
  59626. * Creates a new GradientBlock
  59627. * @param name defines the block name
  59628. */
  59629. constructor(name: string);
  59630. /**
  59631. * Gets the current class name
  59632. * @returns the class name
  59633. */
  59634. getClassName(): string;
  59635. /**
  59636. * Gets the gradient input component
  59637. */
  59638. readonly gradient: NodeMaterialConnectionPoint;
  59639. /**
  59640. * Gets the output component
  59641. */
  59642. readonly output: NodeMaterialConnectionPoint;
  59643. private _writeColorConstant;
  59644. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59645. serialize(): any;
  59646. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59647. protected _dumpPropertiesCode(): string;
  59648. }
  59649. }
  59650. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  59651. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59652. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59653. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59654. /**
  59655. * Block used to normalize lerp between 2 values
  59656. */
  59657. export class NLerpBlock extends NodeMaterialBlock {
  59658. /**
  59659. * Creates a new NLerpBlock
  59660. * @param name defines the block name
  59661. */
  59662. constructor(name: string);
  59663. /**
  59664. * Gets the current class name
  59665. * @returns the class name
  59666. */
  59667. getClassName(): string;
  59668. /**
  59669. * Gets the left operand input component
  59670. */
  59671. readonly left: NodeMaterialConnectionPoint;
  59672. /**
  59673. * Gets the right operand input component
  59674. */
  59675. readonly right: NodeMaterialConnectionPoint;
  59676. /**
  59677. * Gets the gradient operand input component
  59678. */
  59679. readonly gradient: NodeMaterialConnectionPoint;
  59680. /**
  59681. * Gets the output component
  59682. */
  59683. readonly output: NodeMaterialConnectionPoint;
  59684. protected _buildBlock(state: NodeMaterialBuildState): this;
  59685. }
  59686. }
  59687. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  59688. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59689. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59690. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59691. import { Scene } from "babylonjs/scene";
  59692. /**
  59693. * block used to Generate a Worley Noise 3D Noise Pattern
  59694. */
  59695. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  59696. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  59697. manhattanDistance: boolean;
  59698. /**
  59699. * Creates a new WorleyNoise3DBlock
  59700. * @param name defines the block name
  59701. */
  59702. constructor(name: string);
  59703. /**
  59704. * Gets the current class name
  59705. * @returns the class name
  59706. */
  59707. getClassName(): string;
  59708. /**
  59709. * Gets the seed input component
  59710. */
  59711. readonly seed: NodeMaterialConnectionPoint;
  59712. /**
  59713. * Gets the jitter input component
  59714. */
  59715. readonly jitter: NodeMaterialConnectionPoint;
  59716. /**
  59717. * Gets the output component
  59718. */
  59719. readonly output: NodeMaterialConnectionPoint;
  59720. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59721. /**
  59722. * Exposes the properties to the UI?
  59723. */
  59724. protected _dumpPropertiesCode(): string;
  59725. /**
  59726. * Exposes the properties to the Seralize?
  59727. */
  59728. serialize(): any;
  59729. /**
  59730. * Exposes the properties to the deseralize?
  59731. */
  59732. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59733. }
  59734. }
  59735. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  59736. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59737. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59738. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59739. /**
  59740. * block used to Generate a Simplex Perlin 3d Noise Pattern
  59741. */
  59742. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  59743. /**
  59744. * Creates a new SimplexPerlin3DBlock
  59745. * @param name defines the block name
  59746. */
  59747. constructor(name: string);
  59748. /**
  59749. * Gets the current class name
  59750. * @returns the class name
  59751. */
  59752. getClassName(): string;
  59753. /**
  59754. * Gets the seed operand input component
  59755. */
  59756. readonly seed: NodeMaterialConnectionPoint;
  59757. /**
  59758. * Gets the output component
  59759. */
  59760. readonly output: NodeMaterialConnectionPoint;
  59761. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59762. }
  59763. }
  59764. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  59765. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59766. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59767. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59768. /**
  59769. * Block used to blend normals
  59770. */
  59771. export class NormalBlendBlock extends NodeMaterialBlock {
  59772. /**
  59773. * Creates a new NormalBlendBlock
  59774. * @param name defines the block name
  59775. */
  59776. constructor(name: string);
  59777. /**
  59778. * Gets the current class name
  59779. * @returns the class name
  59780. */
  59781. getClassName(): string;
  59782. /**
  59783. * Gets the first input component
  59784. */
  59785. readonly normalMap0: NodeMaterialConnectionPoint;
  59786. /**
  59787. * Gets the second input component
  59788. */
  59789. readonly normalMap1: NodeMaterialConnectionPoint;
  59790. /**
  59791. * Gets the output component
  59792. */
  59793. readonly output: NodeMaterialConnectionPoint;
  59794. protected _buildBlock(state: NodeMaterialBuildState): this;
  59795. }
  59796. }
  59797. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  59798. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59799. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59800. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59801. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  59802. /**
  59803. * Block used to rotate a 2d vector by a given angle
  59804. */
  59805. export class Rotate2dBlock extends NodeMaterialBlock {
  59806. /**
  59807. * Creates a new Rotate2dBlock
  59808. * @param name defines the block name
  59809. */
  59810. constructor(name: string);
  59811. /**
  59812. * Gets the current class name
  59813. * @returns the class name
  59814. */
  59815. getClassName(): string;
  59816. /**
  59817. * Gets the input vector
  59818. */
  59819. readonly input: NodeMaterialConnectionPoint;
  59820. /**
  59821. * Gets the input angle
  59822. */
  59823. readonly angle: NodeMaterialConnectionPoint;
  59824. /**
  59825. * Gets the output component
  59826. */
  59827. readonly output: NodeMaterialConnectionPoint;
  59828. autoConfigure(material: NodeMaterial): void;
  59829. protected _buildBlock(state: NodeMaterialBuildState): this;
  59830. }
  59831. }
  59832. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  59833. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59834. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59835. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59836. /**
  59837. * Block used to get the reflected vector from a direction and a normal
  59838. */
  59839. export class ReflectBlock extends NodeMaterialBlock {
  59840. /**
  59841. * Creates a new ReflectBlock
  59842. * @param name defines the block name
  59843. */
  59844. constructor(name: string);
  59845. /**
  59846. * Gets the current class name
  59847. * @returns the class name
  59848. */
  59849. getClassName(): string;
  59850. /**
  59851. * Gets the incident component
  59852. */
  59853. readonly incident: NodeMaterialConnectionPoint;
  59854. /**
  59855. * Gets the normal component
  59856. */
  59857. readonly normal: NodeMaterialConnectionPoint;
  59858. /**
  59859. * Gets the output component
  59860. */
  59861. readonly output: NodeMaterialConnectionPoint;
  59862. protected _buildBlock(state: NodeMaterialBuildState): this;
  59863. }
  59864. }
  59865. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  59866. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59867. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59868. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59869. /**
  59870. * Block used to get the refracted vector from a direction and a normal
  59871. */
  59872. export class RefractBlock extends NodeMaterialBlock {
  59873. /**
  59874. * Creates a new RefractBlock
  59875. * @param name defines the block name
  59876. */
  59877. constructor(name: string);
  59878. /**
  59879. * Gets the current class name
  59880. * @returns the class name
  59881. */
  59882. getClassName(): string;
  59883. /**
  59884. * Gets the incident component
  59885. */
  59886. readonly incident: NodeMaterialConnectionPoint;
  59887. /**
  59888. * Gets the normal component
  59889. */
  59890. readonly normal: NodeMaterialConnectionPoint;
  59891. /**
  59892. * Gets the index of refraction component
  59893. */
  59894. readonly ior: NodeMaterialConnectionPoint;
  59895. /**
  59896. * Gets the output component
  59897. */
  59898. readonly output: NodeMaterialConnectionPoint;
  59899. protected _buildBlock(state: NodeMaterialBuildState): this;
  59900. }
  59901. }
  59902. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  59903. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59904. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59905. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59906. /**
  59907. * Block used to desaturate a color
  59908. */
  59909. export class DesaturateBlock extends NodeMaterialBlock {
  59910. /**
  59911. * Creates a new DesaturateBlock
  59912. * @param name defines the block name
  59913. */
  59914. constructor(name: string);
  59915. /**
  59916. * Gets the current class name
  59917. * @returns the class name
  59918. */
  59919. getClassName(): string;
  59920. /**
  59921. * Gets the color operand input component
  59922. */
  59923. readonly color: NodeMaterialConnectionPoint;
  59924. /**
  59925. * Gets the level operand input component
  59926. */
  59927. readonly level: NodeMaterialConnectionPoint;
  59928. /**
  59929. * Gets the output component
  59930. */
  59931. readonly output: NodeMaterialConnectionPoint;
  59932. protected _buildBlock(state: NodeMaterialBuildState): this;
  59933. }
  59934. }
  59935. declare module "babylonjs/Materials/Node/Blocks/index" {
  59936. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  59937. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  59938. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  59939. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  59940. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  59941. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  59942. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  59943. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  59944. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  59945. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  59946. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  59947. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  59948. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  59949. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  59950. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  59951. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  59952. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  59953. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  59954. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  59955. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  59956. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  59957. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  59958. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  59959. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  59960. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  59961. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  59962. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  59963. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  59964. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  59965. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  59966. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  59967. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  59968. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  59969. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  59970. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  59971. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  59972. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  59973. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  59974. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  59975. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  59976. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  59977. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  59978. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  59979. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  59980. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  59981. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  59982. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  59983. }
  59984. declare module "babylonjs/Materials/Node/Optimizers/index" {
  59985. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  59986. }
  59987. declare module "babylonjs/Materials/Node/index" {
  59988. export * from "babylonjs/Materials/Node/Enums/index";
  59989. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59990. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  59991. export * from "babylonjs/Materials/Node/nodeMaterial";
  59992. export * from "babylonjs/Materials/Node/Blocks/index";
  59993. export * from "babylonjs/Materials/Node/Optimizers/index";
  59994. }
  59995. declare module "babylonjs/Materials/effectRenderer" {
  59996. import { Nullable } from "babylonjs/types";
  59997. import { Texture } from "babylonjs/Materials/Textures/texture";
  59998. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59999. import { Viewport } from "babylonjs/Maths/math.viewport";
  60000. import { Observable } from "babylonjs/Misc/observable";
  60001. import { Effect } from "babylonjs/Materials/effect";
  60002. import "babylonjs/Engines/Extensions/engine.renderTarget";
  60003. import "babylonjs/Shaders/postprocess.vertex";
  60004. /**
  60005. * Effect Render Options
  60006. */
  60007. export interface IEffectRendererOptions {
  60008. /**
  60009. * Defines the vertices positions.
  60010. */
  60011. positions?: number[];
  60012. /**
  60013. * Defines the indices.
  60014. */
  60015. indices?: number[];
  60016. }
  60017. /**
  60018. * Helper class to render one or more effects
  60019. */
  60020. export class EffectRenderer {
  60021. private engine;
  60022. private static _DefaultOptions;
  60023. private _vertexBuffers;
  60024. private _indexBuffer;
  60025. private _ringBufferIndex;
  60026. private _ringScreenBuffer;
  60027. private _fullscreenViewport;
  60028. private _getNextFrameBuffer;
  60029. /**
  60030. * Creates an effect renderer
  60031. * @param engine the engine to use for rendering
  60032. * @param options defines the options of the effect renderer
  60033. */
  60034. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60035. /**
  60036. * Sets the current viewport in normalized coordinates 0-1
  60037. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60038. */
  60039. setViewport(viewport?: Viewport): void;
  60040. /**
  60041. * Binds the embedded attributes buffer to the effect.
  60042. * @param effect Defines the effect to bind the attributes for
  60043. */
  60044. bindBuffers(effect: Effect): void;
  60045. /**
  60046. * Sets the current effect wrapper to use during draw.
  60047. * The effect needs to be ready before calling this api.
  60048. * This also sets the default full screen position attribute.
  60049. * @param effectWrapper Defines the effect to draw with
  60050. */
  60051. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60052. /**
  60053. * Draws a full screen quad.
  60054. */
  60055. draw(): void;
  60056. /**
  60057. * renders one or more effects to a specified texture
  60058. * @param effectWrappers list of effects to renderer
  60059. * @param outputTexture texture to draw to, if null it will render to the screen
  60060. */
  60061. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  60062. /**
  60063. * Disposes of the effect renderer
  60064. */
  60065. dispose(): void;
  60066. }
  60067. /**
  60068. * Options to create an EffectWrapper
  60069. */
  60070. interface EffectWrapperCreationOptions {
  60071. /**
  60072. * Engine to use to create the effect
  60073. */
  60074. engine: ThinEngine;
  60075. /**
  60076. * Fragment shader for the effect
  60077. */
  60078. fragmentShader: string;
  60079. /**
  60080. * Vertex shader for the effect
  60081. */
  60082. vertexShader?: string;
  60083. /**
  60084. * Attributes to use in the shader
  60085. */
  60086. attributeNames?: Array<string>;
  60087. /**
  60088. * Uniforms to use in the shader
  60089. */
  60090. uniformNames?: Array<string>;
  60091. /**
  60092. * Texture sampler names to use in the shader
  60093. */
  60094. samplerNames?: Array<string>;
  60095. /**
  60096. * The friendly name of the effect displayed in Spector.
  60097. */
  60098. name?: string;
  60099. }
  60100. /**
  60101. * Wraps an effect to be used for rendering
  60102. */
  60103. export class EffectWrapper {
  60104. /**
  60105. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60106. */
  60107. onApplyObservable: Observable<{}>;
  60108. /**
  60109. * The underlying effect
  60110. */
  60111. effect: Effect;
  60112. /**
  60113. * Creates an effect to be renderer
  60114. * @param creationOptions options to create the effect
  60115. */
  60116. constructor(creationOptions: EffectWrapperCreationOptions);
  60117. /**
  60118. * Disposes of the effect wrapper
  60119. */
  60120. dispose(): void;
  60121. }
  60122. }
  60123. declare module "babylonjs/Materials/index" {
  60124. export * from "babylonjs/Materials/Background/index";
  60125. export * from "babylonjs/Materials/colorCurves";
  60126. export * from "babylonjs/Materials/iEffectFallbacks";
  60127. export * from "babylonjs/Materials/effectFallbacks";
  60128. export * from "babylonjs/Materials/effect";
  60129. export * from "babylonjs/Materials/fresnelParameters";
  60130. export * from "babylonjs/Materials/imageProcessingConfiguration";
  60131. export * from "babylonjs/Materials/material";
  60132. export * from "babylonjs/Materials/materialDefines";
  60133. export * from "babylonjs/Materials/materialHelper";
  60134. export * from "babylonjs/Materials/multiMaterial";
  60135. export * from "babylonjs/Materials/PBR/index";
  60136. export * from "babylonjs/Materials/pushMaterial";
  60137. export * from "babylonjs/Materials/shaderMaterial";
  60138. export * from "babylonjs/Materials/standardMaterial";
  60139. export * from "babylonjs/Materials/Textures/index";
  60140. export * from "babylonjs/Materials/uniformBuffer";
  60141. export * from "babylonjs/Materials/materialFlags";
  60142. export * from "babylonjs/Materials/Node/index";
  60143. export * from "babylonjs/Materials/effectRenderer";
  60144. }
  60145. declare module "babylonjs/Maths/index" {
  60146. export * from "babylonjs/Maths/math.scalar";
  60147. export * from "babylonjs/Maths/math";
  60148. export * from "babylonjs/Maths/sphericalPolynomial";
  60149. }
  60150. declare module "babylonjs/Misc/workerPool" {
  60151. import { IDisposable } from "babylonjs/scene";
  60152. /**
  60153. * Helper class to push actions to a pool of workers.
  60154. */
  60155. export class WorkerPool implements IDisposable {
  60156. private _workerInfos;
  60157. private _pendingActions;
  60158. /**
  60159. * Constructor
  60160. * @param workers Array of workers to use for actions
  60161. */
  60162. constructor(workers: Array<Worker>);
  60163. /**
  60164. * Terminates all workers and clears any pending actions.
  60165. */
  60166. dispose(): void;
  60167. /**
  60168. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60169. * pended until a worker has completed its action.
  60170. * @param action The action to perform. Call onComplete when the action is complete.
  60171. */
  60172. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60173. private _execute;
  60174. }
  60175. }
  60176. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  60177. import { IDisposable } from "babylonjs/scene";
  60178. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  60179. /**
  60180. * Configuration for Draco compression
  60181. */
  60182. export interface IDracoCompressionConfiguration {
  60183. /**
  60184. * Configuration for the decoder.
  60185. */
  60186. decoder: {
  60187. /**
  60188. * The url to the WebAssembly module.
  60189. */
  60190. wasmUrl?: string;
  60191. /**
  60192. * The url to the WebAssembly binary.
  60193. */
  60194. wasmBinaryUrl?: string;
  60195. /**
  60196. * The url to the fallback JavaScript module.
  60197. */
  60198. fallbackUrl?: string;
  60199. };
  60200. }
  60201. /**
  60202. * Draco compression (https://google.github.io/draco/)
  60203. *
  60204. * This class wraps the Draco module.
  60205. *
  60206. * **Encoder**
  60207. *
  60208. * The encoder is not currently implemented.
  60209. *
  60210. * **Decoder**
  60211. *
  60212. * 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.
  60213. *
  60214. * To update the configuration, use the following code:
  60215. * ```javascript
  60216. * DracoCompression.Configuration = {
  60217. * decoder: {
  60218. * wasmUrl: "<url to the WebAssembly library>",
  60219. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  60220. * fallbackUrl: "<url to the fallback JavaScript library>",
  60221. * }
  60222. * };
  60223. * ```
  60224. *
  60225. * 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.
  60226. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  60227. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  60228. *
  60229. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  60230. * ```javascript
  60231. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  60232. * ```
  60233. *
  60234. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  60235. */
  60236. export class DracoCompression implements IDisposable {
  60237. private _workerPoolPromise?;
  60238. private _decoderModulePromise?;
  60239. /**
  60240. * The configuration. Defaults to the following urls:
  60241. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  60242. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  60243. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  60244. */
  60245. static Configuration: IDracoCompressionConfiguration;
  60246. /**
  60247. * Returns true if the decoder configuration is available.
  60248. */
  60249. static readonly DecoderAvailable: boolean;
  60250. /**
  60251. * Default number of workers to create when creating the draco compression object.
  60252. */
  60253. static DefaultNumWorkers: number;
  60254. private static GetDefaultNumWorkers;
  60255. private static _Default;
  60256. /**
  60257. * Default instance for the draco compression object.
  60258. */
  60259. static readonly Default: DracoCompression;
  60260. /**
  60261. * Constructor
  60262. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60263. */
  60264. constructor(numWorkers?: number);
  60265. /**
  60266. * Stop all async operations and release resources.
  60267. */
  60268. dispose(): void;
  60269. /**
  60270. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  60271. * @returns a promise that resolves when ready
  60272. */
  60273. whenReadyAsync(): Promise<void>;
  60274. /**
  60275. * Decode Draco compressed mesh data to vertex data.
  60276. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  60277. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  60278. * @returns A promise that resolves with the decoded vertex data
  60279. */
  60280. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  60281. [kind: string]: number;
  60282. }): Promise<VertexData>;
  60283. }
  60284. }
  60285. declare module "babylonjs/Meshes/Compression/index" {
  60286. export * from "babylonjs/Meshes/Compression/dracoCompression";
  60287. }
  60288. declare module "babylonjs/Meshes/csg" {
  60289. import { Nullable } from "babylonjs/types";
  60290. import { Scene } from "babylonjs/scene";
  60291. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60292. import { Mesh } from "babylonjs/Meshes/mesh";
  60293. import { Material } from "babylonjs/Materials/material";
  60294. /**
  60295. * Class for building Constructive Solid Geometry
  60296. */
  60297. export class CSG {
  60298. private polygons;
  60299. /**
  60300. * The world matrix
  60301. */
  60302. matrix: Matrix;
  60303. /**
  60304. * Stores the position
  60305. */
  60306. position: Vector3;
  60307. /**
  60308. * Stores the rotation
  60309. */
  60310. rotation: Vector3;
  60311. /**
  60312. * Stores the rotation quaternion
  60313. */
  60314. rotationQuaternion: Nullable<Quaternion>;
  60315. /**
  60316. * Stores the scaling vector
  60317. */
  60318. scaling: Vector3;
  60319. /**
  60320. * Convert the Mesh to CSG
  60321. * @param mesh The Mesh to convert to CSG
  60322. * @returns A new CSG from the Mesh
  60323. */
  60324. static FromMesh(mesh: Mesh): CSG;
  60325. /**
  60326. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  60327. * @param polygons Polygons used to construct a CSG solid
  60328. */
  60329. private static FromPolygons;
  60330. /**
  60331. * Clones, or makes a deep copy, of the CSG
  60332. * @returns A new CSG
  60333. */
  60334. clone(): CSG;
  60335. /**
  60336. * Unions this CSG with another CSG
  60337. * @param csg The CSG to union against this CSG
  60338. * @returns The unioned CSG
  60339. */
  60340. union(csg: CSG): CSG;
  60341. /**
  60342. * Unions this CSG with another CSG in place
  60343. * @param csg The CSG to union against this CSG
  60344. */
  60345. unionInPlace(csg: CSG): void;
  60346. /**
  60347. * Subtracts this CSG with another CSG
  60348. * @param csg The CSG to subtract against this CSG
  60349. * @returns A new CSG
  60350. */
  60351. subtract(csg: CSG): CSG;
  60352. /**
  60353. * Subtracts this CSG with another CSG in place
  60354. * @param csg The CSG to subtact against this CSG
  60355. */
  60356. subtractInPlace(csg: CSG): void;
  60357. /**
  60358. * Intersect this CSG with another CSG
  60359. * @param csg The CSG to intersect against this CSG
  60360. * @returns A new CSG
  60361. */
  60362. intersect(csg: CSG): CSG;
  60363. /**
  60364. * Intersects this CSG with another CSG in place
  60365. * @param csg The CSG to intersect against this CSG
  60366. */
  60367. intersectInPlace(csg: CSG): void;
  60368. /**
  60369. * Return a new CSG solid with solid and empty space switched. This solid is
  60370. * not modified.
  60371. * @returns A new CSG solid with solid and empty space switched
  60372. */
  60373. inverse(): CSG;
  60374. /**
  60375. * Inverses the CSG in place
  60376. */
  60377. inverseInPlace(): void;
  60378. /**
  60379. * This is used to keep meshes transformations so they can be restored
  60380. * when we build back a Babylon Mesh
  60381. * NB : All CSG operations are performed in world coordinates
  60382. * @param csg The CSG to copy the transform attributes from
  60383. * @returns This CSG
  60384. */
  60385. copyTransformAttributes(csg: CSG): CSG;
  60386. /**
  60387. * Build Raw mesh from CSG
  60388. * Coordinates here are in world space
  60389. * @param name The name of the mesh geometry
  60390. * @param scene The Scene
  60391. * @param keepSubMeshes Specifies if the submeshes should be kept
  60392. * @returns A new Mesh
  60393. */
  60394. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60395. /**
  60396. * Build Mesh from CSG taking material and transforms into account
  60397. * @param name The name of the Mesh
  60398. * @param material The material of the Mesh
  60399. * @param scene The Scene
  60400. * @param keepSubMeshes Specifies if submeshes should be kept
  60401. * @returns The new Mesh
  60402. */
  60403. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60404. }
  60405. }
  60406. declare module "babylonjs/Meshes/trailMesh" {
  60407. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60408. import { Mesh } from "babylonjs/Meshes/mesh";
  60409. import { Scene } from "babylonjs/scene";
  60410. /**
  60411. * Class used to create a trail following a mesh
  60412. */
  60413. export class TrailMesh extends Mesh {
  60414. private _generator;
  60415. private _autoStart;
  60416. private _running;
  60417. private _diameter;
  60418. private _length;
  60419. private _sectionPolygonPointsCount;
  60420. private _sectionVectors;
  60421. private _sectionNormalVectors;
  60422. private _beforeRenderObserver;
  60423. /**
  60424. * @constructor
  60425. * @param name The value used by scene.getMeshByName() to do a lookup.
  60426. * @param generator The mesh to generate a trail.
  60427. * @param scene The scene to add this mesh to.
  60428. * @param diameter Diameter of trailing mesh. Default is 1.
  60429. * @param length Length of trailing mesh. Default is 60.
  60430. * @param autoStart Automatically start trailing mesh. Default true.
  60431. */
  60432. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  60433. /**
  60434. * "TrailMesh"
  60435. * @returns "TrailMesh"
  60436. */
  60437. getClassName(): string;
  60438. private _createMesh;
  60439. /**
  60440. * Start trailing mesh.
  60441. */
  60442. start(): void;
  60443. /**
  60444. * Stop trailing mesh.
  60445. */
  60446. stop(): void;
  60447. /**
  60448. * Update trailing mesh geometry.
  60449. */
  60450. update(): void;
  60451. /**
  60452. * Returns a new TrailMesh object.
  60453. * @param name is a string, the name given to the new mesh
  60454. * @param newGenerator use new generator object for cloned trail mesh
  60455. * @returns a new mesh
  60456. */
  60457. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  60458. /**
  60459. * Serializes this trail mesh
  60460. * @param serializationObject object to write serialization to
  60461. */
  60462. serialize(serializationObject: any): void;
  60463. /**
  60464. * Parses a serialized trail mesh
  60465. * @param parsedMesh the serialized mesh
  60466. * @param scene the scene to create the trail mesh in
  60467. * @returns the created trail mesh
  60468. */
  60469. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  60470. }
  60471. }
  60472. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  60473. import { Nullable } from "babylonjs/types";
  60474. import { Scene } from "babylonjs/scene";
  60475. import { Vector4 } from "babylonjs/Maths/math.vector";
  60476. import { Color4 } from "babylonjs/Maths/math.color";
  60477. import { Mesh } from "babylonjs/Meshes/mesh";
  60478. /**
  60479. * Class containing static functions to help procedurally build meshes
  60480. */
  60481. export class TiledBoxBuilder {
  60482. /**
  60483. * Creates a box mesh
  60484. * 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)
  60485. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60486. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60487. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60489. * @param name defines the name of the mesh
  60490. * @param options defines the options used to create the mesh
  60491. * @param scene defines the hosting scene
  60492. * @returns the box mesh
  60493. */
  60494. static CreateTiledBox(name: string, options: {
  60495. pattern?: number;
  60496. width?: number;
  60497. height?: number;
  60498. depth?: number;
  60499. tileSize?: number;
  60500. tileWidth?: number;
  60501. tileHeight?: number;
  60502. alignHorizontal?: number;
  60503. alignVertical?: number;
  60504. faceUV?: Vector4[];
  60505. faceColors?: Color4[];
  60506. sideOrientation?: number;
  60507. updatable?: boolean;
  60508. }, scene?: Nullable<Scene>): Mesh;
  60509. }
  60510. }
  60511. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  60512. import { Vector4 } from "babylonjs/Maths/math.vector";
  60513. import { Mesh } from "babylonjs/Meshes/mesh";
  60514. /**
  60515. * Class containing static functions to help procedurally build meshes
  60516. */
  60517. export class TorusKnotBuilder {
  60518. /**
  60519. * Creates a torus knot mesh
  60520. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60521. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60522. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60523. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60524. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60525. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60526. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60527. * @param name defines the name of the mesh
  60528. * @param options defines the options used to create the mesh
  60529. * @param scene defines the hosting scene
  60530. * @returns the torus knot mesh
  60531. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  60532. */
  60533. static CreateTorusKnot(name: string, options: {
  60534. radius?: number;
  60535. tube?: number;
  60536. radialSegments?: number;
  60537. tubularSegments?: number;
  60538. p?: number;
  60539. q?: number;
  60540. updatable?: boolean;
  60541. sideOrientation?: number;
  60542. frontUVs?: Vector4;
  60543. backUVs?: Vector4;
  60544. }, scene: any): Mesh;
  60545. }
  60546. }
  60547. declare module "babylonjs/Meshes/polygonMesh" {
  60548. import { Scene } from "babylonjs/scene";
  60549. import { Vector2 } from "babylonjs/Maths/math.vector";
  60550. import { Mesh } from "babylonjs/Meshes/mesh";
  60551. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  60552. import { Path2 } from "babylonjs/Maths/math.path";
  60553. /**
  60554. * Polygon
  60555. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  60556. */
  60557. export class Polygon {
  60558. /**
  60559. * Creates a rectangle
  60560. * @param xmin bottom X coord
  60561. * @param ymin bottom Y coord
  60562. * @param xmax top X coord
  60563. * @param ymax top Y coord
  60564. * @returns points that make the resulting rectation
  60565. */
  60566. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  60567. /**
  60568. * Creates a circle
  60569. * @param radius radius of circle
  60570. * @param cx scale in x
  60571. * @param cy scale in y
  60572. * @param numberOfSides number of sides that make up the circle
  60573. * @returns points that make the resulting circle
  60574. */
  60575. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  60576. /**
  60577. * Creates a polygon from input string
  60578. * @param input Input polygon data
  60579. * @returns the parsed points
  60580. */
  60581. static Parse(input: string): Vector2[];
  60582. /**
  60583. * Starts building a polygon from x and y coordinates
  60584. * @param x x coordinate
  60585. * @param y y coordinate
  60586. * @returns the started path2
  60587. */
  60588. static StartingAt(x: number, y: number): Path2;
  60589. }
  60590. /**
  60591. * Builds a polygon
  60592. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  60593. */
  60594. export class PolygonMeshBuilder {
  60595. private _points;
  60596. private _outlinepoints;
  60597. private _holes;
  60598. private _name;
  60599. private _scene;
  60600. private _epoints;
  60601. private _eholes;
  60602. private _addToepoint;
  60603. /**
  60604. * Babylon reference to the earcut plugin.
  60605. */
  60606. bjsEarcut: any;
  60607. /**
  60608. * Creates a PolygonMeshBuilder
  60609. * @param name name of the builder
  60610. * @param contours Path of the polygon
  60611. * @param scene scene to add to when creating the mesh
  60612. * @param earcutInjection can be used to inject your own earcut reference
  60613. */
  60614. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  60615. /**
  60616. * Adds a whole within the polygon
  60617. * @param hole Array of points defining the hole
  60618. * @returns this
  60619. */
  60620. addHole(hole: Vector2[]): PolygonMeshBuilder;
  60621. /**
  60622. * Creates the polygon
  60623. * @param updatable If the mesh should be updatable
  60624. * @param depth The depth of the mesh created
  60625. * @returns the created mesh
  60626. */
  60627. build(updatable?: boolean, depth?: number): Mesh;
  60628. /**
  60629. * Creates the polygon
  60630. * @param depth The depth of the mesh created
  60631. * @returns the created VertexData
  60632. */
  60633. buildVertexData(depth?: number): VertexData;
  60634. /**
  60635. * Adds a side to the polygon
  60636. * @param positions points that make the polygon
  60637. * @param normals normals of the polygon
  60638. * @param uvs uvs of the polygon
  60639. * @param indices indices of the polygon
  60640. * @param bounds bounds of the polygon
  60641. * @param points points of the polygon
  60642. * @param depth depth of the polygon
  60643. * @param flip flip of the polygon
  60644. */
  60645. private addSide;
  60646. }
  60647. }
  60648. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  60649. import { Scene } from "babylonjs/scene";
  60650. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  60651. import { Color4 } from "babylonjs/Maths/math.color";
  60652. import { Mesh } from "babylonjs/Meshes/mesh";
  60653. import { Nullable } from "babylonjs/types";
  60654. /**
  60655. * Class containing static functions to help procedurally build meshes
  60656. */
  60657. export class PolygonBuilder {
  60658. /**
  60659. * Creates a polygon mesh
  60660. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60661. * * 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
  60662. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60663. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60664. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  60665. * * Remember you can only change the shape positions, not their number when updating a polygon
  60666. * @param name defines the name of the mesh
  60667. * @param options defines the options used to create the mesh
  60668. * @param scene defines the hosting scene
  60669. * @param earcutInjection can be used to inject your own earcut reference
  60670. * @returns the polygon mesh
  60671. */
  60672. static CreatePolygon(name: string, options: {
  60673. shape: Vector3[];
  60674. holes?: Vector3[][];
  60675. depth?: number;
  60676. faceUV?: Vector4[];
  60677. faceColors?: Color4[];
  60678. updatable?: boolean;
  60679. sideOrientation?: number;
  60680. frontUVs?: Vector4;
  60681. backUVs?: Vector4;
  60682. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60683. /**
  60684. * Creates an extruded polygon mesh, with depth in the Y direction.
  60685. * * 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)
  60686. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60687. * @param name defines the name of the mesh
  60688. * @param options defines the options used to create the mesh
  60689. * @param scene defines the hosting scene
  60690. * @param earcutInjection can be used to inject your own earcut reference
  60691. * @returns the polygon mesh
  60692. */
  60693. static ExtrudePolygon(name: string, options: {
  60694. shape: Vector3[];
  60695. holes?: Vector3[][];
  60696. depth?: number;
  60697. faceUV?: Vector4[];
  60698. faceColors?: Color4[];
  60699. updatable?: boolean;
  60700. sideOrientation?: number;
  60701. frontUVs?: Vector4;
  60702. backUVs?: Vector4;
  60703. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60704. }
  60705. }
  60706. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  60707. import { Scene } from "babylonjs/scene";
  60708. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  60709. import { Mesh } from "babylonjs/Meshes/mesh";
  60710. import { Nullable } from "babylonjs/types";
  60711. /**
  60712. * Class containing static functions to help procedurally build meshes
  60713. */
  60714. export class LatheBuilder {
  60715. /**
  60716. * Creates lathe mesh.
  60717. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  60718. * * 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
  60719. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  60720. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  60721. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  60722. * * 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
  60723. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  60724. * * 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
  60725. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60726. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60727. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60728. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60729. * @param name defines the name of the mesh
  60730. * @param options defines the options used to create the mesh
  60731. * @param scene defines the hosting scene
  60732. * @returns the lathe mesh
  60733. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  60734. */
  60735. static CreateLathe(name: string, options: {
  60736. shape: Vector3[];
  60737. radius?: number;
  60738. tessellation?: number;
  60739. clip?: number;
  60740. arc?: number;
  60741. closed?: boolean;
  60742. updatable?: boolean;
  60743. sideOrientation?: number;
  60744. frontUVs?: Vector4;
  60745. backUVs?: Vector4;
  60746. cap?: number;
  60747. invertUV?: boolean;
  60748. }, scene?: Nullable<Scene>): Mesh;
  60749. }
  60750. }
  60751. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  60752. import { Nullable } from "babylonjs/types";
  60753. import { Scene } from "babylonjs/scene";
  60754. import { Vector4 } from "babylonjs/Maths/math.vector";
  60755. import { Mesh } from "babylonjs/Meshes/mesh";
  60756. /**
  60757. * Class containing static functions to help procedurally build meshes
  60758. */
  60759. export class TiledPlaneBuilder {
  60760. /**
  60761. * Creates a tiled plane mesh
  60762. * * The parameter `pattern` will, depending on value, do nothing or
  60763. * * * flip (reflect about central vertical) alternate tiles across and up
  60764. * * * flip every tile on alternate rows
  60765. * * * rotate (180 degs) alternate tiles across and up
  60766. * * * rotate every tile on alternate rows
  60767. * * * flip and rotate alternate tiles across and up
  60768. * * * flip and rotate every tile on alternate rows
  60769. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  60770. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  60771. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60772. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60773. * * 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)
  60774. * * 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)
  60775. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60776. * @param name defines the name of the mesh
  60777. * @param options defines the options used to create the mesh
  60778. * @param scene defines the hosting scene
  60779. * @returns the box mesh
  60780. */
  60781. static CreateTiledPlane(name: string, options: {
  60782. pattern?: number;
  60783. tileSize?: number;
  60784. tileWidth?: number;
  60785. tileHeight?: number;
  60786. size?: number;
  60787. width?: number;
  60788. height?: number;
  60789. alignHorizontal?: number;
  60790. alignVertical?: number;
  60791. sideOrientation?: number;
  60792. frontUVs?: Vector4;
  60793. backUVs?: Vector4;
  60794. updatable?: boolean;
  60795. }, scene?: Nullable<Scene>): Mesh;
  60796. }
  60797. }
  60798. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  60799. import { Nullable } from "babylonjs/types";
  60800. import { Scene } from "babylonjs/scene";
  60801. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  60802. import { Mesh } from "babylonjs/Meshes/mesh";
  60803. /**
  60804. * Class containing static functions to help procedurally build meshes
  60805. */
  60806. export class TubeBuilder {
  60807. /**
  60808. * Creates a tube mesh.
  60809. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60810. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60811. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60812. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60813. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60814. * * 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)
  60815. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60816. * * 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
  60817. * * 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
  60818. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60819. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60820. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60821. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60822. * @param name defines the name of the mesh
  60823. * @param options defines the options used to create the mesh
  60824. * @param scene defines the hosting scene
  60825. * @returns the tube mesh
  60826. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60827. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60828. */
  60829. static CreateTube(name: string, options: {
  60830. path: Vector3[];
  60831. radius?: number;
  60832. tessellation?: number;
  60833. radiusFunction?: {
  60834. (i: number, distance: number): number;
  60835. };
  60836. cap?: number;
  60837. arc?: number;
  60838. updatable?: boolean;
  60839. sideOrientation?: number;
  60840. frontUVs?: Vector4;
  60841. backUVs?: Vector4;
  60842. instance?: Mesh;
  60843. invertUV?: boolean;
  60844. }, scene?: Nullable<Scene>): Mesh;
  60845. }
  60846. }
  60847. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  60848. import { Scene } from "babylonjs/scene";
  60849. import { Vector4 } from "babylonjs/Maths/math.vector";
  60850. import { Mesh } from "babylonjs/Meshes/mesh";
  60851. import { Nullable } from "babylonjs/types";
  60852. /**
  60853. * Class containing static functions to help procedurally build meshes
  60854. */
  60855. export class IcoSphereBuilder {
  60856. /**
  60857. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  60858. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  60859. * * 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`)
  60860. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  60861. * * 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
  60862. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60863. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60864. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60865. * @param name defines the name of the mesh
  60866. * @param options defines the options used to create the mesh
  60867. * @param scene defines the hosting scene
  60868. * @returns the icosahedron mesh
  60869. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  60870. */
  60871. static CreateIcoSphere(name: string, options: {
  60872. radius?: number;
  60873. radiusX?: number;
  60874. radiusY?: number;
  60875. radiusZ?: number;
  60876. flat?: boolean;
  60877. subdivisions?: number;
  60878. sideOrientation?: number;
  60879. frontUVs?: Vector4;
  60880. backUVs?: Vector4;
  60881. updatable?: boolean;
  60882. }, scene?: Nullable<Scene>): Mesh;
  60883. }
  60884. }
  60885. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  60886. import { Vector3 } from "babylonjs/Maths/math.vector";
  60887. import { Mesh } from "babylonjs/Meshes/mesh";
  60888. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60889. /**
  60890. * Class containing static functions to help procedurally build meshes
  60891. */
  60892. export class DecalBuilder {
  60893. /**
  60894. * Creates a decal mesh.
  60895. * 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
  60896. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  60897. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  60898. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  60899. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  60900. * @param name defines the name of the mesh
  60901. * @param sourceMesh defines the mesh where the decal must be applied
  60902. * @param options defines the options used to create the mesh
  60903. * @param scene defines the hosting scene
  60904. * @returns the decal mesh
  60905. * @see https://doc.babylonjs.com/how_to/decals
  60906. */
  60907. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  60908. position?: Vector3;
  60909. normal?: Vector3;
  60910. size?: Vector3;
  60911. angle?: number;
  60912. }): Mesh;
  60913. }
  60914. }
  60915. declare module "babylonjs/Meshes/meshBuilder" {
  60916. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  60917. import { Nullable } from "babylonjs/types";
  60918. import { Scene } from "babylonjs/scene";
  60919. import { Mesh } from "babylonjs/Meshes/mesh";
  60920. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  60921. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  60922. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60923. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60924. import { Plane } from "babylonjs/Maths/math.plane";
  60925. /**
  60926. * Class containing static functions to help procedurally build meshes
  60927. */
  60928. export class MeshBuilder {
  60929. /**
  60930. * Creates a box mesh
  60931. * * The parameter `size` sets the size (float) of each box side (default 1)
  60932. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  60933. * * 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)
  60934. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60935. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60936. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60937. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60938. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60939. * @param name defines the name of the mesh
  60940. * @param options defines the options used to create the mesh
  60941. * @param scene defines the hosting scene
  60942. * @returns the box mesh
  60943. */
  60944. static CreateBox(name: string, options: {
  60945. size?: number;
  60946. width?: number;
  60947. height?: number;
  60948. depth?: number;
  60949. faceUV?: Vector4[];
  60950. faceColors?: Color4[];
  60951. sideOrientation?: number;
  60952. frontUVs?: Vector4;
  60953. backUVs?: Vector4;
  60954. updatable?: boolean;
  60955. }, scene?: Nullable<Scene>): Mesh;
  60956. /**
  60957. * Creates a tiled box mesh
  60958. * * faceTiles sets the pattern, tile size and number of tiles for a face
  60959. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60960. * @param name defines the name of the mesh
  60961. * @param options defines the options used to create the mesh
  60962. * @param scene defines the hosting scene
  60963. * @returns the tiled box mesh
  60964. */
  60965. static CreateTiledBox(name: string, options: {
  60966. pattern?: number;
  60967. size?: number;
  60968. width?: number;
  60969. height?: number;
  60970. depth: number;
  60971. tileSize?: number;
  60972. tileWidth?: number;
  60973. tileHeight?: number;
  60974. faceUV?: Vector4[];
  60975. faceColors?: Color4[];
  60976. alignHorizontal?: number;
  60977. alignVertical?: number;
  60978. sideOrientation?: number;
  60979. updatable?: boolean;
  60980. }, scene?: Nullable<Scene>): Mesh;
  60981. /**
  60982. * Creates a sphere mesh
  60983. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  60984. * * 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`)
  60985. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  60986. * * 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
  60987. * * 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)
  60988. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60989. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60990. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60991. * @param name defines the name of the mesh
  60992. * @param options defines the options used to create the mesh
  60993. * @param scene defines the hosting scene
  60994. * @returns the sphere mesh
  60995. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  60996. */
  60997. static CreateSphere(name: string, options: {
  60998. segments?: number;
  60999. diameter?: number;
  61000. diameterX?: number;
  61001. diameterY?: number;
  61002. diameterZ?: number;
  61003. arc?: number;
  61004. slice?: number;
  61005. sideOrientation?: number;
  61006. frontUVs?: Vector4;
  61007. backUVs?: Vector4;
  61008. updatable?: boolean;
  61009. }, scene?: Nullable<Scene>): Mesh;
  61010. /**
  61011. * Creates a plane polygonal mesh. By default, this is a disc
  61012. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  61013. * * 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
  61014. * * 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
  61015. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61016. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61017. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61018. * @param name defines the name of the mesh
  61019. * @param options defines the options used to create the mesh
  61020. * @param scene defines the hosting scene
  61021. * @returns the plane polygonal mesh
  61022. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  61023. */
  61024. static CreateDisc(name: string, options: {
  61025. radius?: number;
  61026. tessellation?: number;
  61027. arc?: number;
  61028. updatable?: boolean;
  61029. sideOrientation?: number;
  61030. frontUVs?: Vector4;
  61031. backUVs?: Vector4;
  61032. }, scene?: Nullable<Scene>): Mesh;
  61033. /**
  61034. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61035. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61036. * * 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`)
  61037. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61038. * * 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
  61039. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61040. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61041. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61042. * @param name defines the name of the mesh
  61043. * @param options defines the options used to create the mesh
  61044. * @param scene defines the hosting scene
  61045. * @returns the icosahedron mesh
  61046. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61047. */
  61048. static CreateIcoSphere(name: string, options: {
  61049. radius?: number;
  61050. radiusX?: number;
  61051. radiusY?: number;
  61052. radiusZ?: number;
  61053. flat?: boolean;
  61054. subdivisions?: number;
  61055. sideOrientation?: number;
  61056. frontUVs?: Vector4;
  61057. backUVs?: Vector4;
  61058. updatable?: boolean;
  61059. }, scene?: Nullable<Scene>): Mesh;
  61060. /**
  61061. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61062. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61063. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61064. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61065. * * 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
  61066. * * 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
  61067. * * 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
  61068. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61069. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61070. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61071. * * 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
  61072. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61073. * * 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
  61074. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61076. * @param name defines the name of the mesh
  61077. * @param options defines the options used to create the mesh
  61078. * @param scene defines the hosting scene
  61079. * @returns the ribbon mesh
  61080. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61081. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61082. */
  61083. static CreateRibbon(name: string, options: {
  61084. pathArray: Vector3[][];
  61085. closeArray?: boolean;
  61086. closePath?: boolean;
  61087. offset?: number;
  61088. updatable?: boolean;
  61089. sideOrientation?: number;
  61090. frontUVs?: Vector4;
  61091. backUVs?: Vector4;
  61092. instance?: Mesh;
  61093. invertUV?: boolean;
  61094. uvs?: Vector2[];
  61095. colors?: Color4[];
  61096. }, scene?: Nullable<Scene>): Mesh;
  61097. /**
  61098. * Creates a cylinder or a cone mesh
  61099. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  61100. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  61101. * * 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.
  61102. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  61103. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  61104. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  61105. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  61106. * * 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).
  61107. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  61108. * * 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).
  61109. * * 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
  61110. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  61111. * * 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
  61112. * * 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.
  61113. * * If `enclose` is false, a ring surface is one element.
  61114. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  61115. * * 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
  61116. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61117. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61118. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61119. * @param name defines the name of the mesh
  61120. * @param options defines the options used to create the mesh
  61121. * @param scene defines the hosting scene
  61122. * @returns the cylinder mesh
  61123. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  61124. */
  61125. static CreateCylinder(name: string, options: {
  61126. height?: number;
  61127. diameterTop?: number;
  61128. diameterBottom?: number;
  61129. diameter?: number;
  61130. tessellation?: number;
  61131. subdivisions?: number;
  61132. arc?: number;
  61133. faceColors?: Color4[];
  61134. faceUV?: Vector4[];
  61135. updatable?: boolean;
  61136. hasRings?: boolean;
  61137. enclose?: boolean;
  61138. cap?: number;
  61139. sideOrientation?: number;
  61140. frontUVs?: Vector4;
  61141. backUVs?: Vector4;
  61142. }, scene?: Nullable<Scene>): Mesh;
  61143. /**
  61144. * Creates a torus mesh
  61145. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  61146. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  61147. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  61148. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61149. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61150. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61151. * @param name defines the name of the mesh
  61152. * @param options defines the options used to create the mesh
  61153. * @param scene defines the hosting scene
  61154. * @returns the torus mesh
  61155. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  61156. */
  61157. static CreateTorus(name: string, options: {
  61158. diameter?: number;
  61159. thickness?: number;
  61160. tessellation?: number;
  61161. updatable?: boolean;
  61162. sideOrientation?: number;
  61163. frontUVs?: Vector4;
  61164. backUVs?: Vector4;
  61165. }, scene?: Nullable<Scene>): Mesh;
  61166. /**
  61167. * Creates a torus knot mesh
  61168. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61169. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61170. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61171. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61172. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61173. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61174. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61175. * @param name defines the name of the mesh
  61176. * @param options defines the options used to create the mesh
  61177. * @param scene defines the hosting scene
  61178. * @returns the torus knot mesh
  61179. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61180. */
  61181. static CreateTorusKnot(name: string, options: {
  61182. radius?: number;
  61183. tube?: number;
  61184. radialSegments?: number;
  61185. tubularSegments?: number;
  61186. p?: number;
  61187. q?: number;
  61188. updatable?: boolean;
  61189. sideOrientation?: number;
  61190. frontUVs?: Vector4;
  61191. backUVs?: Vector4;
  61192. }, scene?: Nullable<Scene>): Mesh;
  61193. /**
  61194. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  61195. * * 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
  61196. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  61197. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  61198. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  61199. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  61200. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  61201. * * 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
  61202. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  61203. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61204. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  61205. * @param name defines the name of the new line system
  61206. * @param options defines the options used to create the line system
  61207. * @param scene defines the hosting scene
  61208. * @returns a new line system mesh
  61209. */
  61210. static CreateLineSystem(name: string, options: {
  61211. lines: Vector3[][];
  61212. updatable?: boolean;
  61213. instance?: Nullable<LinesMesh>;
  61214. colors?: Nullable<Color4[][]>;
  61215. useVertexAlpha?: boolean;
  61216. }, scene: Nullable<Scene>): LinesMesh;
  61217. /**
  61218. * Creates a line mesh
  61219. * 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
  61220. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61221. * * The parameter `points` is an array successive Vector3
  61222. * * 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
  61223. * * The optional parameter `colors` is an array of successive Color4, one per line point
  61224. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  61225. * * When updating an instance, remember that only point positions can change, not the number of points
  61226. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61227. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  61228. * @param name defines the name of the new line system
  61229. * @param options defines the options used to create the line system
  61230. * @param scene defines the hosting scene
  61231. * @returns a new line mesh
  61232. */
  61233. static CreateLines(name: string, options: {
  61234. points: Vector3[];
  61235. updatable?: boolean;
  61236. instance?: Nullable<LinesMesh>;
  61237. colors?: Color4[];
  61238. useVertexAlpha?: boolean;
  61239. }, scene?: Nullable<Scene>): LinesMesh;
  61240. /**
  61241. * Creates a dashed line mesh
  61242. * * 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
  61243. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61244. * * The parameter `points` is an array successive Vector3
  61245. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  61246. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  61247. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  61248. * * 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
  61249. * * When updating an instance, remember that only point positions can change, not the number of points
  61250. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61251. * @param name defines the name of the mesh
  61252. * @param options defines the options used to create the mesh
  61253. * @param scene defines the hosting scene
  61254. * @returns the dashed line mesh
  61255. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  61256. */
  61257. static CreateDashedLines(name: string, options: {
  61258. points: Vector3[];
  61259. dashSize?: number;
  61260. gapSize?: number;
  61261. dashNb?: number;
  61262. updatable?: boolean;
  61263. instance?: LinesMesh;
  61264. }, scene?: Nullable<Scene>): LinesMesh;
  61265. /**
  61266. * 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.
  61267. * * 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.
  61268. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61269. * * 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.
  61270. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  61271. * * 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
  61272. * * 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
  61273. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  61274. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61275. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61276. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  61277. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61278. * @param name defines the name of the mesh
  61279. * @param options defines the options used to create the mesh
  61280. * @param scene defines the hosting scene
  61281. * @returns the extruded shape mesh
  61282. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61283. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61284. */
  61285. static ExtrudeShape(name: string, options: {
  61286. shape: Vector3[];
  61287. path: Vector3[];
  61288. scale?: number;
  61289. rotation?: number;
  61290. cap?: number;
  61291. updatable?: boolean;
  61292. sideOrientation?: number;
  61293. frontUVs?: Vector4;
  61294. backUVs?: Vector4;
  61295. instance?: Mesh;
  61296. invertUV?: boolean;
  61297. }, scene?: Nullable<Scene>): Mesh;
  61298. /**
  61299. * Creates an custom extruded shape mesh.
  61300. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61301. * * 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.
  61302. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61303. * * 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
  61304. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  61305. * * 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
  61306. * * It must returns a float value that will be the scale value applied to the shape on each path point
  61307. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  61308. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  61309. * * 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
  61310. * * 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
  61311. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  61312. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61313. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61314. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61315. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61316. * @param name defines the name of the mesh
  61317. * @param options defines the options used to create the mesh
  61318. * @param scene defines the hosting scene
  61319. * @returns the custom extruded shape mesh
  61320. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  61321. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61322. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61323. */
  61324. static ExtrudeShapeCustom(name: string, options: {
  61325. shape: Vector3[];
  61326. path: Vector3[];
  61327. scaleFunction?: any;
  61328. rotationFunction?: any;
  61329. ribbonCloseArray?: boolean;
  61330. ribbonClosePath?: boolean;
  61331. cap?: number;
  61332. updatable?: boolean;
  61333. sideOrientation?: number;
  61334. frontUVs?: Vector4;
  61335. backUVs?: Vector4;
  61336. instance?: Mesh;
  61337. invertUV?: boolean;
  61338. }, scene?: Nullable<Scene>): Mesh;
  61339. /**
  61340. * Creates lathe mesh.
  61341. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61342. * * 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
  61343. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61344. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61345. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61346. * * 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
  61347. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61348. * * 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
  61349. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61350. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61351. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61352. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61353. * @param name defines the name of the mesh
  61354. * @param options defines the options used to create the mesh
  61355. * @param scene defines the hosting scene
  61356. * @returns the lathe mesh
  61357. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61358. */
  61359. static CreateLathe(name: string, options: {
  61360. shape: Vector3[];
  61361. radius?: number;
  61362. tessellation?: number;
  61363. clip?: number;
  61364. arc?: number;
  61365. closed?: boolean;
  61366. updatable?: boolean;
  61367. sideOrientation?: number;
  61368. frontUVs?: Vector4;
  61369. backUVs?: Vector4;
  61370. cap?: number;
  61371. invertUV?: boolean;
  61372. }, scene?: Nullable<Scene>): Mesh;
  61373. /**
  61374. * Creates a tiled plane mesh
  61375. * * You can set a limited pattern arrangement with the tiles
  61376. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61377. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61378. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61379. * @param name defines the name of the mesh
  61380. * @param options defines the options used to create the mesh
  61381. * @param scene defines the hosting scene
  61382. * @returns the plane mesh
  61383. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61384. */
  61385. static CreateTiledPlane(name: string, options: {
  61386. pattern?: number;
  61387. tileSize?: number;
  61388. tileWidth?: number;
  61389. tileHeight?: number;
  61390. size?: number;
  61391. width?: number;
  61392. height?: number;
  61393. alignHorizontal?: number;
  61394. alignVertical?: number;
  61395. sideOrientation?: number;
  61396. frontUVs?: Vector4;
  61397. backUVs?: Vector4;
  61398. updatable?: boolean;
  61399. }, scene?: Nullable<Scene>): Mesh;
  61400. /**
  61401. * Creates a plane mesh
  61402. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  61403. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  61404. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  61405. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61406. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61407. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61408. * @param name defines the name of the mesh
  61409. * @param options defines the options used to create the mesh
  61410. * @param scene defines the hosting scene
  61411. * @returns the plane mesh
  61412. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61413. */
  61414. static CreatePlane(name: string, options: {
  61415. size?: number;
  61416. width?: number;
  61417. height?: number;
  61418. sideOrientation?: number;
  61419. frontUVs?: Vector4;
  61420. backUVs?: Vector4;
  61421. updatable?: boolean;
  61422. sourcePlane?: Plane;
  61423. }, scene?: Nullable<Scene>): Mesh;
  61424. /**
  61425. * Creates a ground mesh
  61426. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  61427. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  61428. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61429. * @param name defines the name of the mesh
  61430. * @param options defines the options used to create the mesh
  61431. * @param scene defines the hosting scene
  61432. * @returns the ground mesh
  61433. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  61434. */
  61435. static CreateGround(name: string, options: {
  61436. width?: number;
  61437. height?: number;
  61438. subdivisions?: number;
  61439. subdivisionsX?: number;
  61440. subdivisionsY?: number;
  61441. updatable?: boolean;
  61442. }, scene?: Nullable<Scene>): Mesh;
  61443. /**
  61444. * Creates a tiled ground mesh
  61445. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  61446. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  61447. * * 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
  61448. * * 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
  61449. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61450. * @param name defines the name of the mesh
  61451. * @param options defines the options used to create the mesh
  61452. * @param scene defines the hosting scene
  61453. * @returns the tiled ground mesh
  61454. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  61455. */
  61456. static CreateTiledGround(name: string, options: {
  61457. xmin: number;
  61458. zmin: number;
  61459. xmax: number;
  61460. zmax: number;
  61461. subdivisions?: {
  61462. w: number;
  61463. h: number;
  61464. };
  61465. precision?: {
  61466. w: number;
  61467. h: number;
  61468. };
  61469. updatable?: boolean;
  61470. }, scene?: Nullable<Scene>): Mesh;
  61471. /**
  61472. * Creates a ground mesh from a height map
  61473. * * The parameter `url` sets the URL of the height map image resource.
  61474. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  61475. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  61476. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  61477. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  61478. * * 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.
  61479. * * 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).
  61480. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  61481. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61482. * @param name defines the name of the mesh
  61483. * @param url defines the url to the height map
  61484. * @param options defines the options used to create the mesh
  61485. * @param scene defines the hosting scene
  61486. * @returns the ground mesh
  61487. * @see https://doc.babylonjs.com/babylon101/height_map
  61488. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  61489. */
  61490. static CreateGroundFromHeightMap(name: string, url: string, options: {
  61491. width?: number;
  61492. height?: number;
  61493. subdivisions?: number;
  61494. minHeight?: number;
  61495. maxHeight?: number;
  61496. colorFilter?: Color3;
  61497. alphaFilter?: number;
  61498. updatable?: boolean;
  61499. onReady?: (mesh: GroundMesh) => void;
  61500. }, scene?: Nullable<Scene>): GroundMesh;
  61501. /**
  61502. * Creates a polygon mesh
  61503. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61504. * * 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
  61505. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61506. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61507. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  61508. * * Remember you can only change the shape positions, not their number when updating a polygon
  61509. * @param name defines the name of the mesh
  61510. * @param options defines the options used to create the mesh
  61511. * @param scene defines the hosting scene
  61512. * @param earcutInjection can be used to inject your own earcut reference
  61513. * @returns the polygon mesh
  61514. */
  61515. static CreatePolygon(name: string, options: {
  61516. shape: Vector3[];
  61517. holes?: Vector3[][];
  61518. depth?: number;
  61519. faceUV?: Vector4[];
  61520. faceColors?: Color4[];
  61521. updatable?: boolean;
  61522. sideOrientation?: number;
  61523. frontUVs?: Vector4;
  61524. backUVs?: Vector4;
  61525. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61526. /**
  61527. * Creates an extruded polygon mesh, with depth in the Y direction.
  61528. * * 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)
  61529. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61530. * @param name defines the name of the mesh
  61531. * @param options defines the options used to create the mesh
  61532. * @param scene defines the hosting scene
  61533. * @param earcutInjection can be used to inject your own earcut reference
  61534. * @returns the polygon mesh
  61535. */
  61536. static ExtrudePolygon(name: string, options: {
  61537. shape: Vector3[];
  61538. holes?: Vector3[][];
  61539. depth?: number;
  61540. faceUV?: Vector4[];
  61541. faceColors?: Color4[];
  61542. updatable?: boolean;
  61543. sideOrientation?: number;
  61544. frontUVs?: Vector4;
  61545. backUVs?: Vector4;
  61546. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61547. /**
  61548. * Creates a tube mesh.
  61549. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61550. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61551. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61552. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61553. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61554. * * 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)
  61555. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61556. * * 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
  61557. * * 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
  61558. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61559. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61560. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61561. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61562. * @param name defines the name of the mesh
  61563. * @param options defines the options used to create the mesh
  61564. * @param scene defines the hosting scene
  61565. * @returns the tube mesh
  61566. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61567. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61568. */
  61569. static CreateTube(name: string, options: {
  61570. path: Vector3[];
  61571. radius?: number;
  61572. tessellation?: number;
  61573. radiusFunction?: {
  61574. (i: number, distance: number): number;
  61575. };
  61576. cap?: number;
  61577. arc?: number;
  61578. updatable?: boolean;
  61579. sideOrientation?: number;
  61580. frontUVs?: Vector4;
  61581. backUVs?: Vector4;
  61582. instance?: Mesh;
  61583. invertUV?: boolean;
  61584. }, scene?: Nullable<Scene>): Mesh;
  61585. /**
  61586. * Creates a polyhedron mesh
  61587. * * 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
  61588. * * The parameter `size` (positive float, default 1) sets the polygon size
  61589. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  61590. * * 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`
  61591. * * 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
  61592. * * 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)`)
  61593. * * 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
  61594. * * 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
  61595. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61596. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61597. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61598. * @param name defines the name of the mesh
  61599. * @param options defines the options used to create the mesh
  61600. * @param scene defines the hosting scene
  61601. * @returns the polyhedron mesh
  61602. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  61603. */
  61604. static CreatePolyhedron(name: string, options: {
  61605. type?: number;
  61606. size?: number;
  61607. sizeX?: number;
  61608. sizeY?: number;
  61609. sizeZ?: number;
  61610. custom?: any;
  61611. faceUV?: Vector4[];
  61612. faceColors?: Color4[];
  61613. flat?: boolean;
  61614. updatable?: boolean;
  61615. sideOrientation?: number;
  61616. frontUVs?: Vector4;
  61617. backUVs?: Vector4;
  61618. }, scene?: Nullable<Scene>): Mesh;
  61619. /**
  61620. * Creates a decal mesh.
  61621. * 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
  61622. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61623. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61624. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61625. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61626. * @param name defines the name of the mesh
  61627. * @param sourceMesh defines the mesh where the decal must be applied
  61628. * @param options defines the options used to create the mesh
  61629. * @param scene defines the hosting scene
  61630. * @returns the decal mesh
  61631. * @see https://doc.babylonjs.com/how_to/decals
  61632. */
  61633. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61634. position?: Vector3;
  61635. normal?: Vector3;
  61636. size?: Vector3;
  61637. angle?: number;
  61638. }): Mesh;
  61639. }
  61640. }
  61641. declare module "babylonjs/Meshes/meshSimplification" {
  61642. import { Mesh } from "babylonjs/Meshes/mesh";
  61643. /**
  61644. * A simplifier interface for future simplification implementations
  61645. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61646. */
  61647. export interface ISimplifier {
  61648. /**
  61649. * Simplification of a given mesh according to the given settings.
  61650. * Since this requires computation, it is assumed that the function runs async.
  61651. * @param settings The settings of the simplification, including quality and distance
  61652. * @param successCallback A callback that will be called after the mesh was simplified.
  61653. * @param errorCallback in case of an error, this callback will be called. optional.
  61654. */
  61655. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  61656. }
  61657. /**
  61658. * Expected simplification settings.
  61659. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  61660. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61661. */
  61662. export interface ISimplificationSettings {
  61663. /**
  61664. * Gets or sets the expected quality
  61665. */
  61666. quality: number;
  61667. /**
  61668. * Gets or sets the distance when this optimized version should be used
  61669. */
  61670. distance: number;
  61671. /**
  61672. * Gets an already optimized mesh
  61673. */
  61674. optimizeMesh?: boolean;
  61675. }
  61676. /**
  61677. * Class used to specify simplification options
  61678. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61679. */
  61680. export class SimplificationSettings implements ISimplificationSettings {
  61681. /** expected quality */
  61682. quality: number;
  61683. /** distance when this optimized version should be used */
  61684. distance: number;
  61685. /** already optimized mesh */
  61686. optimizeMesh?: boolean | undefined;
  61687. /**
  61688. * Creates a SimplificationSettings
  61689. * @param quality expected quality
  61690. * @param distance distance when this optimized version should be used
  61691. * @param optimizeMesh already optimized mesh
  61692. */
  61693. constructor(
  61694. /** expected quality */
  61695. quality: number,
  61696. /** distance when this optimized version should be used */
  61697. distance: number,
  61698. /** already optimized mesh */
  61699. optimizeMesh?: boolean | undefined);
  61700. }
  61701. /**
  61702. * Interface used to define a simplification task
  61703. */
  61704. export interface ISimplificationTask {
  61705. /**
  61706. * Array of settings
  61707. */
  61708. settings: Array<ISimplificationSettings>;
  61709. /**
  61710. * Simplification type
  61711. */
  61712. simplificationType: SimplificationType;
  61713. /**
  61714. * Mesh to simplify
  61715. */
  61716. mesh: Mesh;
  61717. /**
  61718. * Callback called on success
  61719. */
  61720. successCallback?: () => void;
  61721. /**
  61722. * Defines if parallel processing can be used
  61723. */
  61724. parallelProcessing: boolean;
  61725. }
  61726. /**
  61727. * Queue used to order the simplification tasks
  61728. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61729. */
  61730. export class SimplificationQueue {
  61731. private _simplificationArray;
  61732. /**
  61733. * Gets a boolean indicating that the process is still running
  61734. */
  61735. running: boolean;
  61736. /**
  61737. * Creates a new queue
  61738. */
  61739. constructor();
  61740. /**
  61741. * Adds a new simplification task
  61742. * @param task defines a task to add
  61743. */
  61744. addTask(task: ISimplificationTask): void;
  61745. /**
  61746. * Execute next task
  61747. */
  61748. executeNext(): void;
  61749. /**
  61750. * Execute a simplification task
  61751. * @param task defines the task to run
  61752. */
  61753. runSimplification(task: ISimplificationTask): void;
  61754. private getSimplifier;
  61755. }
  61756. /**
  61757. * The implemented types of simplification
  61758. * At the moment only Quadratic Error Decimation is implemented
  61759. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61760. */
  61761. export enum SimplificationType {
  61762. /** Quadratic error decimation */
  61763. QUADRATIC = 0
  61764. }
  61765. }
  61766. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  61767. import { Scene } from "babylonjs/scene";
  61768. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  61769. import { ISceneComponent } from "babylonjs/sceneComponent";
  61770. module "babylonjs/scene" {
  61771. interface Scene {
  61772. /** @hidden (Backing field) */
  61773. _simplificationQueue: SimplificationQueue;
  61774. /**
  61775. * Gets or sets the simplification queue attached to the scene
  61776. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61777. */
  61778. simplificationQueue: SimplificationQueue;
  61779. }
  61780. }
  61781. module "babylonjs/Meshes/mesh" {
  61782. interface Mesh {
  61783. /**
  61784. * Simplify the mesh according to the given array of settings.
  61785. * Function will return immediately and will simplify async
  61786. * @param settings a collection of simplification settings
  61787. * @param parallelProcessing should all levels calculate parallel or one after the other
  61788. * @param simplificationType the type of simplification to run
  61789. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  61790. * @returns the current mesh
  61791. */
  61792. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  61793. }
  61794. }
  61795. /**
  61796. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  61797. * created in a scene
  61798. */
  61799. export class SimplicationQueueSceneComponent implements ISceneComponent {
  61800. /**
  61801. * The component name helpfull to identify the component in the list of scene components.
  61802. */
  61803. readonly name: string;
  61804. /**
  61805. * The scene the component belongs to.
  61806. */
  61807. scene: Scene;
  61808. /**
  61809. * Creates a new instance of the component for the given scene
  61810. * @param scene Defines the scene to register the component in
  61811. */
  61812. constructor(scene: Scene);
  61813. /**
  61814. * Registers the component in a given scene
  61815. */
  61816. register(): void;
  61817. /**
  61818. * Rebuilds the elements related to this component in case of
  61819. * context lost for instance.
  61820. */
  61821. rebuild(): void;
  61822. /**
  61823. * Disposes the component and the associated ressources
  61824. */
  61825. dispose(): void;
  61826. private _beforeCameraUpdate;
  61827. }
  61828. }
  61829. declare module "babylonjs/Meshes/Builders/index" {
  61830. export * from "babylonjs/Meshes/Builders/boxBuilder";
  61831. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  61832. export * from "babylonjs/Meshes/Builders/discBuilder";
  61833. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  61834. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  61835. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  61836. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  61837. export * from "babylonjs/Meshes/Builders/torusBuilder";
  61838. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  61839. export * from "babylonjs/Meshes/Builders/linesBuilder";
  61840. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  61841. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  61842. export * from "babylonjs/Meshes/Builders/latheBuilder";
  61843. export * from "babylonjs/Meshes/Builders/planeBuilder";
  61844. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  61845. export * from "babylonjs/Meshes/Builders/groundBuilder";
  61846. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  61847. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  61848. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  61849. export * from "babylonjs/Meshes/Builders/decalBuilder";
  61850. }
  61851. declare module "babylonjs/Meshes/index" {
  61852. export * from "babylonjs/Meshes/abstractMesh";
  61853. export * from "babylonjs/Meshes/buffer";
  61854. export * from "babylonjs/Meshes/Compression/index";
  61855. export * from "babylonjs/Meshes/csg";
  61856. export * from "babylonjs/Meshes/geometry";
  61857. export * from "babylonjs/Meshes/groundMesh";
  61858. export * from "babylonjs/Meshes/trailMesh";
  61859. export * from "babylonjs/Meshes/instancedMesh";
  61860. export * from "babylonjs/Meshes/linesMesh";
  61861. export * from "babylonjs/Meshes/mesh";
  61862. export * from "babylonjs/Meshes/mesh.vertexData";
  61863. export * from "babylonjs/Meshes/meshBuilder";
  61864. export * from "babylonjs/Meshes/meshSimplification";
  61865. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  61866. export * from "babylonjs/Meshes/polygonMesh";
  61867. export * from "babylonjs/Meshes/subMesh";
  61868. export * from "babylonjs/Meshes/meshLODLevel";
  61869. export * from "babylonjs/Meshes/transformNode";
  61870. export * from "babylonjs/Meshes/Builders/index";
  61871. export * from "babylonjs/Meshes/dataBuffer";
  61872. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  61873. }
  61874. declare module "babylonjs/Morph/index" {
  61875. export * from "babylonjs/Morph/morphTarget";
  61876. export * from "babylonjs/Morph/morphTargetManager";
  61877. }
  61878. declare module "babylonjs/Navigation/INavigationEngine" {
  61879. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61880. import { Vector3 } from "babylonjs/Maths/math";
  61881. import { Mesh } from "babylonjs/Meshes/mesh";
  61882. import { Scene } from "babylonjs/scene";
  61883. /**
  61884. * Navigation plugin interface to add navigation constrained by a navigation mesh
  61885. */
  61886. export interface INavigationEnginePlugin {
  61887. /**
  61888. * plugin name
  61889. */
  61890. name: string;
  61891. /**
  61892. * Creates a navigation mesh
  61893. * @param meshes array of all the geometry used to compute the navigatio mesh
  61894. * @param parameters bunch of parameters used to filter geometry
  61895. */
  61896. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  61897. /**
  61898. * Create a navigation mesh debug mesh
  61899. * @param scene is where the mesh will be added
  61900. * @returns debug display mesh
  61901. */
  61902. createDebugNavMesh(scene: Scene): Mesh;
  61903. /**
  61904. * Get a navigation mesh constrained position, closest to the parameter position
  61905. * @param position world position
  61906. * @returns the closest point to position constrained by the navigation mesh
  61907. */
  61908. getClosestPoint(position: Vector3): Vector3;
  61909. /**
  61910. * Get a navigation mesh constrained position, within a particular radius
  61911. * @param position world position
  61912. * @param maxRadius the maximum distance to the constrained world position
  61913. * @returns the closest point to position constrained by the navigation mesh
  61914. */
  61915. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  61916. /**
  61917. * Compute the final position from a segment made of destination-position
  61918. * @param position world position
  61919. * @param destination world position
  61920. * @returns the resulting point along the navmesh
  61921. */
  61922. moveAlong(position: Vector3, destination: Vector3): Vector3;
  61923. /**
  61924. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  61925. * @param start world position
  61926. * @param end world position
  61927. * @returns array containing world position composing the path
  61928. */
  61929. computePath(start: Vector3, end: Vector3): Vector3[];
  61930. /**
  61931. * If this plugin is supported
  61932. * @returns true if plugin is supported
  61933. */
  61934. isSupported(): boolean;
  61935. /**
  61936. * Create a new Crowd so you can add agents
  61937. * @param maxAgents the maximum agent count in the crowd
  61938. * @param maxAgentRadius the maximum radius an agent can have
  61939. * @param scene to attach the crowd to
  61940. * @returns the crowd you can add agents to
  61941. */
  61942. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  61943. /**
  61944. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61945. * The queries will try to find a solution within those bounds
  61946. * default is (1,1,1)
  61947. * @param extent x,y,z value that define the extent around the queries point of reference
  61948. */
  61949. setDefaultQueryExtent(extent: Vector3): void;
  61950. /**
  61951. * Get the Bounding box extent specified by setDefaultQueryExtent
  61952. * @returns the box extent values
  61953. */
  61954. getDefaultQueryExtent(): Vector3;
  61955. /**
  61956. * Release all resources
  61957. */
  61958. dispose(): void;
  61959. }
  61960. /**
  61961. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  61962. */
  61963. export interface ICrowd {
  61964. /**
  61965. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  61966. * You can attach anything to that node. The node position is updated in the scene update tick.
  61967. * @param pos world position that will be constrained by the navigation mesh
  61968. * @param parameters agent parameters
  61969. * @param transform hooked to the agent that will be update by the scene
  61970. * @returns agent index
  61971. */
  61972. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  61973. /**
  61974. * Returns the agent position in world space
  61975. * @param index agent index returned by addAgent
  61976. * @returns world space position
  61977. */
  61978. getAgentPosition(index: number): Vector3;
  61979. /**
  61980. * Gets the agent velocity in world space
  61981. * @param index agent index returned by addAgent
  61982. * @returns world space velocity
  61983. */
  61984. getAgentVelocity(index: number): Vector3;
  61985. /**
  61986. * remove a particular agent previously created
  61987. * @param index agent index returned by addAgent
  61988. */
  61989. removeAgent(index: number): void;
  61990. /**
  61991. * get the list of all agents attached to this crowd
  61992. * @returns list of agent indices
  61993. */
  61994. getAgents(): number[];
  61995. /**
  61996. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  61997. * @param deltaTime in seconds
  61998. */
  61999. update(deltaTime: number): void;
  62000. /**
  62001. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62002. * @param index agent index returned by addAgent
  62003. * @param destination targeted world position
  62004. */
  62005. agentGoto(index: number, destination: Vector3): void;
  62006. /**
  62007. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62008. * The queries will try to find a solution within those bounds
  62009. * default is (1,1,1)
  62010. * @param extent x,y,z value that define the extent around the queries point of reference
  62011. */
  62012. setDefaultQueryExtent(extent: Vector3): void;
  62013. /**
  62014. * Get the Bounding box extent specified by setDefaultQueryExtent
  62015. * @returns the box extent values
  62016. */
  62017. getDefaultQueryExtent(): Vector3;
  62018. /**
  62019. * Release all resources
  62020. */
  62021. dispose(): void;
  62022. }
  62023. /**
  62024. * Configures an agent
  62025. */
  62026. export interface IAgentParameters {
  62027. /**
  62028. * Agent radius. [Limit: >= 0]
  62029. */
  62030. radius: number;
  62031. /**
  62032. * Agent height. [Limit: > 0]
  62033. */
  62034. height: number;
  62035. /**
  62036. * Maximum allowed acceleration. [Limit: >= 0]
  62037. */
  62038. maxAcceleration: number;
  62039. /**
  62040. * Maximum allowed speed. [Limit: >= 0]
  62041. */
  62042. maxSpeed: number;
  62043. /**
  62044. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  62045. */
  62046. collisionQueryRange: number;
  62047. /**
  62048. * The path visibility optimization range. [Limit: > 0]
  62049. */
  62050. pathOptimizationRange: number;
  62051. /**
  62052. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  62053. */
  62054. separationWeight: number;
  62055. }
  62056. /**
  62057. * Configures the navigation mesh creation
  62058. */
  62059. export interface INavMeshParameters {
  62060. /**
  62061. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  62062. */
  62063. cs: number;
  62064. /**
  62065. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  62066. */
  62067. ch: number;
  62068. /**
  62069. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  62070. */
  62071. walkableSlopeAngle: number;
  62072. /**
  62073. * Minimum floor to 'ceiling' height that will still allow the floor area to
  62074. * be considered walkable. [Limit: >= 3] [Units: vx]
  62075. */
  62076. walkableHeight: number;
  62077. /**
  62078. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  62079. */
  62080. walkableClimb: number;
  62081. /**
  62082. * The distance to erode/shrink the walkable area of the heightfield away from
  62083. * obstructions. [Limit: >=0] [Units: vx]
  62084. */
  62085. walkableRadius: number;
  62086. /**
  62087. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  62088. */
  62089. maxEdgeLen: number;
  62090. /**
  62091. * The maximum distance a simplfied contour's border edges should deviate
  62092. * the original raw contour. [Limit: >=0] [Units: vx]
  62093. */
  62094. maxSimplificationError: number;
  62095. /**
  62096. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  62097. */
  62098. minRegionArea: number;
  62099. /**
  62100. * Any regions with a span count smaller than this value will, if possible,
  62101. * be merged with larger regions. [Limit: >=0] [Units: vx]
  62102. */
  62103. mergeRegionArea: number;
  62104. /**
  62105. * The maximum number of vertices allowed for polygons generated during the
  62106. * contour to polygon conversion process. [Limit: >= 3]
  62107. */
  62108. maxVertsPerPoly: number;
  62109. /**
  62110. * Sets the sampling distance to use when generating the detail mesh.
  62111. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  62112. */
  62113. detailSampleDist: number;
  62114. /**
  62115. * The maximum distance the detail mesh surface should deviate from heightfield
  62116. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  62117. */
  62118. detailSampleMaxError: number;
  62119. }
  62120. }
  62121. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  62122. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  62123. import { Mesh } from "babylonjs/Meshes/mesh";
  62124. import { Scene } from "babylonjs/scene";
  62125. import { Vector3 } from "babylonjs/Maths/math";
  62126. import { TransformNode } from "babylonjs/Meshes/transformNode";
  62127. /**
  62128. * RecastJS navigation plugin
  62129. */
  62130. export class RecastJSPlugin implements INavigationEnginePlugin {
  62131. /**
  62132. * Reference to the Recast library
  62133. */
  62134. bjsRECAST: any;
  62135. /**
  62136. * plugin name
  62137. */
  62138. name: string;
  62139. /**
  62140. * the first navmesh created. We might extend this to support multiple navmeshes
  62141. */
  62142. navMesh: any;
  62143. /**
  62144. * Initializes the recastJS plugin
  62145. * @param recastInjection can be used to inject your own recast reference
  62146. */
  62147. constructor(recastInjection?: any);
  62148. /**
  62149. * Creates a navigation mesh
  62150. * @param meshes array of all the geometry used to compute the navigatio mesh
  62151. * @param parameters bunch of parameters used to filter geometry
  62152. */
  62153. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62154. /**
  62155. * Create a navigation mesh debug mesh
  62156. * @param scene is where the mesh will be added
  62157. * @returns debug display mesh
  62158. */
  62159. createDebugNavMesh(scene: Scene): Mesh;
  62160. /**
  62161. * Get a navigation mesh constrained position, closest to the parameter position
  62162. * @param position world position
  62163. * @returns the closest point to position constrained by the navigation mesh
  62164. */
  62165. getClosestPoint(position: Vector3): Vector3;
  62166. /**
  62167. * Get a navigation mesh constrained position, within a particular radius
  62168. * @param position world position
  62169. * @param maxRadius the maximum distance to the constrained world position
  62170. * @returns the closest point to position constrained by the navigation mesh
  62171. */
  62172. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62173. /**
  62174. * Compute the final position from a segment made of destination-position
  62175. * @param position world position
  62176. * @param destination world position
  62177. * @returns the resulting point along the navmesh
  62178. */
  62179. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62180. /**
  62181. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62182. * @param start world position
  62183. * @param end world position
  62184. * @returns array containing world position composing the path
  62185. */
  62186. computePath(start: Vector3, end: Vector3): Vector3[];
  62187. /**
  62188. * Create a new Crowd so you can add agents
  62189. * @param maxAgents the maximum agent count in the crowd
  62190. * @param maxAgentRadius the maximum radius an agent can have
  62191. * @param scene to attach the crowd to
  62192. * @returns the crowd you can add agents to
  62193. */
  62194. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62195. /**
  62196. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62197. * The queries will try to find a solution within those bounds
  62198. * default is (1,1,1)
  62199. * @param extent x,y,z value that define the extent around the queries point of reference
  62200. */
  62201. setDefaultQueryExtent(extent: Vector3): void;
  62202. /**
  62203. * Get the Bounding box extent specified by setDefaultQueryExtent
  62204. * @returns the box extent values
  62205. */
  62206. getDefaultQueryExtent(): Vector3;
  62207. /**
  62208. * Disposes
  62209. */
  62210. dispose(): void;
  62211. /**
  62212. * If this plugin is supported
  62213. * @returns true if plugin is supported
  62214. */
  62215. isSupported(): boolean;
  62216. }
  62217. /**
  62218. * Recast detour crowd implementation
  62219. */
  62220. export class RecastJSCrowd implements ICrowd {
  62221. /**
  62222. * Recast/detour plugin
  62223. */
  62224. bjsRECASTPlugin: RecastJSPlugin;
  62225. /**
  62226. * Link to the detour crowd
  62227. */
  62228. recastCrowd: any;
  62229. /**
  62230. * One transform per agent
  62231. */
  62232. transforms: TransformNode[];
  62233. /**
  62234. * All agents created
  62235. */
  62236. agents: number[];
  62237. /**
  62238. * Link to the scene is kept to unregister the crowd from the scene
  62239. */
  62240. private _scene;
  62241. /**
  62242. * Observer for crowd updates
  62243. */
  62244. private _onBeforeAnimationsObserver;
  62245. /**
  62246. * Constructor
  62247. * @param plugin recastJS plugin
  62248. * @param maxAgents the maximum agent count in the crowd
  62249. * @param maxAgentRadius the maximum radius an agent can have
  62250. * @param scene to attach the crowd to
  62251. * @returns the crowd you can add agents to
  62252. */
  62253. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  62254. /**
  62255. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62256. * You can attach anything to that node. The node position is updated in the scene update tick.
  62257. * @param pos world position that will be constrained by the navigation mesh
  62258. * @param parameters agent parameters
  62259. * @param transform hooked to the agent that will be update by the scene
  62260. * @returns agent index
  62261. */
  62262. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62263. /**
  62264. * Returns the agent position in world space
  62265. * @param index agent index returned by addAgent
  62266. * @returns world space position
  62267. */
  62268. getAgentPosition(index: number): Vector3;
  62269. /**
  62270. * Returns the agent velocity in world space
  62271. * @param index agent index returned by addAgent
  62272. * @returns world space velocity
  62273. */
  62274. getAgentVelocity(index: number): Vector3;
  62275. /**
  62276. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62277. * @param index agent index returned by addAgent
  62278. * @param destination targeted world position
  62279. */
  62280. agentGoto(index: number, destination: Vector3): void;
  62281. /**
  62282. * remove a particular agent previously created
  62283. * @param index agent index returned by addAgent
  62284. */
  62285. removeAgent(index: number): void;
  62286. /**
  62287. * get the list of all agents attached to this crowd
  62288. * @returns list of agent indices
  62289. */
  62290. getAgents(): number[];
  62291. /**
  62292. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62293. * @param deltaTime in seconds
  62294. */
  62295. update(deltaTime: number): void;
  62296. /**
  62297. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62298. * The queries will try to find a solution within those bounds
  62299. * default is (1,1,1)
  62300. * @param extent x,y,z value that define the extent around the queries point of reference
  62301. */
  62302. setDefaultQueryExtent(extent: Vector3): void;
  62303. /**
  62304. * Get the Bounding box extent specified by setDefaultQueryExtent
  62305. * @returns the box extent values
  62306. */
  62307. getDefaultQueryExtent(): Vector3;
  62308. /**
  62309. * Release all resources
  62310. */
  62311. dispose(): void;
  62312. }
  62313. }
  62314. declare module "babylonjs/Navigation/Plugins/index" {
  62315. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  62316. }
  62317. declare module "babylonjs/Navigation/index" {
  62318. export * from "babylonjs/Navigation/INavigationEngine";
  62319. export * from "babylonjs/Navigation/Plugins/index";
  62320. }
  62321. declare module "babylonjs/Offline/database" {
  62322. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  62323. /**
  62324. * Class used to enable access to IndexedDB
  62325. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  62326. */
  62327. export class Database implements IOfflineProvider {
  62328. private _callbackManifestChecked;
  62329. private _currentSceneUrl;
  62330. private _db;
  62331. private _enableSceneOffline;
  62332. private _enableTexturesOffline;
  62333. private _manifestVersionFound;
  62334. private _mustUpdateRessources;
  62335. private _hasReachedQuota;
  62336. private _isSupported;
  62337. private _idbFactory;
  62338. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  62339. private static IsUASupportingBlobStorage;
  62340. /**
  62341. * Gets a boolean indicating if Database storate is enabled (off by default)
  62342. */
  62343. static IDBStorageEnabled: boolean;
  62344. /**
  62345. * Gets a boolean indicating if scene must be saved in the database
  62346. */
  62347. readonly enableSceneOffline: boolean;
  62348. /**
  62349. * Gets a boolean indicating if textures must be saved in the database
  62350. */
  62351. readonly enableTexturesOffline: boolean;
  62352. /**
  62353. * Creates a new Database
  62354. * @param urlToScene defines the url to load the scene
  62355. * @param callbackManifestChecked defines the callback to use when manifest is checked
  62356. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  62357. */
  62358. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  62359. private static _ParseURL;
  62360. private static _ReturnFullUrlLocation;
  62361. private _checkManifestFile;
  62362. /**
  62363. * Open the database and make it available
  62364. * @param successCallback defines the callback to call on success
  62365. * @param errorCallback defines the callback to call on error
  62366. */
  62367. open(successCallback: () => void, errorCallback: () => void): void;
  62368. /**
  62369. * Loads an image from the database
  62370. * @param url defines the url to load from
  62371. * @param image defines the target DOM image
  62372. */
  62373. loadImage(url: string, image: HTMLImageElement): void;
  62374. private _loadImageFromDBAsync;
  62375. private _saveImageIntoDBAsync;
  62376. private _checkVersionFromDB;
  62377. private _loadVersionFromDBAsync;
  62378. private _saveVersionIntoDBAsync;
  62379. /**
  62380. * Loads a file from database
  62381. * @param url defines the URL to load from
  62382. * @param sceneLoaded defines a callback to call on success
  62383. * @param progressCallBack defines a callback to call when progress changed
  62384. * @param errorCallback defines a callback to call on error
  62385. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  62386. */
  62387. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  62388. private _loadFileAsync;
  62389. private _saveFileAsync;
  62390. /**
  62391. * Validates if xhr data is correct
  62392. * @param xhr defines the request to validate
  62393. * @param dataType defines the expected data type
  62394. * @returns true if data is correct
  62395. */
  62396. private static _ValidateXHRData;
  62397. }
  62398. }
  62399. declare module "babylonjs/Offline/index" {
  62400. export * from "babylonjs/Offline/database";
  62401. export * from "babylonjs/Offline/IOfflineProvider";
  62402. }
  62403. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  62404. /** @hidden */
  62405. export var gpuUpdateParticlesPixelShader: {
  62406. name: string;
  62407. shader: string;
  62408. };
  62409. }
  62410. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  62411. /** @hidden */
  62412. export var gpuUpdateParticlesVertexShader: {
  62413. name: string;
  62414. shader: string;
  62415. };
  62416. }
  62417. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  62418. /** @hidden */
  62419. export var clipPlaneFragmentDeclaration2: {
  62420. name: string;
  62421. shader: string;
  62422. };
  62423. }
  62424. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  62425. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  62426. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  62427. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62428. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  62429. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  62430. /** @hidden */
  62431. export var gpuRenderParticlesPixelShader: {
  62432. name: string;
  62433. shader: string;
  62434. };
  62435. }
  62436. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  62437. /** @hidden */
  62438. export var clipPlaneVertexDeclaration2: {
  62439. name: string;
  62440. shader: string;
  62441. };
  62442. }
  62443. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  62444. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  62445. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  62446. /** @hidden */
  62447. export var gpuRenderParticlesVertexShader: {
  62448. name: string;
  62449. shader: string;
  62450. };
  62451. }
  62452. declare module "babylonjs/Particles/gpuParticleSystem" {
  62453. import { Nullable } from "babylonjs/types";
  62454. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  62455. import { Observable } from "babylonjs/Misc/observable";
  62456. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  62457. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62458. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  62459. import { Scene, IDisposable } from "babylonjs/scene";
  62460. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  62461. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  62462. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  62463. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  62464. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  62465. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  62466. /**
  62467. * This represents a GPU particle system in Babylon
  62468. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  62469. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  62470. */
  62471. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  62472. /**
  62473. * The layer mask we are rendering the particles through.
  62474. */
  62475. layerMask: number;
  62476. private _capacity;
  62477. private _activeCount;
  62478. private _currentActiveCount;
  62479. private _accumulatedCount;
  62480. private _renderEffect;
  62481. private _updateEffect;
  62482. private _buffer0;
  62483. private _buffer1;
  62484. private _spriteBuffer;
  62485. private _updateVAO;
  62486. private _renderVAO;
  62487. private _targetIndex;
  62488. private _sourceBuffer;
  62489. private _targetBuffer;
  62490. private _engine;
  62491. private _currentRenderId;
  62492. private _started;
  62493. private _stopped;
  62494. private _timeDelta;
  62495. private _randomTexture;
  62496. private _randomTexture2;
  62497. private _attributesStrideSize;
  62498. private _updateEffectOptions;
  62499. private _randomTextureSize;
  62500. private _actualFrame;
  62501. private readonly _rawTextureWidth;
  62502. /**
  62503. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  62504. */
  62505. static readonly IsSupported: boolean;
  62506. /**
  62507. * An event triggered when the system is disposed.
  62508. */
  62509. onDisposeObservable: Observable<GPUParticleSystem>;
  62510. /**
  62511. * Gets the maximum number of particles active at the same time.
  62512. * @returns The max number of active particles.
  62513. */
  62514. getCapacity(): number;
  62515. /**
  62516. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  62517. * to override the particles.
  62518. */
  62519. forceDepthWrite: boolean;
  62520. /**
  62521. * Gets or set the number of active particles
  62522. */
  62523. activeParticleCount: number;
  62524. private _preWarmDone;
  62525. /**
  62526. * Is this system ready to be used/rendered
  62527. * @return true if the system is ready
  62528. */
  62529. isReady(): boolean;
  62530. /**
  62531. * Gets if the system has been started. (Note: this will still be true after stop is called)
  62532. * @returns True if it has been started, otherwise false.
  62533. */
  62534. isStarted(): boolean;
  62535. /**
  62536. * Starts the particle system and begins to emit
  62537. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  62538. */
  62539. start(delay?: number): void;
  62540. /**
  62541. * Stops the particle system.
  62542. */
  62543. stop(): void;
  62544. /**
  62545. * Remove all active particles
  62546. */
  62547. reset(): void;
  62548. /**
  62549. * Returns the string "GPUParticleSystem"
  62550. * @returns a string containing the class name
  62551. */
  62552. getClassName(): string;
  62553. private _colorGradientsTexture;
  62554. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  62555. /**
  62556. * Adds a new color gradient
  62557. * @param gradient defines the gradient to use (between 0 and 1)
  62558. * @param color1 defines the color to affect to the specified gradient
  62559. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  62560. * @returns the current particle system
  62561. */
  62562. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  62563. /**
  62564. * Remove a specific color gradient
  62565. * @param gradient defines the gradient to remove
  62566. * @returns the current particle system
  62567. */
  62568. removeColorGradient(gradient: number): GPUParticleSystem;
  62569. private _angularSpeedGradientsTexture;
  62570. private _sizeGradientsTexture;
  62571. private _velocityGradientsTexture;
  62572. private _limitVelocityGradientsTexture;
  62573. private _dragGradientsTexture;
  62574. private _addFactorGradient;
  62575. /**
  62576. * Adds a new size gradient
  62577. * @param gradient defines the gradient to use (between 0 and 1)
  62578. * @param factor defines the size factor to affect to the specified gradient
  62579. * @returns the current particle system
  62580. */
  62581. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  62582. /**
  62583. * Remove a specific size gradient
  62584. * @param gradient defines the gradient to remove
  62585. * @returns the current particle system
  62586. */
  62587. removeSizeGradient(gradient: number): GPUParticleSystem;
  62588. /**
  62589. * Adds a new angular speed gradient
  62590. * @param gradient defines the gradient to use (between 0 and 1)
  62591. * @param factor defines the angular speed to affect to the specified gradient
  62592. * @returns the current particle system
  62593. */
  62594. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  62595. /**
  62596. * Remove a specific angular speed gradient
  62597. * @param gradient defines the gradient to remove
  62598. * @returns the current particle system
  62599. */
  62600. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  62601. /**
  62602. * Adds a new velocity gradient
  62603. * @param gradient defines the gradient to use (between 0 and 1)
  62604. * @param factor defines the velocity to affect to the specified gradient
  62605. * @returns the current particle system
  62606. */
  62607. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62608. /**
  62609. * Remove a specific velocity gradient
  62610. * @param gradient defines the gradient to remove
  62611. * @returns the current particle system
  62612. */
  62613. removeVelocityGradient(gradient: number): GPUParticleSystem;
  62614. /**
  62615. * Adds a new limit velocity gradient
  62616. * @param gradient defines the gradient to use (between 0 and 1)
  62617. * @param factor defines the limit velocity value to affect to the specified gradient
  62618. * @returns the current particle system
  62619. */
  62620. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62621. /**
  62622. * Remove a specific limit velocity gradient
  62623. * @param gradient defines the gradient to remove
  62624. * @returns the current particle system
  62625. */
  62626. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  62627. /**
  62628. * Adds a new drag gradient
  62629. * @param gradient defines the gradient to use (between 0 and 1)
  62630. * @param factor defines the drag value to affect to the specified gradient
  62631. * @returns the current particle system
  62632. */
  62633. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  62634. /**
  62635. * Remove a specific drag gradient
  62636. * @param gradient defines the gradient to remove
  62637. * @returns the current particle system
  62638. */
  62639. removeDragGradient(gradient: number): GPUParticleSystem;
  62640. /**
  62641. * Not supported by GPUParticleSystem
  62642. * @param gradient defines the gradient to use (between 0 and 1)
  62643. * @param factor defines the emit rate value to affect to the specified gradient
  62644. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62645. * @returns the current particle system
  62646. */
  62647. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62648. /**
  62649. * Not supported by GPUParticleSystem
  62650. * @param gradient defines the gradient to remove
  62651. * @returns the current particle system
  62652. */
  62653. removeEmitRateGradient(gradient: number): IParticleSystem;
  62654. /**
  62655. * Not supported by GPUParticleSystem
  62656. * @param gradient defines the gradient to use (between 0 and 1)
  62657. * @param factor defines the start size value to affect to the specified gradient
  62658. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62659. * @returns the current particle system
  62660. */
  62661. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62662. /**
  62663. * Not supported by GPUParticleSystem
  62664. * @param gradient defines the gradient to remove
  62665. * @returns the current particle system
  62666. */
  62667. removeStartSizeGradient(gradient: number): IParticleSystem;
  62668. /**
  62669. * Not supported by GPUParticleSystem
  62670. * @param gradient defines the gradient to use (between 0 and 1)
  62671. * @param min defines the color remap minimal range
  62672. * @param max defines the color remap maximal range
  62673. * @returns the current particle system
  62674. */
  62675. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62676. /**
  62677. * Not supported by GPUParticleSystem
  62678. * @param gradient defines the gradient to remove
  62679. * @returns the current particle system
  62680. */
  62681. removeColorRemapGradient(): IParticleSystem;
  62682. /**
  62683. * Not supported by GPUParticleSystem
  62684. * @param gradient defines the gradient to use (between 0 and 1)
  62685. * @param min defines the alpha remap minimal range
  62686. * @param max defines the alpha remap maximal range
  62687. * @returns the current particle system
  62688. */
  62689. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62690. /**
  62691. * Not supported by GPUParticleSystem
  62692. * @param gradient defines the gradient to remove
  62693. * @returns the current particle system
  62694. */
  62695. removeAlphaRemapGradient(): IParticleSystem;
  62696. /**
  62697. * Not supported by GPUParticleSystem
  62698. * @param gradient defines the gradient to use (between 0 and 1)
  62699. * @param color defines the color to affect to the specified gradient
  62700. * @returns the current particle system
  62701. */
  62702. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  62703. /**
  62704. * Not supported by GPUParticleSystem
  62705. * @param gradient defines the gradient to remove
  62706. * @returns the current particle system
  62707. */
  62708. removeRampGradient(): IParticleSystem;
  62709. /**
  62710. * Not supported by GPUParticleSystem
  62711. * @returns the list of ramp gradients
  62712. */
  62713. getRampGradients(): Nullable<Array<Color3Gradient>>;
  62714. /**
  62715. * Not supported by GPUParticleSystem
  62716. * Gets or sets a boolean indicating that ramp gradients must be used
  62717. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  62718. */
  62719. useRampGradients: boolean;
  62720. /**
  62721. * Not supported by GPUParticleSystem
  62722. * @param gradient defines the gradient to use (between 0 and 1)
  62723. * @param factor defines the life time factor to affect to the specified gradient
  62724. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62725. * @returns the current particle system
  62726. */
  62727. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62728. /**
  62729. * Not supported by GPUParticleSystem
  62730. * @param gradient defines the gradient to remove
  62731. * @returns the current particle system
  62732. */
  62733. removeLifeTimeGradient(gradient: number): IParticleSystem;
  62734. /**
  62735. * Instantiates a GPU particle system.
  62736. * 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.
  62737. * @param name The name of the particle system
  62738. * @param options The options used to create the system
  62739. * @param scene The scene the particle system belongs to
  62740. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  62741. */
  62742. constructor(name: string, options: Partial<{
  62743. capacity: number;
  62744. randomTextureSize: number;
  62745. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  62746. protected _reset(): void;
  62747. private _createUpdateVAO;
  62748. private _createRenderVAO;
  62749. private _initialize;
  62750. /** @hidden */
  62751. _recreateUpdateEffect(): void;
  62752. /** @hidden */
  62753. _recreateRenderEffect(): void;
  62754. /**
  62755. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  62756. * @param preWarm defines if we are in the pre-warmimg phase
  62757. */
  62758. animate(preWarm?: boolean): void;
  62759. private _createFactorGradientTexture;
  62760. private _createSizeGradientTexture;
  62761. private _createAngularSpeedGradientTexture;
  62762. private _createVelocityGradientTexture;
  62763. private _createLimitVelocityGradientTexture;
  62764. private _createDragGradientTexture;
  62765. private _createColorGradientTexture;
  62766. /**
  62767. * Renders the particle system in its current state
  62768. * @param preWarm defines if the system should only update the particles but not render them
  62769. * @returns the current number of particles
  62770. */
  62771. render(preWarm?: boolean): number;
  62772. /**
  62773. * Rebuilds the particle system
  62774. */
  62775. rebuild(): void;
  62776. private _releaseBuffers;
  62777. private _releaseVAOs;
  62778. /**
  62779. * Disposes the particle system and free the associated resources
  62780. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  62781. */
  62782. dispose(disposeTexture?: boolean): void;
  62783. /**
  62784. * Clones the particle system.
  62785. * @param name The name of the cloned object
  62786. * @param newEmitter The new emitter to use
  62787. * @returns the cloned particle system
  62788. */
  62789. clone(name: string, newEmitter: any): GPUParticleSystem;
  62790. /**
  62791. * Serializes the particle system to a JSON object.
  62792. * @returns the JSON object
  62793. */
  62794. serialize(): any;
  62795. /**
  62796. * Parses a JSON object to create a GPU particle system.
  62797. * @param parsedParticleSystem The JSON object to parse
  62798. * @param scene The scene to create the particle system in
  62799. * @param rootUrl The root url to use to load external dependencies like texture
  62800. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  62801. * @returns the parsed GPU particle system
  62802. */
  62803. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  62804. }
  62805. }
  62806. declare module "babylonjs/Particles/particleSystemSet" {
  62807. import { Nullable } from "babylonjs/types";
  62808. import { Color3 } from "babylonjs/Maths/math.color";
  62809. import { TransformNode } from "babylonjs/Meshes/transformNode";
  62810. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62811. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62812. import { Scene, IDisposable } from "babylonjs/scene";
  62813. /**
  62814. * Represents a set of particle systems working together to create a specific effect
  62815. */
  62816. export class ParticleSystemSet implements IDisposable {
  62817. /**
  62818. * Gets or sets base Assets URL
  62819. */
  62820. static BaseAssetsUrl: string;
  62821. private _emitterCreationOptions;
  62822. private _emitterNode;
  62823. /**
  62824. * Gets the particle system list
  62825. */
  62826. systems: IParticleSystem[];
  62827. /**
  62828. * Gets the emitter node used with this set
  62829. */
  62830. readonly emitterNode: Nullable<TransformNode>;
  62831. /**
  62832. * Creates a new emitter mesh as a sphere
  62833. * @param options defines the options used to create the sphere
  62834. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  62835. * @param scene defines the hosting scene
  62836. */
  62837. setEmitterAsSphere(options: {
  62838. diameter: number;
  62839. segments: number;
  62840. color: Color3;
  62841. }, renderingGroupId: number, scene: Scene): void;
  62842. /**
  62843. * Starts all particle systems of the set
  62844. * @param emitter defines an optional mesh to use as emitter for the particle systems
  62845. */
  62846. start(emitter?: AbstractMesh): void;
  62847. /**
  62848. * Release all associated resources
  62849. */
  62850. dispose(): void;
  62851. /**
  62852. * Serialize the set into a JSON compatible object
  62853. * @returns a JSON compatible representation of the set
  62854. */
  62855. serialize(): any;
  62856. /**
  62857. * Parse a new ParticleSystemSet from a serialized source
  62858. * @param data defines a JSON compatible representation of the set
  62859. * @param scene defines the hosting scene
  62860. * @param gpu defines if we want GPU particles or CPU particles
  62861. * @returns a new ParticleSystemSet
  62862. */
  62863. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  62864. }
  62865. }
  62866. declare module "babylonjs/Particles/particleHelper" {
  62867. import { Nullable } from "babylonjs/types";
  62868. import { Scene } from "babylonjs/scene";
  62869. import { Vector3 } from "babylonjs/Maths/math.vector";
  62870. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62871. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62872. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  62873. /**
  62874. * This class is made for on one-liner static method to help creating particle system set.
  62875. */
  62876. export class ParticleHelper {
  62877. /**
  62878. * Gets or sets base Assets URL
  62879. */
  62880. static BaseAssetsUrl: string;
  62881. /**
  62882. * Create a default particle system that you can tweak
  62883. * @param emitter defines the emitter to use
  62884. * @param capacity defines the system capacity (default is 500 particles)
  62885. * @param scene defines the hosting scene
  62886. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  62887. * @returns the new Particle system
  62888. */
  62889. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  62890. /**
  62891. * This is the main static method (one-liner) of this helper to create different particle systems
  62892. * @param type This string represents the type to the particle system to create
  62893. * @param scene The scene where the particle system should live
  62894. * @param gpu If the system will use gpu
  62895. * @returns the ParticleSystemSet created
  62896. */
  62897. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  62898. /**
  62899. * Static function used to export a particle system to a ParticleSystemSet variable.
  62900. * Please note that the emitter shape is not exported
  62901. * @param systems defines the particle systems to export
  62902. * @returns the created particle system set
  62903. */
  62904. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  62905. }
  62906. }
  62907. declare module "babylonjs/Particles/particleSystemComponent" {
  62908. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62909. import { Effect } from "babylonjs/Materials/effect";
  62910. import "babylonjs/Shaders/particles.vertex";
  62911. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  62912. module "babylonjs/Engines/engine" {
  62913. interface Engine {
  62914. /**
  62915. * Create an effect to use with particle systems.
  62916. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  62917. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  62918. * @param uniformsNames defines a list of attribute names
  62919. * @param samplers defines an array of string used to represent textures
  62920. * @param defines defines the string containing the defines to use to compile the shaders
  62921. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  62922. * @param onCompiled defines a function to call when the effect creation is successful
  62923. * @param onError defines a function to call when the effect creation has failed
  62924. * @returns the new Effect
  62925. */
  62926. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  62927. }
  62928. }
  62929. module "babylonjs/Meshes/mesh" {
  62930. interface Mesh {
  62931. /**
  62932. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  62933. * @returns an array of IParticleSystem
  62934. */
  62935. getEmittedParticleSystems(): IParticleSystem[];
  62936. /**
  62937. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  62938. * @returns an array of IParticleSystem
  62939. */
  62940. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  62941. }
  62942. }
  62943. /**
  62944. * @hidden
  62945. */
  62946. export var _IDoNeedToBeInTheBuild: number;
  62947. }
  62948. declare module "babylonjs/Particles/pointsCloudSystem" {
  62949. import { Color4 } from "babylonjs/Maths/math";
  62950. import { Mesh } from "babylonjs/Meshes/mesh";
  62951. import { Scene, IDisposable } from "babylonjs/scene";
  62952. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  62953. /** Defines the 4 color options */
  62954. export enum PointColor {
  62955. /** color value */
  62956. Color = 2,
  62957. /** uv value */
  62958. UV = 1,
  62959. /** random value */
  62960. Random = 0,
  62961. /** stated value */
  62962. Stated = 3
  62963. }
  62964. /**
  62965. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  62966. * 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.
  62967. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  62968. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  62969. *
  62970. * Full documentation here : TO BE ENTERED
  62971. */
  62972. export class PointsCloudSystem implements IDisposable {
  62973. /**
  62974. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  62975. * Example : var p = SPS.particles[i];
  62976. */
  62977. particles: CloudPoint[];
  62978. /**
  62979. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  62980. */
  62981. nbParticles: number;
  62982. /**
  62983. * This a counter for your own usage. It's not set by any SPS functions.
  62984. */
  62985. counter: number;
  62986. /**
  62987. * The PCS name. This name is also given to the underlying mesh.
  62988. */
  62989. name: string;
  62990. /**
  62991. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  62992. */
  62993. mesh: Mesh;
  62994. /**
  62995. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  62996. * Please read :
  62997. */
  62998. vars: any;
  62999. /**
  63000. * @hidden
  63001. */
  63002. _size: number;
  63003. private _scene;
  63004. private _promises;
  63005. private _positions;
  63006. private _indices;
  63007. private _normals;
  63008. private _colors;
  63009. private _uvs;
  63010. private _indices32;
  63011. private _positions32;
  63012. private _colors32;
  63013. private _uvs32;
  63014. private _updatable;
  63015. private _isVisibilityBoxLocked;
  63016. private _alwaysVisible;
  63017. private _groups;
  63018. private _groupCounter;
  63019. private _computeParticleColor;
  63020. private _computeParticleTexture;
  63021. private _computeParticleRotation;
  63022. private _computeBoundingBox;
  63023. private _isReady;
  63024. /**
  63025. * Creates a PCS (Points Cloud System) object
  63026. * @param name (String) is the PCS name, this will be the underlying mesh name
  63027. * @param pointSize (number) is the size for each point
  63028. * @param scene (Scene) is the scene in which the PCS is added
  63029. * @param options defines the options of the PCS e.g.
  63030. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  63031. */
  63032. constructor(name: string, pointSize: number, scene: Scene, options?: {
  63033. updatable?: boolean;
  63034. });
  63035. /**
  63036. * Builds the PCS underlying mesh. Returns a standard Mesh.
  63037. * If no points were added to the PCS, the returned mesh is just a single point.
  63038. * @returns a promise for the created mesh
  63039. */
  63040. buildMeshAsync(): Promise<Mesh>;
  63041. /**
  63042. * @hidden
  63043. */
  63044. private _buildMesh;
  63045. private _addParticle;
  63046. private _randomUnitVector;
  63047. private _getColorIndicesForCoord;
  63048. private _setPointsColorOrUV;
  63049. private _colorFromTexture;
  63050. private _calculateDensity;
  63051. /**
  63052. * Adds points to the PCS in random positions within a unit sphere
  63053. * @param nb (positive integer) the number of particles to be created from this model
  63054. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  63055. * @returns the number of groups in the system
  63056. */
  63057. addPoints(nb: number, pointFunction?: any): number;
  63058. /**
  63059. * Adds points to the PCS from the surface of the model shape
  63060. * @param mesh is any Mesh object that will be used as a surface model for the points
  63061. * @param nb (positive integer) the number of particles to be created from this model
  63062. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63063. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63064. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63065. * @returns the number of groups in the system
  63066. */
  63067. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63068. /**
  63069. * Adds points to the PCS inside the model shape
  63070. * @param mesh is any Mesh object that will be used as a surface model for the points
  63071. * @param nb (positive integer) the number of particles to be created from this model
  63072. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63073. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63074. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63075. * @returns the number of groups in the system
  63076. */
  63077. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63078. /**
  63079. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  63080. * This method calls `updateParticle()` for each particle of the SPS.
  63081. * For an animated SPS, it is usually called within the render loop.
  63082. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  63083. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  63084. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  63085. * @returns the PCS.
  63086. */
  63087. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  63088. /**
  63089. * Disposes the PCS.
  63090. */
  63091. dispose(): void;
  63092. /**
  63093. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  63094. * doc :
  63095. * @returns the PCS.
  63096. */
  63097. refreshVisibleSize(): PointsCloudSystem;
  63098. /**
  63099. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  63100. * @param size the size (float) of the visibility box
  63101. * note : this doesn't lock the PCS mesh bounding box.
  63102. * doc :
  63103. */
  63104. setVisibilityBox(size: number): void;
  63105. /**
  63106. * Gets whether the PCS is always visible or not
  63107. * doc :
  63108. */
  63109. /**
  63110. * Sets the PCS as always visible or not
  63111. * doc :
  63112. */
  63113. isAlwaysVisible: boolean;
  63114. /**
  63115. * Tells to `setParticles()` to compute the particle rotations or not
  63116. * Default value : false. The PCS is faster when it's set to false
  63117. * Note : particle rotations are only applied to parent particles
  63118. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  63119. */
  63120. computeParticleRotation: boolean;
  63121. /**
  63122. * Tells to `setParticles()` to compute the particle colors or not.
  63123. * Default value : true. The PCS is faster when it's set to false.
  63124. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63125. */
  63126. /**
  63127. * Gets if `setParticles()` computes the particle colors or not.
  63128. * Default value : false. The PCS is faster when it's set to false.
  63129. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63130. */
  63131. computeParticleColor: boolean;
  63132. /**
  63133. * Gets if `setParticles()` computes the particle textures or not.
  63134. * Default value : false. The PCS is faster when it's set to false.
  63135. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  63136. */
  63137. computeParticleTexture: boolean;
  63138. /**
  63139. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  63140. */
  63141. /**
  63142. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  63143. */
  63144. computeBoundingBox: boolean;
  63145. /**
  63146. * This function does nothing. It may be overwritten to set all the particle first values.
  63147. * The PCS doesn't call this function, you may have to call it by your own.
  63148. * doc :
  63149. */
  63150. initParticles(): void;
  63151. /**
  63152. * This function does nothing. It may be overwritten to recycle a particle
  63153. * The PCS doesn't call this function, you can to call it
  63154. * doc :
  63155. * @param particle The particle to recycle
  63156. * @returns the recycled particle
  63157. */
  63158. recycleParticle(particle: CloudPoint): CloudPoint;
  63159. /**
  63160. * Updates a particle : this function should be overwritten by the user.
  63161. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  63162. * doc :
  63163. * @example : just set a particle position or velocity and recycle conditions
  63164. * @param particle The particle to update
  63165. * @returns the updated particle
  63166. */
  63167. updateParticle(particle: CloudPoint): CloudPoint;
  63168. /**
  63169. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  63170. * This does nothing and may be overwritten by the user.
  63171. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63172. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63173. * @param update the boolean update value actually passed to setParticles()
  63174. */
  63175. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63176. /**
  63177. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  63178. * This will be passed three parameters.
  63179. * This does nothing and may be overwritten by the user.
  63180. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63181. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63182. * @param update the boolean update value actually passed to setParticles()
  63183. */
  63184. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63185. }
  63186. }
  63187. declare module "babylonjs/Particles/cloudPoint" {
  63188. import { Nullable } from "babylonjs/types";
  63189. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  63190. import { Mesh } from "babylonjs/Meshes/mesh";
  63191. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  63192. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  63193. /**
  63194. * Represents one particle of a points cloud system.
  63195. */
  63196. export class CloudPoint {
  63197. /**
  63198. * particle global index
  63199. */
  63200. idx: number;
  63201. /**
  63202. * The color of the particle
  63203. */
  63204. color: Nullable<Color4>;
  63205. /**
  63206. * The world space position of the particle.
  63207. */
  63208. position: Vector3;
  63209. /**
  63210. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  63211. */
  63212. rotation: Vector3;
  63213. /**
  63214. * The world space rotation quaternion of the particle.
  63215. */
  63216. rotationQuaternion: Nullable<Quaternion>;
  63217. /**
  63218. * The uv of the particle.
  63219. */
  63220. uv: Nullable<Vector2>;
  63221. /**
  63222. * The current speed of the particle.
  63223. */
  63224. velocity: Vector3;
  63225. /**
  63226. * The pivot point in the particle local space.
  63227. */
  63228. pivot: Vector3;
  63229. /**
  63230. * Must the particle be translated from its pivot point in its local space ?
  63231. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  63232. * Default : false
  63233. */
  63234. translateFromPivot: boolean;
  63235. /**
  63236. * Index of this particle in the global "positions" array (Internal use)
  63237. * @hidden
  63238. */
  63239. _pos: number;
  63240. /**
  63241. * @hidden Index of this particle in the global "indices" array (Internal use)
  63242. */
  63243. _ind: number;
  63244. /**
  63245. * Group this particle belongs to
  63246. */
  63247. _group: PointsGroup;
  63248. /**
  63249. * Group id of this particle
  63250. */
  63251. groupId: number;
  63252. /**
  63253. * Index of the particle in its group id (Internal use)
  63254. */
  63255. idxInGroup: number;
  63256. /**
  63257. * @hidden Particle BoundingInfo object (Internal use)
  63258. */
  63259. _boundingInfo: BoundingInfo;
  63260. /**
  63261. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  63262. */
  63263. _pcs: PointsCloudSystem;
  63264. /**
  63265. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  63266. */
  63267. _stillInvisible: boolean;
  63268. /**
  63269. * @hidden Last computed particle rotation matrix
  63270. */
  63271. _rotationMatrix: number[];
  63272. /**
  63273. * Parent particle Id, if any.
  63274. * Default null.
  63275. */
  63276. parentId: Nullable<number>;
  63277. /**
  63278. * @hidden Internal global position in the PCS.
  63279. */
  63280. _globalPosition: Vector3;
  63281. /**
  63282. * Creates a Point Cloud object.
  63283. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  63284. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  63285. * @param group (PointsGroup) is the group the particle belongs to
  63286. * @param groupId (integer) is the group identifier in the PCS.
  63287. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  63288. * @param pcs defines the PCS it is associated to
  63289. */
  63290. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  63291. /**
  63292. * get point size
  63293. */
  63294. /**
  63295. * Set point size
  63296. */
  63297. size: Vector3;
  63298. /**
  63299. * Legacy support, changed quaternion to rotationQuaternion
  63300. */
  63301. /**
  63302. * Legacy support, changed quaternion to rotationQuaternion
  63303. */
  63304. quaternion: Nullable<Quaternion>;
  63305. /**
  63306. * Returns a boolean. True if the particle intersects a mesh, else false
  63307. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  63308. * @param target is the object (point or mesh) what the intersection is computed against
  63309. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  63310. * @returns true if it intersects
  63311. */
  63312. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  63313. /**
  63314. * get the rotation matrix of the particle
  63315. * @hidden
  63316. */
  63317. getRotationMatrix(m: Matrix): void;
  63318. }
  63319. /**
  63320. * Represents a group of points in a points cloud system
  63321. * * PCS internal tool, don't use it manually.
  63322. */
  63323. export class PointsGroup {
  63324. /**
  63325. * The group id
  63326. * @hidden
  63327. */
  63328. groupID: number;
  63329. /**
  63330. * image data for group (internal use)
  63331. * @hidden
  63332. */
  63333. _groupImageData: Nullable<ArrayBufferView>;
  63334. /**
  63335. * Image Width (internal use)
  63336. * @hidden
  63337. */
  63338. _groupImgWidth: number;
  63339. /**
  63340. * Image Height (internal use)
  63341. * @hidden
  63342. */
  63343. _groupImgHeight: number;
  63344. /**
  63345. * Custom position function (internal use)
  63346. * @hidden
  63347. */
  63348. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  63349. /**
  63350. * density per facet for surface points
  63351. * @hidden
  63352. */
  63353. _groupDensity: number[];
  63354. /**
  63355. * Only when points are colored by texture carries pointer to texture list array
  63356. * @hidden
  63357. */
  63358. _textureNb: number;
  63359. /**
  63360. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  63361. * PCS internal tool, don't use it manually.
  63362. * @hidden
  63363. */
  63364. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  63365. }
  63366. }
  63367. declare module "babylonjs/Particles/index" {
  63368. export * from "babylonjs/Particles/baseParticleSystem";
  63369. export * from "babylonjs/Particles/EmitterTypes/index";
  63370. export * from "babylonjs/Particles/gpuParticleSystem";
  63371. export * from "babylonjs/Particles/IParticleSystem";
  63372. export * from "babylonjs/Particles/particle";
  63373. export * from "babylonjs/Particles/particleHelper";
  63374. export * from "babylonjs/Particles/particleSystem";
  63375. export * from "babylonjs/Particles/particleSystemComponent";
  63376. export * from "babylonjs/Particles/particleSystemSet";
  63377. export * from "babylonjs/Particles/solidParticle";
  63378. export * from "babylonjs/Particles/solidParticleSystem";
  63379. export * from "babylonjs/Particles/cloudPoint";
  63380. export * from "babylonjs/Particles/pointsCloudSystem";
  63381. export * from "babylonjs/Particles/subEmitter";
  63382. }
  63383. declare module "babylonjs/Physics/physicsEngineComponent" {
  63384. import { Nullable } from "babylonjs/types";
  63385. import { Observable, Observer } from "babylonjs/Misc/observable";
  63386. import { Vector3 } from "babylonjs/Maths/math.vector";
  63387. import { Mesh } from "babylonjs/Meshes/mesh";
  63388. import { ISceneComponent } from "babylonjs/sceneComponent";
  63389. import { Scene } from "babylonjs/scene";
  63390. import { Node } from "babylonjs/node";
  63391. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  63392. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63393. module "babylonjs/scene" {
  63394. interface Scene {
  63395. /** @hidden (Backing field) */
  63396. _physicsEngine: Nullable<IPhysicsEngine>;
  63397. /** @hidden */
  63398. _physicsTimeAccumulator: number;
  63399. /**
  63400. * Gets the current physics engine
  63401. * @returns a IPhysicsEngine or null if none attached
  63402. */
  63403. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  63404. /**
  63405. * Enables physics to the current scene
  63406. * @param gravity defines the scene's gravity for the physics engine
  63407. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  63408. * @return a boolean indicating if the physics engine was initialized
  63409. */
  63410. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  63411. /**
  63412. * Disables and disposes the physics engine associated with the scene
  63413. */
  63414. disablePhysicsEngine(): void;
  63415. /**
  63416. * Gets a boolean indicating if there is an active physics engine
  63417. * @returns a boolean indicating if there is an active physics engine
  63418. */
  63419. isPhysicsEnabled(): boolean;
  63420. /**
  63421. * Deletes a physics compound impostor
  63422. * @param compound defines the compound to delete
  63423. */
  63424. deleteCompoundImpostor(compound: any): void;
  63425. /**
  63426. * An event triggered when physic simulation is about to be run
  63427. */
  63428. onBeforePhysicsObservable: Observable<Scene>;
  63429. /**
  63430. * An event triggered when physic simulation has been done
  63431. */
  63432. onAfterPhysicsObservable: Observable<Scene>;
  63433. }
  63434. }
  63435. module "babylonjs/Meshes/abstractMesh" {
  63436. interface AbstractMesh {
  63437. /** @hidden */
  63438. _physicsImpostor: Nullable<PhysicsImpostor>;
  63439. /**
  63440. * Gets or sets impostor used for physic simulation
  63441. * @see http://doc.babylonjs.com/features/physics_engine
  63442. */
  63443. physicsImpostor: Nullable<PhysicsImpostor>;
  63444. /**
  63445. * Gets the current physics impostor
  63446. * @see http://doc.babylonjs.com/features/physics_engine
  63447. * @returns a physics impostor or null
  63448. */
  63449. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  63450. /** Apply a physic impulse to the mesh
  63451. * @param force defines the force to apply
  63452. * @param contactPoint defines where to apply the force
  63453. * @returns the current mesh
  63454. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  63455. */
  63456. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  63457. /**
  63458. * Creates a physic joint between two meshes
  63459. * @param otherMesh defines the other mesh to use
  63460. * @param pivot1 defines the pivot to use on this mesh
  63461. * @param pivot2 defines the pivot to use on the other mesh
  63462. * @param options defines additional options (can be plugin dependent)
  63463. * @returns the current mesh
  63464. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  63465. */
  63466. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  63467. /** @hidden */
  63468. _disposePhysicsObserver: Nullable<Observer<Node>>;
  63469. }
  63470. }
  63471. /**
  63472. * Defines the physics engine scene component responsible to manage a physics engine
  63473. */
  63474. export class PhysicsEngineSceneComponent implements ISceneComponent {
  63475. /**
  63476. * The component name helpful to identify the component in the list of scene components.
  63477. */
  63478. readonly name: string;
  63479. /**
  63480. * The scene the component belongs to.
  63481. */
  63482. scene: Scene;
  63483. /**
  63484. * Creates a new instance of the component for the given scene
  63485. * @param scene Defines the scene to register the component in
  63486. */
  63487. constructor(scene: Scene);
  63488. /**
  63489. * Registers the component in a given scene
  63490. */
  63491. register(): void;
  63492. /**
  63493. * Rebuilds the elements related to this component in case of
  63494. * context lost for instance.
  63495. */
  63496. rebuild(): void;
  63497. /**
  63498. * Disposes the component and the associated ressources
  63499. */
  63500. dispose(): void;
  63501. }
  63502. }
  63503. declare module "babylonjs/Physics/physicsHelper" {
  63504. import { Nullable } from "babylonjs/types";
  63505. import { Vector3 } from "babylonjs/Maths/math.vector";
  63506. import { Mesh } from "babylonjs/Meshes/mesh";
  63507. import { Scene } from "babylonjs/scene";
  63508. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63509. /**
  63510. * A helper for physics simulations
  63511. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63512. */
  63513. export class PhysicsHelper {
  63514. private _scene;
  63515. private _physicsEngine;
  63516. /**
  63517. * Initializes the Physics helper
  63518. * @param scene Babylon.js scene
  63519. */
  63520. constructor(scene: Scene);
  63521. /**
  63522. * Applies a radial explosion impulse
  63523. * @param origin the origin of the explosion
  63524. * @param radiusOrEventOptions the radius or the options of radial explosion
  63525. * @param strength the explosion strength
  63526. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63527. * @returns A physics radial explosion event, or null
  63528. */
  63529. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63530. /**
  63531. * Applies a radial explosion force
  63532. * @param origin the origin of the explosion
  63533. * @param radiusOrEventOptions the radius or the options of radial explosion
  63534. * @param strength the explosion strength
  63535. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63536. * @returns A physics radial explosion event, or null
  63537. */
  63538. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63539. /**
  63540. * Creates a gravitational field
  63541. * @param origin the origin of the explosion
  63542. * @param radiusOrEventOptions the radius or the options of radial explosion
  63543. * @param strength the explosion strength
  63544. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63545. * @returns A physics gravitational field event, or null
  63546. */
  63547. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  63548. /**
  63549. * Creates a physics updraft event
  63550. * @param origin the origin of the updraft
  63551. * @param radiusOrEventOptions the radius or the options of the updraft
  63552. * @param strength the strength of the updraft
  63553. * @param height the height of the updraft
  63554. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  63555. * @returns A physics updraft event, or null
  63556. */
  63557. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  63558. /**
  63559. * Creates a physics vortex event
  63560. * @param origin the of the vortex
  63561. * @param radiusOrEventOptions the radius or the options of the vortex
  63562. * @param strength the strength of the vortex
  63563. * @param height the height of the vortex
  63564. * @returns a Physics vortex event, or null
  63565. * A physics vortex event or null
  63566. */
  63567. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  63568. }
  63569. /**
  63570. * Represents a physics radial explosion event
  63571. */
  63572. class PhysicsRadialExplosionEvent {
  63573. private _scene;
  63574. private _options;
  63575. private _sphere;
  63576. private _dataFetched;
  63577. /**
  63578. * Initializes a radial explosioin event
  63579. * @param _scene BabylonJS scene
  63580. * @param _options The options for the vortex event
  63581. */
  63582. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  63583. /**
  63584. * Returns the data related to the radial explosion event (sphere).
  63585. * @returns The radial explosion event data
  63586. */
  63587. getData(): PhysicsRadialExplosionEventData;
  63588. /**
  63589. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  63590. * @param impostor A physics imposter
  63591. * @param origin the origin of the explosion
  63592. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  63593. */
  63594. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  63595. /**
  63596. * Triggers affecterd impostors callbacks
  63597. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  63598. */
  63599. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  63600. /**
  63601. * Disposes the sphere.
  63602. * @param force Specifies if the sphere should be disposed by force
  63603. */
  63604. dispose(force?: boolean): void;
  63605. /*** Helpers ***/
  63606. private _prepareSphere;
  63607. private _intersectsWithSphere;
  63608. }
  63609. /**
  63610. * Represents a gravitational field event
  63611. */
  63612. class PhysicsGravitationalFieldEvent {
  63613. private _physicsHelper;
  63614. private _scene;
  63615. private _origin;
  63616. private _options;
  63617. private _tickCallback;
  63618. private _sphere;
  63619. private _dataFetched;
  63620. /**
  63621. * Initializes the physics gravitational field event
  63622. * @param _physicsHelper A physics helper
  63623. * @param _scene BabylonJS scene
  63624. * @param _origin The origin position of the gravitational field event
  63625. * @param _options The options for the vortex event
  63626. */
  63627. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  63628. /**
  63629. * Returns the data related to the gravitational field event (sphere).
  63630. * @returns A gravitational field event
  63631. */
  63632. getData(): PhysicsGravitationalFieldEventData;
  63633. /**
  63634. * Enables the gravitational field.
  63635. */
  63636. enable(): void;
  63637. /**
  63638. * Disables the gravitational field.
  63639. */
  63640. disable(): void;
  63641. /**
  63642. * Disposes the sphere.
  63643. * @param force The force to dispose from the gravitational field event
  63644. */
  63645. dispose(force?: boolean): void;
  63646. private _tick;
  63647. }
  63648. /**
  63649. * Represents a physics updraft event
  63650. */
  63651. class PhysicsUpdraftEvent {
  63652. private _scene;
  63653. private _origin;
  63654. private _options;
  63655. private _physicsEngine;
  63656. private _originTop;
  63657. private _originDirection;
  63658. private _tickCallback;
  63659. private _cylinder;
  63660. private _cylinderPosition;
  63661. private _dataFetched;
  63662. /**
  63663. * Initializes the physics updraft event
  63664. * @param _scene BabylonJS scene
  63665. * @param _origin The origin position of the updraft
  63666. * @param _options The options for the updraft event
  63667. */
  63668. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  63669. /**
  63670. * Returns the data related to the updraft event (cylinder).
  63671. * @returns A physics updraft event
  63672. */
  63673. getData(): PhysicsUpdraftEventData;
  63674. /**
  63675. * Enables the updraft.
  63676. */
  63677. enable(): void;
  63678. /**
  63679. * Disables the updraft.
  63680. */
  63681. disable(): void;
  63682. /**
  63683. * Disposes the cylinder.
  63684. * @param force Specifies if the updraft should be disposed by force
  63685. */
  63686. dispose(force?: boolean): void;
  63687. private getImpostorHitData;
  63688. private _tick;
  63689. /*** Helpers ***/
  63690. private _prepareCylinder;
  63691. private _intersectsWithCylinder;
  63692. }
  63693. /**
  63694. * Represents a physics vortex event
  63695. */
  63696. class PhysicsVortexEvent {
  63697. private _scene;
  63698. private _origin;
  63699. private _options;
  63700. private _physicsEngine;
  63701. private _originTop;
  63702. private _tickCallback;
  63703. private _cylinder;
  63704. private _cylinderPosition;
  63705. private _dataFetched;
  63706. /**
  63707. * Initializes the physics vortex event
  63708. * @param _scene The BabylonJS scene
  63709. * @param _origin The origin position of the vortex
  63710. * @param _options The options for the vortex event
  63711. */
  63712. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  63713. /**
  63714. * Returns the data related to the vortex event (cylinder).
  63715. * @returns The physics vortex event data
  63716. */
  63717. getData(): PhysicsVortexEventData;
  63718. /**
  63719. * Enables the vortex.
  63720. */
  63721. enable(): void;
  63722. /**
  63723. * Disables the cortex.
  63724. */
  63725. disable(): void;
  63726. /**
  63727. * Disposes the sphere.
  63728. * @param force
  63729. */
  63730. dispose(force?: boolean): void;
  63731. private getImpostorHitData;
  63732. private _tick;
  63733. /*** Helpers ***/
  63734. private _prepareCylinder;
  63735. private _intersectsWithCylinder;
  63736. }
  63737. /**
  63738. * Options fot the radial explosion event
  63739. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63740. */
  63741. export class PhysicsRadialExplosionEventOptions {
  63742. /**
  63743. * The radius of the sphere for the radial explosion.
  63744. */
  63745. radius: number;
  63746. /**
  63747. * The strenth of the explosion.
  63748. */
  63749. strength: number;
  63750. /**
  63751. * The strenght of the force in correspondence to the distance of the affected object
  63752. */
  63753. falloff: PhysicsRadialImpulseFalloff;
  63754. /**
  63755. * Sphere options for the radial explosion.
  63756. */
  63757. sphere: {
  63758. segments: number;
  63759. diameter: number;
  63760. };
  63761. /**
  63762. * Sphere options for the radial explosion.
  63763. */
  63764. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  63765. }
  63766. /**
  63767. * Options fot the updraft event
  63768. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63769. */
  63770. export class PhysicsUpdraftEventOptions {
  63771. /**
  63772. * The radius of the cylinder for the vortex
  63773. */
  63774. radius: number;
  63775. /**
  63776. * The strenth of the updraft.
  63777. */
  63778. strength: number;
  63779. /**
  63780. * The height of the cylinder for the updraft.
  63781. */
  63782. height: number;
  63783. /**
  63784. * The mode for the the updraft.
  63785. */
  63786. updraftMode: PhysicsUpdraftMode;
  63787. }
  63788. /**
  63789. * Options fot the vortex event
  63790. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63791. */
  63792. export class PhysicsVortexEventOptions {
  63793. /**
  63794. * The radius of the cylinder for the vortex
  63795. */
  63796. radius: number;
  63797. /**
  63798. * The strenth of the vortex.
  63799. */
  63800. strength: number;
  63801. /**
  63802. * The height of the cylinder for the vortex.
  63803. */
  63804. height: number;
  63805. /**
  63806. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  63807. */
  63808. centripetalForceThreshold: number;
  63809. /**
  63810. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  63811. */
  63812. centripetalForceMultiplier: number;
  63813. /**
  63814. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  63815. */
  63816. centrifugalForceMultiplier: number;
  63817. /**
  63818. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  63819. */
  63820. updraftForceMultiplier: number;
  63821. }
  63822. /**
  63823. * The strenght of the force in correspondence to the distance of the affected object
  63824. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63825. */
  63826. export enum PhysicsRadialImpulseFalloff {
  63827. /** Defines that impulse is constant in strength across it's whole radius */
  63828. Constant = 0,
  63829. /** Defines that impulse gets weaker if it's further from the origin */
  63830. Linear = 1
  63831. }
  63832. /**
  63833. * The strength of the force in correspondence to the distance of the affected object
  63834. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63835. */
  63836. export enum PhysicsUpdraftMode {
  63837. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  63838. Center = 0,
  63839. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  63840. Perpendicular = 1
  63841. }
  63842. /**
  63843. * Interface for a physics hit data
  63844. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63845. */
  63846. export interface PhysicsHitData {
  63847. /**
  63848. * The force applied at the contact point
  63849. */
  63850. force: Vector3;
  63851. /**
  63852. * The contact point
  63853. */
  63854. contactPoint: Vector3;
  63855. /**
  63856. * The distance from the origin to the contact point
  63857. */
  63858. distanceFromOrigin: number;
  63859. }
  63860. /**
  63861. * Interface for radial explosion event data
  63862. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63863. */
  63864. export interface PhysicsRadialExplosionEventData {
  63865. /**
  63866. * A sphere used for the radial explosion event
  63867. */
  63868. sphere: Mesh;
  63869. }
  63870. /**
  63871. * Interface for gravitational field event data
  63872. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63873. */
  63874. export interface PhysicsGravitationalFieldEventData {
  63875. /**
  63876. * A sphere mesh used for the gravitational field event
  63877. */
  63878. sphere: Mesh;
  63879. }
  63880. /**
  63881. * Interface for updraft event data
  63882. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63883. */
  63884. export interface PhysicsUpdraftEventData {
  63885. /**
  63886. * A cylinder used for the updraft event
  63887. */
  63888. cylinder: Mesh;
  63889. }
  63890. /**
  63891. * Interface for vortex event data
  63892. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63893. */
  63894. export interface PhysicsVortexEventData {
  63895. /**
  63896. * A cylinder used for the vortex event
  63897. */
  63898. cylinder: Mesh;
  63899. }
  63900. /**
  63901. * Interface for an affected physics impostor
  63902. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63903. */
  63904. export interface PhysicsAffectedImpostorWithData {
  63905. /**
  63906. * The impostor affected by the effect
  63907. */
  63908. impostor: PhysicsImpostor;
  63909. /**
  63910. * The data about the hit/horce from the explosion
  63911. */
  63912. hitData: PhysicsHitData;
  63913. }
  63914. }
  63915. declare module "babylonjs/Physics/Plugins/index" {
  63916. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  63917. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  63918. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  63919. }
  63920. declare module "babylonjs/Physics/index" {
  63921. export * from "babylonjs/Physics/IPhysicsEngine";
  63922. export * from "babylonjs/Physics/physicsEngine";
  63923. export * from "babylonjs/Physics/physicsEngineComponent";
  63924. export * from "babylonjs/Physics/physicsHelper";
  63925. export * from "babylonjs/Physics/physicsImpostor";
  63926. export * from "babylonjs/Physics/physicsJoint";
  63927. export * from "babylonjs/Physics/Plugins/index";
  63928. }
  63929. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  63930. /** @hidden */
  63931. export var blackAndWhitePixelShader: {
  63932. name: string;
  63933. shader: string;
  63934. };
  63935. }
  63936. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  63937. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63938. import { Camera } from "babylonjs/Cameras/camera";
  63939. import { Engine } from "babylonjs/Engines/engine";
  63940. import "babylonjs/Shaders/blackAndWhite.fragment";
  63941. /**
  63942. * Post process used to render in black and white
  63943. */
  63944. export class BlackAndWhitePostProcess extends PostProcess {
  63945. /**
  63946. * Linear about to convert he result to black and white (default: 1)
  63947. */
  63948. degree: number;
  63949. /**
  63950. * Creates a black and white post process
  63951. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  63952. * @param name The name of the effect.
  63953. * @param options The required width/height ratio to downsize to before computing the render pass.
  63954. * @param camera The camera to apply the render pass to.
  63955. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63956. * @param engine The engine which the post process will be applied. (default: current engine)
  63957. * @param reusable If the post process can be reused on the same frame. (default: false)
  63958. */
  63959. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63960. }
  63961. }
  63962. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  63963. import { Nullable } from "babylonjs/types";
  63964. import { Camera } from "babylonjs/Cameras/camera";
  63965. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63966. import { Engine } from "babylonjs/Engines/engine";
  63967. /**
  63968. * This represents a set of one or more post processes in Babylon.
  63969. * A post process can be used to apply a shader to a texture after it is rendered.
  63970. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63971. */
  63972. export class PostProcessRenderEffect {
  63973. private _postProcesses;
  63974. private _getPostProcesses;
  63975. private _singleInstance;
  63976. private _cameras;
  63977. private _indicesForCamera;
  63978. /**
  63979. * Name of the effect
  63980. * @hidden
  63981. */
  63982. _name: string;
  63983. /**
  63984. * Instantiates a post process render effect.
  63985. * A post process can be used to apply a shader to a texture after it is rendered.
  63986. * @param engine The engine the effect is tied to
  63987. * @param name The name of the effect
  63988. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  63989. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  63990. */
  63991. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  63992. /**
  63993. * Checks if all the post processes in the effect are supported.
  63994. */
  63995. readonly isSupported: boolean;
  63996. /**
  63997. * Updates the current state of the effect
  63998. * @hidden
  63999. */
  64000. _update(): void;
  64001. /**
  64002. * Attaches the effect on cameras
  64003. * @param cameras The camera to attach to.
  64004. * @hidden
  64005. */
  64006. _attachCameras(cameras: Camera): void;
  64007. /**
  64008. * Attaches the effect on cameras
  64009. * @param cameras The camera to attach to.
  64010. * @hidden
  64011. */
  64012. _attachCameras(cameras: Camera[]): void;
  64013. /**
  64014. * Detaches the effect on cameras
  64015. * @param cameras The camera to detatch from.
  64016. * @hidden
  64017. */
  64018. _detachCameras(cameras: Camera): void;
  64019. /**
  64020. * Detatches the effect on cameras
  64021. * @param cameras The camera to detatch from.
  64022. * @hidden
  64023. */
  64024. _detachCameras(cameras: Camera[]): void;
  64025. /**
  64026. * Enables the effect on given cameras
  64027. * @param cameras The camera to enable.
  64028. * @hidden
  64029. */
  64030. _enable(cameras: Camera): void;
  64031. /**
  64032. * Enables the effect on given cameras
  64033. * @param cameras The camera to enable.
  64034. * @hidden
  64035. */
  64036. _enable(cameras: Nullable<Camera[]>): void;
  64037. /**
  64038. * Disables the effect on the given cameras
  64039. * @param cameras The camera to disable.
  64040. * @hidden
  64041. */
  64042. _disable(cameras: Camera): void;
  64043. /**
  64044. * Disables the effect on the given cameras
  64045. * @param cameras The camera to disable.
  64046. * @hidden
  64047. */
  64048. _disable(cameras: Nullable<Camera[]>): void;
  64049. /**
  64050. * Gets a list of the post processes contained in the effect.
  64051. * @param camera The camera to get the post processes on.
  64052. * @returns The list of the post processes in the effect.
  64053. */
  64054. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  64055. }
  64056. }
  64057. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  64058. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64059. /** @hidden */
  64060. export var extractHighlightsPixelShader: {
  64061. name: string;
  64062. shader: string;
  64063. };
  64064. }
  64065. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  64066. import { Nullable } from "babylonjs/types";
  64067. import { Camera } from "babylonjs/Cameras/camera";
  64068. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64069. import { Engine } from "babylonjs/Engines/engine";
  64070. import "babylonjs/Shaders/extractHighlights.fragment";
  64071. /**
  64072. * 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.
  64073. */
  64074. export class ExtractHighlightsPostProcess extends PostProcess {
  64075. /**
  64076. * The luminance threshold, pixels below this value will be set to black.
  64077. */
  64078. threshold: number;
  64079. /** @hidden */
  64080. _exposure: number;
  64081. /**
  64082. * Post process which has the input texture to be used when performing highlight extraction
  64083. * @hidden
  64084. */
  64085. _inputPostProcess: Nullable<PostProcess>;
  64086. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64087. }
  64088. }
  64089. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  64090. /** @hidden */
  64091. export var bloomMergePixelShader: {
  64092. name: string;
  64093. shader: string;
  64094. };
  64095. }
  64096. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  64097. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64098. import { Nullable } from "babylonjs/types";
  64099. import { Engine } from "babylonjs/Engines/engine";
  64100. import { Camera } from "babylonjs/Cameras/camera";
  64101. import "babylonjs/Shaders/bloomMerge.fragment";
  64102. /**
  64103. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64104. */
  64105. export class BloomMergePostProcess extends PostProcess {
  64106. /** Weight of the bloom to be added to the original input. */
  64107. weight: number;
  64108. /**
  64109. * Creates a new instance of @see BloomMergePostProcess
  64110. * @param name The name of the effect.
  64111. * @param originalFromInput Post process which's input will be used for the merge.
  64112. * @param blurred Blurred highlights post process which's output will be used.
  64113. * @param weight Weight of the bloom to be added to the original input.
  64114. * @param options The required width/height ratio to downsize to before computing the render pass.
  64115. * @param camera The camera to apply the render pass to.
  64116. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64117. * @param engine The engine which the post process will be applied. (default: current engine)
  64118. * @param reusable If the post process can be reused on the same frame. (default: false)
  64119. * @param textureType Type of textures used when performing the post process. (default: 0)
  64120. * @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)
  64121. */
  64122. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  64123. /** Weight of the bloom to be added to the original input. */
  64124. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64125. }
  64126. }
  64127. declare module "babylonjs/PostProcesses/bloomEffect" {
  64128. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64129. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64130. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  64131. import { Camera } from "babylonjs/Cameras/camera";
  64132. import { Scene } from "babylonjs/scene";
  64133. /**
  64134. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  64135. */
  64136. export class BloomEffect extends PostProcessRenderEffect {
  64137. private bloomScale;
  64138. /**
  64139. * @hidden Internal
  64140. */
  64141. _effects: Array<PostProcess>;
  64142. /**
  64143. * @hidden Internal
  64144. */
  64145. _downscale: ExtractHighlightsPostProcess;
  64146. private _blurX;
  64147. private _blurY;
  64148. private _merge;
  64149. /**
  64150. * The luminance threshold to find bright areas of the image to bloom.
  64151. */
  64152. threshold: number;
  64153. /**
  64154. * The strength of the bloom.
  64155. */
  64156. weight: number;
  64157. /**
  64158. * Specifies the size of the bloom blur kernel, relative to the final output size
  64159. */
  64160. kernel: number;
  64161. /**
  64162. * Creates a new instance of @see BloomEffect
  64163. * @param scene The scene the effect belongs to.
  64164. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  64165. * @param bloomKernel The size of the kernel to be used when applying the blur.
  64166. * @param bloomWeight The the strength of bloom.
  64167. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64168. * @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)
  64169. */
  64170. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  64171. /**
  64172. * Disposes each of the internal effects for a given camera.
  64173. * @param camera The camera to dispose the effect on.
  64174. */
  64175. disposeEffects(camera: Camera): void;
  64176. /**
  64177. * @hidden Internal
  64178. */
  64179. _updateEffects(): void;
  64180. /**
  64181. * Internal
  64182. * @returns if all the contained post processes are ready.
  64183. * @hidden
  64184. */
  64185. _isReady(): boolean;
  64186. }
  64187. }
  64188. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  64189. /** @hidden */
  64190. export var chromaticAberrationPixelShader: {
  64191. name: string;
  64192. shader: string;
  64193. };
  64194. }
  64195. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  64196. import { Vector2 } from "babylonjs/Maths/math.vector";
  64197. import { Nullable } from "babylonjs/types";
  64198. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64199. import { Camera } from "babylonjs/Cameras/camera";
  64200. import { Engine } from "babylonjs/Engines/engine";
  64201. import "babylonjs/Shaders/chromaticAberration.fragment";
  64202. /**
  64203. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  64204. */
  64205. export class ChromaticAberrationPostProcess extends PostProcess {
  64206. /**
  64207. * The amount of seperation of rgb channels (default: 30)
  64208. */
  64209. aberrationAmount: number;
  64210. /**
  64211. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  64212. */
  64213. radialIntensity: number;
  64214. /**
  64215. * 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))
  64216. */
  64217. direction: Vector2;
  64218. /**
  64219. * 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))
  64220. */
  64221. centerPosition: Vector2;
  64222. /**
  64223. * Creates a new instance ChromaticAberrationPostProcess
  64224. * @param name The name of the effect.
  64225. * @param screenWidth The width of the screen to apply the effect on.
  64226. * @param screenHeight The height of the screen to apply the effect on.
  64227. * @param options The required width/height ratio to downsize to before computing the render pass.
  64228. * @param camera The camera to apply the render pass to.
  64229. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64230. * @param engine The engine which the post process will be applied. (default: current engine)
  64231. * @param reusable If the post process can be reused on the same frame. (default: false)
  64232. * @param textureType Type of textures used when performing the post process. (default: 0)
  64233. * @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)
  64234. */
  64235. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64236. }
  64237. }
  64238. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  64239. /** @hidden */
  64240. export var circleOfConfusionPixelShader: {
  64241. name: string;
  64242. shader: string;
  64243. };
  64244. }
  64245. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  64246. import { Nullable } from "babylonjs/types";
  64247. import { Engine } from "babylonjs/Engines/engine";
  64248. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64249. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64250. import { Camera } from "babylonjs/Cameras/camera";
  64251. import "babylonjs/Shaders/circleOfConfusion.fragment";
  64252. /**
  64253. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  64254. */
  64255. export class CircleOfConfusionPostProcess extends PostProcess {
  64256. /**
  64257. * 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.
  64258. */
  64259. lensSize: number;
  64260. /**
  64261. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64262. */
  64263. fStop: number;
  64264. /**
  64265. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64266. */
  64267. focusDistance: number;
  64268. /**
  64269. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  64270. */
  64271. focalLength: number;
  64272. private _depthTexture;
  64273. /**
  64274. * Creates a new instance CircleOfConfusionPostProcess
  64275. * @param name The name of the effect.
  64276. * @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.
  64277. * @param options The required width/height ratio to downsize to before computing the render pass.
  64278. * @param camera The camera to apply the render pass to.
  64279. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64280. * @param engine The engine which the post process will be applied. (default: current engine)
  64281. * @param reusable If the post process can be reused on the same frame. (default: false)
  64282. * @param textureType Type of textures used when performing the post process. (default: 0)
  64283. * @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)
  64284. */
  64285. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64286. /**
  64287. * 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.
  64288. */
  64289. depthTexture: RenderTargetTexture;
  64290. }
  64291. }
  64292. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  64293. /** @hidden */
  64294. export var colorCorrectionPixelShader: {
  64295. name: string;
  64296. shader: string;
  64297. };
  64298. }
  64299. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  64300. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64301. import { Engine } from "babylonjs/Engines/engine";
  64302. import { Camera } from "babylonjs/Cameras/camera";
  64303. import "babylonjs/Shaders/colorCorrection.fragment";
  64304. /**
  64305. *
  64306. * This post-process allows the modification of rendered colors by using
  64307. * a 'look-up table' (LUT). This effect is also called Color Grading.
  64308. *
  64309. * The object needs to be provided an url to a texture containing the color
  64310. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  64311. * Use an image editing software to tweak the LUT to match your needs.
  64312. *
  64313. * For an example of a color LUT, see here:
  64314. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  64315. * For explanations on color grading, see here:
  64316. * @see http://udn.epicgames.com/Three/ColorGrading.html
  64317. *
  64318. */
  64319. export class ColorCorrectionPostProcess extends PostProcess {
  64320. private _colorTableTexture;
  64321. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64322. }
  64323. }
  64324. declare module "babylonjs/Shaders/convolution.fragment" {
  64325. /** @hidden */
  64326. export var convolutionPixelShader: {
  64327. name: string;
  64328. shader: string;
  64329. };
  64330. }
  64331. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  64332. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64333. import { Nullable } from "babylonjs/types";
  64334. import { Camera } from "babylonjs/Cameras/camera";
  64335. import { Engine } from "babylonjs/Engines/engine";
  64336. import "babylonjs/Shaders/convolution.fragment";
  64337. /**
  64338. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  64339. * input texture to perform effects such as edge detection or sharpening
  64340. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64341. */
  64342. export class ConvolutionPostProcess extends PostProcess {
  64343. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64344. kernel: number[];
  64345. /**
  64346. * Creates a new instance ConvolutionPostProcess
  64347. * @param name The name of the effect.
  64348. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  64349. * @param options The required width/height ratio to downsize to before computing the render pass.
  64350. * @param camera The camera to apply the render pass to.
  64351. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64352. * @param engine The engine which the post process will be applied. (default: current engine)
  64353. * @param reusable If the post process can be reused on the same frame. (default: false)
  64354. * @param textureType Type of textures used when performing the post process. (default: 0)
  64355. */
  64356. constructor(name: string,
  64357. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64358. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64359. /**
  64360. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64361. */
  64362. static EdgeDetect0Kernel: number[];
  64363. /**
  64364. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64365. */
  64366. static EdgeDetect1Kernel: number[];
  64367. /**
  64368. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64369. */
  64370. static EdgeDetect2Kernel: number[];
  64371. /**
  64372. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64373. */
  64374. static SharpenKernel: number[];
  64375. /**
  64376. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64377. */
  64378. static EmbossKernel: number[];
  64379. /**
  64380. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64381. */
  64382. static GaussianKernel: number[];
  64383. }
  64384. }
  64385. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  64386. import { Nullable } from "babylonjs/types";
  64387. import { Vector2 } from "babylonjs/Maths/math.vector";
  64388. import { Camera } from "babylonjs/Cameras/camera";
  64389. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64390. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  64391. import { Engine } from "babylonjs/Engines/engine";
  64392. import { Scene } from "babylonjs/scene";
  64393. /**
  64394. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  64395. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  64396. * based on samples that have a large difference in distance than the center pixel.
  64397. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  64398. */
  64399. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  64400. direction: Vector2;
  64401. /**
  64402. * Creates a new instance CircleOfConfusionPostProcess
  64403. * @param name The name of the effect.
  64404. * @param scene The scene the effect belongs to.
  64405. * @param direction The direction the blur should be applied.
  64406. * @param kernel The size of the kernel used to blur.
  64407. * @param options The required width/height ratio to downsize to before computing the render pass.
  64408. * @param camera The camera to apply the render pass to.
  64409. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  64410. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  64411. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64412. * @param engine The engine which the post process will be applied. (default: current engine)
  64413. * @param reusable If the post process can be reused on the same frame. (default: false)
  64414. * @param textureType Type of textures used when performing the post process. (default: 0)
  64415. * @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)
  64416. */
  64417. 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);
  64418. }
  64419. }
  64420. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  64421. /** @hidden */
  64422. export var depthOfFieldMergePixelShader: {
  64423. name: string;
  64424. shader: string;
  64425. };
  64426. }
  64427. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  64428. import { Nullable } from "babylonjs/types";
  64429. import { Camera } from "babylonjs/Cameras/camera";
  64430. import { Effect } from "babylonjs/Materials/effect";
  64431. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64432. import { Engine } from "babylonjs/Engines/engine";
  64433. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  64434. /**
  64435. * Options to be set when merging outputs from the default pipeline.
  64436. */
  64437. export class DepthOfFieldMergePostProcessOptions {
  64438. /**
  64439. * The original image to merge on top of
  64440. */
  64441. originalFromInput: PostProcess;
  64442. /**
  64443. * Parameters to perform the merge of the depth of field effect
  64444. */
  64445. depthOfField?: {
  64446. circleOfConfusion: PostProcess;
  64447. blurSteps: Array<PostProcess>;
  64448. };
  64449. /**
  64450. * Parameters to perform the merge of bloom effect
  64451. */
  64452. bloom?: {
  64453. blurred: PostProcess;
  64454. weight: number;
  64455. };
  64456. }
  64457. /**
  64458. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64459. */
  64460. export class DepthOfFieldMergePostProcess extends PostProcess {
  64461. private blurSteps;
  64462. /**
  64463. * Creates a new instance of DepthOfFieldMergePostProcess
  64464. * @param name The name of the effect.
  64465. * @param originalFromInput Post process which's input will be used for the merge.
  64466. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  64467. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  64468. * @param options The required width/height ratio to downsize to before computing the render pass.
  64469. * @param camera The camera to apply the render pass to.
  64470. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64471. * @param engine The engine which the post process will be applied. (default: current engine)
  64472. * @param reusable If the post process can be reused on the same frame. (default: false)
  64473. * @param textureType Type of textures used when performing the post process. (default: 0)
  64474. * @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)
  64475. */
  64476. 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);
  64477. /**
  64478. * Updates the effect with the current post process compile time values and recompiles the shader.
  64479. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  64480. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  64481. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  64482. * @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
  64483. * @param onCompiled Called when the shader has been compiled.
  64484. * @param onError Called if there is an error when compiling a shader.
  64485. */
  64486. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  64487. }
  64488. }
  64489. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  64490. import { Nullable } from "babylonjs/types";
  64491. import { Camera } from "babylonjs/Cameras/camera";
  64492. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64493. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64494. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64495. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  64496. import { Scene } from "babylonjs/scene";
  64497. /**
  64498. * Specifies the level of max blur that should be applied when using the depth of field effect
  64499. */
  64500. export enum DepthOfFieldEffectBlurLevel {
  64501. /**
  64502. * Subtle blur
  64503. */
  64504. Low = 0,
  64505. /**
  64506. * Medium blur
  64507. */
  64508. Medium = 1,
  64509. /**
  64510. * Large blur
  64511. */
  64512. High = 2
  64513. }
  64514. /**
  64515. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  64516. */
  64517. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  64518. private _circleOfConfusion;
  64519. /**
  64520. * @hidden Internal, blurs from high to low
  64521. */
  64522. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  64523. private _depthOfFieldBlurY;
  64524. private _dofMerge;
  64525. /**
  64526. * @hidden Internal post processes in depth of field effect
  64527. */
  64528. _effects: Array<PostProcess>;
  64529. /**
  64530. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  64531. */
  64532. focalLength: number;
  64533. /**
  64534. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64535. */
  64536. fStop: number;
  64537. /**
  64538. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64539. */
  64540. focusDistance: number;
  64541. /**
  64542. * 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.
  64543. */
  64544. lensSize: number;
  64545. /**
  64546. * Creates a new instance DepthOfFieldEffect
  64547. * @param scene The scene the effect belongs to.
  64548. * @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.
  64549. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64550. * @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)
  64551. */
  64552. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  64553. /**
  64554. * Get the current class name of the current effet
  64555. * @returns "DepthOfFieldEffect"
  64556. */
  64557. getClassName(): string;
  64558. /**
  64559. * 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.
  64560. */
  64561. depthTexture: RenderTargetTexture;
  64562. /**
  64563. * Disposes each of the internal effects for a given camera.
  64564. * @param camera The camera to dispose the effect on.
  64565. */
  64566. disposeEffects(camera: Camera): void;
  64567. /**
  64568. * @hidden Internal
  64569. */
  64570. _updateEffects(): void;
  64571. /**
  64572. * Internal
  64573. * @returns if all the contained post processes are ready.
  64574. * @hidden
  64575. */
  64576. _isReady(): boolean;
  64577. }
  64578. }
  64579. declare module "babylonjs/Shaders/displayPass.fragment" {
  64580. /** @hidden */
  64581. export var displayPassPixelShader: {
  64582. name: string;
  64583. shader: string;
  64584. };
  64585. }
  64586. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  64587. import { Nullable } from "babylonjs/types";
  64588. import { Camera } from "babylonjs/Cameras/camera";
  64589. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64590. import { Engine } from "babylonjs/Engines/engine";
  64591. import "babylonjs/Shaders/displayPass.fragment";
  64592. /**
  64593. * DisplayPassPostProcess which produces an output the same as it's input
  64594. */
  64595. export class DisplayPassPostProcess extends PostProcess {
  64596. /**
  64597. * Creates the DisplayPassPostProcess
  64598. * @param name The name of the effect.
  64599. * @param options The required width/height ratio to downsize to before computing the render pass.
  64600. * @param camera The camera to apply the render pass to.
  64601. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64602. * @param engine The engine which the post process will be applied. (default: current engine)
  64603. * @param reusable If the post process can be reused on the same frame. (default: false)
  64604. */
  64605. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64606. }
  64607. }
  64608. declare module "babylonjs/Shaders/filter.fragment" {
  64609. /** @hidden */
  64610. export var filterPixelShader: {
  64611. name: string;
  64612. shader: string;
  64613. };
  64614. }
  64615. declare module "babylonjs/PostProcesses/filterPostProcess" {
  64616. import { Nullable } from "babylonjs/types";
  64617. import { Matrix } from "babylonjs/Maths/math.vector";
  64618. import { Camera } from "babylonjs/Cameras/camera";
  64619. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64620. import { Engine } from "babylonjs/Engines/engine";
  64621. import "babylonjs/Shaders/filter.fragment";
  64622. /**
  64623. * Applies a kernel filter to the image
  64624. */
  64625. export class FilterPostProcess extends PostProcess {
  64626. /** The matrix to be applied to the image */
  64627. kernelMatrix: Matrix;
  64628. /**
  64629. *
  64630. * @param name The name of the effect.
  64631. * @param kernelMatrix The matrix to be applied to the image
  64632. * @param options The required width/height ratio to downsize to before computing the render pass.
  64633. * @param camera The camera to apply the render pass to.
  64634. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64635. * @param engine The engine which the post process will be applied. (default: current engine)
  64636. * @param reusable If the post process can be reused on the same frame. (default: false)
  64637. */
  64638. constructor(name: string,
  64639. /** The matrix to be applied to the image */
  64640. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64641. }
  64642. }
  64643. declare module "babylonjs/Shaders/fxaa.fragment" {
  64644. /** @hidden */
  64645. export var fxaaPixelShader: {
  64646. name: string;
  64647. shader: string;
  64648. };
  64649. }
  64650. declare module "babylonjs/Shaders/fxaa.vertex" {
  64651. /** @hidden */
  64652. export var fxaaVertexShader: {
  64653. name: string;
  64654. shader: string;
  64655. };
  64656. }
  64657. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  64658. import { Nullable } from "babylonjs/types";
  64659. import { Camera } from "babylonjs/Cameras/camera";
  64660. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64661. import { Engine } from "babylonjs/Engines/engine";
  64662. import "babylonjs/Shaders/fxaa.fragment";
  64663. import "babylonjs/Shaders/fxaa.vertex";
  64664. /**
  64665. * Fxaa post process
  64666. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  64667. */
  64668. export class FxaaPostProcess extends PostProcess {
  64669. /** @hidden */
  64670. texelWidth: number;
  64671. /** @hidden */
  64672. texelHeight: number;
  64673. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64674. private _getDefines;
  64675. }
  64676. }
  64677. declare module "babylonjs/Shaders/grain.fragment" {
  64678. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64679. /** @hidden */
  64680. export var grainPixelShader: {
  64681. name: string;
  64682. shader: string;
  64683. };
  64684. }
  64685. declare module "babylonjs/PostProcesses/grainPostProcess" {
  64686. import { Nullable } from "babylonjs/types";
  64687. import { Camera } from "babylonjs/Cameras/camera";
  64688. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64689. import { Engine } from "babylonjs/Engines/engine";
  64690. import "babylonjs/Shaders/grain.fragment";
  64691. /**
  64692. * The GrainPostProcess adds noise to the image at mid luminance levels
  64693. */
  64694. export class GrainPostProcess extends PostProcess {
  64695. /**
  64696. * The intensity of the grain added (default: 30)
  64697. */
  64698. intensity: number;
  64699. /**
  64700. * If the grain should be randomized on every frame
  64701. */
  64702. animated: boolean;
  64703. /**
  64704. * Creates a new instance of @see GrainPostProcess
  64705. * @param name The name of the effect.
  64706. * @param options The required width/height ratio to downsize to before computing the render pass.
  64707. * @param camera The camera to apply the render pass to.
  64708. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64709. * @param engine The engine which the post process will be applied. (default: current engine)
  64710. * @param reusable If the post process can be reused on the same frame. (default: false)
  64711. * @param textureType Type of textures used when performing the post process. (default: 0)
  64712. * @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)
  64713. */
  64714. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64715. }
  64716. }
  64717. declare module "babylonjs/Shaders/highlights.fragment" {
  64718. /** @hidden */
  64719. export var highlightsPixelShader: {
  64720. name: string;
  64721. shader: string;
  64722. };
  64723. }
  64724. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  64725. import { Nullable } from "babylonjs/types";
  64726. import { Camera } from "babylonjs/Cameras/camera";
  64727. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64728. import { Engine } from "babylonjs/Engines/engine";
  64729. import "babylonjs/Shaders/highlights.fragment";
  64730. /**
  64731. * Extracts highlights from the image
  64732. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64733. */
  64734. export class HighlightsPostProcess extends PostProcess {
  64735. /**
  64736. * Extracts highlights from the image
  64737. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64738. * @param name The name of the effect.
  64739. * @param options The required width/height ratio to downsize to before computing the render pass.
  64740. * @param camera The camera to apply the render pass to.
  64741. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64742. * @param engine The engine which the post process will be applied. (default: current engine)
  64743. * @param reusable If the post process can be reused on the same frame. (default: false)
  64744. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  64745. */
  64746. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64747. }
  64748. }
  64749. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  64750. /** @hidden */
  64751. export var mrtFragmentDeclaration: {
  64752. name: string;
  64753. shader: string;
  64754. };
  64755. }
  64756. declare module "babylonjs/Shaders/geometry.fragment" {
  64757. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  64758. /** @hidden */
  64759. export var geometryPixelShader: {
  64760. name: string;
  64761. shader: string;
  64762. };
  64763. }
  64764. declare module "babylonjs/Shaders/geometry.vertex" {
  64765. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64766. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64767. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64768. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64769. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64770. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64771. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64772. /** @hidden */
  64773. export var geometryVertexShader: {
  64774. name: string;
  64775. shader: string;
  64776. };
  64777. }
  64778. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  64779. import { Matrix } from "babylonjs/Maths/math.vector";
  64780. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64781. import { Mesh } from "babylonjs/Meshes/mesh";
  64782. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  64783. import { Effect } from "babylonjs/Materials/effect";
  64784. import { Scene } from "babylonjs/scene";
  64785. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64786. import "babylonjs/Shaders/geometry.fragment";
  64787. import "babylonjs/Shaders/geometry.vertex";
  64788. /** @hidden */
  64789. interface ISavedTransformationMatrix {
  64790. world: Matrix;
  64791. viewProjection: Matrix;
  64792. }
  64793. /**
  64794. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  64795. */
  64796. export class GeometryBufferRenderer {
  64797. /**
  64798. * Constant used to retrieve the position texture index in the G-Buffer textures array
  64799. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  64800. */
  64801. static readonly POSITION_TEXTURE_TYPE: number;
  64802. /**
  64803. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  64804. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  64805. */
  64806. static readonly VELOCITY_TEXTURE_TYPE: number;
  64807. /**
  64808. * Dictionary used to store the previous transformation matrices of each rendered mesh
  64809. * in order to compute objects velocities when enableVelocity is set to "true"
  64810. * @hidden
  64811. */
  64812. _previousTransformationMatrices: {
  64813. [index: number]: ISavedTransformationMatrix;
  64814. };
  64815. /**
  64816. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  64817. * in order to compute objects velocities when enableVelocity is set to "true"
  64818. * @hidden
  64819. */
  64820. _previousBonesTransformationMatrices: {
  64821. [index: number]: Float32Array;
  64822. };
  64823. /**
  64824. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  64825. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  64826. */
  64827. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  64828. private _scene;
  64829. private _multiRenderTarget;
  64830. private _ratio;
  64831. private _enablePosition;
  64832. private _enableVelocity;
  64833. private _positionIndex;
  64834. private _velocityIndex;
  64835. protected _effect: Effect;
  64836. protected _cachedDefines: string;
  64837. /**
  64838. * Set the render list (meshes to be rendered) used in the G buffer.
  64839. */
  64840. renderList: Mesh[];
  64841. /**
  64842. * Gets wether or not G buffer are supported by the running hardware.
  64843. * This requires draw buffer supports
  64844. */
  64845. readonly isSupported: boolean;
  64846. /**
  64847. * Returns the index of the given texture type in the G-Buffer textures array
  64848. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  64849. * @returns the index of the given texture type in the G-Buffer textures array
  64850. */
  64851. getTextureIndex(textureType: number): number;
  64852. /**
  64853. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  64854. */
  64855. /**
  64856. * Sets whether or not objects positions are enabled for the G buffer.
  64857. */
  64858. enablePosition: boolean;
  64859. /**
  64860. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  64861. */
  64862. /**
  64863. * Sets wether or not objects velocities are enabled for the G buffer.
  64864. */
  64865. enableVelocity: boolean;
  64866. /**
  64867. * Gets the scene associated with the buffer.
  64868. */
  64869. readonly scene: Scene;
  64870. /**
  64871. * Gets the ratio used by the buffer during its creation.
  64872. * How big is the buffer related to the main canvas.
  64873. */
  64874. readonly ratio: number;
  64875. /** @hidden */
  64876. static _SceneComponentInitialization: (scene: Scene) => void;
  64877. /**
  64878. * Creates a new G Buffer for the scene
  64879. * @param scene The scene the buffer belongs to
  64880. * @param ratio How big is the buffer related to the main canvas.
  64881. */
  64882. constructor(scene: Scene, ratio?: number);
  64883. /**
  64884. * Checks wether everything is ready to render a submesh to the G buffer.
  64885. * @param subMesh the submesh to check readiness for
  64886. * @param useInstances is the mesh drawn using instance or not
  64887. * @returns true if ready otherwise false
  64888. */
  64889. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64890. /**
  64891. * Gets the current underlying G Buffer.
  64892. * @returns the buffer
  64893. */
  64894. getGBuffer(): MultiRenderTarget;
  64895. /**
  64896. * Gets the number of samples used to render the buffer (anti aliasing).
  64897. */
  64898. /**
  64899. * Sets the number of samples used to render the buffer (anti aliasing).
  64900. */
  64901. samples: number;
  64902. /**
  64903. * Disposes the renderer and frees up associated resources.
  64904. */
  64905. dispose(): void;
  64906. protected _createRenderTargets(): void;
  64907. private _copyBonesTransformationMatrices;
  64908. }
  64909. }
  64910. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  64911. import { Nullable } from "babylonjs/types";
  64912. import { Scene } from "babylonjs/scene";
  64913. import { ISceneComponent } from "babylonjs/sceneComponent";
  64914. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  64915. module "babylonjs/scene" {
  64916. interface Scene {
  64917. /** @hidden (Backing field) */
  64918. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64919. /**
  64920. * Gets or Sets the current geometry buffer associated to the scene.
  64921. */
  64922. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64923. /**
  64924. * Enables a GeometryBufferRender and associates it with the scene
  64925. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  64926. * @returns the GeometryBufferRenderer
  64927. */
  64928. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  64929. /**
  64930. * Disables the GeometryBufferRender associated with the scene
  64931. */
  64932. disableGeometryBufferRenderer(): void;
  64933. }
  64934. }
  64935. /**
  64936. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  64937. * in several rendering techniques.
  64938. */
  64939. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  64940. /**
  64941. * The component name helpful to identify the component in the list of scene components.
  64942. */
  64943. readonly name: string;
  64944. /**
  64945. * The scene the component belongs to.
  64946. */
  64947. scene: Scene;
  64948. /**
  64949. * Creates a new instance of the component for the given scene
  64950. * @param scene Defines the scene to register the component in
  64951. */
  64952. constructor(scene: Scene);
  64953. /**
  64954. * Registers the component in a given scene
  64955. */
  64956. register(): void;
  64957. /**
  64958. * Rebuilds the elements related to this component in case of
  64959. * context lost for instance.
  64960. */
  64961. rebuild(): void;
  64962. /**
  64963. * Disposes the component and the associated ressources
  64964. */
  64965. dispose(): void;
  64966. private _gatherRenderTargets;
  64967. }
  64968. }
  64969. declare module "babylonjs/Shaders/motionBlur.fragment" {
  64970. /** @hidden */
  64971. export var motionBlurPixelShader: {
  64972. name: string;
  64973. shader: string;
  64974. };
  64975. }
  64976. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  64977. import { Nullable } from "babylonjs/types";
  64978. import { Camera } from "babylonjs/Cameras/camera";
  64979. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64980. import { Scene } from "babylonjs/scene";
  64981. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64982. import "babylonjs/Animations/animatable";
  64983. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  64984. import "babylonjs/Shaders/motionBlur.fragment";
  64985. import { Engine } from "babylonjs/Engines/engine";
  64986. /**
  64987. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  64988. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  64989. * As an example, all you have to do is to create the post-process:
  64990. * var mb = new BABYLON.MotionBlurPostProcess(
  64991. * 'mb', // The name of the effect.
  64992. * scene, // The scene containing the objects to blur according to their velocity.
  64993. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  64994. * camera // The camera to apply the render pass to.
  64995. * );
  64996. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  64997. */
  64998. export class MotionBlurPostProcess extends PostProcess {
  64999. /**
  65000. * Defines how much the image is blurred by the movement. Default value is equal to 1
  65001. */
  65002. motionStrength: number;
  65003. /**
  65004. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  65005. */
  65006. /**
  65007. * Sets the number of iterations to be used for motion blur quality
  65008. */
  65009. motionBlurSamples: number;
  65010. private _motionBlurSamples;
  65011. private _geometryBufferRenderer;
  65012. /**
  65013. * Creates a new instance MotionBlurPostProcess
  65014. * @param name The name of the effect.
  65015. * @param scene The scene containing the objects to blur according to their velocity.
  65016. * @param options The required width/height ratio to downsize to before computing the render pass.
  65017. * @param camera The camera to apply the render pass to.
  65018. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65019. * @param engine The engine which the post process will be applied. (default: current engine)
  65020. * @param reusable If the post process can be reused on the same frame. (default: false)
  65021. * @param textureType Type of textures used when performing the post process. (default: 0)
  65022. * @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)
  65023. */
  65024. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65025. /**
  65026. * Excludes the given skinned mesh from computing bones velocities.
  65027. * 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.
  65028. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  65029. */
  65030. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65031. /**
  65032. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  65033. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  65034. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  65035. */
  65036. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65037. /**
  65038. * Disposes the post process.
  65039. * @param camera The camera to dispose the post process on.
  65040. */
  65041. dispose(camera?: Camera): void;
  65042. }
  65043. }
  65044. declare module "babylonjs/Shaders/refraction.fragment" {
  65045. /** @hidden */
  65046. export var refractionPixelShader: {
  65047. name: string;
  65048. shader: string;
  65049. };
  65050. }
  65051. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  65052. import { Color3 } from "babylonjs/Maths/math.color";
  65053. import { Camera } from "babylonjs/Cameras/camera";
  65054. import { Texture } from "babylonjs/Materials/Textures/texture";
  65055. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65056. import { Engine } from "babylonjs/Engines/engine";
  65057. import "babylonjs/Shaders/refraction.fragment";
  65058. /**
  65059. * Post process which applies a refractin texture
  65060. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65061. */
  65062. export class RefractionPostProcess extends PostProcess {
  65063. /** the base color of the refraction (used to taint the rendering) */
  65064. color: Color3;
  65065. /** simulated refraction depth */
  65066. depth: number;
  65067. /** the coefficient of the base color (0 to remove base color tainting) */
  65068. colorLevel: number;
  65069. private _refTexture;
  65070. private _ownRefractionTexture;
  65071. /**
  65072. * Gets or sets the refraction texture
  65073. * Please note that you are responsible for disposing the texture if you set it manually
  65074. */
  65075. refractionTexture: Texture;
  65076. /**
  65077. * Initializes the RefractionPostProcess
  65078. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65079. * @param name The name of the effect.
  65080. * @param refractionTextureUrl Url of the refraction texture to use
  65081. * @param color the base color of the refraction (used to taint the rendering)
  65082. * @param depth simulated refraction depth
  65083. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  65084. * @param camera The camera to apply the render pass to.
  65085. * @param options The required width/height ratio to downsize to before computing the render pass.
  65086. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65087. * @param engine The engine which the post process will be applied. (default: current engine)
  65088. * @param reusable If the post process can be reused on the same frame. (default: false)
  65089. */
  65090. constructor(name: string, refractionTextureUrl: string,
  65091. /** the base color of the refraction (used to taint the rendering) */
  65092. color: Color3,
  65093. /** simulated refraction depth */
  65094. depth: number,
  65095. /** the coefficient of the base color (0 to remove base color tainting) */
  65096. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65097. /**
  65098. * Disposes of the post process
  65099. * @param camera Camera to dispose post process on
  65100. */
  65101. dispose(camera: Camera): void;
  65102. }
  65103. }
  65104. declare module "babylonjs/Shaders/sharpen.fragment" {
  65105. /** @hidden */
  65106. export var sharpenPixelShader: {
  65107. name: string;
  65108. shader: string;
  65109. };
  65110. }
  65111. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  65112. import { Nullable } from "babylonjs/types";
  65113. import { Camera } from "babylonjs/Cameras/camera";
  65114. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65115. import "babylonjs/Shaders/sharpen.fragment";
  65116. import { Engine } from "babylonjs/Engines/engine";
  65117. /**
  65118. * The SharpenPostProcess applies a sharpen kernel to every pixel
  65119. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65120. */
  65121. export class SharpenPostProcess extends PostProcess {
  65122. /**
  65123. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  65124. */
  65125. colorAmount: number;
  65126. /**
  65127. * How much sharpness should be applied (default: 0.3)
  65128. */
  65129. edgeAmount: number;
  65130. /**
  65131. * Creates a new instance ConvolutionPostProcess
  65132. * @param name The name of the effect.
  65133. * @param options The required width/height ratio to downsize to before computing the render pass.
  65134. * @param camera The camera to apply the render pass to.
  65135. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65136. * @param engine The engine which the post process will be applied. (default: current engine)
  65137. * @param reusable If the post process can be reused on the same frame. (default: false)
  65138. * @param textureType Type of textures used when performing the post process. (default: 0)
  65139. * @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)
  65140. */
  65141. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65142. }
  65143. }
  65144. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  65145. import { Nullable } from "babylonjs/types";
  65146. import { Camera } from "babylonjs/Cameras/camera";
  65147. import { Engine } from "babylonjs/Engines/engine";
  65148. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  65149. import { IInspectable } from "babylonjs/Misc/iInspectable";
  65150. /**
  65151. * PostProcessRenderPipeline
  65152. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65153. */
  65154. export class PostProcessRenderPipeline {
  65155. private engine;
  65156. private _renderEffects;
  65157. private _renderEffectsForIsolatedPass;
  65158. /**
  65159. * List of inspectable custom properties (used by the Inspector)
  65160. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  65161. */
  65162. inspectableCustomProperties: IInspectable[];
  65163. /**
  65164. * @hidden
  65165. */
  65166. protected _cameras: Camera[];
  65167. /** @hidden */
  65168. _name: string;
  65169. /**
  65170. * Gets pipeline name
  65171. */
  65172. readonly name: string;
  65173. /** Gets the list of attached cameras */
  65174. readonly cameras: Camera[];
  65175. /**
  65176. * Initializes a PostProcessRenderPipeline
  65177. * @param engine engine to add the pipeline to
  65178. * @param name name of the pipeline
  65179. */
  65180. constructor(engine: Engine, name: string);
  65181. /**
  65182. * Gets the class name
  65183. * @returns "PostProcessRenderPipeline"
  65184. */
  65185. getClassName(): string;
  65186. /**
  65187. * If all the render effects in the pipeline are supported
  65188. */
  65189. readonly isSupported: boolean;
  65190. /**
  65191. * Adds an effect to the pipeline
  65192. * @param renderEffect the effect to add
  65193. */
  65194. addEffect(renderEffect: PostProcessRenderEffect): void;
  65195. /** @hidden */
  65196. _rebuild(): void;
  65197. /** @hidden */
  65198. _enableEffect(renderEffectName: string, cameras: Camera): void;
  65199. /** @hidden */
  65200. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  65201. /** @hidden */
  65202. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65203. /** @hidden */
  65204. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65205. /** @hidden */
  65206. _attachCameras(cameras: Camera, unique: boolean): void;
  65207. /** @hidden */
  65208. _attachCameras(cameras: Camera[], unique: boolean): void;
  65209. /** @hidden */
  65210. _detachCameras(cameras: Camera): void;
  65211. /** @hidden */
  65212. _detachCameras(cameras: Nullable<Camera[]>): void;
  65213. /** @hidden */
  65214. _update(): void;
  65215. /** @hidden */
  65216. _reset(): void;
  65217. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  65218. /**
  65219. * Disposes of the pipeline
  65220. */
  65221. dispose(): void;
  65222. }
  65223. }
  65224. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  65225. import { Camera } from "babylonjs/Cameras/camera";
  65226. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65227. /**
  65228. * PostProcessRenderPipelineManager class
  65229. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65230. */
  65231. export class PostProcessRenderPipelineManager {
  65232. private _renderPipelines;
  65233. /**
  65234. * Initializes a PostProcessRenderPipelineManager
  65235. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65236. */
  65237. constructor();
  65238. /**
  65239. * Gets the list of supported render pipelines
  65240. */
  65241. readonly supportedPipelines: PostProcessRenderPipeline[];
  65242. /**
  65243. * Adds a pipeline to the manager
  65244. * @param renderPipeline The pipeline to add
  65245. */
  65246. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  65247. /**
  65248. * Attaches a camera to the pipeline
  65249. * @param renderPipelineName The name of the pipeline to attach to
  65250. * @param cameras the camera to attach
  65251. * @param unique if the camera can be attached multiple times to the pipeline
  65252. */
  65253. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  65254. /**
  65255. * Detaches a camera from the pipeline
  65256. * @param renderPipelineName The name of the pipeline to detach from
  65257. * @param cameras the camera to detach
  65258. */
  65259. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  65260. /**
  65261. * Enables an effect by name on a pipeline
  65262. * @param renderPipelineName the name of the pipeline to enable the effect in
  65263. * @param renderEffectName the name of the effect to enable
  65264. * @param cameras the cameras that the effect should be enabled on
  65265. */
  65266. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65267. /**
  65268. * Disables an effect by name on a pipeline
  65269. * @param renderPipelineName the name of the pipeline to disable the effect in
  65270. * @param renderEffectName the name of the effect to disable
  65271. * @param cameras the cameras that the effect should be disabled on
  65272. */
  65273. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65274. /**
  65275. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  65276. */
  65277. update(): void;
  65278. /** @hidden */
  65279. _rebuild(): void;
  65280. /**
  65281. * Disposes of the manager and pipelines
  65282. */
  65283. dispose(): void;
  65284. }
  65285. }
  65286. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  65287. import { ISceneComponent } from "babylonjs/sceneComponent";
  65288. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  65289. import { Scene } from "babylonjs/scene";
  65290. module "babylonjs/scene" {
  65291. interface Scene {
  65292. /** @hidden (Backing field) */
  65293. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65294. /**
  65295. * Gets the postprocess render pipeline manager
  65296. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65297. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65298. */
  65299. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65300. }
  65301. }
  65302. /**
  65303. * Defines the Render Pipeline scene component responsible to rendering pipelines
  65304. */
  65305. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  65306. /**
  65307. * The component name helpfull to identify the component in the list of scene components.
  65308. */
  65309. readonly name: string;
  65310. /**
  65311. * The scene the component belongs to.
  65312. */
  65313. scene: Scene;
  65314. /**
  65315. * Creates a new instance of the component for the given scene
  65316. * @param scene Defines the scene to register the component in
  65317. */
  65318. constructor(scene: Scene);
  65319. /**
  65320. * Registers the component in a given scene
  65321. */
  65322. register(): void;
  65323. /**
  65324. * Rebuilds the elements related to this component in case of
  65325. * context lost for instance.
  65326. */
  65327. rebuild(): void;
  65328. /**
  65329. * Disposes the component and the associated ressources
  65330. */
  65331. dispose(): void;
  65332. private _gatherRenderTargets;
  65333. }
  65334. }
  65335. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  65336. import { Nullable } from "babylonjs/types";
  65337. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65338. import { Camera } from "babylonjs/Cameras/camera";
  65339. import { IDisposable } from "babylonjs/scene";
  65340. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  65341. import { Scene } from "babylonjs/scene";
  65342. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  65343. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  65344. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  65345. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  65346. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  65347. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65348. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  65349. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65350. import { Animation } from "babylonjs/Animations/animation";
  65351. /**
  65352. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  65353. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65354. */
  65355. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65356. private _scene;
  65357. private _camerasToBeAttached;
  65358. /**
  65359. * ID of the sharpen post process,
  65360. */
  65361. private readonly SharpenPostProcessId;
  65362. /**
  65363. * @ignore
  65364. * ID of the image processing post process;
  65365. */
  65366. readonly ImageProcessingPostProcessId: string;
  65367. /**
  65368. * @ignore
  65369. * ID of the Fast Approximate Anti-Aliasing post process;
  65370. */
  65371. readonly FxaaPostProcessId: string;
  65372. /**
  65373. * ID of the chromatic aberration post process,
  65374. */
  65375. private readonly ChromaticAberrationPostProcessId;
  65376. /**
  65377. * ID of the grain post process
  65378. */
  65379. private readonly GrainPostProcessId;
  65380. /**
  65381. * Sharpen post process which will apply a sharpen convolution to enhance edges
  65382. */
  65383. sharpen: SharpenPostProcess;
  65384. private _sharpenEffect;
  65385. private bloom;
  65386. /**
  65387. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  65388. */
  65389. depthOfField: DepthOfFieldEffect;
  65390. /**
  65391. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65392. */
  65393. fxaa: FxaaPostProcess;
  65394. /**
  65395. * Image post processing pass used to perform operations such as tone mapping or color grading.
  65396. */
  65397. imageProcessing: ImageProcessingPostProcess;
  65398. /**
  65399. * Chromatic aberration post process which will shift rgb colors in the image
  65400. */
  65401. chromaticAberration: ChromaticAberrationPostProcess;
  65402. private _chromaticAberrationEffect;
  65403. /**
  65404. * Grain post process which add noise to the image
  65405. */
  65406. grain: GrainPostProcess;
  65407. private _grainEffect;
  65408. /**
  65409. * Glow post process which adds a glow to emissive areas of the image
  65410. */
  65411. private _glowLayer;
  65412. /**
  65413. * Animations which can be used to tweak settings over a period of time
  65414. */
  65415. animations: Animation[];
  65416. private _imageProcessingConfigurationObserver;
  65417. private _sharpenEnabled;
  65418. private _bloomEnabled;
  65419. private _depthOfFieldEnabled;
  65420. private _depthOfFieldBlurLevel;
  65421. private _fxaaEnabled;
  65422. private _imageProcessingEnabled;
  65423. private _defaultPipelineTextureType;
  65424. private _bloomScale;
  65425. private _chromaticAberrationEnabled;
  65426. private _grainEnabled;
  65427. private _buildAllowed;
  65428. /**
  65429. * Gets active scene
  65430. */
  65431. readonly scene: Scene;
  65432. /**
  65433. * Enable or disable the sharpen process from the pipeline
  65434. */
  65435. sharpenEnabled: boolean;
  65436. private _resizeObserver;
  65437. private _hardwareScaleLevel;
  65438. private _bloomKernel;
  65439. /**
  65440. * Specifies the size of the bloom blur kernel, relative to the final output size
  65441. */
  65442. bloomKernel: number;
  65443. /**
  65444. * Specifies the weight of the bloom in the final rendering
  65445. */
  65446. private _bloomWeight;
  65447. /**
  65448. * Specifies the luma threshold for the area that will be blurred by the bloom
  65449. */
  65450. private _bloomThreshold;
  65451. private _hdr;
  65452. /**
  65453. * The strength of the bloom.
  65454. */
  65455. bloomWeight: number;
  65456. /**
  65457. * The strength of the bloom.
  65458. */
  65459. bloomThreshold: number;
  65460. /**
  65461. * The scale of the bloom, lower value will provide better performance.
  65462. */
  65463. bloomScale: number;
  65464. /**
  65465. * Enable or disable the bloom from the pipeline
  65466. */
  65467. bloomEnabled: boolean;
  65468. private _rebuildBloom;
  65469. /**
  65470. * If the depth of field is enabled.
  65471. */
  65472. depthOfFieldEnabled: boolean;
  65473. /**
  65474. * Blur level of the depth of field effect. (Higher blur will effect performance)
  65475. */
  65476. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  65477. /**
  65478. * If the anti aliasing is enabled.
  65479. */
  65480. fxaaEnabled: boolean;
  65481. private _samples;
  65482. /**
  65483. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65484. */
  65485. samples: number;
  65486. /**
  65487. * If image processing is enabled.
  65488. */
  65489. imageProcessingEnabled: boolean;
  65490. /**
  65491. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  65492. */
  65493. glowLayerEnabled: boolean;
  65494. /**
  65495. * Gets the glow layer (or null if not defined)
  65496. */
  65497. readonly glowLayer: Nullable<GlowLayer>;
  65498. /**
  65499. * Enable or disable the chromaticAberration process from the pipeline
  65500. */
  65501. chromaticAberrationEnabled: boolean;
  65502. /**
  65503. * Enable or disable the grain process from the pipeline
  65504. */
  65505. grainEnabled: boolean;
  65506. /**
  65507. * @constructor
  65508. * @param name - The rendering pipeline name (default: "")
  65509. * @param hdr - If high dynamic range textures should be used (default: true)
  65510. * @param scene - The scene linked to this pipeline (default: the last created scene)
  65511. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  65512. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  65513. */
  65514. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  65515. /**
  65516. * Get the class name
  65517. * @returns "DefaultRenderingPipeline"
  65518. */
  65519. getClassName(): string;
  65520. /**
  65521. * Force the compilation of the entire pipeline.
  65522. */
  65523. prepare(): void;
  65524. private _hasCleared;
  65525. private _prevPostProcess;
  65526. private _prevPrevPostProcess;
  65527. private _setAutoClearAndTextureSharing;
  65528. private _depthOfFieldSceneObserver;
  65529. private _buildPipeline;
  65530. private _disposePostProcesses;
  65531. /**
  65532. * Adds a camera to the pipeline
  65533. * @param camera the camera to be added
  65534. */
  65535. addCamera(camera: Camera): void;
  65536. /**
  65537. * Removes a camera from the pipeline
  65538. * @param camera the camera to remove
  65539. */
  65540. removeCamera(camera: Camera): void;
  65541. /**
  65542. * Dispose of the pipeline and stop all post processes
  65543. */
  65544. dispose(): void;
  65545. /**
  65546. * Serialize the rendering pipeline (Used when exporting)
  65547. * @returns the serialized object
  65548. */
  65549. serialize(): any;
  65550. /**
  65551. * Parse the serialized pipeline
  65552. * @param source Source pipeline.
  65553. * @param scene The scene to load the pipeline to.
  65554. * @param rootUrl The URL of the serialized pipeline.
  65555. * @returns An instantiated pipeline from the serialized object.
  65556. */
  65557. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  65558. }
  65559. }
  65560. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  65561. /** @hidden */
  65562. export var lensHighlightsPixelShader: {
  65563. name: string;
  65564. shader: string;
  65565. };
  65566. }
  65567. declare module "babylonjs/Shaders/depthOfField.fragment" {
  65568. /** @hidden */
  65569. export var depthOfFieldPixelShader: {
  65570. name: string;
  65571. shader: string;
  65572. };
  65573. }
  65574. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  65575. import { Camera } from "babylonjs/Cameras/camera";
  65576. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65577. import { Scene } from "babylonjs/scene";
  65578. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65579. import "babylonjs/Shaders/chromaticAberration.fragment";
  65580. import "babylonjs/Shaders/lensHighlights.fragment";
  65581. import "babylonjs/Shaders/depthOfField.fragment";
  65582. /**
  65583. * BABYLON.JS Chromatic Aberration GLSL Shader
  65584. * Author: Olivier Guyot
  65585. * Separates very slightly R, G and B colors on the edges of the screen
  65586. * Inspired by Francois Tarlier & Martins Upitis
  65587. */
  65588. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  65589. /**
  65590. * @ignore
  65591. * The chromatic aberration PostProcess id in the pipeline
  65592. */
  65593. LensChromaticAberrationEffect: string;
  65594. /**
  65595. * @ignore
  65596. * The highlights enhancing PostProcess id in the pipeline
  65597. */
  65598. HighlightsEnhancingEffect: string;
  65599. /**
  65600. * @ignore
  65601. * The depth-of-field PostProcess id in the pipeline
  65602. */
  65603. LensDepthOfFieldEffect: string;
  65604. private _scene;
  65605. private _depthTexture;
  65606. private _grainTexture;
  65607. private _chromaticAberrationPostProcess;
  65608. private _highlightsPostProcess;
  65609. private _depthOfFieldPostProcess;
  65610. private _edgeBlur;
  65611. private _grainAmount;
  65612. private _chromaticAberration;
  65613. private _distortion;
  65614. private _highlightsGain;
  65615. private _highlightsThreshold;
  65616. private _dofDistance;
  65617. private _dofAperture;
  65618. private _dofDarken;
  65619. private _dofPentagon;
  65620. private _blurNoise;
  65621. /**
  65622. * @constructor
  65623. *
  65624. * Effect parameters are as follow:
  65625. * {
  65626. * chromatic_aberration: number; // from 0 to x (1 for realism)
  65627. * edge_blur: number; // from 0 to x (1 for realism)
  65628. * distortion: number; // from 0 to x (1 for realism)
  65629. * grain_amount: number; // from 0 to 1
  65630. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  65631. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  65632. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  65633. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  65634. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  65635. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  65636. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  65637. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  65638. * }
  65639. * Note: if an effect parameter is unset, effect is disabled
  65640. *
  65641. * @param name The rendering pipeline name
  65642. * @param parameters - An object containing all parameters (see above)
  65643. * @param scene The scene linked to this pipeline
  65644. * @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)
  65645. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65646. */
  65647. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  65648. /**
  65649. * Get the class name
  65650. * @returns "LensRenderingPipeline"
  65651. */
  65652. getClassName(): string;
  65653. /**
  65654. * Gets associated scene
  65655. */
  65656. readonly scene: Scene;
  65657. /**
  65658. * Gets or sets the edge blur
  65659. */
  65660. edgeBlur: number;
  65661. /**
  65662. * Gets or sets the grain amount
  65663. */
  65664. grainAmount: number;
  65665. /**
  65666. * Gets or sets the chromatic aberration amount
  65667. */
  65668. chromaticAberration: number;
  65669. /**
  65670. * Gets or sets the depth of field aperture
  65671. */
  65672. dofAperture: number;
  65673. /**
  65674. * Gets or sets the edge distortion
  65675. */
  65676. edgeDistortion: number;
  65677. /**
  65678. * Gets or sets the depth of field distortion
  65679. */
  65680. dofDistortion: number;
  65681. /**
  65682. * Gets or sets the darken out of focus amount
  65683. */
  65684. darkenOutOfFocus: number;
  65685. /**
  65686. * Gets or sets a boolean indicating if blur noise is enabled
  65687. */
  65688. blurNoise: boolean;
  65689. /**
  65690. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  65691. */
  65692. pentagonBokeh: boolean;
  65693. /**
  65694. * Gets or sets the highlight grain amount
  65695. */
  65696. highlightsGain: number;
  65697. /**
  65698. * Gets or sets the highlight threshold
  65699. */
  65700. highlightsThreshold: number;
  65701. /**
  65702. * Sets the amount of blur at the edges
  65703. * @param amount blur amount
  65704. */
  65705. setEdgeBlur(amount: number): void;
  65706. /**
  65707. * Sets edge blur to 0
  65708. */
  65709. disableEdgeBlur(): void;
  65710. /**
  65711. * Sets the amout of grain
  65712. * @param amount Amount of grain
  65713. */
  65714. setGrainAmount(amount: number): void;
  65715. /**
  65716. * Set grain amount to 0
  65717. */
  65718. disableGrain(): void;
  65719. /**
  65720. * Sets the chromatic aberration amount
  65721. * @param amount amount of chromatic aberration
  65722. */
  65723. setChromaticAberration(amount: number): void;
  65724. /**
  65725. * Sets chromatic aberration amount to 0
  65726. */
  65727. disableChromaticAberration(): void;
  65728. /**
  65729. * Sets the EdgeDistortion amount
  65730. * @param amount amount of EdgeDistortion
  65731. */
  65732. setEdgeDistortion(amount: number): void;
  65733. /**
  65734. * Sets edge distortion to 0
  65735. */
  65736. disableEdgeDistortion(): void;
  65737. /**
  65738. * Sets the FocusDistance amount
  65739. * @param amount amount of FocusDistance
  65740. */
  65741. setFocusDistance(amount: number): void;
  65742. /**
  65743. * Disables depth of field
  65744. */
  65745. disableDepthOfField(): void;
  65746. /**
  65747. * Sets the Aperture amount
  65748. * @param amount amount of Aperture
  65749. */
  65750. setAperture(amount: number): void;
  65751. /**
  65752. * Sets the DarkenOutOfFocus amount
  65753. * @param amount amount of DarkenOutOfFocus
  65754. */
  65755. setDarkenOutOfFocus(amount: number): void;
  65756. private _pentagonBokehIsEnabled;
  65757. /**
  65758. * Creates a pentagon bokeh effect
  65759. */
  65760. enablePentagonBokeh(): void;
  65761. /**
  65762. * Disables the pentagon bokeh effect
  65763. */
  65764. disablePentagonBokeh(): void;
  65765. /**
  65766. * Enables noise blur
  65767. */
  65768. enableNoiseBlur(): void;
  65769. /**
  65770. * Disables noise blur
  65771. */
  65772. disableNoiseBlur(): void;
  65773. /**
  65774. * Sets the HighlightsGain amount
  65775. * @param amount amount of HighlightsGain
  65776. */
  65777. setHighlightsGain(amount: number): void;
  65778. /**
  65779. * Sets the HighlightsThreshold amount
  65780. * @param amount amount of HighlightsThreshold
  65781. */
  65782. setHighlightsThreshold(amount: number): void;
  65783. /**
  65784. * Disables highlights
  65785. */
  65786. disableHighlights(): void;
  65787. /**
  65788. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  65789. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  65790. */
  65791. dispose(disableDepthRender?: boolean): void;
  65792. private _createChromaticAberrationPostProcess;
  65793. private _createHighlightsPostProcess;
  65794. private _createDepthOfFieldPostProcess;
  65795. private _createGrainTexture;
  65796. }
  65797. }
  65798. declare module "babylonjs/Shaders/ssao2.fragment" {
  65799. /** @hidden */
  65800. export var ssao2PixelShader: {
  65801. name: string;
  65802. shader: string;
  65803. };
  65804. }
  65805. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  65806. /** @hidden */
  65807. export var ssaoCombinePixelShader: {
  65808. name: string;
  65809. shader: string;
  65810. };
  65811. }
  65812. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  65813. import { Camera } from "babylonjs/Cameras/camera";
  65814. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65815. import { Scene } from "babylonjs/scene";
  65816. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65817. import "babylonjs/Shaders/ssao2.fragment";
  65818. import "babylonjs/Shaders/ssaoCombine.fragment";
  65819. /**
  65820. * Render pipeline to produce ssao effect
  65821. */
  65822. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  65823. /**
  65824. * @ignore
  65825. * The PassPostProcess id in the pipeline that contains the original scene color
  65826. */
  65827. SSAOOriginalSceneColorEffect: string;
  65828. /**
  65829. * @ignore
  65830. * The SSAO PostProcess id in the pipeline
  65831. */
  65832. SSAORenderEffect: string;
  65833. /**
  65834. * @ignore
  65835. * The horizontal blur PostProcess id in the pipeline
  65836. */
  65837. SSAOBlurHRenderEffect: string;
  65838. /**
  65839. * @ignore
  65840. * The vertical blur PostProcess id in the pipeline
  65841. */
  65842. SSAOBlurVRenderEffect: string;
  65843. /**
  65844. * @ignore
  65845. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65846. */
  65847. SSAOCombineRenderEffect: string;
  65848. /**
  65849. * The output strength of the SSAO post-process. Default value is 1.0.
  65850. */
  65851. totalStrength: number;
  65852. /**
  65853. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  65854. */
  65855. maxZ: number;
  65856. /**
  65857. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  65858. */
  65859. minZAspect: number;
  65860. private _samples;
  65861. /**
  65862. * Number of samples used for the SSAO calculations. Default value is 8
  65863. */
  65864. samples: number;
  65865. private _textureSamples;
  65866. /**
  65867. * Number of samples to use for antialiasing
  65868. */
  65869. textureSamples: number;
  65870. /**
  65871. * Ratio object used for SSAO ratio and blur ratio
  65872. */
  65873. private _ratio;
  65874. /**
  65875. * Dynamically generated sphere sampler.
  65876. */
  65877. private _sampleSphere;
  65878. /**
  65879. * Blur filter offsets
  65880. */
  65881. private _samplerOffsets;
  65882. private _expensiveBlur;
  65883. /**
  65884. * If bilateral blur should be used
  65885. */
  65886. expensiveBlur: boolean;
  65887. /**
  65888. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  65889. */
  65890. radius: number;
  65891. /**
  65892. * The base color of the SSAO post-process
  65893. * The final result is "base + ssao" between [0, 1]
  65894. */
  65895. base: number;
  65896. /**
  65897. * Support test.
  65898. */
  65899. static readonly IsSupported: boolean;
  65900. private _scene;
  65901. private _depthTexture;
  65902. private _normalTexture;
  65903. private _randomTexture;
  65904. private _originalColorPostProcess;
  65905. private _ssaoPostProcess;
  65906. private _blurHPostProcess;
  65907. private _blurVPostProcess;
  65908. private _ssaoCombinePostProcess;
  65909. /**
  65910. * Gets active scene
  65911. */
  65912. readonly scene: Scene;
  65913. /**
  65914. * @constructor
  65915. * @param name The rendering pipeline name
  65916. * @param scene The scene linked to this pipeline
  65917. * @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 }
  65918. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65919. */
  65920. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65921. /**
  65922. * Get the class name
  65923. * @returns "SSAO2RenderingPipeline"
  65924. */
  65925. getClassName(): string;
  65926. /**
  65927. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65928. */
  65929. dispose(disableGeometryBufferRenderer?: boolean): void;
  65930. private _createBlurPostProcess;
  65931. /** @hidden */
  65932. _rebuild(): void;
  65933. private _bits;
  65934. private _radicalInverse_VdC;
  65935. private _hammersley;
  65936. private _hemisphereSample_uniform;
  65937. private _generateHemisphere;
  65938. private _createSSAOPostProcess;
  65939. private _createSSAOCombinePostProcess;
  65940. private _createRandomTexture;
  65941. /**
  65942. * Serialize the rendering pipeline (Used when exporting)
  65943. * @returns the serialized object
  65944. */
  65945. serialize(): any;
  65946. /**
  65947. * Parse the serialized pipeline
  65948. * @param source Source pipeline.
  65949. * @param scene The scene to load the pipeline to.
  65950. * @param rootUrl The URL of the serialized pipeline.
  65951. * @returns An instantiated pipeline from the serialized object.
  65952. */
  65953. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  65954. }
  65955. }
  65956. declare module "babylonjs/Shaders/ssao.fragment" {
  65957. /** @hidden */
  65958. export var ssaoPixelShader: {
  65959. name: string;
  65960. shader: string;
  65961. };
  65962. }
  65963. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  65964. import { Camera } from "babylonjs/Cameras/camera";
  65965. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65966. import { Scene } from "babylonjs/scene";
  65967. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65968. import "babylonjs/Shaders/ssao.fragment";
  65969. import "babylonjs/Shaders/ssaoCombine.fragment";
  65970. /**
  65971. * Render pipeline to produce ssao effect
  65972. */
  65973. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  65974. /**
  65975. * @ignore
  65976. * The PassPostProcess id in the pipeline that contains the original scene color
  65977. */
  65978. SSAOOriginalSceneColorEffect: string;
  65979. /**
  65980. * @ignore
  65981. * The SSAO PostProcess id in the pipeline
  65982. */
  65983. SSAORenderEffect: string;
  65984. /**
  65985. * @ignore
  65986. * The horizontal blur PostProcess id in the pipeline
  65987. */
  65988. SSAOBlurHRenderEffect: string;
  65989. /**
  65990. * @ignore
  65991. * The vertical blur PostProcess id in the pipeline
  65992. */
  65993. SSAOBlurVRenderEffect: string;
  65994. /**
  65995. * @ignore
  65996. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65997. */
  65998. SSAOCombineRenderEffect: string;
  65999. /**
  66000. * The output strength of the SSAO post-process. Default value is 1.0.
  66001. */
  66002. totalStrength: number;
  66003. /**
  66004. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  66005. */
  66006. radius: number;
  66007. /**
  66008. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  66009. * Must not be equal to fallOff and superior to fallOff.
  66010. * Default value is 0.0075
  66011. */
  66012. area: number;
  66013. /**
  66014. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  66015. * Must not be equal to area and inferior to area.
  66016. * Default value is 0.000001
  66017. */
  66018. fallOff: number;
  66019. /**
  66020. * The base color of the SSAO post-process
  66021. * The final result is "base + ssao" between [0, 1]
  66022. */
  66023. base: number;
  66024. private _scene;
  66025. private _depthTexture;
  66026. private _randomTexture;
  66027. private _originalColorPostProcess;
  66028. private _ssaoPostProcess;
  66029. private _blurHPostProcess;
  66030. private _blurVPostProcess;
  66031. private _ssaoCombinePostProcess;
  66032. private _firstUpdate;
  66033. /**
  66034. * Gets active scene
  66035. */
  66036. readonly scene: Scene;
  66037. /**
  66038. * @constructor
  66039. * @param name - The rendering pipeline name
  66040. * @param scene - The scene linked to this pipeline
  66041. * @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 }
  66042. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  66043. */
  66044. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66045. /**
  66046. * Get the class name
  66047. * @returns "SSAORenderingPipeline"
  66048. */
  66049. getClassName(): string;
  66050. /**
  66051. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66052. */
  66053. dispose(disableDepthRender?: boolean): void;
  66054. private _createBlurPostProcess;
  66055. /** @hidden */
  66056. _rebuild(): void;
  66057. private _createSSAOPostProcess;
  66058. private _createSSAOCombinePostProcess;
  66059. private _createRandomTexture;
  66060. }
  66061. }
  66062. declare module "babylonjs/Shaders/standard.fragment" {
  66063. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  66064. /** @hidden */
  66065. export var standardPixelShader: {
  66066. name: string;
  66067. shader: string;
  66068. };
  66069. }
  66070. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  66071. import { Nullable } from "babylonjs/types";
  66072. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  66073. import { Camera } from "babylonjs/Cameras/camera";
  66074. import { Texture } from "babylonjs/Materials/Textures/texture";
  66075. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  66076. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  66077. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  66078. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  66079. import { IDisposable } from "babylonjs/scene";
  66080. import { SpotLight } from "babylonjs/Lights/spotLight";
  66081. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  66082. import { Scene } from "babylonjs/scene";
  66083. import { Animation } from "babylonjs/Animations/animation";
  66084. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  66085. import "babylonjs/Shaders/standard.fragment";
  66086. /**
  66087. * Standard rendering pipeline
  66088. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66089. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  66090. */
  66091. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66092. /**
  66093. * Public members
  66094. */
  66095. /**
  66096. * Post-process which contains the original scene color before the pipeline applies all the effects
  66097. */
  66098. originalPostProcess: Nullable<PostProcess>;
  66099. /**
  66100. * Post-process used to down scale an image x4
  66101. */
  66102. downSampleX4PostProcess: Nullable<PostProcess>;
  66103. /**
  66104. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  66105. */
  66106. brightPassPostProcess: Nullable<PostProcess>;
  66107. /**
  66108. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  66109. */
  66110. blurHPostProcesses: PostProcess[];
  66111. /**
  66112. * Post-process array storing all the vertical blur post-processes used by the pipeline
  66113. */
  66114. blurVPostProcesses: PostProcess[];
  66115. /**
  66116. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  66117. */
  66118. textureAdderPostProcess: Nullable<PostProcess>;
  66119. /**
  66120. * Post-process used to create volumetric lighting effect
  66121. */
  66122. volumetricLightPostProcess: Nullable<PostProcess>;
  66123. /**
  66124. * Post-process used to smooth the previous volumetric light post-process on the X axis
  66125. */
  66126. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  66127. /**
  66128. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  66129. */
  66130. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  66131. /**
  66132. * Post-process used to merge the volumetric light effect and the real scene color
  66133. */
  66134. volumetricLightMergePostProces: Nullable<PostProcess>;
  66135. /**
  66136. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  66137. */
  66138. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  66139. /**
  66140. * Base post-process used to calculate the average luminance of the final image for HDR
  66141. */
  66142. luminancePostProcess: Nullable<PostProcess>;
  66143. /**
  66144. * Post-processes used to create down sample post-processes in order to get
  66145. * the average luminance of the final image for HDR
  66146. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  66147. */
  66148. luminanceDownSamplePostProcesses: PostProcess[];
  66149. /**
  66150. * Post-process used to create a HDR effect (light adaptation)
  66151. */
  66152. hdrPostProcess: Nullable<PostProcess>;
  66153. /**
  66154. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  66155. */
  66156. textureAdderFinalPostProcess: Nullable<PostProcess>;
  66157. /**
  66158. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  66159. */
  66160. lensFlareFinalPostProcess: Nullable<PostProcess>;
  66161. /**
  66162. * Post-process used to merge the final HDR post-process and the real scene color
  66163. */
  66164. hdrFinalPostProcess: Nullable<PostProcess>;
  66165. /**
  66166. * Post-process used to create a lens flare effect
  66167. */
  66168. lensFlarePostProcess: Nullable<PostProcess>;
  66169. /**
  66170. * Post-process that merges the result of the lens flare post-process and the real scene color
  66171. */
  66172. lensFlareComposePostProcess: Nullable<PostProcess>;
  66173. /**
  66174. * Post-process used to create a motion blur effect
  66175. */
  66176. motionBlurPostProcess: Nullable<PostProcess>;
  66177. /**
  66178. * Post-process used to create a depth of field effect
  66179. */
  66180. depthOfFieldPostProcess: Nullable<PostProcess>;
  66181. /**
  66182. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66183. */
  66184. fxaaPostProcess: Nullable<FxaaPostProcess>;
  66185. /**
  66186. * Represents the brightness threshold in order to configure the illuminated surfaces
  66187. */
  66188. brightThreshold: number;
  66189. /**
  66190. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  66191. */
  66192. blurWidth: number;
  66193. /**
  66194. * Sets if the blur for highlighted surfaces must be only horizontal
  66195. */
  66196. horizontalBlur: boolean;
  66197. /**
  66198. * Gets the overall exposure used by the pipeline
  66199. */
  66200. /**
  66201. * Sets the overall exposure used by the pipeline
  66202. */
  66203. exposure: number;
  66204. /**
  66205. * Texture used typically to simulate "dirty" on camera lens
  66206. */
  66207. lensTexture: Nullable<Texture>;
  66208. /**
  66209. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  66210. */
  66211. volumetricLightCoefficient: number;
  66212. /**
  66213. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  66214. */
  66215. volumetricLightPower: number;
  66216. /**
  66217. * Used the set the blur intensity to smooth the volumetric lights
  66218. */
  66219. volumetricLightBlurScale: number;
  66220. /**
  66221. * Light (spot or directional) used to generate the volumetric lights rays
  66222. * The source light must have a shadow generate so the pipeline can get its
  66223. * depth map
  66224. */
  66225. sourceLight: Nullable<SpotLight | DirectionalLight>;
  66226. /**
  66227. * For eye adaptation, represents the minimum luminance the eye can see
  66228. */
  66229. hdrMinimumLuminance: number;
  66230. /**
  66231. * For eye adaptation, represents the decrease luminance speed
  66232. */
  66233. hdrDecreaseRate: number;
  66234. /**
  66235. * For eye adaptation, represents the increase luminance speed
  66236. */
  66237. hdrIncreaseRate: number;
  66238. /**
  66239. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66240. */
  66241. /**
  66242. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66243. */
  66244. hdrAutoExposure: boolean;
  66245. /**
  66246. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  66247. */
  66248. lensColorTexture: Nullable<Texture>;
  66249. /**
  66250. * The overall strengh for the lens flare effect
  66251. */
  66252. lensFlareStrength: number;
  66253. /**
  66254. * Dispersion coefficient for lens flare ghosts
  66255. */
  66256. lensFlareGhostDispersal: number;
  66257. /**
  66258. * Main lens flare halo width
  66259. */
  66260. lensFlareHaloWidth: number;
  66261. /**
  66262. * Based on the lens distortion effect, defines how much the lens flare result
  66263. * is distorted
  66264. */
  66265. lensFlareDistortionStrength: number;
  66266. /**
  66267. * Configures the blur intensity used for for lens flare (halo)
  66268. */
  66269. lensFlareBlurWidth: number;
  66270. /**
  66271. * Lens star texture must be used to simulate rays on the flares and is available
  66272. * in the documentation
  66273. */
  66274. lensStarTexture: Nullable<Texture>;
  66275. /**
  66276. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  66277. * flare effect by taking account of the dirt texture
  66278. */
  66279. lensFlareDirtTexture: Nullable<Texture>;
  66280. /**
  66281. * Represents the focal length for the depth of field effect
  66282. */
  66283. depthOfFieldDistance: number;
  66284. /**
  66285. * Represents the blur intensity for the blurred part of the depth of field effect
  66286. */
  66287. depthOfFieldBlurWidth: number;
  66288. /**
  66289. * Gets how much the image is blurred by the movement while using the motion blur post-process
  66290. */
  66291. /**
  66292. * Sets how much the image is blurred by the movement while using the motion blur post-process
  66293. */
  66294. motionStrength: number;
  66295. /**
  66296. * Gets wether or not the motion blur post-process is object based or screen based.
  66297. */
  66298. /**
  66299. * Sets wether or not the motion blur post-process should be object based or screen based
  66300. */
  66301. objectBasedMotionBlur: boolean;
  66302. /**
  66303. * List of animations for the pipeline (IAnimatable implementation)
  66304. */
  66305. animations: Animation[];
  66306. /**
  66307. * Private members
  66308. */
  66309. private _scene;
  66310. private _currentDepthOfFieldSource;
  66311. private _basePostProcess;
  66312. private _fixedExposure;
  66313. private _currentExposure;
  66314. private _hdrAutoExposure;
  66315. private _hdrCurrentLuminance;
  66316. private _motionStrength;
  66317. private _isObjectBasedMotionBlur;
  66318. private _floatTextureType;
  66319. private _camerasToBeAttached;
  66320. private _ratio;
  66321. private _bloomEnabled;
  66322. private _depthOfFieldEnabled;
  66323. private _vlsEnabled;
  66324. private _lensFlareEnabled;
  66325. private _hdrEnabled;
  66326. private _motionBlurEnabled;
  66327. private _fxaaEnabled;
  66328. private _motionBlurSamples;
  66329. private _volumetricLightStepsCount;
  66330. private _samples;
  66331. /**
  66332. * @ignore
  66333. * Specifies if the bloom pipeline is enabled
  66334. */
  66335. BloomEnabled: boolean;
  66336. /**
  66337. * @ignore
  66338. * Specifies if the depth of field pipeline is enabed
  66339. */
  66340. DepthOfFieldEnabled: boolean;
  66341. /**
  66342. * @ignore
  66343. * Specifies if the lens flare pipeline is enabed
  66344. */
  66345. LensFlareEnabled: boolean;
  66346. /**
  66347. * @ignore
  66348. * Specifies if the HDR pipeline is enabled
  66349. */
  66350. HDREnabled: boolean;
  66351. /**
  66352. * @ignore
  66353. * Specifies if the volumetric lights scattering effect is enabled
  66354. */
  66355. VLSEnabled: boolean;
  66356. /**
  66357. * @ignore
  66358. * Specifies if the motion blur effect is enabled
  66359. */
  66360. MotionBlurEnabled: boolean;
  66361. /**
  66362. * Specifies if anti-aliasing is enabled
  66363. */
  66364. fxaaEnabled: boolean;
  66365. /**
  66366. * Specifies the number of steps used to calculate the volumetric lights
  66367. * Typically in interval [50, 200]
  66368. */
  66369. volumetricLightStepsCount: number;
  66370. /**
  66371. * Specifies the number of samples used for the motion blur effect
  66372. * Typically in interval [16, 64]
  66373. */
  66374. motionBlurSamples: number;
  66375. /**
  66376. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66377. */
  66378. samples: number;
  66379. /**
  66380. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66381. * @constructor
  66382. * @param name The rendering pipeline name
  66383. * @param scene The scene linked to this pipeline
  66384. * @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)
  66385. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  66386. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66387. */
  66388. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  66389. private _buildPipeline;
  66390. private _createDownSampleX4PostProcess;
  66391. private _createBrightPassPostProcess;
  66392. private _createBlurPostProcesses;
  66393. private _createTextureAdderPostProcess;
  66394. private _createVolumetricLightPostProcess;
  66395. private _createLuminancePostProcesses;
  66396. private _createHdrPostProcess;
  66397. private _createLensFlarePostProcess;
  66398. private _createDepthOfFieldPostProcess;
  66399. private _createMotionBlurPostProcess;
  66400. private _getDepthTexture;
  66401. private _disposePostProcesses;
  66402. /**
  66403. * Dispose of the pipeline and stop all post processes
  66404. */
  66405. dispose(): void;
  66406. /**
  66407. * Serialize the rendering pipeline (Used when exporting)
  66408. * @returns the serialized object
  66409. */
  66410. serialize(): any;
  66411. /**
  66412. * Parse the serialized pipeline
  66413. * @param source Source pipeline.
  66414. * @param scene The scene to load the pipeline to.
  66415. * @param rootUrl The URL of the serialized pipeline.
  66416. * @returns An instantiated pipeline from the serialized object.
  66417. */
  66418. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  66419. /**
  66420. * Luminance steps
  66421. */
  66422. static LuminanceSteps: number;
  66423. }
  66424. }
  66425. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  66426. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  66427. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  66428. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  66429. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  66430. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  66431. }
  66432. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  66433. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  66434. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  66435. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  66436. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  66437. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  66438. }
  66439. declare module "babylonjs/Shaders/tonemap.fragment" {
  66440. /** @hidden */
  66441. export var tonemapPixelShader: {
  66442. name: string;
  66443. shader: string;
  66444. };
  66445. }
  66446. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  66447. import { Camera } from "babylonjs/Cameras/camera";
  66448. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  66449. import "babylonjs/Shaders/tonemap.fragment";
  66450. import { Engine } from "babylonjs/Engines/engine";
  66451. /** Defines operator used for tonemapping */
  66452. export enum TonemappingOperator {
  66453. /** Hable */
  66454. Hable = 0,
  66455. /** Reinhard */
  66456. Reinhard = 1,
  66457. /** HejiDawson */
  66458. HejiDawson = 2,
  66459. /** Photographic */
  66460. Photographic = 3
  66461. }
  66462. /**
  66463. * Defines a post process to apply tone mapping
  66464. */
  66465. export class TonemapPostProcess extends PostProcess {
  66466. private _operator;
  66467. /** Defines the required exposure adjustement */
  66468. exposureAdjustment: number;
  66469. /**
  66470. * Creates a new TonemapPostProcess
  66471. * @param name defines the name of the postprocess
  66472. * @param _operator defines the operator to use
  66473. * @param exposureAdjustment defines the required exposure adjustement
  66474. * @param camera defines the camera to use (can be null)
  66475. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  66476. * @param engine defines the hosting engine (can be ignore if camera is set)
  66477. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66478. */
  66479. constructor(name: string, _operator: TonemappingOperator,
  66480. /** Defines the required exposure adjustement */
  66481. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  66482. }
  66483. }
  66484. declare module "babylonjs/Shaders/depth.vertex" {
  66485. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66486. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66487. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66488. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66489. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66490. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66491. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66492. /** @hidden */
  66493. export var depthVertexShader: {
  66494. name: string;
  66495. shader: string;
  66496. };
  66497. }
  66498. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  66499. /** @hidden */
  66500. export var volumetricLightScatteringPixelShader: {
  66501. name: string;
  66502. shader: string;
  66503. };
  66504. }
  66505. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  66506. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66507. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66508. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66509. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66510. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66511. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66512. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66513. /** @hidden */
  66514. export var volumetricLightScatteringPassVertexShader: {
  66515. name: string;
  66516. shader: string;
  66517. };
  66518. }
  66519. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  66520. /** @hidden */
  66521. export var volumetricLightScatteringPassPixelShader: {
  66522. name: string;
  66523. shader: string;
  66524. };
  66525. }
  66526. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  66527. import { Vector3 } from "babylonjs/Maths/math.vector";
  66528. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66529. import { Mesh } from "babylonjs/Meshes/mesh";
  66530. import { Camera } from "babylonjs/Cameras/camera";
  66531. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66532. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  66533. import { Scene } from "babylonjs/scene";
  66534. import "babylonjs/Meshes/Builders/planeBuilder";
  66535. import "babylonjs/Shaders/depth.vertex";
  66536. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  66537. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  66538. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  66539. import { Engine } from "babylonjs/Engines/engine";
  66540. /**
  66541. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  66542. */
  66543. export class VolumetricLightScatteringPostProcess extends PostProcess {
  66544. private _volumetricLightScatteringPass;
  66545. private _volumetricLightScatteringRTT;
  66546. private _viewPort;
  66547. private _screenCoordinates;
  66548. private _cachedDefines;
  66549. /**
  66550. * If not undefined, the mesh position is computed from the attached node position
  66551. */
  66552. attachedNode: {
  66553. position: Vector3;
  66554. };
  66555. /**
  66556. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  66557. */
  66558. customMeshPosition: Vector3;
  66559. /**
  66560. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  66561. */
  66562. useCustomMeshPosition: boolean;
  66563. /**
  66564. * If the post-process should inverse the light scattering direction
  66565. */
  66566. invert: boolean;
  66567. /**
  66568. * The internal mesh used by the post-process
  66569. */
  66570. mesh: Mesh;
  66571. /**
  66572. * @hidden
  66573. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  66574. */
  66575. useDiffuseColor: boolean;
  66576. /**
  66577. * Array containing the excluded meshes not rendered in the internal pass
  66578. */
  66579. excludedMeshes: AbstractMesh[];
  66580. /**
  66581. * Controls the overall intensity of the post-process
  66582. */
  66583. exposure: number;
  66584. /**
  66585. * Dissipates each sample's contribution in range [0, 1]
  66586. */
  66587. decay: number;
  66588. /**
  66589. * Controls the overall intensity of each sample
  66590. */
  66591. weight: number;
  66592. /**
  66593. * Controls the density of each sample
  66594. */
  66595. density: number;
  66596. /**
  66597. * @constructor
  66598. * @param name The post-process name
  66599. * @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)
  66600. * @param camera The camera that the post-process will be attached to
  66601. * @param mesh The mesh used to create the light scattering
  66602. * @param samples The post-process quality, default 100
  66603. * @param samplingModeThe post-process filtering mode
  66604. * @param engine The babylon engine
  66605. * @param reusable If the post-process is reusable
  66606. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  66607. */
  66608. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  66609. /**
  66610. * Returns the string "VolumetricLightScatteringPostProcess"
  66611. * @returns "VolumetricLightScatteringPostProcess"
  66612. */
  66613. getClassName(): string;
  66614. private _isReady;
  66615. /**
  66616. * Sets the new light position for light scattering effect
  66617. * @param position The new custom light position
  66618. */
  66619. setCustomMeshPosition(position: Vector3): void;
  66620. /**
  66621. * Returns the light position for light scattering effect
  66622. * @return Vector3 The custom light position
  66623. */
  66624. getCustomMeshPosition(): Vector3;
  66625. /**
  66626. * Disposes the internal assets and detaches the post-process from the camera
  66627. */
  66628. dispose(camera: Camera): void;
  66629. /**
  66630. * Returns the render target texture used by the post-process
  66631. * @return the render target texture used by the post-process
  66632. */
  66633. getPass(): RenderTargetTexture;
  66634. private _meshExcluded;
  66635. private _createPass;
  66636. private _updateMeshScreenCoordinates;
  66637. /**
  66638. * Creates a default mesh for the Volumeric Light Scattering post-process
  66639. * @param name The mesh name
  66640. * @param scene The scene where to create the mesh
  66641. * @return the default mesh
  66642. */
  66643. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  66644. }
  66645. }
  66646. declare module "babylonjs/PostProcesses/index" {
  66647. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  66648. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  66649. export * from "babylonjs/PostProcesses/bloomEffect";
  66650. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  66651. export * from "babylonjs/PostProcesses/blurPostProcess";
  66652. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  66653. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  66654. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  66655. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  66656. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  66657. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  66658. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  66659. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  66660. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  66661. export * from "babylonjs/PostProcesses/filterPostProcess";
  66662. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  66663. export * from "babylonjs/PostProcesses/grainPostProcess";
  66664. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  66665. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  66666. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  66667. export * from "babylonjs/PostProcesses/passPostProcess";
  66668. export * from "babylonjs/PostProcesses/postProcess";
  66669. export * from "babylonjs/PostProcesses/postProcessManager";
  66670. export * from "babylonjs/PostProcesses/refractionPostProcess";
  66671. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  66672. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  66673. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  66674. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  66675. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  66676. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  66677. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  66678. }
  66679. declare module "babylonjs/Probes/index" {
  66680. export * from "babylonjs/Probes/reflectionProbe";
  66681. }
  66682. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  66683. import { Scene } from "babylonjs/scene";
  66684. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66685. import { SmartArray } from "babylonjs/Misc/smartArray";
  66686. import { ISceneComponent } from "babylonjs/sceneComponent";
  66687. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  66688. import "babylonjs/Meshes/Builders/boxBuilder";
  66689. import "babylonjs/Shaders/color.fragment";
  66690. import "babylonjs/Shaders/color.vertex";
  66691. import { Color3 } from "babylonjs/Maths/math.color";
  66692. module "babylonjs/scene" {
  66693. interface Scene {
  66694. /** @hidden (Backing field) */
  66695. _boundingBoxRenderer: BoundingBoxRenderer;
  66696. /** @hidden (Backing field) */
  66697. _forceShowBoundingBoxes: boolean;
  66698. /**
  66699. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  66700. */
  66701. forceShowBoundingBoxes: boolean;
  66702. /**
  66703. * Gets the bounding box renderer associated with the scene
  66704. * @returns a BoundingBoxRenderer
  66705. */
  66706. getBoundingBoxRenderer(): BoundingBoxRenderer;
  66707. }
  66708. }
  66709. module "babylonjs/Meshes/abstractMesh" {
  66710. interface AbstractMesh {
  66711. /** @hidden (Backing field) */
  66712. _showBoundingBox: boolean;
  66713. /**
  66714. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  66715. */
  66716. showBoundingBox: boolean;
  66717. }
  66718. }
  66719. /**
  66720. * Component responsible of rendering the bounding box of the meshes in a scene.
  66721. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  66722. */
  66723. export class BoundingBoxRenderer implements ISceneComponent {
  66724. /**
  66725. * The component name helpfull to identify the component in the list of scene components.
  66726. */
  66727. readonly name: string;
  66728. /**
  66729. * The scene the component belongs to.
  66730. */
  66731. scene: Scene;
  66732. /**
  66733. * Color of the bounding box lines placed in front of an object
  66734. */
  66735. frontColor: Color3;
  66736. /**
  66737. * Color of the bounding box lines placed behind an object
  66738. */
  66739. backColor: Color3;
  66740. /**
  66741. * Defines if the renderer should show the back lines or not
  66742. */
  66743. showBackLines: boolean;
  66744. /**
  66745. * @hidden
  66746. */
  66747. renderList: SmartArray<BoundingBox>;
  66748. private _colorShader;
  66749. private _vertexBuffers;
  66750. private _indexBuffer;
  66751. private _fillIndexBuffer;
  66752. private _fillIndexData;
  66753. /**
  66754. * Instantiates a new bounding box renderer in a scene.
  66755. * @param scene the scene the renderer renders in
  66756. */
  66757. constructor(scene: Scene);
  66758. /**
  66759. * Registers the component in a given scene
  66760. */
  66761. register(): void;
  66762. private _evaluateSubMesh;
  66763. private _activeMesh;
  66764. private _prepareRessources;
  66765. private _createIndexBuffer;
  66766. /**
  66767. * Rebuilds the elements related to this component in case of
  66768. * context lost for instance.
  66769. */
  66770. rebuild(): void;
  66771. /**
  66772. * @hidden
  66773. */
  66774. reset(): void;
  66775. /**
  66776. * Render the bounding boxes of a specific rendering group
  66777. * @param renderingGroupId defines the rendering group to render
  66778. */
  66779. render(renderingGroupId: number): void;
  66780. /**
  66781. * In case of occlusion queries, we can render the occlusion bounding box through this method
  66782. * @param mesh Define the mesh to render the occlusion bounding box for
  66783. */
  66784. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  66785. /**
  66786. * Dispose and release the resources attached to this renderer.
  66787. */
  66788. dispose(): void;
  66789. }
  66790. }
  66791. declare module "babylonjs/Shaders/depth.fragment" {
  66792. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  66793. /** @hidden */
  66794. export var depthPixelShader: {
  66795. name: string;
  66796. shader: string;
  66797. };
  66798. }
  66799. declare module "babylonjs/Rendering/depthRenderer" {
  66800. import { Nullable } from "babylonjs/types";
  66801. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66802. import { Scene } from "babylonjs/scene";
  66803. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66804. import { Camera } from "babylonjs/Cameras/camera";
  66805. import "babylonjs/Shaders/depth.fragment";
  66806. import "babylonjs/Shaders/depth.vertex";
  66807. /**
  66808. * This represents a depth renderer in Babylon.
  66809. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  66810. */
  66811. export class DepthRenderer {
  66812. private _scene;
  66813. private _depthMap;
  66814. private _effect;
  66815. private readonly _storeNonLinearDepth;
  66816. private readonly _clearColor;
  66817. /** Get if the depth renderer is using packed depth or not */
  66818. readonly isPacked: boolean;
  66819. private _cachedDefines;
  66820. private _camera;
  66821. /**
  66822. * Specifiess that the depth renderer will only be used within
  66823. * the camera it is created for.
  66824. * This can help forcing its rendering during the camera processing.
  66825. */
  66826. useOnlyInActiveCamera: boolean;
  66827. /** @hidden */
  66828. static _SceneComponentInitialization: (scene: Scene) => void;
  66829. /**
  66830. * Instantiates a depth renderer
  66831. * @param scene The scene the renderer belongs to
  66832. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  66833. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  66834. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66835. */
  66836. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  66837. /**
  66838. * Creates the depth rendering effect and checks if the effect is ready.
  66839. * @param subMesh The submesh to be used to render the depth map of
  66840. * @param useInstances If multiple world instances should be used
  66841. * @returns if the depth renderer is ready to render the depth map
  66842. */
  66843. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66844. /**
  66845. * Gets the texture which the depth map will be written to.
  66846. * @returns The depth map texture
  66847. */
  66848. getDepthMap(): RenderTargetTexture;
  66849. /**
  66850. * Disposes of the depth renderer.
  66851. */
  66852. dispose(): void;
  66853. }
  66854. }
  66855. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  66856. import { Nullable } from "babylonjs/types";
  66857. import { Scene } from "babylonjs/scene";
  66858. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  66859. import { Camera } from "babylonjs/Cameras/camera";
  66860. import { ISceneComponent } from "babylonjs/sceneComponent";
  66861. module "babylonjs/scene" {
  66862. interface Scene {
  66863. /** @hidden (Backing field) */
  66864. _depthRenderer: {
  66865. [id: string]: DepthRenderer;
  66866. };
  66867. /**
  66868. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  66869. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  66870. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66871. * @returns the created depth renderer
  66872. */
  66873. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  66874. /**
  66875. * Disables a depth renderer for a given camera
  66876. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  66877. */
  66878. disableDepthRenderer(camera?: Nullable<Camera>): void;
  66879. }
  66880. }
  66881. /**
  66882. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  66883. * in several rendering techniques.
  66884. */
  66885. export class DepthRendererSceneComponent implements ISceneComponent {
  66886. /**
  66887. * The component name helpfull to identify the component in the list of scene components.
  66888. */
  66889. readonly name: string;
  66890. /**
  66891. * The scene the component belongs to.
  66892. */
  66893. scene: Scene;
  66894. /**
  66895. * Creates a new instance of the component for the given scene
  66896. * @param scene Defines the scene to register the component in
  66897. */
  66898. constructor(scene: Scene);
  66899. /**
  66900. * Registers the component in a given scene
  66901. */
  66902. register(): void;
  66903. /**
  66904. * Rebuilds the elements related to this component in case of
  66905. * context lost for instance.
  66906. */
  66907. rebuild(): void;
  66908. /**
  66909. * Disposes the component and the associated ressources
  66910. */
  66911. dispose(): void;
  66912. private _gatherRenderTargets;
  66913. private _gatherActiveCameraRenderTargets;
  66914. }
  66915. }
  66916. declare module "babylonjs/Shaders/outline.fragment" {
  66917. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  66918. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  66919. /** @hidden */
  66920. export var outlinePixelShader: {
  66921. name: string;
  66922. shader: string;
  66923. };
  66924. }
  66925. declare module "babylonjs/Shaders/outline.vertex" {
  66926. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66927. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66928. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66929. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66930. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  66931. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66932. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66933. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66934. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  66935. /** @hidden */
  66936. export var outlineVertexShader: {
  66937. name: string;
  66938. shader: string;
  66939. };
  66940. }
  66941. declare module "babylonjs/Rendering/outlineRenderer" {
  66942. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66943. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  66944. import { Scene } from "babylonjs/scene";
  66945. import { ISceneComponent } from "babylonjs/sceneComponent";
  66946. import "babylonjs/Shaders/outline.fragment";
  66947. import "babylonjs/Shaders/outline.vertex";
  66948. module "babylonjs/scene" {
  66949. interface Scene {
  66950. /** @hidden */
  66951. _outlineRenderer: OutlineRenderer;
  66952. /**
  66953. * Gets the outline renderer associated with the scene
  66954. * @returns a OutlineRenderer
  66955. */
  66956. getOutlineRenderer(): OutlineRenderer;
  66957. }
  66958. }
  66959. module "babylonjs/Meshes/abstractMesh" {
  66960. interface AbstractMesh {
  66961. /** @hidden (Backing field) */
  66962. _renderOutline: boolean;
  66963. /**
  66964. * Gets or sets a boolean indicating if the outline must be rendered as well
  66965. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  66966. */
  66967. renderOutline: boolean;
  66968. /** @hidden (Backing field) */
  66969. _renderOverlay: boolean;
  66970. /**
  66971. * Gets or sets a boolean indicating if the overlay must be rendered as well
  66972. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  66973. */
  66974. renderOverlay: boolean;
  66975. }
  66976. }
  66977. /**
  66978. * This class is responsible to draw bothe outline/overlay of meshes.
  66979. * It should not be used directly but through the available method on mesh.
  66980. */
  66981. export class OutlineRenderer implements ISceneComponent {
  66982. /**
  66983. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  66984. */
  66985. private static _StencilReference;
  66986. /**
  66987. * The name of the component. Each component must have a unique name.
  66988. */
  66989. name: string;
  66990. /**
  66991. * The scene the component belongs to.
  66992. */
  66993. scene: Scene;
  66994. /**
  66995. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  66996. */
  66997. zOffset: number;
  66998. private _engine;
  66999. private _effect;
  67000. private _cachedDefines;
  67001. private _savedDepthWrite;
  67002. /**
  67003. * Instantiates a new outline renderer. (There could be only one per scene).
  67004. * @param scene Defines the scene it belongs to
  67005. */
  67006. constructor(scene: Scene);
  67007. /**
  67008. * Register the component to one instance of a scene.
  67009. */
  67010. register(): void;
  67011. /**
  67012. * Rebuilds the elements related to this component in case of
  67013. * context lost for instance.
  67014. */
  67015. rebuild(): void;
  67016. /**
  67017. * Disposes the component and the associated ressources.
  67018. */
  67019. dispose(): void;
  67020. /**
  67021. * Renders the outline in the canvas.
  67022. * @param subMesh Defines the sumesh to render
  67023. * @param batch Defines the batch of meshes in case of instances
  67024. * @param useOverlay Defines if the rendering is for the overlay or the outline
  67025. */
  67026. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  67027. /**
  67028. * Returns whether or not the outline renderer is ready for a given submesh.
  67029. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  67030. * @param subMesh Defines the submesh to check readyness for
  67031. * @param useInstances Defines wheter wee are trying to render instances or not
  67032. * @returns true if ready otherwise false
  67033. */
  67034. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67035. private _beforeRenderingMesh;
  67036. private _afterRenderingMesh;
  67037. }
  67038. }
  67039. declare module "babylonjs/Rendering/index" {
  67040. export * from "babylonjs/Rendering/boundingBoxRenderer";
  67041. export * from "babylonjs/Rendering/depthRenderer";
  67042. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  67043. export * from "babylonjs/Rendering/edgesRenderer";
  67044. export * from "babylonjs/Rendering/geometryBufferRenderer";
  67045. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  67046. export * from "babylonjs/Rendering/outlineRenderer";
  67047. export * from "babylonjs/Rendering/renderingGroup";
  67048. export * from "babylonjs/Rendering/renderingManager";
  67049. export * from "babylonjs/Rendering/utilityLayerRenderer";
  67050. }
  67051. declare module "babylonjs/Sprites/spritePackedManager" {
  67052. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  67053. import { Scene } from "babylonjs/scene";
  67054. /**
  67055. * Class used to manage multiple sprites of different sizes on the same spritesheet
  67056. * @see http://doc.babylonjs.com/babylon101/sprites
  67057. */
  67058. export class SpritePackedManager extends SpriteManager {
  67059. /** defines the packed manager's name */
  67060. name: string;
  67061. /**
  67062. * Creates a new sprite manager from a packed sprite sheet
  67063. * @param name defines the manager's name
  67064. * @param imgUrl defines the sprite sheet url
  67065. * @param capacity defines the maximum allowed number of sprites
  67066. * @param scene defines the hosting scene
  67067. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  67068. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  67069. * @param samplingMode defines the smapling mode to use with spritesheet
  67070. * @param fromPacked set to true; do not alter
  67071. */
  67072. constructor(
  67073. /** defines the packed manager's name */
  67074. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  67075. }
  67076. }
  67077. declare module "babylonjs/Sprites/index" {
  67078. export * from "babylonjs/Sprites/sprite";
  67079. export * from "babylonjs/Sprites/spriteManager";
  67080. export * from "babylonjs/Sprites/spritePackedManager";
  67081. export * from "babylonjs/Sprites/spriteSceneComponent";
  67082. }
  67083. declare module "babylonjs/States/index" {
  67084. export * from "babylonjs/States/alphaCullingState";
  67085. export * from "babylonjs/States/depthCullingState";
  67086. export * from "babylonjs/States/stencilState";
  67087. }
  67088. declare module "babylonjs/Misc/assetsManager" {
  67089. import { Scene } from "babylonjs/scene";
  67090. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67091. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  67092. import { Skeleton } from "babylonjs/Bones/skeleton";
  67093. import { Observable } from "babylonjs/Misc/observable";
  67094. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  67095. import { Texture } from "babylonjs/Materials/Textures/texture";
  67096. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  67097. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  67098. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  67099. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  67100. /**
  67101. * Defines the list of states available for a task inside a AssetsManager
  67102. */
  67103. export enum AssetTaskState {
  67104. /**
  67105. * Initialization
  67106. */
  67107. INIT = 0,
  67108. /**
  67109. * Running
  67110. */
  67111. RUNNING = 1,
  67112. /**
  67113. * Done
  67114. */
  67115. DONE = 2,
  67116. /**
  67117. * Error
  67118. */
  67119. ERROR = 3
  67120. }
  67121. /**
  67122. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  67123. */
  67124. export abstract class AbstractAssetTask {
  67125. /**
  67126. * Task name
  67127. */ name: string;
  67128. /**
  67129. * Callback called when the task is successful
  67130. */
  67131. onSuccess: (task: any) => void;
  67132. /**
  67133. * Callback called when the task is not successful
  67134. */
  67135. onError: (task: any, message?: string, exception?: any) => void;
  67136. /**
  67137. * Creates a new AssetsManager
  67138. * @param name defines the name of the task
  67139. */
  67140. constructor(
  67141. /**
  67142. * Task name
  67143. */ name: string);
  67144. private _isCompleted;
  67145. private _taskState;
  67146. private _errorObject;
  67147. /**
  67148. * Get if the task is completed
  67149. */
  67150. readonly isCompleted: boolean;
  67151. /**
  67152. * Gets the current state of the task
  67153. */
  67154. readonly taskState: AssetTaskState;
  67155. /**
  67156. * Gets the current error object (if task is in error)
  67157. */
  67158. readonly errorObject: {
  67159. message?: string;
  67160. exception?: any;
  67161. };
  67162. /**
  67163. * Internal only
  67164. * @hidden
  67165. */
  67166. _setErrorObject(message?: string, exception?: any): void;
  67167. /**
  67168. * Execute the current task
  67169. * @param scene defines the scene where you want your assets to be loaded
  67170. * @param onSuccess is a callback called when the task is successfully executed
  67171. * @param onError is a callback called if an error occurs
  67172. */
  67173. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67174. /**
  67175. * Execute the current task
  67176. * @param scene defines the scene where you want your assets to be loaded
  67177. * @param onSuccess is a callback called when the task is successfully executed
  67178. * @param onError is a callback called if an error occurs
  67179. */
  67180. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67181. /**
  67182. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  67183. * This can be used with failed tasks that have the reason for failure fixed.
  67184. */
  67185. reset(): void;
  67186. private onErrorCallback;
  67187. private onDoneCallback;
  67188. }
  67189. /**
  67190. * Define the interface used by progress events raised during assets loading
  67191. */
  67192. export interface IAssetsProgressEvent {
  67193. /**
  67194. * Defines the number of remaining tasks to process
  67195. */
  67196. remainingCount: number;
  67197. /**
  67198. * Defines the total number of tasks
  67199. */
  67200. totalCount: number;
  67201. /**
  67202. * Defines the task that was just processed
  67203. */
  67204. task: AbstractAssetTask;
  67205. }
  67206. /**
  67207. * Class used to share progress information about assets loading
  67208. */
  67209. export class AssetsProgressEvent implements IAssetsProgressEvent {
  67210. /**
  67211. * Defines the number of remaining tasks to process
  67212. */
  67213. remainingCount: number;
  67214. /**
  67215. * Defines the total number of tasks
  67216. */
  67217. totalCount: number;
  67218. /**
  67219. * Defines the task that was just processed
  67220. */
  67221. task: AbstractAssetTask;
  67222. /**
  67223. * Creates a AssetsProgressEvent
  67224. * @param remainingCount defines the number of remaining tasks to process
  67225. * @param totalCount defines the total number of tasks
  67226. * @param task defines the task that was just processed
  67227. */
  67228. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  67229. }
  67230. /**
  67231. * Define a task used by AssetsManager to load meshes
  67232. */
  67233. export class MeshAssetTask extends AbstractAssetTask {
  67234. /**
  67235. * Defines the name of the task
  67236. */
  67237. name: string;
  67238. /**
  67239. * Defines the list of mesh's names you want to load
  67240. */
  67241. meshesNames: any;
  67242. /**
  67243. * Defines the root url to use as a base to load your meshes and associated resources
  67244. */
  67245. rootUrl: string;
  67246. /**
  67247. * Defines the filename of the scene to load from
  67248. */
  67249. sceneFilename: string;
  67250. /**
  67251. * Gets the list of loaded meshes
  67252. */
  67253. loadedMeshes: Array<AbstractMesh>;
  67254. /**
  67255. * Gets the list of loaded particle systems
  67256. */
  67257. loadedParticleSystems: Array<IParticleSystem>;
  67258. /**
  67259. * Gets the list of loaded skeletons
  67260. */
  67261. loadedSkeletons: Array<Skeleton>;
  67262. /**
  67263. * Gets the list of loaded animation groups
  67264. */
  67265. loadedAnimationGroups: Array<AnimationGroup>;
  67266. /**
  67267. * Callback called when the task is successful
  67268. */
  67269. onSuccess: (task: MeshAssetTask) => void;
  67270. /**
  67271. * Callback called when the task is successful
  67272. */
  67273. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  67274. /**
  67275. * Creates a new MeshAssetTask
  67276. * @param name defines the name of the task
  67277. * @param meshesNames defines the list of mesh's names you want to load
  67278. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  67279. * @param sceneFilename defines the filename of the scene to load from
  67280. */
  67281. constructor(
  67282. /**
  67283. * Defines the name of the task
  67284. */
  67285. name: string,
  67286. /**
  67287. * Defines the list of mesh's names you want to load
  67288. */
  67289. meshesNames: any,
  67290. /**
  67291. * Defines the root url to use as a base to load your meshes and associated resources
  67292. */
  67293. rootUrl: string,
  67294. /**
  67295. * Defines the filename of the scene to load from
  67296. */
  67297. sceneFilename: string);
  67298. /**
  67299. * Execute the current task
  67300. * @param scene defines the scene where you want your assets to be loaded
  67301. * @param onSuccess is a callback called when the task is successfully executed
  67302. * @param onError is a callback called if an error occurs
  67303. */
  67304. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67305. }
  67306. /**
  67307. * Define a task used by AssetsManager to load text content
  67308. */
  67309. export class TextFileAssetTask extends AbstractAssetTask {
  67310. /**
  67311. * Defines the name of the task
  67312. */
  67313. name: string;
  67314. /**
  67315. * Defines the location of the file to load
  67316. */
  67317. url: string;
  67318. /**
  67319. * Gets the loaded text string
  67320. */
  67321. text: string;
  67322. /**
  67323. * Callback called when the task is successful
  67324. */
  67325. onSuccess: (task: TextFileAssetTask) => void;
  67326. /**
  67327. * Callback called when the task is successful
  67328. */
  67329. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  67330. /**
  67331. * Creates a new TextFileAssetTask object
  67332. * @param name defines the name of the task
  67333. * @param url defines the location of the file to load
  67334. */
  67335. constructor(
  67336. /**
  67337. * Defines the name of the task
  67338. */
  67339. name: string,
  67340. /**
  67341. * Defines the location of the file to load
  67342. */
  67343. url: string);
  67344. /**
  67345. * Execute the current task
  67346. * @param scene defines the scene where you want your assets to be loaded
  67347. * @param onSuccess is a callback called when the task is successfully executed
  67348. * @param onError is a callback called if an error occurs
  67349. */
  67350. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67351. }
  67352. /**
  67353. * Define a task used by AssetsManager to load binary data
  67354. */
  67355. export class BinaryFileAssetTask extends AbstractAssetTask {
  67356. /**
  67357. * Defines the name of the task
  67358. */
  67359. name: string;
  67360. /**
  67361. * Defines the location of the file to load
  67362. */
  67363. url: string;
  67364. /**
  67365. * Gets the lodaded data (as an array buffer)
  67366. */
  67367. data: ArrayBuffer;
  67368. /**
  67369. * Callback called when the task is successful
  67370. */
  67371. onSuccess: (task: BinaryFileAssetTask) => void;
  67372. /**
  67373. * Callback called when the task is successful
  67374. */
  67375. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  67376. /**
  67377. * Creates a new BinaryFileAssetTask object
  67378. * @param name defines the name of the new task
  67379. * @param url defines the location of the file to load
  67380. */
  67381. constructor(
  67382. /**
  67383. * Defines the name of the task
  67384. */
  67385. name: string,
  67386. /**
  67387. * Defines the location of the file to load
  67388. */
  67389. url: string);
  67390. /**
  67391. * Execute the current task
  67392. * @param scene defines the scene where you want your assets to be loaded
  67393. * @param onSuccess is a callback called when the task is successfully executed
  67394. * @param onError is a callback called if an error occurs
  67395. */
  67396. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67397. }
  67398. /**
  67399. * Define a task used by AssetsManager to load images
  67400. */
  67401. export class ImageAssetTask extends AbstractAssetTask {
  67402. /**
  67403. * Defines the name of the task
  67404. */
  67405. name: string;
  67406. /**
  67407. * Defines the location of the image to load
  67408. */
  67409. url: string;
  67410. /**
  67411. * Gets the loaded images
  67412. */
  67413. image: HTMLImageElement;
  67414. /**
  67415. * Callback called when the task is successful
  67416. */
  67417. onSuccess: (task: ImageAssetTask) => void;
  67418. /**
  67419. * Callback called when the task is successful
  67420. */
  67421. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  67422. /**
  67423. * Creates a new ImageAssetTask
  67424. * @param name defines the name of the task
  67425. * @param url defines the location of the image to load
  67426. */
  67427. constructor(
  67428. /**
  67429. * Defines the name of the task
  67430. */
  67431. name: string,
  67432. /**
  67433. * Defines the location of the image to load
  67434. */
  67435. url: string);
  67436. /**
  67437. * Execute the current task
  67438. * @param scene defines the scene where you want your assets to be loaded
  67439. * @param onSuccess is a callback called when the task is successfully executed
  67440. * @param onError is a callback called if an error occurs
  67441. */
  67442. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67443. }
  67444. /**
  67445. * Defines the interface used by texture loading tasks
  67446. */
  67447. export interface ITextureAssetTask<TEX extends BaseTexture> {
  67448. /**
  67449. * Gets the loaded texture
  67450. */
  67451. texture: TEX;
  67452. }
  67453. /**
  67454. * Define a task used by AssetsManager to load 2D textures
  67455. */
  67456. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  67457. /**
  67458. * Defines the name of the task
  67459. */
  67460. name: string;
  67461. /**
  67462. * Defines the location of the file to load
  67463. */
  67464. url: string;
  67465. /**
  67466. * Defines if mipmap should not be generated (default is false)
  67467. */
  67468. noMipmap?: boolean | undefined;
  67469. /**
  67470. * Defines if texture must be inverted on Y axis (default is false)
  67471. */
  67472. invertY?: boolean | undefined;
  67473. /**
  67474. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67475. */
  67476. samplingMode: number;
  67477. /**
  67478. * Gets the loaded texture
  67479. */
  67480. texture: Texture;
  67481. /**
  67482. * Callback called when the task is successful
  67483. */
  67484. onSuccess: (task: TextureAssetTask) => void;
  67485. /**
  67486. * Callback called when the task is successful
  67487. */
  67488. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  67489. /**
  67490. * Creates a new TextureAssetTask object
  67491. * @param name defines the name of the task
  67492. * @param url defines the location of the file to load
  67493. * @param noMipmap defines if mipmap should not be generated (default is false)
  67494. * @param invertY defines if texture must be inverted on Y axis (default is false)
  67495. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67496. */
  67497. constructor(
  67498. /**
  67499. * Defines the name of the task
  67500. */
  67501. name: string,
  67502. /**
  67503. * Defines the location of the file to load
  67504. */
  67505. url: string,
  67506. /**
  67507. * Defines if mipmap should not be generated (default is false)
  67508. */
  67509. noMipmap?: boolean | undefined,
  67510. /**
  67511. * Defines if texture must be inverted on Y axis (default is false)
  67512. */
  67513. invertY?: boolean | undefined,
  67514. /**
  67515. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67516. */
  67517. samplingMode?: number);
  67518. /**
  67519. * Execute the current task
  67520. * @param scene defines the scene where you want your assets to be loaded
  67521. * @param onSuccess is a callback called when the task is successfully executed
  67522. * @param onError is a callback called if an error occurs
  67523. */
  67524. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67525. }
  67526. /**
  67527. * Define a task used by AssetsManager to load cube textures
  67528. */
  67529. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  67530. /**
  67531. * Defines the name of the task
  67532. */
  67533. name: string;
  67534. /**
  67535. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67536. */
  67537. url: string;
  67538. /**
  67539. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67540. */
  67541. extensions?: string[] | undefined;
  67542. /**
  67543. * Defines if mipmaps should not be generated (default is false)
  67544. */
  67545. noMipmap?: boolean | undefined;
  67546. /**
  67547. * Defines the explicit list of files (undefined by default)
  67548. */
  67549. files?: string[] | undefined;
  67550. /**
  67551. * Gets the loaded texture
  67552. */
  67553. texture: CubeTexture;
  67554. /**
  67555. * Callback called when the task is successful
  67556. */
  67557. onSuccess: (task: CubeTextureAssetTask) => void;
  67558. /**
  67559. * Callback called when the task is successful
  67560. */
  67561. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  67562. /**
  67563. * Creates a new CubeTextureAssetTask
  67564. * @param name defines the name of the task
  67565. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67566. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67567. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67568. * @param files defines the explicit list of files (undefined by default)
  67569. */
  67570. constructor(
  67571. /**
  67572. * Defines the name of the task
  67573. */
  67574. name: string,
  67575. /**
  67576. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67577. */
  67578. url: string,
  67579. /**
  67580. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67581. */
  67582. extensions?: string[] | undefined,
  67583. /**
  67584. * Defines if mipmaps should not be generated (default is false)
  67585. */
  67586. noMipmap?: boolean | undefined,
  67587. /**
  67588. * Defines the explicit list of files (undefined by default)
  67589. */
  67590. files?: string[] | undefined);
  67591. /**
  67592. * Execute the current task
  67593. * @param scene defines the scene where you want your assets to be loaded
  67594. * @param onSuccess is a callback called when the task is successfully executed
  67595. * @param onError is a callback called if an error occurs
  67596. */
  67597. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67598. }
  67599. /**
  67600. * Define a task used by AssetsManager to load HDR cube textures
  67601. */
  67602. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  67603. /**
  67604. * Defines the name of the task
  67605. */
  67606. name: string;
  67607. /**
  67608. * Defines the location of the file to load
  67609. */
  67610. url: string;
  67611. /**
  67612. * Defines the desired size (the more it increases the longer the generation will be)
  67613. */
  67614. size: number;
  67615. /**
  67616. * Defines if mipmaps should not be generated (default is false)
  67617. */
  67618. noMipmap: boolean;
  67619. /**
  67620. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67621. */
  67622. generateHarmonics: boolean;
  67623. /**
  67624. * 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)
  67625. */
  67626. gammaSpace: boolean;
  67627. /**
  67628. * Internal Use Only
  67629. */
  67630. reserved: boolean;
  67631. /**
  67632. * Gets the loaded texture
  67633. */
  67634. texture: HDRCubeTexture;
  67635. /**
  67636. * Callback called when the task is successful
  67637. */
  67638. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  67639. /**
  67640. * Callback called when the task is successful
  67641. */
  67642. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  67643. /**
  67644. * Creates a new HDRCubeTextureAssetTask object
  67645. * @param name defines the name of the task
  67646. * @param url defines the location of the file to load
  67647. * @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.
  67648. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67649. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67650. * @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)
  67651. * @param reserved Internal use only
  67652. */
  67653. constructor(
  67654. /**
  67655. * Defines the name of the task
  67656. */
  67657. name: string,
  67658. /**
  67659. * Defines the location of the file to load
  67660. */
  67661. url: string,
  67662. /**
  67663. * Defines the desired size (the more it increases the longer the generation will be)
  67664. */
  67665. size: number,
  67666. /**
  67667. * Defines if mipmaps should not be generated (default is false)
  67668. */
  67669. noMipmap?: boolean,
  67670. /**
  67671. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67672. */
  67673. generateHarmonics?: boolean,
  67674. /**
  67675. * 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)
  67676. */
  67677. gammaSpace?: boolean,
  67678. /**
  67679. * Internal Use Only
  67680. */
  67681. reserved?: boolean);
  67682. /**
  67683. * Execute the current task
  67684. * @param scene defines the scene where you want your assets to be loaded
  67685. * @param onSuccess is a callback called when the task is successfully executed
  67686. * @param onError is a callback called if an error occurs
  67687. */
  67688. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67689. }
  67690. /**
  67691. * Define a task used by AssetsManager to load Equirectangular cube textures
  67692. */
  67693. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  67694. /**
  67695. * Defines the name of the task
  67696. */
  67697. name: string;
  67698. /**
  67699. * Defines the location of the file to load
  67700. */
  67701. url: string;
  67702. /**
  67703. * Defines the desired size (the more it increases the longer the generation will be)
  67704. */
  67705. size: number;
  67706. /**
  67707. * Defines if mipmaps should not be generated (default is false)
  67708. */
  67709. noMipmap: boolean;
  67710. /**
  67711. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67712. * but the standard material would require them in Gamma space) (default is true)
  67713. */
  67714. gammaSpace: boolean;
  67715. /**
  67716. * Gets the loaded texture
  67717. */
  67718. texture: EquiRectangularCubeTexture;
  67719. /**
  67720. * Callback called when the task is successful
  67721. */
  67722. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  67723. /**
  67724. * Callback called when the task is successful
  67725. */
  67726. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  67727. /**
  67728. * Creates a new EquiRectangularCubeTextureAssetTask object
  67729. * @param name defines the name of the task
  67730. * @param url defines the location of the file to load
  67731. * @param size defines the desired size (the more it increases the longer the generation will be)
  67732. * If the size is omitted this implies you are using a preprocessed cubemap.
  67733. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67734. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  67735. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  67736. * (default is true)
  67737. */
  67738. constructor(
  67739. /**
  67740. * Defines the name of the task
  67741. */
  67742. name: string,
  67743. /**
  67744. * Defines the location of the file to load
  67745. */
  67746. url: string,
  67747. /**
  67748. * Defines the desired size (the more it increases the longer the generation will be)
  67749. */
  67750. size: number,
  67751. /**
  67752. * Defines if mipmaps should not be generated (default is false)
  67753. */
  67754. noMipmap?: boolean,
  67755. /**
  67756. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67757. * but the standard material would require them in Gamma space) (default is true)
  67758. */
  67759. gammaSpace?: boolean);
  67760. /**
  67761. * Execute the current task
  67762. * @param scene defines the scene where you want your assets to be loaded
  67763. * @param onSuccess is a callback called when the task is successfully executed
  67764. * @param onError is a callback called if an error occurs
  67765. */
  67766. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67767. }
  67768. /**
  67769. * This class can be used to easily import assets into a scene
  67770. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  67771. */
  67772. export class AssetsManager {
  67773. private _scene;
  67774. private _isLoading;
  67775. protected _tasks: AbstractAssetTask[];
  67776. protected _waitingTasksCount: number;
  67777. protected _totalTasksCount: number;
  67778. /**
  67779. * Callback called when all tasks are processed
  67780. */
  67781. onFinish: (tasks: AbstractAssetTask[]) => void;
  67782. /**
  67783. * Callback called when a task is successful
  67784. */
  67785. onTaskSuccess: (task: AbstractAssetTask) => void;
  67786. /**
  67787. * Callback called when a task had an error
  67788. */
  67789. onTaskError: (task: AbstractAssetTask) => void;
  67790. /**
  67791. * Callback called when a task is done (whatever the result is)
  67792. */
  67793. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  67794. /**
  67795. * Observable called when all tasks are processed
  67796. */
  67797. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  67798. /**
  67799. * Observable called when a task had an error
  67800. */
  67801. onTaskErrorObservable: Observable<AbstractAssetTask>;
  67802. /**
  67803. * Observable called when all tasks were executed
  67804. */
  67805. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  67806. /**
  67807. * Observable called when a task is done (whatever the result is)
  67808. */
  67809. onProgressObservable: Observable<IAssetsProgressEvent>;
  67810. /**
  67811. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  67812. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  67813. */
  67814. useDefaultLoadingScreen: boolean;
  67815. /**
  67816. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  67817. * when all assets have been downloaded.
  67818. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  67819. */
  67820. autoHideLoadingUI: boolean;
  67821. /**
  67822. * Creates a new AssetsManager
  67823. * @param scene defines the scene to work on
  67824. */
  67825. constructor(scene: Scene);
  67826. /**
  67827. * Add a MeshAssetTask to the list of active tasks
  67828. * @param taskName defines the name of the new task
  67829. * @param meshesNames defines the name of meshes to load
  67830. * @param rootUrl defines the root url to use to locate files
  67831. * @param sceneFilename defines the filename of the scene file
  67832. * @returns a new MeshAssetTask object
  67833. */
  67834. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  67835. /**
  67836. * Add a TextFileAssetTask to the list of active tasks
  67837. * @param taskName defines the name of the new task
  67838. * @param url defines the url of the file to load
  67839. * @returns a new TextFileAssetTask object
  67840. */
  67841. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  67842. /**
  67843. * Add a BinaryFileAssetTask to the list of active tasks
  67844. * @param taskName defines the name of the new task
  67845. * @param url defines the url of the file to load
  67846. * @returns a new BinaryFileAssetTask object
  67847. */
  67848. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  67849. /**
  67850. * Add a ImageAssetTask to the list of active tasks
  67851. * @param taskName defines the name of the new task
  67852. * @param url defines the url of the file to load
  67853. * @returns a new ImageAssetTask object
  67854. */
  67855. addImageTask(taskName: string, url: string): ImageAssetTask;
  67856. /**
  67857. * Add a TextureAssetTask to the list of active tasks
  67858. * @param taskName defines the name of the new task
  67859. * @param url defines the url of the file to load
  67860. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67861. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  67862. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  67863. * @returns a new TextureAssetTask object
  67864. */
  67865. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  67866. /**
  67867. * Add a CubeTextureAssetTask to the list of active tasks
  67868. * @param taskName defines the name of the new task
  67869. * @param url defines the url of the file to load
  67870. * @param extensions defines the extension to use to load the cube map (can be null)
  67871. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67872. * @param files defines the list of files to load (can be null)
  67873. * @returns a new CubeTextureAssetTask object
  67874. */
  67875. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  67876. /**
  67877. *
  67878. * Add a HDRCubeTextureAssetTask to the list of active tasks
  67879. * @param taskName defines the name of the new task
  67880. * @param url defines the url of the file to load
  67881. * @param size defines the size you want for the cubemap (can be null)
  67882. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67883. * @param generateHarmonics defines if you want to automatically generate (true by default)
  67884. * @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)
  67885. * @param reserved Internal use only
  67886. * @returns a new HDRCubeTextureAssetTask object
  67887. */
  67888. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  67889. /**
  67890. *
  67891. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  67892. * @param taskName defines the name of the new task
  67893. * @param url defines the url of the file to load
  67894. * @param size defines the size you want for the cubemap (can be null)
  67895. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67896. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  67897. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  67898. * @returns a new EquiRectangularCubeTextureAssetTask object
  67899. */
  67900. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  67901. /**
  67902. * Remove a task from the assets manager.
  67903. * @param task the task to remove
  67904. */
  67905. removeTask(task: AbstractAssetTask): void;
  67906. private _decreaseWaitingTasksCount;
  67907. private _runTask;
  67908. /**
  67909. * Reset the AssetsManager and remove all tasks
  67910. * @return the current instance of the AssetsManager
  67911. */
  67912. reset(): AssetsManager;
  67913. /**
  67914. * Start the loading process
  67915. * @return the current instance of the AssetsManager
  67916. */
  67917. load(): AssetsManager;
  67918. /**
  67919. * Start the loading process as an async operation
  67920. * @return a promise returning the list of failed tasks
  67921. */
  67922. loadAsync(): Promise<void>;
  67923. }
  67924. }
  67925. declare module "babylonjs/Misc/deferred" {
  67926. /**
  67927. * Wrapper class for promise with external resolve and reject.
  67928. */
  67929. export class Deferred<T> {
  67930. /**
  67931. * The promise associated with this deferred object.
  67932. */
  67933. readonly promise: Promise<T>;
  67934. private _resolve;
  67935. private _reject;
  67936. /**
  67937. * The resolve method of the promise associated with this deferred object.
  67938. */
  67939. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  67940. /**
  67941. * The reject method of the promise associated with this deferred object.
  67942. */
  67943. readonly reject: (reason?: any) => void;
  67944. /**
  67945. * Constructor for this deferred object.
  67946. */
  67947. constructor();
  67948. }
  67949. }
  67950. declare module "babylonjs/Misc/meshExploder" {
  67951. import { Mesh } from "babylonjs/Meshes/mesh";
  67952. /**
  67953. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  67954. */
  67955. export class MeshExploder {
  67956. private _centerMesh;
  67957. private _meshes;
  67958. private _meshesOrigins;
  67959. private _toCenterVectors;
  67960. private _scaledDirection;
  67961. private _newPosition;
  67962. private _centerPosition;
  67963. /**
  67964. * Explodes meshes from a center mesh.
  67965. * @param meshes The meshes to explode.
  67966. * @param centerMesh The mesh to be center of explosion.
  67967. */
  67968. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  67969. private _setCenterMesh;
  67970. /**
  67971. * Get class name
  67972. * @returns "MeshExploder"
  67973. */
  67974. getClassName(): string;
  67975. /**
  67976. * "Exploded meshes"
  67977. * @returns Array of meshes with the centerMesh at index 0.
  67978. */
  67979. getMeshes(): Array<Mesh>;
  67980. /**
  67981. * Explodes meshes giving a specific direction
  67982. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  67983. */
  67984. explode(direction?: number): void;
  67985. }
  67986. }
  67987. declare module "babylonjs/Misc/filesInput" {
  67988. import { Engine } from "babylonjs/Engines/engine";
  67989. import { Scene } from "babylonjs/scene";
  67990. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  67991. /**
  67992. * Class used to help managing file picking and drag'n'drop
  67993. */
  67994. export class FilesInput {
  67995. /**
  67996. * List of files ready to be loaded
  67997. */
  67998. static readonly FilesToLoad: {
  67999. [key: string]: File;
  68000. };
  68001. /**
  68002. * Callback called when a file is processed
  68003. */
  68004. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  68005. private _engine;
  68006. private _currentScene;
  68007. private _sceneLoadedCallback;
  68008. private _progressCallback;
  68009. private _additionalRenderLoopLogicCallback;
  68010. private _textureLoadingCallback;
  68011. private _startingProcessingFilesCallback;
  68012. private _onReloadCallback;
  68013. private _errorCallback;
  68014. private _elementToMonitor;
  68015. private _sceneFileToLoad;
  68016. private _filesToLoad;
  68017. /**
  68018. * Creates a new FilesInput
  68019. * @param engine defines the rendering engine
  68020. * @param scene defines the hosting scene
  68021. * @param sceneLoadedCallback callback called when scene is loaded
  68022. * @param progressCallback callback called to track progress
  68023. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  68024. * @param textureLoadingCallback callback called when a texture is loading
  68025. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  68026. * @param onReloadCallback callback called when a reload is requested
  68027. * @param errorCallback callback call if an error occurs
  68028. */
  68029. 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);
  68030. private _dragEnterHandler;
  68031. private _dragOverHandler;
  68032. private _dropHandler;
  68033. /**
  68034. * Calls this function to listen to drag'n'drop events on a specific DOM element
  68035. * @param elementToMonitor defines the DOM element to track
  68036. */
  68037. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  68038. /**
  68039. * Release all associated resources
  68040. */
  68041. dispose(): void;
  68042. private renderFunction;
  68043. private drag;
  68044. private drop;
  68045. private _traverseFolder;
  68046. private _processFiles;
  68047. /**
  68048. * Load files from a drop event
  68049. * @param event defines the drop event to use as source
  68050. */
  68051. loadFiles(event: any): void;
  68052. private _processReload;
  68053. /**
  68054. * Reload the current scene from the loaded files
  68055. */
  68056. reload(): void;
  68057. }
  68058. }
  68059. declare module "babylonjs/Misc/HighDynamicRange/index" {
  68060. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  68061. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  68062. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  68063. }
  68064. declare module "babylonjs/Misc/sceneOptimizer" {
  68065. import { Scene, IDisposable } from "babylonjs/scene";
  68066. import { Observable } from "babylonjs/Misc/observable";
  68067. /**
  68068. * Defines the root class used to create scene optimization to use with SceneOptimizer
  68069. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68070. */
  68071. export class SceneOptimization {
  68072. /**
  68073. * Defines the priority of this optimization (0 by default which means first in the list)
  68074. */
  68075. priority: number;
  68076. /**
  68077. * Gets a string describing the action executed by the current optimization
  68078. * @returns description string
  68079. */
  68080. getDescription(): string;
  68081. /**
  68082. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68083. * @param scene defines the current scene where to apply this optimization
  68084. * @param optimizer defines the current optimizer
  68085. * @returns true if everything that can be done was applied
  68086. */
  68087. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68088. /**
  68089. * Creates the SceneOptimization object
  68090. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68091. * @param desc defines the description associated with the optimization
  68092. */
  68093. constructor(
  68094. /**
  68095. * Defines the priority of this optimization (0 by default which means first in the list)
  68096. */
  68097. priority?: number);
  68098. }
  68099. /**
  68100. * Defines an optimization used to reduce the size of render target textures
  68101. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68102. */
  68103. export class TextureOptimization extends SceneOptimization {
  68104. /**
  68105. * Defines the priority of this optimization (0 by default which means first in the list)
  68106. */
  68107. priority: number;
  68108. /**
  68109. * 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
  68110. */
  68111. maximumSize: number;
  68112. /**
  68113. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68114. */
  68115. step: number;
  68116. /**
  68117. * Gets a string describing the action executed by the current optimization
  68118. * @returns description string
  68119. */
  68120. getDescription(): string;
  68121. /**
  68122. * Creates the TextureOptimization object
  68123. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68124. * @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
  68125. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68126. */
  68127. constructor(
  68128. /**
  68129. * Defines the priority of this optimization (0 by default which means first in the list)
  68130. */
  68131. priority?: number,
  68132. /**
  68133. * 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
  68134. */
  68135. maximumSize?: number,
  68136. /**
  68137. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68138. */
  68139. step?: number);
  68140. /**
  68141. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68142. * @param scene defines the current scene where to apply this optimization
  68143. * @param optimizer defines the current optimizer
  68144. * @returns true if everything that can be done was applied
  68145. */
  68146. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68147. }
  68148. /**
  68149. * Defines an optimization used to increase or decrease the rendering resolution
  68150. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68151. */
  68152. export class HardwareScalingOptimization extends SceneOptimization {
  68153. /**
  68154. * Defines the priority of this optimization (0 by default which means first in the list)
  68155. */
  68156. priority: number;
  68157. /**
  68158. * Defines the maximum scale to use (2 by default)
  68159. */
  68160. maximumScale: number;
  68161. /**
  68162. * Defines the step to use between two passes (0.5 by default)
  68163. */
  68164. step: number;
  68165. private _currentScale;
  68166. private _directionOffset;
  68167. /**
  68168. * Gets a string describing the action executed by the current optimization
  68169. * @return description string
  68170. */
  68171. getDescription(): string;
  68172. /**
  68173. * Creates the HardwareScalingOptimization object
  68174. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68175. * @param maximumScale defines the maximum scale to use (2 by default)
  68176. * @param step defines the step to use between two passes (0.5 by default)
  68177. */
  68178. constructor(
  68179. /**
  68180. * Defines the priority of this optimization (0 by default which means first in the list)
  68181. */
  68182. priority?: number,
  68183. /**
  68184. * Defines the maximum scale to use (2 by default)
  68185. */
  68186. maximumScale?: number,
  68187. /**
  68188. * Defines the step to use between two passes (0.5 by default)
  68189. */
  68190. step?: number);
  68191. /**
  68192. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68193. * @param scene defines the current scene where to apply this optimization
  68194. * @param optimizer defines the current optimizer
  68195. * @returns true if everything that can be done was applied
  68196. */
  68197. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68198. }
  68199. /**
  68200. * Defines an optimization used to remove shadows
  68201. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68202. */
  68203. export class ShadowsOptimization extends SceneOptimization {
  68204. /**
  68205. * Gets a string describing the action executed by the current optimization
  68206. * @return description string
  68207. */
  68208. getDescription(): string;
  68209. /**
  68210. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68211. * @param scene defines the current scene where to apply this optimization
  68212. * @param optimizer defines the current optimizer
  68213. * @returns true if everything that can be done was applied
  68214. */
  68215. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68216. }
  68217. /**
  68218. * Defines an optimization used to turn post-processes off
  68219. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68220. */
  68221. export class PostProcessesOptimization extends SceneOptimization {
  68222. /**
  68223. * Gets a string describing the action executed by the current optimization
  68224. * @return description string
  68225. */
  68226. getDescription(): string;
  68227. /**
  68228. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68229. * @param scene defines the current scene where to apply this optimization
  68230. * @param optimizer defines the current optimizer
  68231. * @returns true if everything that can be done was applied
  68232. */
  68233. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68234. }
  68235. /**
  68236. * Defines an optimization used to turn lens flares off
  68237. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68238. */
  68239. export class LensFlaresOptimization extends SceneOptimization {
  68240. /**
  68241. * Gets a string describing the action executed by the current optimization
  68242. * @return description string
  68243. */
  68244. getDescription(): string;
  68245. /**
  68246. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68247. * @param scene defines the current scene where to apply this optimization
  68248. * @param optimizer defines the current optimizer
  68249. * @returns true if everything that can be done was applied
  68250. */
  68251. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68252. }
  68253. /**
  68254. * Defines an optimization based on user defined callback.
  68255. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68256. */
  68257. export class CustomOptimization extends SceneOptimization {
  68258. /**
  68259. * Callback called to apply the custom optimization.
  68260. */
  68261. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  68262. /**
  68263. * Callback called to get custom description
  68264. */
  68265. onGetDescription: () => string;
  68266. /**
  68267. * Gets a string describing the action executed by the current optimization
  68268. * @returns description string
  68269. */
  68270. getDescription(): string;
  68271. /**
  68272. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68273. * @param scene defines the current scene where to apply this optimization
  68274. * @param optimizer defines the current optimizer
  68275. * @returns true if everything that can be done was applied
  68276. */
  68277. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68278. }
  68279. /**
  68280. * Defines an optimization used to turn particles off
  68281. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68282. */
  68283. export class ParticlesOptimization extends SceneOptimization {
  68284. /**
  68285. * Gets a string describing the action executed by the current optimization
  68286. * @return description string
  68287. */
  68288. getDescription(): string;
  68289. /**
  68290. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68291. * @param scene defines the current scene where to apply this optimization
  68292. * @param optimizer defines the current optimizer
  68293. * @returns true if everything that can be done was applied
  68294. */
  68295. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68296. }
  68297. /**
  68298. * Defines an optimization used to turn render targets off
  68299. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68300. */
  68301. export class RenderTargetsOptimization extends SceneOptimization {
  68302. /**
  68303. * Gets a string describing the action executed by the current optimization
  68304. * @return description string
  68305. */
  68306. getDescription(): string;
  68307. /**
  68308. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68309. * @param scene defines the current scene where to apply this optimization
  68310. * @param optimizer defines the current optimizer
  68311. * @returns true if everything that can be done was applied
  68312. */
  68313. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68314. }
  68315. /**
  68316. * Defines an optimization used to merge meshes with compatible materials
  68317. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68318. */
  68319. export class MergeMeshesOptimization extends SceneOptimization {
  68320. private static _UpdateSelectionTree;
  68321. /**
  68322. * Gets or sets a boolean which defines if optimization octree has to be updated
  68323. */
  68324. /**
  68325. * Gets or sets a boolean which defines if optimization octree has to be updated
  68326. */
  68327. static UpdateSelectionTree: boolean;
  68328. /**
  68329. * Gets a string describing the action executed by the current optimization
  68330. * @return description string
  68331. */
  68332. getDescription(): string;
  68333. private _canBeMerged;
  68334. /**
  68335. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68336. * @param scene defines the current scene where to apply this optimization
  68337. * @param optimizer defines the current optimizer
  68338. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  68339. * @returns true if everything that can be done was applied
  68340. */
  68341. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  68342. }
  68343. /**
  68344. * Defines a list of options used by SceneOptimizer
  68345. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68346. */
  68347. export class SceneOptimizerOptions {
  68348. /**
  68349. * Defines the target frame rate to reach (60 by default)
  68350. */
  68351. targetFrameRate: number;
  68352. /**
  68353. * Defines the interval between two checkes (2000ms by default)
  68354. */
  68355. trackerDuration: number;
  68356. /**
  68357. * Gets the list of optimizations to apply
  68358. */
  68359. optimizations: SceneOptimization[];
  68360. /**
  68361. * Creates a new list of options used by SceneOptimizer
  68362. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  68363. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  68364. */
  68365. constructor(
  68366. /**
  68367. * Defines the target frame rate to reach (60 by default)
  68368. */
  68369. targetFrameRate?: number,
  68370. /**
  68371. * Defines the interval between two checkes (2000ms by default)
  68372. */
  68373. trackerDuration?: number);
  68374. /**
  68375. * Add a new optimization
  68376. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  68377. * @returns the current SceneOptimizerOptions
  68378. */
  68379. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  68380. /**
  68381. * Add a new custom optimization
  68382. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  68383. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  68384. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68385. * @returns the current SceneOptimizerOptions
  68386. */
  68387. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  68388. /**
  68389. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  68390. * @param targetFrameRate defines the target frame rate (60 by default)
  68391. * @returns a SceneOptimizerOptions object
  68392. */
  68393. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68394. /**
  68395. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  68396. * @param targetFrameRate defines the target frame rate (60 by default)
  68397. * @returns a SceneOptimizerOptions object
  68398. */
  68399. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68400. /**
  68401. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  68402. * @param targetFrameRate defines the target frame rate (60 by default)
  68403. * @returns a SceneOptimizerOptions object
  68404. */
  68405. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68406. }
  68407. /**
  68408. * Class used to run optimizations in order to reach a target frame rate
  68409. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68410. */
  68411. export class SceneOptimizer implements IDisposable {
  68412. private _isRunning;
  68413. private _options;
  68414. private _scene;
  68415. private _currentPriorityLevel;
  68416. private _targetFrameRate;
  68417. private _trackerDuration;
  68418. private _currentFrameRate;
  68419. private _sceneDisposeObserver;
  68420. private _improvementMode;
  68421. /**
  68422. * Defines an observable called when the optimizer reaches the target frame rate
  68423. */
  68424. onSuccessObservable: Observable<SceneOptimizer>;
  68425. /**
  68426. * Defines an observable called when the optimizer enables an optimization
  68427. */
  68428. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  68429. /**
  68430. * Defines an observable called when the optimizer is not able to reach the target frame rate
  68431. */
  68432. onFailureObservable: Observable<SceneOptimizer>;
  68433. /**
  68434. * Gets a boolean indicating if the optimizer is in improvement mode
  68435. */
  68436. readonly isInImprovementMode: boolean;
  68437. /**
  68438. * Gets the current priority level (0 at start)
  68439. */
  68440. readonly currentPriorityLevel: number;
  68441. /**
  68442. * Gets the current frame rate checked by the SceneOptimizer
  68443. */
  68444. readonly currentFrameRate: number;
  68445. /**
  68446. * Gets or sets the current target frame rate (60 by default)
  68447. */
  68448. /**
  68449. * Gets or sets the current target frame rate (60 by default)
  68450. */
  68451. targetFrameRate: number;
  68452. /**
  68453. * Gets or sets the current interval between two checks (every 2000ms by default)
  68454. */
  68455. /**
  68456. * Gets or sets the current interval between two checks (every 2000ms by default)
  68457. */
  68458. trackerDuration: number;
  68459. /**
  68460. * Gets the list of active optimizations
  68461. */
  68462. readonly optimizations: SceneOptimization[];
  68463. /**
  68464. * Creates a new SceneOptimizer
  68465. * @param scene defines the scene to work on
  68466. * @param options defines the options to use with the SceneOptimizer
  68467. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  68468. * @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)
  68469. */
  68470. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  68471. /**
  68472. * Stops the current optimizer
  68473. */
  68474. stop(): void;
  68475. /**
  68476. * Reset the optimizer to initial step (current priority level = 0)
  68477. */
  68478. reset(): void;
  68479. /**
  68480. * Start the optimizer. By default it will try to reach a specific framerate
  68481. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  68482. */
  68483. start(): void;
  68484. private _checkCurrentState;
  68485. /**
  68486. * Release all resources
  68487. */
  68488. dispose(): void;
  68489. /**
  68490. * Helper function to create a SceneOptimizer with one single line of code
  68491. * @param scene defines the scene to work on
  68492. * @param options defines the options to use with the SceneOptimizer
  68493. * @param onSuccess defines a callback to call on success
  68494. * @param onFailure defines a callback to call on failure
  68495. * @returns the new SceneOptimizer object
  68496. */
  68497. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  68498. }
  68499. }
  68500. declare module "babylonjs/Misc/sceneSerializer" {
  68501. import { Scene } from "babylonjs/scene";
  68502. /**
  68503. * Class used to serialize a scene into a string
  68504. */
  68505. export class SceneSerializer {
  68506. /**
  68507. * Clear cache used by a previous serialization
  68508. */
  68509. static ClearCache(): void;
  68510. /**
  68511. * Serialize a scene into a JSON compatible object
  68512. * @param scene defines the scene to serialize
  68513. * @returns a JSON compatible object
  68514. */
  68515. static Serialize(scene: Scene): any;
  68516. /**
  68517. * Serialize a mesh into a JSON compatible object
  68518. * @param toSerialize defines the mesh to serialize
  68519. * @param withParents defines if parents must be serialized as well
  68520. * @param withChildren defines if children must be serialized as well
  68521. * @returns a JSON compatible object
  68522. */
  68523. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  68524. }
  68525. }
  68526. declare module "babylonjs/Misc/textureTools" {
  68527. import { Texture } from "babylonjs/Materials/Textures/texture";
  68528. /**
  68529. * Class used to host texture specific utilities
  68530. */
  68531. export class TextureTools {
  68532. /**
  68533. * Uses the GPU to create a copy texture rescaled at a given size
  68534. * @param texture Texture to copy from
  68535. * @param width defines the desired width
  68536. * @param height defines the desired height
  68537. * @param useBilinearMode defines if bilinear mode has to be used
  68538. * @return the generated texture
  68539. */
  68540. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  68541. }
  68542. }
  68543. declare module "babylonjs/Misc/videoRecorder" {
  68544. import { Nullable } from "babylonjs/types";
  68545. import { Engine } from "babylonjs/Engines/engine";
  68546. /**
  68547. * This represents the different options available for the video capture.
  68548. */
  68549. export interface VideoRecorderOptions {
  68550. /** Defines the mime type of the video. */
  68551. mimeType: string;
  68552. /** Defines the FPS the video should be recorded at. */
  68553. fps: number;
  68554. /** Defines the chunk size for the recording data. */
  68555. recordChunckSize: number;
  68556. /** The audio tracks to attach to the recording. */
  68557. audioTracks?: MediaStreamTrack[];
  68558. }
  68559. /**
  68560. * This can help with recording videos from BabylonJS.
  68561. * This is based on the available WebRTC functionalities of the browser.
  68562. *
  68563. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  68564. */
  68565. export class VideoRecorder {
  68566. private static readonly _defaultOptions;
  68567. /**
  68568. * Returns whether or not the VideoRecorder is available in your browser.
  68569. * @param engine Defines the Babylon Engine.
  68570. * @returns true if supported otherwise false.
  68571. */
  68572. static IsSupported(engine: Engine): boolean;
  68573. private readonly _options;
  68574. private _canvas;
  68575. private _mediaRecorder;
  68576. private _recordedChunks;
  68577. private _fileName;
  68578. private _resolve;
  68579. private _reject;
  68580. /**
  68581. * True when a recording is already in progress.
  68582. */
  68583. readonly isRecording: boolean;
  68584. /**
  68585. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  68586. * @param engine Defines the BabylonJS Engine you wish to record.
  68587. * @param options Defines options that can be used to customize the capture.
  68588. */
  68589. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  68590. /**
  68591. * Stops the current recording before the default capture timeout passed in the startRecording function.
  68592. */
  68593. stopRecording(): void;
  68594. /**
  68595. * Starts recording the canvas for a max duration specified in parameters.
  68596. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  68597. * If null no automatic download will start and you can rely on the promise to get the data back.
  68598. * @param maxDuration Defines the maximum recording time in seconds.
  68599. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  68600. * @return A promise callback at the end of the recording with the video data in Blob.
  68601. */
  68602. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  68603. /**
  68604. * Releases internal resources used during the recording.
  68605. */
  68606. dispose(): void;
  68607. private _handleDataAvailable;
  68608. private _handleError;
  68609. private _handleStop;
  68610. }
  68611. }
  68612. declare module "babylonjs/Misc/screenshotTools" {
  68613. import { Camera } from "babylonjs/Cameras/camera";
  68614. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  68615. import { Engine } from "babylonjs/Engines/engine";
  68616. /**
  68617. * Class containing a set of static utilities functions for screenshots
  68618. */
  68619. export class ScreenshotTools {
  68620. /**
  68621. * Captures a screenshot of the current rendering
  68622. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68623. * @param engine defines the rendering engine
  68624. * @param camera defines the source camera
  68625. * @param size This parameter can be set to a single number or to an object with the
  68626. * following (optional) properties: precision, width, height. If a single number is passed,
  68627. * it will be used for both width and height. If an object is passed, the screenshot size
  68628. * will be derived from the parameters. The precision property is a multiplier allowing
  68629. * rendering at a higher or lower resolution
  68630. * @param successCallback defines the callback receives a single parameter which contains the
  68631. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68632. * src parameter of an <img> to display it
  68633. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68634. * Check your browser for supported MIME types
  68635. */
  68636. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  68637. /**
  68638. * Captures a screenshot of the current rendering
  68639. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68640. * @param engine defines the rendering engine
  68641. * @param camera defines the source camera
  68642. * @param size This parameter can be set to a single number or to an object with the
  68643. * following (optional) properties: precision, width, height. If a single number is passed,
  68644. * it will be used for both width and height. If an object is passed, the screenshot size
  68645. * will be derived from the parameters. The precision property is a multiplier allowing
  68646. * rendering at a higher or lower resolution
  68647. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68648. * Check your browser for supported MIME types
  68649. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68650. * to the src parameter of an <img> to display it
  68651. */
  68652. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  68653. /**
  68654. * Generates an image screenshot from the specified camera.
  68655. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68656. * @param engine The engine to use for rendering
  68657. * @param camera The camera to use for rendering
  68658. * @param size This parameter can be set to a single number or to an object with the
  68659. * following (optional) properties: precision, width, height. If a single number is passed,
  68660. * it will be used for both width and height. If an object is passed, the screenshot size
  68661. * will be derived from the parameters. The precision property is a multiplier allowing
  68662. * rendering at a higher or lower resolution
  68663. * @param successCallback The callback receives a single parameter which contains the
  68664. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68665. * src parameter of an <img> to display it
  68666. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68667. * Check your browser for supported MIME types
  68668. * @param samples Texture samples (default: 1)
  68669. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68670. * @param fileName A name for for the downloaded file.
  68671. */
  68672. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  68673. /**
  68674. * Generates an image screenshot from the specified camera.
  68675. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68676. * @param engine The engine to use for rendering
  68677. * @param camera The camera to use for rendering
  68678. * @param size This parameter can be set to a single number or to an object with the
  68679. * following (optional) properties: precision, width, height. If a single number is passed,
  68680. * it will be used for both width and height. If an object is passed, the screenshot size
  68681. * will be derived from the parameters. The precision property is a multiplier allowing
  68682. * rendering at a higher or lower resolution
  68683. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68684. * Check your browser for supported MIME types
  68685. * @param samples Texture samples (default: 1)
  68686. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68687. * @param fileName A name for for the downloaded file.
  68688. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68689. * to the src parameter of an <img> to display it
  68690. */
  68691. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  68692. /**
  68693. * Gets height and width for screenshot size
  68694. * @private
  68695. */
  68696. private static _getScreenshotSize;
  68697. }
  68698. }
  68699. declare module "babylonjs/Misc/dataReader" {
  68700. /**
  68701. * Interface for a data buffer
  68702. */
  68703. export interface IDataBuffer {
  68704. /**
  68705. * Reads bytes from the data buffer.
  68706. * @param byteOffset The byte offset to read
  68707. * @param byteLength The byte length to read
  68708. * @returns A promise that resolves when the bytes are read
  68709. */
  68710. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  68711. /**
  68712. * The byte length of the buffer.
  68713. */
  68714. readonly byteLength: number;
  68715. }
  68716. /**
  68717. * Utility class for reading from a data buffer
  68718. */
  68719. export class DataReader {
  68720. /**
  68721. * The data buffer associated with this data reader.
  68722. */
  68723. readonly buffer: IDataBuffer;
  68724. /**
  68725. * The current byte offset from the beginning of the data buffer.
  68726. */
  68727. byteOffset: number;
  68728. private _dataView;
  68729. private _dataByteOffset;
  68730. /**
  68731. * Constructor
  68732. * @param buffer The buffer to read
  68733. */
  68734. constructor(buffer: IDataBuffer);
  68735. /**
  68736. * Loads the given byte length.
  68737. * @param byteLength The byte length to load
  68738. * @returns A promise that resolves when the load is complete
  68739. */
  68740. loadAsync(byteLength: number): Promise<void>;
  68741. /**
  68742. * Read a unsigned 32-bit integer from the currently loaded data range.
  68743. * @returns The 32-bit integer read
  68744. */
  68745. readUint32(): number;
  68746. /**
  68747. * Read a byte array from the currently loaded data range.
  68748. * @param byteLength The byte length to read
  68749. * @returns The byte array read
  68750. */
  68751. readUint8Array(byteLength: number): Uint8Array;
  68752. /**
  68753. * Read a string from the currently loaded data range.
  68754. * @param byteLength The byte length to read
  68755. * @returns The string read
  68756. */
  68757. readString(byteLength: number): string;
  68758. /**
  68759. * Skips the given byte length the currently loaded data range.
  68760. * @param byteLength The byte length to skip
  68761. */
  68762. skipBytes(byteLength: number): void;
  68763. }
  68764. }
  68765. declare module "babylonjs/Misc/index" {
  68766. export * from "babylonjs/Misc/andOrNotEvaluator";
  68767. export * from "babylonjs/Misc/assetsManager";
  68768. export * from "babylonjs/Misc/basis";
  68769. export * from "babylonjs/Misc/dds";
  68770. export * from "babylonjs/Misc/decorators";
  68771. export * from "babylonjs/Misc/deferred";
  68772. export * from "babylonjs/Misc/environmentTextureTools";
  68773. export * from "babylonjs/Misc/meshExploder";
  68774. export * from "babylonjs/Misc/filesInput";
  68775. export * from "babylonjs/Misc/HighDynamicRange/index";
  68776. export * from "babylonjs/Misc/khronosTextureContainer";
  68777. export * from "babylonjs/Misc/observable";
  68778. export * from "babylonjs/Misc/performanceMonitor";
  68779. export * from "babylonjs/Misc/promise";
  68780. export * from "babylonjs/Misc/sceneOptimizer";
  68781. export * from "babylonjs/Misc/sceneSerializer";
  68782. export * from "babylonjs/Misc/smartArray";
  68783. export * from "babylonjs/Misc/stringDictionary";
  68784. export * from "babylonjs/Misc/tags";
  68785. export * from "babylonjs/Misc/textureTools";
  68786. export * from "babylonjs/Misc/tga";
  68787. export * from "babylonjs/Misc/tools";
  68788. export * from "babylonjs/Misc/videoRecorder";
  68789. export * from "babylonjs/Misc/virtualJoystick";
  68790. export * from "babylonjs/Misc/workerPool";
  68791. export * from "babylonjs/Misc/logger";
  68792. export * from "babylonjs/Misc/typeStore";
  68793. export * from "babylonjs/Misc/filesInputStore";
  68794. export * from "babylonjs/Misc/deepCopier";
  68795. export * from "babylonjs/Misc/pivotTools";
  68796. export * from "babylonjs/Misc/precisionDate";
  68797. export * from "babylonjs/Misc/screenshotTools";
  68798. export * from "babylonjs/Misc/typeStore";
  68799. export * from "babylonjs/Misc/webRequest";
  68800. export * from "babylonjs/Misc/iInspectable";
  68801. export * from "babylonjs/Misc/brdfTextureTools";
  68802. export * from "babylonjs/Misc/rgbdTextureTools";
  68803. export * from "babylonjs/Misc/gradients";
  68804. export * from "babylonjs/Misc/perfCounter";
  68805. export * from "babylonjs/Misc/fileRequest";
  68806. export * from "babylonjs/Misc/customAnimationFrameRequester";
  68807. export * from "babylonjs/Misc/retryStrategy";
  68808. export * from "babylonjs/Misc/interfaces/screenshotSize";
  68809. export * from "babylonjs/Misc/canvasGenerator";
  68810. export * from "babylonjs/Misc/fileTools";
  68811. export * from "babylonjs/Misc/stringTools";
  68812. export * from "babylonjs/Misc/dataReader";
  68813. }
  68814. declare module "babylonjs/index" {
  68815. export * from "babylonjs/abstractScene";
  68816. export * from "babylonjs/Actions/index";
  68817. export * from "babylonjs/Animations/index";
  68818. export * from "babylonjs/assetContainer";
  68819. export * from "babylonjs/Audio/index";
  68820. export * from "babylonjs/Behaviors/index";
  68821. export * from "babylonjs/Bones/index";
  68822. export * from "babylonjs/Cameras/index";
  68823. export * from "babylonjs/Collisions/index";
  68824. export * from "babylonjs/Culling/index";
  68825. export * from "babylonjs/Debug/index";
  68826. export * from "babylonjs/Engines/index";
  68827. export * from "babylonjs/Events/index";
  68828. export * from "babylonjs/Gamepads/index";
  68829. export * from "babylonjs/Gizmos/index";
  68830. export * from "babylonjs/Helpers/index";
  68831. export * from "babylonjs/Instrumentation/index";
  68832. export * from "babylonjs/Layers/index";
  68833. export * from "babylonjs/LensFlares/index";
  68834. export * from "babylonjs/Lights/index";
  68835. export * from "babylonjs/Loading/index";
  68836. export * from "babylonjs/Materials/index";
  68837. export * from "babylonjs/Maths/index";
  68838. export * from "babylonjs/Meshes/index";
  68839. export * from "babylonjs/Morph/index";
  68840. export * from "babylonjs/Navigation/index";
  68841. export * from "babylonjs/node";
  68842. export * from "babylonjs/Offline/index";
  68843. export * from "babylonjs/Particles/index";
  68844. export * from "babylonjs/Physics/index";
  68845. export * from "babylonjs/PostProcesses/index";
  68846. export * from "babylonjs/Probes/index";
  68847. export * from "babylonjs/Rendering/index";
  68848. export * from "babylonjs/scene";
  68849. export * from "babylonjs/sceneComponent";
  68850. export * from "babylonjs/Sprites/index";
  68851. export * from "babylonjs/States/index";
  68852. export * from "babylonjs/Misc/index";
  68853. export * from "babylonjs/types";
  68854. }
  68855. declare module "babylonjs/Animations/pathCursor" {
  68856. import { Vector3 } from "babylonjs/Maths/math.vector";
  68857. import { Path2 } from "babylonjs/Maths/math.path";
  68858. /**
  68859. * A cursor which tracks a point on a path
  68860. */
  68861. export class PathCursor {
  68862. private path;
  68863. /**
  68864. * Stores path cursor callbacks for when an onchange event is triggered
  68865. */
  68866. private _onchange;
  68867. /**
  68868. * The value of the path cursor
  68869. */
  68870. value: number;
  68871. /**
  68872. * The animation array of the path cursor
  68873. */
  68874. animations: Animation[];
  68875. /**
  68876. * Initializes the path cursor
  68877. * @param path The path to track
  68878. */
  68879. constructor(path: Path2);
  68880. /**
  68881. * Gets the cursor point on the path
  68882. * @returns A point on the path cursor at the cursor location
  68883. */
  68884. getPoint(): Vector3;
  68885. /**
  68886. * Moves the cursor ahead by the step amount
  68887. * @param step The amount to move the cursor forward
  68888. * @returns This path cursor
  68889. */
  68890. moveAhead(step?: number): PathCursor;
  68891. /**
  68892. * Moves the cursor behind by the step amount
  68893. * @param step The amount to move the cursor back
  68894. * @returns This path cursor
  68895. */
  68896. moveBack(step?: number): PathCursor;
  68897. /**
  68898. * Moves the cursor by the step amount
  68899. * If the step amount is greater than one, an exception is thrown
  68900. * @param step The amount to move the cursor
  68901. * @returns This path cursor
  68902. */
  68903. move(step: number): PathCursor;
  68904. /**
  68905. * Ensures that the value is limited between zero and one
  68906. * @returns This path cursor
  68907. */
  68908. private ensureLimits;
  68909. /**
  68910. * Runs onchange callbacks on change (used by the animation engine)
  68911. * @returns This path cursor
  68912. */
  68913. private raiseOnChange;
  68914. /**
  68915. * Executes a function on change
  68916. * @param f A path cursor onchange callback
  68917. * @returns This path cursor
  68918. */
  68919. onchange(f: (cursor: PathCursor) => void): PathCursor;
  68920. }
  68921. }
  68922. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  68923. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  68924. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  68925. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  68926. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  68927. }
  68928. declare module "babylonjs/Engines/Processors/Expressions/index" {
  68929. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  68930. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  68931. }
  68932. declare module "babylonjs/Engines/Processors/index" {
  68933. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  68934. export * from "babylonjs/Engines/Processors/Expressions/index";
  68935. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  68936. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  68937. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  68938. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  68939. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  68940. export * from "babylonjs/Engines/Processors/shaderProcessor";
  68941. }
  68942. declare module "babylonjs/Legacy/legacy" {
  68943. import * as Babylon from "babylonjs/index";
  68944. export * from "babylonjs/index";
  68945. }
  68946. declare module "babylonjs/Shaders/blur.fragment" {
  68947. /** @hidden */
  68948. export var blurPixelShader: {
  68949. name: string;
  68950. shader: string;
  68951. };
  68952. }
  68953. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  68954. /** @hidden */
  68955. export var pointCloudVertexDeclaration: {
  68956. name: string;
  68957. shader: string;
  68958. };
  68959. }
  68960. declare module "babylonjs" {
  68961. export * from "babylonjs/Legacy/legacy";
  68962. }
  68963. declare module BABYLON {
  68964. /** Alias type for value that can be null */
  68965. export type Nullable<T> = T | null;
  68966. /**
  68967. * Alias type for number that are floats
  68968. * @ignorenaming
  68969. */
  68970. export type float = number;
  68971. /**
  68972. * Alias type for number that are doubles.
  68973. * @ignorenaming
  68974. */
  68975. export type double = number;
  68976. /**
  68977. * Alias type for number that are integer
  68978. * @ignorenaming
  68979. */
  68980. export type int = number;
  68981. /** Alias type for number array or Float32Array */
  68982. export type FloatArray = number[] | Float32Array;
  68983. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  68984. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  68985. /**
  68986. * Alias for types that can be used by a Buffer or VertexBuffer.
  68987. */
  68988. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  68989. /**
  68990. * Alias type for primitive types
  68991. * @ignorenaming
  68992. */
  68993. type Primitive = undefined | null | boolean | string | number | Function;
  68994. /**
  68995. * Type modifier to make all the properties of an object Readonly
  68996. */
  68997. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  68998. /**
  68999. * Type modifier to make all the properties of an object Readonly recursively
  69000. */
  69001. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  69002. /**
  69003. * Type modifier to make object properties readonly.
  69004. */
  69005. export type DeepImmutableObject<T> = {
  69006. readonly [K in keyof T]: DeepImmutable<T[K]>;
  69007. };
  69008. /** @hidden */
  69009. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  69010. }
  69011. }
  69012. declare module BABYLON {
  69013. /**
  69014. * A class serves as a medium between the observable and its observers
  69015. */
  69016. export class EventState {
  69017. /**
  69018. * Create a new EventState
  69019. * @param mask defines the mask associated with this state
  69020. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  69021. * @param target defines the original target of the state
  69022. * @param currentTarget defines the current target of the state
  69023. */
  69024. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  69025. /**
  69026. * Initialize the current event state
  69027. * @param mask defines the mask associated with this state
  69028. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  69029. * @param target defines the original target of the state
  69030. * @param currentTarget defines the current target of the state
  69031. * @returns the current event state
  69032. */
  69033. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  69034. /**
  69035. * An Observer can set this property to true to prevent subsequent observers of being notified
  69036. */
  69037. skipNextObservers: boolean;
  69038. /**
  69039. * Get the mask value that were used to trigger the event corresponding to this EventState object
  69040. */
  69041. mask: number;
  69042. /**
  69043. * The object that originally notified the event
  69044. */
  69045. target?: any;
  69046. /**
  69047. * The current object in the bubbling phase
  69048. */
  69049. currentTarget?: any;
  69050. /**
  69051. * This will be populated with the return value of the last function that was executed.
  69052. * If it is the first function in the callback chain it will be the event data.
  69053. */
  69054. lastReturnValue?: any;
  69055. }
  69056. /**
  69057. * Represent an Observer registered to a given Observable object.
  69058. */
  69059. export class Observer<T> {
  69060. /**
  69061. * Defines the callback to call when the observer is notified
  69062. */
  69063. callback: (eventData: T, eventState: EventState) => void;
  69064. /**
  69065. * Defines the mask of the observer (used to filter notifications)
  69066. */
  69067. mask: number;
  69068. /**
  69069. * Defines the current scope used to restore the JS context
  69070. */
  69071. scope: any;
  69072. /** @hidden */
  69073. _willBeUnregistered: boolean;
  69074. /**
  69075. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  69076. */
  69077. unregisterOnNextCall: boolean;
  69078. /**
  69079. * Creates a new observer
  69080. * @param callback defines the callback to call when the observer is notified
  69081. * @param mask defines the mask of the observer (used to filter notifications)
  69082. * @param scope defines the current scope used to restore the JS context
  69083. */
  69084. constructor(
  69085. /**
  69086. * Defines the callback to call when the observer is notified
  69087. */
  69088. callback: (eventData: T, eventState: EventState) => void,
  69089. /**
  69090. * Defines the mask of the observer (used to filter notifications)
  69091. */
  69092. mask: number,
  69093. /**
  69094. * Defines the current scope used to restore the JS context
  69095. */
  69096. scope?: any);
  69097. }
  69098. /**
  69099. * Represent a list of observers registered to multiple Observables object.
  69100. */
  69101. export class MultiObserver<T> {
  69102. private _observers;
  69103. private _observables;
  69104. /**
  69105. * Release associated resources
  69106. */
  69107. dispose(): void;
  69108. /**
  69109. * Raise a callback when one of the observable will notify
  69110. * @param observables defines a list of observables to watch
  69111. * @param callback defines the callback to call on notification
  69112. * @param mask defines the mask used to filter notifications
  69113. * @param scope defines the current scope used to restore the JS context
  69114. * @returns the new MultiObserver
  69115. */
  69116. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  69117. }
  69118. /**
  69119. * The Observable class is a simple implementation of the Observable pattern.
  69120. *
  69121. * 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.
  69122. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  69123. * 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).
  69124. * 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.
  69125. */
  69126. export class Observable<T> {
  69127. private _observers;
  69128. private _eventState;
  69129. private _onObserverAdded;
  69130. /**
  69131. * Gets the list of observers
  69132. */
  69133. readonly observers: Array<Observer<T>>;
  69134. /**
  69135. * Creates a new observable
  69136. * @param onObserverAdded defines a callback to call when a new observer is added
  69137. */
  69138. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  69139. /**
  69140. * Create a new Observer with the specified callback
  69141. * @param callback the callback that will be executed for that Observer
  69142. * @param mask the mask used to filter observers
  69143. * @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.
  69144. * @param scope optional scope for the callback to be called from
  69145. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  69146. * @returns the new observer created for the callback
  69147. */
  69148. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  69149. /**
  69150. * Create a new Observer with the specified callback and unregisters after the next notification
  69151. * @param callback the callback that will be executed for that Observer
  69152. * @returns the new observer created for the callback
  69153. */
  69154. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  69155. /**
  69156. * Remove an Observer from the Observable object
  69157. * @param observer the instance of the Observer to remove
  69158. * @returns false if it doesn't belong to this Observable
  69159. */
  69160. remove(observer: Nullable<Observer<T>>): boolean;
  69161. /**
  69162. * Remove a callback from the Observable object
  69163. * @param callback the callback to remove
  69164. * @param scope optional scope. If used only the callbacks with this scope will be removed
  69165. * @returns false if it doesn't belong to this Observable
  69166. */
  69167. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  69168. private _deferUnregister;
  69169. private _remove;
  69170. /**
  69171. * Moves the observable to the top of the observer list making it get called first when notified
  69172. * @param observer the observer to move
  69173. */
  69174. makeObserverTopPriority(observer: Observer<T>): void;
  69175. /**
  69176. * Moves the observable to the bottom of the observer list making it get called last when notified
  69177. * @param observer the observer to move
  69178. */
  69179. makeObserverBottomPriority(observer: Observer<T>): void;
  69180. /**
  69181. * Notify all Observers by calling their respective callback with the given data
  69182. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  69183. * @param eventData defines the data to send to all observers
  69184. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  69185. * @param target defines the original target of the state
  69186. * @param currentTarget defines the current target of the state
  69187. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  69188. */
  69189. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  69190. /**
  69191. * Calling this will execute each callback, expecting it to be a promise or return a value.
  69192. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  69193. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  69194. * and it is crucial that all callbacks will be executed.
  69195. * The order of the callbacks is kept, callbacks are not executed parallel.
  69196. *
  69197. * @param eventData The data to be sent to each callback
  69198. * @param mask is used to filter observers defaults to -1
  69199. * @param target defines the callback target (see EventState)
  69200. * @param currentTarget defines he current object in the bubbling phase
  69201. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  69202. */
  69203. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  69204. /**
  69205. * Notify a specific observer
  69206. * @param observer defines the observer to notify
  69207. * @param eventData defines the data to be sent to each callback
  69208. * @param mask is used to filter observers defaults to -1
  69209. */
  69210. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  69211. /**
  69212. * Gets a boolean indicating if the observable has at least one observer
  69213. * @returns true is the Observable has at least one Observer registered
  69214. */
  69215. hasObservers(): boolean;
  69216. /**
  69217. * Clear the list of observers
  69218. */
  69219. clear(): void;
  69220. /**
  69221. * Clone the current observable
  69222. * @returns a new observable
  69223. */
  69224. clone(): Observable<T>;
  69225. /**
  69226. * Does this observable handles observer registered with a given mask
  69227. * @param mask defines the mask to be tested
  69228. * @return whether or not one observer registered with the given mask is handeled
  69229. **/
  69230. hasSpecificMask(mask?: number): boolean;
  69231. }
  69232. }
  69233. declare module BABYLON {
  69234. /**
  69235. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  69236. * Babylon.js
  69237. */
  69238. export class DomManagement {
  69239. /**
  69240. * Checks if the window object exists
  69241. * @returns true if the window object exists
  69242. */
  69243. static IsWindowObjectExist(): boolean;
  69244. /**
  69245. * Checks if the navigator object exists
  69246. * @returns true if the navigator object exists
  69247. */
  69248. static IsNavigatorAvailable(): boolean;
  69249. /**
  69250. * Extracts text content from a DOM element hierarchy
  69251. * @param element defines the root element
  69252. * @returns a string
  69253. */
  69254. static GetDOMTextContent(element: HTMLElement): string;
  69255. }
  69256. }
  69257. declare module BABYLON {
  69258. /**
  69259. * Logger used througouht the application to allow configuration of
  69260. * the log level required for the messages.
  69261. */
  69262. export class Logger {
  69263. /**
  69264. * No log
  69265. */
  69266. static readonly NoneLogLevel: number;
  69267. /**
  69268. * Only message logs
  69269. */
  69270. static readonly MessageLogLevel: number;
  69271. /**
  69272. * Only warning logs
  69273. */
  69274. static readonly WarningLogLevel: number;
  69275. /**
  69276. * Only error logs
  69277. */
  69278. static readonly ErrorLogLevel: number;
  69279. /**
  69280. * All logs
  69281. */
  69282. static readonly AllLogLevel: number;
  69283. private static _LogCache;
  69284. /**
  69285. * Gets a value indicating the number of loading errors
  69286. * @ignorenaming
  69287. */
  69288. static errorsCount: number;
  69289. /**
  69290. * Callback called when a new log is added
  69291. */
  69292. static OnNewCacheEntry: (entry: string) => void;
  69293. private static _AddLogEntry;
  69294. private static _FormatMessage;
  69295. private static _LogDisabled;
  69296. private static _LogEnabled;
  69297. private static _WarnDisabled;
  69298. private static _WarnEnabled;
  69299. private static _ErrorDisabled;
  69300. private static _ErrorEnabled;
  69301. /**
  69302. * Log a message to the console
  69303. */
  69304. static Log: (message: string) => void;
  69305. /**
  69306. * Write a warning message to the console
  69307. */
  69308. static Warn: (message: string) => void;
  69309. /**
  69310. * Write an error message to the console
  69311. */
  69312. static Error: (message: string) => void;
  69313. /**
  69314. * Gets current log cache (list of logs)
  69315. */
  69316. static readonly LogCache: string;
  69317. /**
  69318. * Clears the log cache
  69319. */
  69320. static ClearLogCache(): void;
  69321. /**
  69322. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  69323. */
  69324. static LogLevels: number;
  69325. }
  69326. }
  69327. declare module BABYLON {
  69328. /** @hidden */
  69329. export class _TypeStore {
  69330. /** @hidden */
  69331. static RegisteredTypes: {
  69332. [key: string]: Object;
  69333. };
  69334. /** @hidden */
  69335. static GetClass(fqdn: string): any;
  69336. }
  69337. }
  69338. declare module BABYLON {
  69339. /**
  69340. * Helper to manipulate strings
  69341. */
  69342. export class StringTools {
  69343. /**
  69344. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  69345. * @param str Source string
  69346. * @param suffix Suffix to search for in the source string
  69347. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  69348. */
  69349. static EndsWith(str: string, suffix: string): boolean;
  69350. /**
  69351. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  69352. * @param str Source string
  69353. * @param suffix Suffix to search for in the source string
  69354. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  69355. */
  69356. static StartsWith(str: string, suffix: string): boolean;
  69357. /**
  69358. * Decodes a buffer into a string
  69359. * @param buffer The buffer to decode
  69360. * @returns The decoded string
  69361. */
  69362. static Decode(buffer: Uint8Array | Uint16Array): string;
  69363. /**
  69364. * Encode a buffer to a base64 string
  69365. * @param buffer defines the buffer to encode
  69366. * @returns the encoded string
  69367. */
  69368. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  69369. }
  69370. }
  69371. declare module BABYLON {
  69372. /**
  69373. * Class containing a set of static utilities functions for deep copy.
  69374. */
  69375. export class DeepCopier {
  69376. /**
  69377. * Tries to copy an object by duplicating every property
  69378. * @param source defines the source object
  69379. * @param destination defines the target object
  69380. * @param doNotCopyList defines a list of properties to avoid
  69381. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  69382. */
  69383. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  69384. }
  69385. }
  69386. declare module BABYLON {
  69387. /**
  69388. * Class containing a set of static utilities functions for precision date
  69389. */
  69390. export class PrecisionDate {
  69391. /**
  69392. * Gets either window.performance.now() if supported or Date.now() else
  69393. */
  69394. static readonly Now: number;
  69395. }
  69396. }
  69397. declare module BABYLON {
  69398. /** @hidden */
  69399. export class _DevTools {
  69400. static WarnImport(name: string): string;
  69401. }
  69402. }
  69403. declare module BABYLON {
  69404. /**
  69405. * Interface used to define the mechanism to get data from the network
  69406. */
  69407. export interface IWebRequest {
  69408. /**
  69409. * Returns client's response url
  69410. */
  69411. responseURL: string;
  69412. /**
  69413. * Returns client's status
  69414. */
  69415. status: number;
  69416. /**
  69417. * Returns client's status as a text
  69418. */
  69419. statusText: string;
  69420. }
  69421. }
  69422. declare module BABYLON {
  69423. /**
  69424. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  69425. */
  69426. export class WebRequest implements IWebRequest {
  69427. private _xhr;
  69428. /**
  69429. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  69430. * i.e. when loading files, where the server/service expects an Authorization header
  69431. */
  69432. static CustomRequestHeaders: {
  69433. [key: string]: string;
  69434. };
  69435. /**
  69436. * Add callback functions in this array to update all the requests before they get sent to the network
  69437. */
  69438. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  69439. private _injectCustomRequestHeaders;
  69440. /**
  69441. * Gets or sets a function to be called when loading progress changes
  69442. */
  69443. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  69444. /**
  69445. * Returns client's state
  69446. */
  69447. readonly readyState: number;
  69448. /**
  69449. * Returns client's status
  69450. */
  69451. readonly status: number;
  69452. /**
  69453. * Returns client's status as a text
  69454. */
  69455. readonly statusText: string;
  69456. /**
  69457. * Returns client's response
  69458. */
  69459. readonly response: any;
  69460. /**
  69461. * Returns client's response url
  69462. */
  69463. readonly responseURL: string;
  69464. /**
  69465. * Returns client's response as text
  69466. */
  69467. readonly responseText: string;
  69468. /**
  69469. * Gets or sets the expected response type
  69470. */
  69471. responseType: XMLHttpRequestResponseType;
  69472. /** @hidden */
  69473. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  69474. /** @hidden */
  69475. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  69476. /**
  69477. * Cancels any network activity
  69478. */
  69479. abort(): void;
  69480. /**
  69481. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  69482. * @param body defines an optional request body
  69483. */
  69484. send(body?: Document | BodyInit | null): void;
  69485. /**
  69486. * Sets the request method, request URL
  69487. * @param method defines the method to use (GET, POST, etc..)
  69488. * @param url defines the url to connect with
  69489. */
  69490. open(method: string, url: string): void;
  69491. /**
  69492. * Sets the value of a request header.
  69493. * @param name The name of the header whose value is to be set
  69494. * @param value The value to set as the body of the header
  69495. */
  69496. setRequestHeader(name: string, value: string): void;
  69497. /**
  69498. * Get the string containing the text of a particular header's value.
  69499. * @param name The name of the header
  69500. * @returns The string containing the text of the given header name
  69501. */
  69502. getResponseHeader(name: string): Nullable<string>;
  69503. }
  69504. }
  69505. declare module BABYLON {
  69506. /**
  69507. * File request interface
  69508. */
  69509. export interface IFileRequest {
  69510. /**
  69511. * Raised when the request is complete (success or error).
  69512. */
  69513. onCompleteObservable: Observable<IFileRequest>;
  69514. /**
  69515. * Aborts the request for a file.
  69516. */
  69517. abort: () => void;
  69518. }
  69519. }
  69520. declare module BABYLON {
  69521. /**
  69522. * Define options used to create a render target texture
  69523. */
  69524. export class RenderTargetCreationOptions {
  69525. /**
  69526. * Specifies is mipmaps must be generated
  69527. */
  69528. generateMipMaps?: boolean;
  69529. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  69530. generateDepthBuffer?: boolean;
  69531. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  69532. generateStencilBuffer?: boolean;
  69533. /** Defines texture type (int by default) */
  69534. type?: number;
  69535. /** Defines sampling mode (trilinear by default) */
  69536. samplingMode?: number;
  69537. /** Defines format (RGBA by default) */
  69538. format?: number;
  69539. }
  69540. }
  69541. declare module BABYLON {
  69542. /**
  69543. * @hidden
  69544. **/
  69545. export class _TimeToken {
  69546. _startTimeQuery: Nullable<WebGLQuery>;
  69547. _endTimeQuery: Nullable<WebGLQuery>;
  69548. _timeElapsedQuery: Nullable<WebGLQuery>;
  69549. _timeElapsedQueryEnded: boolean;
  69550. }
  69551. }
  69552. declare module BABYLON {
  69553. /** Defines the cross module used constants to avoid circular dependncies */
  69554. export class Constants {
  69555. /** Defines that alpha blending is disabled */
  69556. static readonly ALPHA_DISABLE: number;
  69557. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  69558. static readonly ALPHA_ADD: number;
  69559. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  69560. static readonly ALPHA_COMBINE: number;
  69561. /** Defines that alpha blending to DEST - SRC * DEST */
  69562. static readonly ALPHA_SUBTRACT: number;
  69563. /** Defines that alpha blending to SRC * DEST */
  69564. static readonly ALPHA_MULTIPLY: number;
  69565. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  69566. static readonly ALPHA_MAXIMIZED: number;
  69567. /** Defines that alpha blending to SRC + DEST */
  69568. static readonly ALPHA_ONEONE: number;
  69569. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  69570. static readonly ALPHA_PREMULTIPLIED: number;
  69571. /**
  69572. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  69573. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  69574. */
  69575. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  69576. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  69577. static readonly ALPHA_INTERPOLATE: number;
  69578. /**
  69579. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  69580. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  69581. */
  69582. static readonly ALPHA_SCREENMODE: number;
  69583. /**
  69584. * Defines that alpha blending to SRC + DST
  69585. * Alpha will be set to SRC ALPHA + DST ALPHA
  69586. */
  69587. static readonly ALPHA_ONEONE_ONEONE: number;
  69588. /**
  69589. * Defines that alpha blending to SRC * DST ALPHA + DST
  69590. * Alpha will be set to 0
  69591. */
  69592. static readonly ALPHA_ALPHATOCOLOR: number;
  69593. /**
  69594. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  69595. */
  69596. static readonly ALPHA_REVERSEONEMINUS: number;
  69597. /**
  69598. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  69599. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  69600. */
  69601. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  69602. /**
  69603. * Defines that alpha blending to SRC + DST
  69604. * Alpha will be set to SRC ALPHA
  69605. */
  69606. static readonly ALPHA_ONEONE_ONEZERO: number;
  69607. /** Defines that alpha blending equation a SUM */
  69608. static readonly ALPHA_EQUATION_ADD: number;
  69609. /** Defines that alpha blending equation a SUBSTRACTION */
  69610. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  69611. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  69612. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  69613. /** Defines that alpha blending equation a MAX operation */
  69614. static readonly ALPHA_EQUATION_MAX: number;
  69615. /** Defines that alpha blending equation a MIN operation */
  69616. static readonly ALPHA_EQUATION_MIN: number;
  69617. /**
  69618. * Defines that alpha blending equation a DARKEN operation:
  69619. * It takes the min of the src and sums the alpha channels.
  69620. */
  69621. static readonly ALPHA_EQUATION_DARKEN: number;
  69622. /** Defines that the ressource is not delayed*/
  69623. static readonly DELAYLOADSTATE_NONE: number;
  69624. /** Defines that the ressource was successfully delay loaded */
  69625. static readonly DELAYLOADSTATE_LOADED: number;
  69626. /** Defines that the ressource is currently delay loading */
  69627. static readonly DELAYLOADSTATE_LOADING: number;
  69628. /** Defines that the ressource is delayed and has not started loading */
  69629. static readonly DELAYLOADSTATE_NOTLOADED: number;
  69630. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  69631. static readonly NEVER: number;
  69632. /** 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 */
  69633. static readonly ALWAYS: number;
  69634. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  69635. static readonly LESS: number;
  69636. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  69637. static readonly EQUAL: number;
  69638. /** 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 */
  69639. static readonly LEQUAL: number;
  69640. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  69641. static readonly GREATER: number;
  69642. /** 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 */
  69643. static readonly GEQUAL: number;
  69644. /** 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 */
  69645. static readonly NOTEQUAL: number;
  69646. /** Passed to stencilOperation to specify that stencil value must be kept */
  69647. static readonly KEEP: number;
  69648. /** Passed to stencilOperation to specify that stencil value must be replaced */
  69649. static readonly REPLACE: number;
  69650. /** Passed to stencilOperation to specify that stencil value must be incremented */
  69651. static readonly INCR: number;
  69652. /** Passed to stencilOperation to specify that stencil value must be decremented */
  69653. static readonly DECR: number;
  69654. /** Passed to stencilOperation to specify that stencil value must be inverted */
  69655. static readonly INVERT: number;
  69656. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  69657. static readonly INCR_WRAP: number;
  69658. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  69659. static readonly DECR_WRAP: number;
  69660. /** Texture is not repeating outside of 0..1 UVs */
  69661. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  69662. /** Texture is repeating outside of 0..1 UVs */
  69663. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  69664. /** Texture is repeating and mirrored */
  69665. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  69666. /** ALPHA */
  69667. static readonly TEXTUREFORMAT_ALPHA: number;
  69668. /** LUMINANCE */
  69669. static readonly TEXTUREFORMAT_LUMINANCE: number;
  69670. /** LUMINANCE_ALPHA */
  69671. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  69672. /** RGB */
  69673. static readonly TEXTUREFORMAT_RGB: number;
  69674. /** RGBA */
  69675. static readonly TEXTUREFORMAT_RGBA: number;
  69676. /** RED */
  69677. static readonly TEXTUREFORMAT_RED: number;
  69678. /** RED (2nd reference) */
  69679. static readonly TEXTUREFORMAT_R: number;
  69680. /** RG */
  69681. static readonly TEXTUREFORMAT_RG: number;
  69682. /** RED_INTEGER */
  69683. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  69684. /** RED_INTEGER (2nd reference) */
  69685. static readonly TEXTUREFORMAT_R_INTEGER: number;
  69686. /** RG_INTEGER */
  69687. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  69688. /** RGB_INTEGER */
  69689. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  69690. /** RGBA_INTEGER */
  69691. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  69692. /** UNSIGNED_BYTE */
  69693. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  69694. /** UNSIGNED_BYTE (2nd reference) */
  69695. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  69696. /** FLOAT */
  69697. static readonly TEXTURETYPE_FLOAT: number;
  69698. /** HALF_FLOAT */
  69699. static readonly TEXTURETYPE_HALF_FLOAT: number;
  69700. /** BYTE */
  69701. static readonly TEXTURETYPE_BYTE: number;
  69702. /** SHORT */
  69703. static readonly TEXTURETYPE_SHORT: number;
  69704. /** UNSIGNED_SHORT */
  69705. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  69706. /** INT */
  69707. static readonly TEXTURETYPE_INT: number;
  69708. /** UNSIGNED_INT */
  69709. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  69710. /** UNSIGNED_SHORT_4_4_4_4 */
  69711. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  69712. /** UNSIGNED_SHORT_5_5_5_1 */
  69713. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  69714. /** UNSIGNED_SHORT_5_6_5 */
  69715. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  69716. /** UNSIGNED_INT_2_10_10_10_REV */
  69717. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  69718. /** UNSIGNED_INT_24_8 */
  69719. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  69720. /** UNSIGNED_INT_10F_11F_11F_REV */
  69721. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  69722. /** UNSIGNED_INT_5_9_9_9_REV */
  69723. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  69724. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  69725. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  69726. /** nearest is mag = nearest and min = nearest and mip = nearest */
  69727. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  69728. /** Bilinear is mag = linear and min = linear and mip = nearest */
  69729. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  69730. /** Trilinear is mag = linear and min = linear and mip = linear */
  69731. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  69732. /** nearest is mag = nearest and min = nearest and mip = linear */
  69733. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  69734. /** Bilinear is mag = linear and min = linear and mip = nearest */
  69735. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  69736. /** Trilinear is mag = linear and min = linear and mip = linear */
  69737. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  69738. /** mag = nearest and min = nearest and mip = nearest */
  69739. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  69740. /** mag = nearest and min = linear and mip = nearest */
  69741. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  69742. /** mag = nearest and min = linear and mip = linear */
  69743. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  69744. /** mag = nearest and min = linear and mip = none */
  69745. static readonly TEXTURE_NEAREST_LINEAR: number;
  69746. /** mag = nearest and min = nearest and mip = none */
  69747. static readonly TEXTURE_NEAREST_NEAREST: number;
  69748. /** mag = linear and min = nearest and mip = nearest */
  69749. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  69750. /** mag = linear and min = nearest and mip = linear */
  69751. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  69752. /** mag = linear and min = linear and mip = none */
  69753. static readonly TEXTURE_LINEAR_LINEAR: number;
  69754. /** mag = linear and min = nearest and mip = none */
  69755. static readonly TEXTURE_LINEAR_NEAREST: number;
  69756. /** Explicit coordinates mode */
  69757. static readonly TEXTURE_EXPLICIT_MODE: number;
  69758. /** Spherical coordinates mode */
  69759. static readonly TEXTURE_SPHERICAL_MODE: number;
  69760. /** Planar coordinates mode */
  69761. static readonly TEXTURE_PLANAR_MODE: number;
  69762. /** Cubic coordinates mode */
  69763. static readonly TEXTURE_CUBIC_MODE: number;
  69764. /** Projection coordinates mode */
  69765. static readonly TEXTURE_PROJECTION_MODE: number;
  69766. /** Skybox coordinates mode */
  69767. static readonly TEXTURE_SKYBOX_MODE: number;
  69768. /** Inverse Cubic coordinates mode */
  69769. static readonly TEXTURE_INVCUBIC_MODE: number;
  69770. /** Equirectangular coordinates mode */
  69771. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  69772. /** Equirectangular Fixed coordinates mode */
  69773. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  69774. /** Equirectangular Fixed Mirrored coordinates mode */
  69775. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  69776. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  69777. static readonly SCALEMODE_FLOOR: number;
  69778. /** Defines that texture rescaling will look for the nearest power of 2 size */
  69779. static readonly SCALEMODE_NEAREST: number;
  69780. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  69781. static readonly SCALEMODE_CEILING: number;
  69782. /**
  69783. * The dirty texture flag value
  69784. */
  69785. static readonly MATERIAL_TextureDirtyFlag: number;
  69786. /**
  69787. * The dirty light flag value
  69788. */
  69789. static readonly MATERIAL_LightDirtyFlag: number;
  69790. /**
  69791. * The dirty fresnel flag value
  69792. */
  69793. static readonly MATERIAL_FresnelDirtyFlag: number;
  69794. /**
  69795. * The dirty attribute flag value
  69796. */
  69797. static readonly MATERIAL_AttributesDirtyFlag: number;
  69798. /**
  69799. * The dirty misc flag value
  69800. */
  69801. static readonly MATERIAL_MiscDirtyFlag: number;
  69802. /**
  69803. * The all dirty flag value
  69804. */
  69805. static readonly MATERIAL_AllDirtyFlag: number;
  69806. /**
  69807. * Returns the triangle fill mode
  69808. */
  69809. static readonly MATERIAL_TriangleFillMode: number;
  69810. /**
  69811. * Returns the wireframe mode
  69812. */
  69813. static readonly MATERIAL_WireFrameFillMode: number;
  69814. /**
  69815. * Returns the point fill mode
  69816. */
  69817. static readonly MATERIAL_PointFillMode: number;
  69818. /**
  69819. * Returns the point list draw mode
  69820. */
  69821. static readonly MATERIAL_PointListDrawMode: number;
  69822. /**
  69823. * Returns the line list draw mode
  69824. */
  69825. static readonly MATERIAL_LineListDrawMode: number;
  69826. /**
  69827. * Returns the line loop draw mode
  69828. */
  69829. static readonly MATERIAL_LineLoopDrawMode: number;
  69830. /**
  69831. * Returns the line strip draw mode
  69832. */
  69833. static readonly MATERIAL_LineStripDrawMode: number;
  69834. /**
  69835. * Returns the triangle strip draw mode
  69836. */
  69837. static readonly MATERIAL_TriangleStripDrawMode: number;
  69838. /**
  69839. * Returns the triangle fan draw mode
  69840. */
  69841. static readonly MATERIAL_TriangleFanDrawMode: number;
  69842. /**
  69843. * Stores the clock-wise side orientation
  69844. */
  69845. static readonly MATERIAL_ClockWiseSideOrientation: number;
  69846. /**
  69847. * Stores the counter clock-wise side orientation
  69848. */
  69849. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  69850. /**
  69851. * Nothing
  69852. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69853. */
  69854. static readonly ACTION_NothingTrigger: number;
  69855. /**
  69856. * On pick
  69857. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69858. */
  69859. static readonly ACTION_OnPickTrigger: number;
  69860. /**
  69861. * On left pick
  69862. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69863. */
  69864. static readonly ACTION_OnLeftPickTrigger: number;
  69865. /**
  69866. * On right pick
  69867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69868. */
  69869. static readonly ACTION_OnRightPickTrigger: number;
  69870. /**
  69871. * On center pick
  69872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69873. */
  69874. static readonly ACTION_OnCenterPickTrigger: number;
  69875. /**
  69876. * On pick down
  69877. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69878. */
  69879. static readonly ACTION_OnPickDownTrigger: number;
  69880. /**
  69881. * On double pick
  69882. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69883. */
  69884. static readonly ACTION_OnDoublePickTrigger: number;
  69885. /**
  69886. * On pick up
  69887. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69888. */
  69889. static readonly ACTION_OnPickUpTrigger: number;
  69890. /**
  69891. * On pick out.
  69892. * This trigger will only be raised if you also declared a OnPickDown
  69893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69894. */
  69895. static readonly ACTION_OnPickOutTrigger: number;
  69896. /**
  69897. * On long press
  69898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69899. */
  69900. static readonly ACTION_OnLongPressTrigger: number;
  69901. /**
  69902. * On pointer over
  69903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69904. */
  69905. static readonly ACTION_OnPointerOverTrigger: number;
  69906. /**
  69907. * On pointer out
  69908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69909. */
  69910. static readonly ACTION_OnPointerOutTrigger: number;
  69911. /**
  69912. * On every frame
  69913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69914. */
  69915. static readonly ACTION_OnEveryFrameTrigger: number;
  69916. /**
  69917. * On intersection enter
  69918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69919. */
  69920. static readonly ACTION_OnIntersectionEnterTrigger: number;
  69921. /**
  69922. * On intersection exit
  69923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69924. */
  69925. static readonly ACTION_OnIntersectionExitTrigger: number;
  69926. /**
  69927. * On key down
  69928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69929. */
  69930. static readonly ACTION_OnKeyDownTrigger: number;
  69931. /**
  69932. * On key up
  69933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69934. */
  69935. static readonly ACTION_OnKeyUpTrigger: number;
  69936. /**
  69937. * Billboard mode will only apply to Y axis
  69938. */
  69939. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  69940. /**
  69941. * Billboard mode will apply to all axes
  69942. */
  69943. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  69944. /**
  69945. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  69946. */
  69947. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  69948. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  69949. * Test order :
  69950. * Is the bounding sphere outside the frustum ?
  69951. * If not, are the bounding box vertices outside the frustum ?
  69952. * It not, then the cullable object is in the frustum.
  69953. */
  69954. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  69955. /** Culling strategy : Bounding Sphere Only.
  69956. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  69957. * It's also less accurate than the standard because some not visible objects can still be selected.
  69958. * Test : is the bounding sphere outside the frustum ?
  69959. * If not, then the cullable object is in the frustum.
  69960. */
  69961. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  69962. /** Culling strategy : Optimistic Inclusion.
  69963. * This in an inclusion test first, then the standard exclusion test.
  69964. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  69965. * 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.
  69966. * Anyway, it's as accurate as the standard strategy.
  69967. * Test :
  69968. * Is the cullable object bounding sphere center in the frustum ?
  69969. * If not, apply the default culling strategy.
  69970. */
  69971. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  69972. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  69973. * This in an inclusion test first, then the bounding sphere only exclusion test.
  69974. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  69975. * 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.
  69976. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  69977. * Test :
  69978. * Is the cullable object bounding sphere center in the frustum ?
  69979. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  69980. */
  69981. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  69982. /**
  69983. * No logging while loading
  69984. */
  69985. static readonly SCENELOADER_NO_LOGGING: number;
  69986. /**
  69987. * Minimal logging while loading
  69988. */
  69989. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  69990. /**
  69991. * Summary logging while loading
  69992. */
  69993. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  69994. /**
  69995. * Detailled logging while loading
  69996. */
  69997. static readonly SCENELOADER_DETAILED_LOGGING: number;
  69998. }
  69999. }
  70000. declare module BABYLON {
  70001. /**
  70002. * This represents the required contract to create a new type of texture loader.
  70003. */
  70004. export interface IInternalTextureLoader {
  70005. /**
  70006. * Defines wether the loader supports cascade loading the different faces.
  70007. */
  70008. supportCascades: boolean;
  70009. /**
  70010. * This returns if the loader support the current file information.
  70011. * @param extension defines the file extension of the file being loaded
  70012. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70013. * @param fallback defines the fallback internal texture if any
  70014. * @param isBase64 defines whether the texture is encoded as a base64
  70015. * @param isBuffer defines whether the texture data are stored as a buffer
  70016. * @returns true if the loader can load the specified file
  70017. */
  70018. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  70019. /**
  70020. * Transform the url before loading if required.
  70021. * @param rootUrl the url of the texture
  70022. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70023. * @returns the transformed texture
  70024. */
  70025. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  70026. /**
  70027. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  70028. * @param rootUrl the url of the texture
  70029. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70030. * @returns the fallback texture
  70031. */
  70032. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  70033. /**
  70034. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  70035. * @param data contains the texture data
  70036. * @param texture defines the BabylonJS internal texture
  70037. * @param createPolynomials will be true if polynomials have been requested
  70038. * @param onLoad defines the callback to trigger once the texture is ready
  70039. * @param onError defines the callback to trigger in case of error
  70040. */
  70041. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  70042. /**
  70043. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  70044. * @param data contains the texture data
  70045. * @param texture defines the BabylonJS internal texture
  70046. * @param callback defines the method to call once ready to upload
  70047. */
  70048. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  70049. }
  70050. }
  70051. declare module BABYLON {
  70052. /**
  70053. * Class used to store and describe the pipeline context associated with an effect
  70054. */
  70055. export interface IPipelineContext {
  70056. /**
  70057. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  70058. */
  70059. isAsync: boolean;
  70060. /**
  70061. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  70062. */
  70063. isReady: boolean;
  70064. /** @hidden */
  70065. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  70066. }
  70067. }
  70068. declare module BABYLON {
  70069. /**
  70070. * Class used to store gfx data (like WebGLBuffer)
  70071. */
  70072. export class DataBuffer {
  70073. /**
  70074. * Gets or sets the number of objects referencing this buffer
  70075. */
  70076. references: number;
  70077. /** Gets or sets the size of the underlying buffer */
  70078. capacity: number;
  70079. /**
  70080. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  70081. */
  70082. is32Bits: boolean;
  70083. /**
  70084. * Gets the underlying buffer
  70085. */
  70086. readonly underlyingResource: any;
  70087. }
  70088. }
  70089. declare module BABYLON {
  70090. /** @hidden */
  70091. export interface IShaderProcessor {
  70092. attributeProcessor?: (attribute: string) => string;
  70093. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  70094. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  70095. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  70096. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  70097. lineProcessor?: (line: string, isFragment: boolean) => string;
  70098. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  70099. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  70100. }
  70101. }
  70102. declare module BABYLON {
  70103. /** @hidden */
  70104. export interface ProcessingOptions {
  70105. defines: string[];
  70106. indexParameters: any;
  70107. isFragment: boolean;
  70108. shouldUseHighPrecisionShader: boolean;
  70109. supportsUniformBuffers: boolean;
  70110. shadersRepository: string;
  70111. includesShadersStore: {
  70112. [key: string]: string;
  70113. };
  70114. processor?: IShaderProcessor;
  70115. version: string;
  70116. platformName: string;
  70117. lookForClosingBracketForUniformBuffer?: boolean;
  70118. }
  70119. }
  70120. declare module BABYLON {
  70121. /** @hidden */
  70122. export class ShaderCodeNode {
  70123. line: string;
  70124. children: ShaderCodeNode[];
  70125. additionalDefineKey?: string;
  70126. additionalDefineValue?: string;
  70127. isValid(preprocessors: {
  70128. [key: string]: string;
  70129. }): boolean;
  70130. process(preprocessors: {
  70131. [key: string]: string;
  70132. }, options: ProcessingOptions): string;
  70133. }
  70134. }
  70135. declare module BABYLON {
  70136. /** @hidden */
  70137. export class ShaderCodeCursor {
  70138. private _lines;
  70139. lineIndex: number;
  70140. readonly currentLine: string;
  70141. readonly canRead: boolean;
  70142. lines: string[];
  70143. }
  70144. }
  70145. declare module BABYLON {
  70146. /** @hidden */
  70147. export class ShaderCodeConditionNode extends ShaderCodeNode {
  70148. process(preprocessors: {
  70149. [key: string]: string;
  70150. }, options: ProcessingOptions): string;
  70151. }
  70152. }
  70153. declare module BABYLON {
  70154. /** @hidden */
  70155. export class ShaderDefineExpression {
  70156. isTrue(preprocessors: {
  70157. [key: string]: string;
  70158. }): boolean;
  70159. }
  70160. }
  70161. declare module BABYLON {
  70162. /** @hidden */
  70163. export class ShaderCodeTestNode extends ShaderCodeNode {
  70164. testExpression: ShaderDefineExpression;
  70165. isValid(preprocessors: {
  70166. [key: string]: string;
  70167. }): boolean;
  70168. }
  70169. }
  70170. declare module BABYLON {
  70171. /** @hidden */
  70172. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  70173. define: string;
  70174. not: boolean;
  70175. constructor(define: string, not?: boolean);
  70176. isTrue(preprocessors: {
  70177. [key: string]: string;
  70178. }): boolean;
  70179. }
  70180. }
  70181. declare module BABYLON {
  70182. /** @hidden */
  70183. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  70184. leftOperand: ShaderDefineExpression;
  70185. rightOperand: ShaderDefineExpression;
  70186. isTrue(preprocessors: {
  70187. [key: string]: string;
  70188. }): boolean;
  70189. }
  70190. }
  70191. declare module BABYLON {
  70192. /** @hidden */
  70193. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  70194. leftOperand: ShaderDefineExpression;
  70195. rightOperand: ShaderDefineExpression;
  70196. isTrue(preprocessors: {
  70197. [key: string]: string;
  70198. }): boolean;
  70199. }
  70200. }
  70201. declare module BABYLON {
  70202. /** @hidden */
  70203. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  70204. define: string;
  70205. operand: string;
  70206. testValue: string;
  70207. constructor(define: string, operand: string, testValue: string);
  70208. isTrue(preprocessors: {
  70209. [key: string]: string;
  70210. }): boolean;
  70211. }
  70212. }
  70213. declare module BABYLON {
  70214. /**
  70215. * Class used to enable access to offline support
  70216. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  70217. */
  70218. export interface IOfflineProvider {
  70219. /**
  70220. * Gets a boolean indicating if scene must be saved in the database
  70221. */
  70222. enableSceneOffline: boolean;
  70223. /**
  70224. * Gets a boolean indicating if textures must be saved in the database
  70225. */
  70226. enableTexturesOffline: boolean;
  70227. /**
  70228. * Open the offline support and make it available
  70229. * @param successCallback defines the callback to call on success
  70230. * @param errorCallback defines the callback to call on error
  70231. */
  70232. open(successCallback: () => void, errorCallback: () => void): void;
  70233. /**
  70234. * Loads an image from the offline support
  70235. * @param url defines the url to load from
  70236. * @param image defines the target DOM image
  70237. */
  70238. loadImage(url: string, image: HTMLImageElement): void;
  70239. /**
  70240. * Loads a file from offline support
  70241. * @param url defines the URL to load from
  70242. * @param sceneLoaded defines a callback to call on success
  70243. * @param progressCallBack defines a callback to call when progress changed
  70244. * @param errorCallback defines a callback to call on error
  70245. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  70246. */
  70247. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  70248. }
  70249. }
  70250. declare module BABYLON {
  70251. /**
  70252. * Class used to help managing file picking and drag'n'drop
  70253. * File Storage
  70254. */
  70255. export class FilesInputStore {
  70256. /**
  70257. * List of files ready to be loaded
  70258. */
  70259. static FilesToLoad: {
  70260. [key: string]: File;
  70261. };
  70262. }
  70263. }
  70264. declare module BABYLON {
  70265. /**
  70266. * Class used to define a retry strategy when error happens while loading assets
  70267. */
  70268. export class RetryStrategy {
  70269. /**
  70270. * Function used to defines an exponential back off strategy
  70271. * @param maxRetries defines the maximum number of retries (3 by default)
  70272. * @param baseInterval defines the interval between retries
  70273. * @returns the strategy function to use
  70274. */
  70275. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  70276. }
  70277. }
  70278. declare module BABYLON {
  70279. /**
  70280. * @ignore
  70281. * Application error to support additional information when loading a file
  70282. */
  70283. export abstract class BaseError extends Error {
  70284. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  70285. }
  70286. }
  70287. declare module BABYLON {
  70288. /** @ignore */
  70289. export class LoadFileError extends BaseError {
  70290. request?: WebRequest;
  70291. file?: File;
  70292. /**
  70293. * Creates a new LoadFileError
  70294. * @param message defines the message of the error
  70295. * @param request defines the optional web request
  70296. * @param file defines the optional file
  70297. */
  70298. constructor(message: string, object?: WebRequest | File);
  70299. }
  70300. /** @ignore */
  70301. export class RequestFileError extends BaseError {
  70302. request: WebRequest;
  70303. /**
  70304. * Creates a new LoadFileError
  70305. * @param message defines the message of the error
  70306. * @param request defines the optional web request
  70307. */
  70308. constructor(message: string, request: WebRequest);
  70309. }
  70310. /** @ignore */
  70311. export class ReadFileError extends BaseError {
  70312. file: File;
  70313. /**
  70314. * Creates a new ReadFileError
  70315. * @param message defines the message of the error
  70316. * @param file defines the optional file
  70317. */
  70318. constructor(message: string, file: File);
  70319. }
  70320. /**
  70321. * @hidden
  70322. */
  70323. export class FileTools {
  70324. /**
  70325. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  70326. */
  70327. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  70328. /**
  70329. * Gets or sets the base URL to use to load assets
  70330. */
  70331. static BaseUrl: string;
  70332. /**
  70333. * Default behaviour for cors in the application.
  70334. * It can be a string if the expected behavior is identical in the entire app.
  70335. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  70336. */
  70337. static CorsBehavior: string | ((url: string | string[]) => string);
  70338. /**
  70339. * Gets or sets a function used to pre-process url before using them to load assets
  70340. */
  70341. static PreprocessUrl: (url: string) => string;
  70342. /**
  70343. * Removes unwanted characters from an url
  70344. * @param url defines the url to clean
  70345. * @returns the cleaned url
  70346. */
  70347. private static _CleanUrl;
  70348. /**
  70349. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  70350. * @param url define the url we are trying
  70351. * @param element define the dom element where to configure the cors policy
  70352. */
  70353. static SetCorsBehavior(url: string | string[], element: {
  70354. crossOrigin: string | null;
  70355. }): void;
  70356. /**
  70357. * Loads an image as an HTMLImageElement.
  70358. * @param input url string, ArrayBuffer, or Blob to load
  70359. * @param onLoad callback called when the image successfully loads
  70360. * @param onError callback called when the image fails to load
  70361. * @param offlineProvider offline provider for caching
  70362. * @param mimeType optional mime type
  70363. * @returns the HTMLImageElement of the loaded image
  70364. */
  70365. 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>;
  70366. /**
  70367. * Reads a file from a File object
  70368. * @param file defines the file to load
  70369. * @param onSuccess defines the callback to call when data is loaded
  70370. * @param onProgress defines the callback to call during loading process
  70371. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  70372. * @param onError defines the callback to call when an error occurs
  70373. * @returns a file request object
  70374. */
  70375. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  70376. /**
  70377. * Loads a file from a url
  70378. * @param url url to load
  70379. * @param onSuccess callback called when the file successfully loads
  70380. * @param onProgress callback called while file is loading (if the server supports this mode)
  70381. * @param offlineProvider defines the offline provider for caching
  70382. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  70383. * @param onError callback called when the file fails to load
  70384. * @returns a file request object
  70385. */
  70386. 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;
  70387. /**
  70388. * Loads a file
  70389. * @param url url to load
  70390. * @param onSuccess callback called when the file successfully loads
  70391. * @param onProgress callback called while file is loading (if the server supports this mode)
  70392. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  70393. * @param onError callback called when the file fails to load
  70394. * @param onOpened callback called when the web request is opened
  70395. * @returns a file request object
  70396. */
  70397. 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;
  70398. /**
  70399. * Checks if the loaded document was accessed via `file:`-Protocol.
  70400. * @returns boolean
  70401. */
  70402. static IsFileURL(): boolean;
  70403. }
  70404. }
  70405. declare module BABYLON {
  70406. /** @hidden */
  70407. export class ShaderProcessor {
  70408. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  70409. private static _ProcessPrecision;
  70410. private static _ExtractOperation;
  70411. private static _BuildSubExpression;
  70412. private static _BuildExpression;
  70413. private static _MoveCursorWithinIf;
  70414. private static _MoveCursor;
  70415. private static _EvaluatePreProcessors;
  70416. private static _PreparePreProcessors;
  70417. private static _ProcessShaderConversion;
  70418. private static _ProcessIncludes;
  70419. }
  70420. }
  70421. declare module BABYLON {
  70422. /**
  70423. * @hidden
  70424. */
  70425. export interface IColor4Like {
  70426. r: float;
  70427. g: float;
  70428. b: float;
  70429. a: float;
  70430. }
  70431. /**
  70432. * @hidden
  70433. */
  70434. export interface IColor3Like {
  70435. r: float;
  70436. g: float;
  70437. b: float;
  70438. }
  70439. /**
  70440. * @hidden
  70441. */
  70442. export interface IVector4Like {
  70443. x: float;
  70444. y: float;
  70445. z: float;
  70446. w: float;
  70447. }
  70448. /**
  70449. * @hidden
  70450. */
  70451. export interface IVector3Like {
  70452. x: float;
  70453. y: float;
  70454. z: float;
  70455. }
  70456. /**
  70457. * @hidden
  70458. */
  70459. export interface IVector2Like {
  70460. x: float;
  70461. y: float;
  70462. }
  70463. /**
  70464. * @hidden
  70465. */
  70466. export interface IMatrixLike {
  70467. toArray(): DeepImmutable<Float32Array>;
  70468. updateFlag: int;
  70469. }
  70470. /**
  70471. * @hidden
  70472. */
  70473. export interface IViewportLike {
  70474. x: float;
  70475. y: float;
  70476. width: float;
  70477. height: float;
  70478. }
  70479. /**
  70480. * @hidden
  70481. */
  70482. export interface IPlaneLike {
  70483. normal: IVector3Like;
  70484. d: float;
  70485. normalize(): void;
  70486. }
  70487. }
  70488. declare module BABYLON {
  70489. /**
  70490. * Interface used to define common properties for effect fallbacks
  70491. */
  70492. export interface IEffectFallbacks {
  70493. /**
  70494. * Removes the defines that should be removed when falling back.
  70495. * @param currentDefines defines the current define statements for the shader.
  70496. * @param effect defines the current effect we try to compile
  70497. * @returns The resulting defines with defines of the current rank removed.
  70498. */
  70499. reduce(currentDefines: string, effect: Effect): string;
  70500. /**
  70501. * Removes the fallback from the bound mesh.
  70502. */
  70503. unBindMesh(): void;
  70504. /**
  70505. * Checks to see if more fallbacks are still availible.
  70506. */
  70507. hasMoreFallbacks: boolean;
  70508. }
  70509. }
  70510. declare module BABYLON {
  70511. /**
  70512. * Class used to evalaute queries containing `and` and `or` operators
  70513. */
  70514. export class AndOrNotEvaluator {
  70515. /**
  70516. * Evaluate a query
  70517. * @param query defines the query to evaluate
  70518. * @param evaluateCallback defines the callback used to filter result
  70519. * @returns true if the query matches
  70520. */
  70521. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  70522. private static _HandleParenthesisContent;
  70523. private static _SimplifyNegation;
  70524. }
  70525. }
  70526. declare module BABYLON {
  70527. /**
  70528. * Class used to store custom tags
  70529. */
  70530. export class Tags {
  70531. /**
  70532. * Adds support for tags on the given object
  70533. * @param obj defines the object to use
  70534. */
  70535. static EnableFor(obj: any): void;
  70536. /**
  70537. * Removes tags support
  70538. * @param obj defines the object to use
  70539. */
  70540. static DisableFor(obj: any): void;
  70541. /**
  70542. * Gets a boolean indicating if the given object has tags
  70543. * @param obj defines the object to use
  70544. * @returns a boolean
  70545. */
  70546. static HasTags(obj: any): boolean;
  70547. /**
  70548. * Gets the tags available on a given object
  70549. * @param obj defines the object to use
  70550. * @param asString defines if the tags must be returned as a string instead of an array of strings
  70551. * @returns the tags
  70552. */
  70553. static GetTags(obj: any, asString?: boolean): any;
  70554. /**
  70555. * Adds tags to an object
  70556. * @param obj defines the object to use
  70557. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  70558. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  70559. */
  70560. static AddTagsTo(obj: any, tagsString: string): void;
  70561. /**
  70562. * @hidden
  70563. */
  70564. static _AddTagTo(obj: any, tag: string): void;
  70565. /**
  70566. * Removes specific tags from a specific object
  70567. * @param obj defines the object to use
  70568. * @param tagsString defines the tags to remove
  70569. */
  70570. static RemoveTagsFrom(obj: any, tagsString: string): void;
  70571. /**
  70572. * @hidden
  70573. */
  70574. static _RemoveTagFrom(obj: any, tag: string): void;
  70575. /**
  70576. * Defines if tags hosted on an object match a given query
  70577. * @param obj defines the object to use
  70578. * @param tagsQuery defines the tag query
  70579. * @returns a boolean
  70580. */
  70581. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  70582. }
  70583. }
  70584. declare module BABYLON {
  70585. /**
  70586. * Scalar computation library
  70587. */
  70588. export class Scalar {
  70589. /**
  70590. * Two pi constants convenient for computation.
  70591. */
  70592. static TwoPi: number;
  70593. /**
  70594. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  70595. * @param a number
  70596. * @param b number
  70597. * @param epsilon (default = 1.401298E-45)
  70598. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  70599. */
  70600. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  70601. /**
  70602. * Returns a string : the upper case translation of the number i to hexadecimal.
  70603. * @param i number
  70604. * @returns the upper case translation of the number i to hexadecimal.
  70605. */
  70606. static ToHex(i: number): string;
  70607. /**
  70608. * Returns -1 if value is negative and +1 is value is positive.
  70609. * @param value the value
  70610. * @returns the value itself if it's equal to zero.
  70611. */
  70612. static Sign(value: number): number;
  70613. /**
  70614. * Returns the value itself if it's between min and max.
  70615. * Returns min if the value is lower than min.
  70616. * Returns max if the value is greater than max.
  70617. * @param value the value to clmap
  70618. * @param min the min value to clamp to (default: 0)
  70619. * @param max the max value to clamp to (default: 1)
  70620. * @returns the clamped value
  70621. */
  70622. static Clamp(value: number, min?: number, max?: number): number;
  70623. /**
  70624. * the log2 of value.
  70625. * @param value the value to compute log2 of
  70626. * @returns the log2 of value.
  70627. */
  70628. static Log2(value: number): number;
  70629. /**
  70630. * Loops the value, so that it is never larger than length and never smaller than 0.
  70631. *
  70632. * This is similar to the modulo operator but it works with floating point numbers.
  70633. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  70634. * With t = 5 and length = 2.5, the result would be 0.0.
  70635. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  70636. * @param value the value
  70637. * @param length the length
  70638. * @returns the looped value
  70639. */
  70640. static Repeat(value: number, length: number): number;
  70641. /**
  70642. * Normalize the value between 0.0 and 1.0 using min and max values
  70643. * @param value value to normalize
  70644. * @param min max to normalize between
  70645. * @param max min to normalize between
  70646. * @returns the normalized value
  70647. */
  70648. static Normalize(value: number, min: number, max: number): number;
  70649. /**
  70650. * Denormalize the value from 0.0 and 1.0 using min and max values
  70651. * @param normalized value to denormalize
  70652. * @param min max to denormalize between
  70653. * @param max min to denormalize between
  70654. * @returns the denormalized value
  70655. */
  70656. static Denormalize(normalized: number, min: number, max: number): number;
  70657. /**
  70658. * Calculates the shortest difference between two given angles given in degrees.
  70659. * @param current current angle in degrees
  70660. * @param target target angle in degrees
  70661. * @returns the delta
  70662. */
  70663. static DeltaAngle(current: number, target: number): number;
  70664. /**
  70665. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  70666. * @param tx value
  70667. * @param length length
  70668. * @returns The returned value will move back and forth between 0 and length
  70669. */
  70670. static PingPong(tx: number, length: number): number;
  70671. /**
  70672. * Interpolates between min and max with smoothing at the limits.
  70673. *
  70674. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  70675. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  70676. * @param from from
  70677. * @param to to
  70678. * @param tx value
  70679. * @returns the smooth stepped value
  70680. */
  70681. static SmoothStep(from: number, to: number, tx: number): number;
  70682. /**
  70683. * Moves a value current towards target.
  70684. *
  70685. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  70686. * Negative values of maxDelta pushes the value away from target.
  70687. * @param current current value
  70688. * @param target target value
  70689. * @param maxDelta max distance to move
  70690. * @returns resulting value
  70691. */
  70692. static MoveTowards(current: number, target: number, maxDelta: number): number;
  70693. /**
  70694. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  70695. *
  70696. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  70697. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  70698. * @param current current value
  70699. * @param target target value
  70700. * @param maxDelta max distance to move
  70701. * @returns resulting angle
  70702. */
  70703. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  70704. /**
  70705. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  70706. * @param start start value
  70707. * @param end target value
  70708. * @param amount amount to lerp between
  70709. * @returns the lerped value
  70710. */
  70711. static Lerp(start: number, end: number, amount: number): number;
  70712. /**
  70713. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  70714. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  70715. * @param start start value
  70716. * @param end target value
  70717. * @param amount amount to lerp between
  70718. * @returns the lerped value
  70719. */
  70720. static LerpAngle(start: number, end: number, amount: number): number;
  70721. /**
  70722. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  70723. * @param a start value
  70724. * @param b target value
  70725. * @param value value between a and b
  70726. * @returns the inverseLerp value
  70727. */
  70728. static InverseLerp(a: number, b: number, value: number): number;
  70729. /**
  70730. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  70731. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  70732. * @param value1 spline value
  70733. * @param tangent1 spline value
  70734. * @param value2 spline value
  70735. * @param tangent2 spline value
  70736. * @param amount input value
  70737. * @returns hermite result
  70738. */
  70739. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  70740. /**
  70741. * Returns a random float number between and min and max values
  70742. * @param min min value of random
  70743. * @param max max value of random
  70744. * @returns random value
  70745. */
  70746. static RandomRange(min: number, max: number): number;
  70747. /**
  70748. * This function returns percentage of a number in a given range.
  70749. *
  70750. * RangeToPercent(40,20,60) will return 0.5 (50%)
  70751. * RangeToPercent(34,0,100) will return 0.34 (34%)
  70752. * @param number to convert to percentage
  70753. * @param min min range
  70754. * @param max max range
  70755. * @returns the percentage
  70756. */
  70757. static RangeToPercent(number: number, min: number, max: number): number;
  70758. /**
  70759. * This function returns number that corresponds to the percentage in a given range.
  70760. *
  70761. * PercentToRange(0.34,0,100) will return 34.
  70762. * @param percent to convert to number
  70763. * @param min min range
  70764. * @param max max range
  70765. * @returns the number
  70766. */
  70767. static PercentToRange(percent: number, min: number, max: number): number;
  70768. /**
  70769. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  70770. * @param angle The angle to normalize in radian.
  70771. * @return The converted angle.
  70772. */
  70773. static NormalizeRadians(angle: number): number;
  70774. }
  70775. }
  70776. declare module BABYLON {
  70777. /**
  70778. * Constant used to convert a value to gamma space
  70779. * @ignorenaming
  70780. */
  70781. export const ToGammaSpace: number;
  70782. /**
  70783. * Constant used to convert a value to linear space
  70784. * @ignorenaming
  70785. */
  70786. export const ToLinearSpace = 2.2;
  70787. /**
  70788. * Constant used to define the minimal number value in Babylon.js
  70789. * @ignorenaming
  70790. */
  70791. let Epsilon: number;
  70792. }
  70793. declare module BABYLON {
  70794. /**
  70795. * Class used to represent a viewport on screen
  70796. */
  70797. export class Viewport {
  70798. /** viewport left coordinate */
  70799. x: number;
  70800. /** viewport top coordinate */
  70801. y: number;
  70802. /**viewport width */
  70803. width: number;
  70804. /** viewport height */
  70805. height: number;
  70806. /**
  70807. * Creates a Viewport object located at (x, y) and sized (width, height)
  70808. * @param x defines viewport left coordinate
  70809. * @param y defines viewport top coordinate
  70810. * @param width defines the viewport width
  70811. * @param height defines the viewport height
  70812. */
  70813. constructor(
  70814. /** viewport left coordinate */
  70815. x: number,
  70816. /** viewport top coordinate */
  70817. y: number,
  70818. /**viewport width */
  70819. width: number,
  70820. /** viewport height */
  70821. height: number);
  70822. /**
  70823. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  70824. * @param renderWidth defines the rendering width
  70825. * @param renderHeight defines the rendering height
  70826. * @returns a new Viewport
  70827. */
  70828. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  70829. /**
  70830. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  70831. * @param renderWidth defines the rendering width
  70832. * @param renderHeight defines the rendering height
  70833. * @param ref defines the target viewport
  70834. * @returns the current viewport
  70835. */
  70836. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  70837. /**
  70838. * Returns a new Viewport copied from the current one
  70839. * @returns a new Viewport
  70840. */
  70841. clone(): Viewport;
  70842. }
  70843. }
  70844. declare module BABYLON {
  70845. /**
  70846. * Class containing a set of static utilities functions for arrays.
  70847. */
  70848. export class ArrayTools {
  70849. /**
  70850. * Returns an array of the given size filled with element built from the given constructor and the paramters
  70851. * @param size the number of element to construct and put in the array
  70852. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  70853. * @returns a new array filled with new objects
  70854. */
  70855. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  70856. }
  70857. }
  70858. declare module BABYLON {
  70859. /**
  70860. * Class representing a vector containing 2 coordinates
  70861. */
  70862. export class Vector2 {
  70863. /** defines the first coordinate */
  70864. x: number;
  70865. /** defines the second coordinate */
  70866. y: number;
  70867. /**
  70868. * Creates a new Vector2 from the given x and y coordinates
  70869. * @param x defines the first coordinate
  70870. * @param y defines the second coordinate
  70871. */
  70872. constructor(
  70873. /** defines the first coordinate */
  70874. x?: number,
  70875. /** defines the second coordinate */
  70876. y?: number);
  70877. /**
  70878. * Gets a string with the Vector2 coordinates
  70879. * @returns a string with the Vector2 coordinates
  70880. */
  70881. toString(): string;
  70882. /**
  70883. * Gets class name
  70884. * @returns the string "Vector2"
  70885. */
  70886. getClassName(): string;
  70887. /**
  70888. * Gets current vector hash code
  70889. * @returns the Vector2 hash code as a number
  70890. */
  70891. getHashCode(): number;
  70892. /**
  70893. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  70894. * @param array defines the source array
  70895. * @param index defines the offset in source array
  70896. * @returns the current Vector2
  70897. */
  70898. toArray(array: FloatArray, index?: number): Vector2;
  70899. /**
  70900. * Copy the current vector to an array
  70901. * @returns a new array with 2 elements: the Vector2 coordinates.
  70902. */
  70903. asArray(): number[];
  70904. /**
  70905. * Sets the Vector2 coordinates with the given Vector2 coordinates
  70906. * @param source defines the source Vector2
  70907. * @returns the current updated Vector2
  70908. */
  70909. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  70910. /**
  70911. * Sets the Vector2 coordinates with the given floats
  70912. * @param x defines the first coordinate
  70913. * @param y defines the second coordinate
  70914. * @returns the current updated Vector2
  70915. */
  70916. copyFromFloats(x: number, y: number): Vector2;
  70917. /**
  70918. * Sets the Vector2 coordinates with the given floats
  70919. * @param x defines the first coordinate
  70920. * @param y defines the second coordinate
  70921. * @returns the current updated Vector2
  70922. */
  70923. set(x: number, y: number): Vector2;
  70924. /**
  70925. * Add another vector with the current one
  70926. * @param otherVector defines the other vector
  70927. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  70928. */
  70929. add(otherVector: DeepImmutable<Vector2>): Vector2;
  70930. /**
  70931. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  70932. * @param otherVector defines the other vector
  70933. * @param result defines the target vector
  70934. * @returns the unmodified current Vector2
  70935. */
  70936. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70937. /**
  70938. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  70939. * @param otherVector defines the other vector
  70940. * @returns the current updated Vector2
  70941. */
  70942. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70943. /**
  70944. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  70945. * @param otherVector defines the other vector
  70946. * @returns a new Vector2
  70947. */
  70948. addVector3(otherVector: Vector3): Vector2;
  70949. /**
  70950. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  70951. * @param otherVector defines the other vector
  70952. * @returns a new Vector2
  70953. */
  70954. subtract(otherVector: Vector2): Vector2;
  70955. /**
  70956. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  70957. * @param otherVector defines the other vector
  70958. * @param result defines the target vector
  70959. * @returns the unmodified current Vector2
  70960. */
  70961. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70962. /**
  70963. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  70964. * @param otherVector defines the other vector
  70965. * @returns the current updated Vector2
  70966. */
  70967. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70968. /**
  70969. * Multiplies in place the current Vector2 coordinates by the given ones
  70970. * @param otherVector defines the other vector
  70971. * @returns the current updated Vector2
  70972. */
  70973. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70974. /**
  70975. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  70976. * @param otherVector defines the other vector
  70977. * @returns a new Vector2
  70978. */
  70979. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  70980. /**
  70981. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  70982. * @param otherVector defines the other vector
  70983. * @param result defines the target vector
  70984. * @returns the unmodified current Vector2
  70985. */
  70986. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70987. /**
  70988. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  70989. * @param x defines the first coordinate
  70990. * @param y defines the second coordinate
  70991. * @returns a new Vector2
  70992. */
  70993. multiplyByFloats(x: number, y: number): Vector2;
  70994. /**
  70995. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  70996. * @param otherVector defines the other vector
  70997. * @returns a new Vector2
  70998. */
  70999. divide(otherVector: Vector2): Vector2;
  71000. /**
  71001. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  71002. * @param otherVector defines the other vector
  71003. * @param result defines the target vector
  71004. * @returns the unmodified current Vector2
  71005. */
  71006. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  71007. /**
  71008. * Divides the current Vector2 coordinates by the given ones
  71009. * @param otherVector defines the other vector
  71010. * @returns the current updated Vector2
  71011. */
  71012. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  71013. /**
  71014. * Gets a new Vector2 with current Vector2 negated coordinates
  71015. * @returns a new Vector2
  71016. */
  71017. negate(): Vector2;
  71018. /**
  71019. * Multiply the Vector2 coordinates by scale
  71020. * @param scale defines the scaling factor
  71021. * @returns the current updated Vector2
  71022. */
  71023. scaleInPlace(scale: number): Vector2;
  71024. /**
  71025. * Returns a new Vector2 scaled by "scale" from the current Vector2
  71026. * @param scale defines the scaling factor
  71027. * @returns a new Vector2
  71028. */
  71029. scale(scale: number): Vector2;
  71030. /**
  71031. * Scale the current Vector2 values by a factor to a given Vector2
  71032. * @param scale defines the scale factor
  71033. * @param result defines the Vector2 object where to store the result
  71034. * @returns the unmodified current Vector2
  71035. */
  71036. scaleToRef(scale: number, result: Vector2): Vector2;
  71037. /**
  71038. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  71039. * @param scale defines the scale factor
  71040. * @param result defines the Vector2 object where to store the result
  71041. * @returns the unmodified current Vector2
  71042. */
  71043. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  71044. /**
  71045. * Gets a boolean if two vectors are equals
  71046. * @param otherVector defines the other vector
  71047. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  71048. */
  71049. equals(otherVector: DeepImmutable<Vector2>): boolean;
  71050. /**
  71051. * Gets a boolean if two vectors are equals (using an epsilon value)
  71052. * @param otherVector defines the other vector
  71053. * @param epsilon defines the minimal distance to consider equality
  71054. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  71055. */
  71056. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  71057. /**
  71058. * Gets a new Vector2 from current Vector2 floored values
  71059. * @returns a new Vector2
  71060. */
  71061. floor(): Vector2;
  71062. /**
  71063. * Gets a new Vector2 from current Vector2 floored values
  71064. * @returns a new Vector2
  71065. */
  71066. fract(): Vector2;
  71067. /**
  71068. * Gets the length of the vector
  71069. * @returns the vector length (float)
  71070. */
  71071. length(): number;
  71072. /**
  71073. * Gets the vector squared length
  71074. * @returns the vector squared length (float)
  71075. */
  71076. lengthSquared(): number;
  71077. /**
  71078. * Normalize the vector
  71079. * @returns the current updated Vector2
  71080. */
  71081. normalize(): Vector2;
  71082. /**
  71083. * Gets a new Vector2 copied from the Vector2
  71084. * @returns a new Vector2
  71085. */
  71086. clone(): Vector2;
  71087. /**
  71088. * Gets a new Vector2(0, 0)
  71089. * @returns a new Vector2
  71090. */
  71091. static Zero(): Vector2;
  71092. /**
  71093. * Gets a new Vector2(1, 1)
  71094. * @returns a new Vector2
  71095. */
  71096. static One(): Vector2;
  71097. /**
  71098. * Gets a new Vector2 set from the given index element of the given array
  71099. * @param array defines the data source
  71100. * @param offset defines the offset in the data source
  71101. * @returns a new Vector2
  71102. */
  71103. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  71104. /**
  71105. * Sets "result" from the given index element of the given array
  71106. * @param array defines the data source
  71107. * @param offset defines the offset in the data source
  71108. * @param result defines the target vector
  71109. */
  71110. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  71111. /**
  71112. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  71113. * @param value1 defines 1st point of control
  71114. * @param value2 defines 2nd point of control
  71115. * @param value3 defines 3rd point of control
  71116. * @param value4 defines 4th point of control
  71117. * @param amount defines the interpolation factor
  71118. * @returns a new Vector2
  71119. */
  71120. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  71121. /**
  71122. * 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".
  71123. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  71124. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  71125. * @param value defines the value to clamp
  71126. * @param min defines the lower limit
  71127. * @param max defines the upper limit
  71128. * @returns a new Vector2
  71129. */
  71130. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  71131. /**
  71132. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  71133. * @param value1 defines the 1st control point
  71134. * @param tangent1 defines the outgoing tangent
  71135. * @param value2 defines the 2nd control point
  71136. * @param tangent2 defines the incoming tangent
  71137. * @param amount defines the interpolation factor
  71138. * @returns a new Vector2
  71139. */
  71140. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  71141. /**
  71142. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  71143. * @param start defines the start vector
  71144. * @param end defines the end vector
  71145. * @param amount defines the interpolation factor
  71146. * @returns a new Vector2
  71147. */
  71148. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  71149. /**
  71150. * Gets the dot product of the vector "left" and the vector "right"
  71151. * @param left defines first vector
  71152. * @param right defines second vector
  71153. * @returns the dot product (float)
  71154. */
  71155. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  71156. /**
  71157. * Returns a new Vector2 equal to the normalized given vector
  71158. * @param vector defines the vector to normalize
  71159. * @returns a new Vector2
  71160. */
  71161. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  71162. /**
  71163. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  71164. * @param left defines 1st vector
  71165. * @param right defines 2nd vector
  71166. * @returns a new Vector2
  71167. */
  71168. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  71169. /**
  71170. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  71171. * @param left defines 1st vector
  71172. * @param right defines 2nd vector
  71173. * @returns a new Vector2
  71174. */
  71175. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  71176. /**
  71177. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  71178. * @param vector defines the vector to transform
  71179. * @param transformation defines the matrix to apply
  71180. * @returns a new Vector2
  71181. */
  71182. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  71183. /**
  71184. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  71185. * @param vector defines the vector to transform
  71186. * @param transformation defines the matrix to apply
  71187. * @param result defines the target vector
  71188. */
  71189. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  71190. /**
  71191. * Determines if a given vector is included in a triangle
  71192. * @param p defines the vector to test
  71193. * @param p0 defines 1st triangle point
  71194. * @param p1 defines 2nd triangle point
  71195. * @param p2 defines 3rd triangle point
  71196. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  71197. */
  71198. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  71199. /**
  71200. * Gets the distance between the vectors "value1" and "value2"
  71201. * @param value1 defines first vector
  71202. * @param value2 defines second vector
  71203. * @returns the distance between vectors
  71204. */
  71205. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  71206. /**
  71207. * Returns the squared distance between the vectors "value1" and "value2"
  71208. * @param value1 defines first vector
  71209. * @param value2 defines second vector
  71210. * @returns the squared distance between vectors
  71211. */
  71212. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  71213. /**
  71214. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  71215. * @param value1 defines first vector
  71216. * @param value2 defines second vector
  71217. * @returns a new Vector2
  71218. */
  71219. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  71220. /**
  71221. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  71222. * @param p defines the middle point
  71223. * @param segA defines one point of the segment
  71224. * @param segB defines the other point of the segment
  71225. * @returns the shortest distance
  71226. */
  71227. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  71228. }
  71229. /**
  71230. * Class used to store (x,y,z) vector representation
  71231. * A Vector3 is the main object used in 3D geometry
  71232. * It can represent etiher the coordinates of a point the space, either a direction
  71233. * Reminder: js uses a left handed forward facing system
  71234. */
  71235. export class Vector3 {
  71236. /**
  71237. * Defines the first coordinates (on X axis)
  71238. */
  71239. x: number;
  71240. /**
  71241. * Defines the second coordinates (on Y axis)
  71242. */
  71243. y: number;
  71244. /**
  71245. * Defines the third coordinates (on Z axis)
  71246. */
  71247. z: number;
  71248. private static _UpReadOnly;
  71249. private static _ZeroReadOnly;
  71250. /**
  71251. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  71252. * @param x defines the first coordinates (on X axis)
  71253. * @param y defines the second coordinates (on Y axis)
  71254. * @param z defines the third coordinates (on Z axis)
  71255. */
  71256. constructor(
  71257. /**
  71258. * Defines the first coordinates (on X axis)
  71259. */
  71260. x?: number,
  71261. /**
  71262. * Defines the second coordinates (on Y axis)
  71263. */
  71264. y?: number,
  71265. /**
  71266. * Defines the third coordinates (on Z axis)
  71267. */
  71268. z?: number);
  71269. /**
  71270. * Creates a string representation of the Vector3
  71271. * @returns a string with the Vector3 coordinates.
  71272. */
  71273. toString(): string;
  71274. /**
  71275. * Gets the class name
  71276. * @returns the string "Vector3"
  71277. */
  71278. getClassName(): string;
  71279. /**
  71280. * Creates the Vector3 hash code
  71281. * @returns a number which tends to be unique between Vector3 instances
  71282. */
  71283. getHashCode(): number;
  71284. /**
  71285. * Creates an array containing three elements : the coordinates of the Vector3
  71286. * @returns a new array of numbers
  71287. */
  71288. asArray(): number[];
  71289. /**
  71290. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  71291. * @param array defines the destination array
  71292. * @param index defines the offset in the destination array
  71293. * @returns the current Vector3
  71294. */
  71295. toArray(array: FloatArray, index?: number): Vector3;
  71296. /**
  71297. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  71298. * @returns a new Quaternion object, computed from the Vector3 coordinates
  71299. */
  71300. toQuaternion(): Quaternion;
  71301. /**
  71302. * Adds the given vector to the current Vector3
  71303. * @param otherVector defines the second operand
  71304. * @returns the current updated Vector3
  71305. */
  71306. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  71307. /**
  71308. * Adds the given coordinates to the current Vector3
  71309. * @param x defines the x coordinate of the operand
  71310. * @param y defines the y coordinate of the operand
  71311. * @param z defines the z coordinate of the operand
  71312. * @returns the current updated Vector3
  71313. */
  71314. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  71315. /**
  71316. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  71317. * @param otherVector defines the second operand
  71318. * @returns the resulting Vector3
  71319. */
  71320. add(otherVector: DeepImmutable<Vector3>): Vector3;
  71321. /**
  71322. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  71323. * @param otherVector defines the second operand
  71324. * @param result defines the Vector3 object where to store the result
  71325. * @returns the current Vector3
  71326. */
  71327. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  71328. /**
  71329. * Subtract the given vector from the current Vector3
  71330. * @param otherVector defines the second operand
  71331. * @returns the current updated Vector3
  71332. */
  71333. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  71334. /**
  71335. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  71336. * @param otherVector defines the second operand
  71337. * @returns the resulting Vector3
  71338. */
  71339. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  71340. /**
  71341. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  71342. * @param otherVector defines the second operand
  71343. * @param result defines the Vector3 object where to store the result
  71344. * @returns the current Vector3
  71345. */
  71346. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  71347. /**
  71348. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  71349. * @param x defines the x coordinate of the operand
  71350. * @param y defines the y coordinate of the operand
  71351. * @param z defines the z coordinate of the operand
  71352. * @returns the resulting Vector3
  71353. */
  71354. subtractFromFloats(x: number, y: number, z: number): Vector3;
  71355. /**
  71356. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  71357. * @param x defines the x coordinate of the operand
  71358. * @param y defines the y coordinate of the operand
  71359. * @param z defines the z coordinate of the operand
  71360. * @param result defines the Vector3 object where to store the result
  71361. * @returns the current Vector3
  71362. */
  71363. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  71364. /**
  71365. * Gets a new Vector3 set with the current Vector3 negated coordinates
  71366. * @returns a new Vector3
  71367. */
  71368. negate(): Vector3;
  71369. /**
  71370. * Multiplies the Vector3 coordinates by the float "scale"
  71371. * @param scale defines the multiplier factor
  71372. * @returns the current updated Vector3
  71373. */
  71374. scaleInPlace(scale: number): Vector3;
  71375. /**
  71376. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  71377. * @param scale defines the multiplier factor
  71378. * @returns a new Vector3
  71379. */
  71380. scale(scale: number): Vector3;
  71381. /**
  71382. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  71383. * @param scale defines the multiplier factor
  71384. * @param result defines the Vector3 object where to store the result
  71385. * @returns the current Vector3
  71386. */
  71387. scaleToRef(scale: number, result: Vector3): Vector3;
  71388. /**
  71389. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  71390. * @param scale defines the scale factor
  71391. * @param result defines the Vector3 object where to store the result
  71392. * @returns the unmodified current Vector3
  71393. */
  71394. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  71395. /**
  71396. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  71397. * @param otherVector defines the second operand
  71398. * @returns true if both vectors are equals
  71399. */
  71400. equals(otherVector: DeepImmutable<Vector3>): boolean;
  71401. /**
  71402. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  71403. * @param otherVector defines the second operand
  71404. * @param epsilon defines the minimal distance to define values as equals
  71405. * @returns true if both vectors are distant less than epsilon
  71406. */
  71407. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  71408. /**
  71409. * Returns true if the current Vector3 coordinates equals the given floats
  71410. * @param x defines the x coordinate of the operand
  71411. * @param y defines the y coordinate of the operand
  71412. * @param z defines the z coordinate of the operand
  71413. * @returns true if both vectors are equals
  71414. */
  71415. equalsToFloats(x: number, y: number, z: number): boolean;
  71416. /**
  71417. * Multiplies the current Vector3 coordinates by the given ones
  71418. * @param otherVector defines the second operand
  71419. * @returns the current updated Vector3
  71420. */
  71421. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  71422. /**
  71423. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  71424. * @param otherVector defines the second operand
  71425. * @returns the new Vector3
  71426. */
  71427. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  71428. /**
  71429. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  71430. * @param otherVector defines the second operand
  71431. * @param result defines the Vector3 object where to store the result
  71432. * @returns the current Vector3
  71433. */
  71434. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  71435. /**
  71436. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  71437. * @param x defines the x coordinate of the operand
  71438. * @param y defines the y coordinate of the operand
  71439. * @param z defines the z coordinate of the operand
  71440. * @returns the new Vector3
  71441. */
  71442. multiplyByFloats(x: number, y: number, z: number): Vector3;
  71443. /**
  71444. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  71445. * @param otherVector defines the second operand
  71446. * @returns the new Vector3
  71447. */
  71448. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  71449. /**
  71450. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  71451. * @param otherVector defines the second operand
  71452. * @param result defines the Vector3 object where to store the result
  71453. * @returns the current Vector3
  71454. */
  71455. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  71456. /**
  71457. * Divides the current Vector3 coordinates by the given ones.
  71458. * @param otherVector defines the second operand
  71459. * @returns the current updated Vector3
  71460. */
  71461. divideInPlace(otherVector: Vector3): Vector3;
  71462. /**
  71463. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  71464. * @param other defines the second operand
  71465. * @returns the current updated Vector3
  71466. */
  71467. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  71468. /**
  71469. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  71470. * @param other defines the second operand
  71471. * @returns the current updated Vector3
  71472. */
  71473. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  71474. /**
  71475. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  71476. * @param x defines the x coordinate of the operand
  71477. * @param y defines the y coordinate of the operand
  71478. * @param z defines the z coordinate of the operand
  71479. * @returns the current updated Vector3
  71480. */
  71481. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  71482. /**
  71483. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  71484. * @param x defines the x coordinate of the operand
  71485. * @param y defines the y coordinate of the operand
  71486. * @param z defines the z coordinate of the operand
  71487. * @returns the current updated Vector3
  71488. */
  71489. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  71490. /**
  71491. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  71492. * Check if is non uniform within a certain amount of decimal places to account for this
  71493. * @param epsilon the amount the values can differ
  71494. * @returns if the the vector is non uniform to a certain number of decimal places
  71495. */
  71496. isNonUniformWithinEpsilon(epsilon: number): boolean;
  71497. /**
  71498. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  71499. */
  71500. readonly isNonUniform: boolean;
  71501. /**
  71502. * Gets a new Vector3 from current Vector3 floored values
  71503. * @returns a new Vector3
  71504. */
  71505. floor(): Vector3;
  71506. /**
  71507. * Gets a new Vector3 from current Vector3 floored values
  71508. * @returns a new Vector3
  71509. */
  71510. fract(): Vector3;
  71511. /**
  71512. * Gets the length of the Vector3
  71513. * @returns the length of the Vector3
  71514. */
  71515. length(): number;
  71516. /**
  71517. * Gets the squared length of the Vector3
  71518. * @returns squared length of the Vector3
  71519. */
  71520. lengthSquared(): number;
  71521. /**
  71522. * Normalize the current Vector3.
  71523. * Please note that this is an in place operation.
  71524. * @returns the current updated Vector3
  71525. */
  71526. normalize(): Vector3;
  71527. /**
  71528. * Reorders the x y z properties of the vector in place
  71529. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  71530. * @returns the current updated vector
  71531. */
  71532. reorderInPlace(order: string): this;
  71533. /**
  71534. * Rotates the vector around 0,0,0 by a quaternion
  71535. * @param quaternion the rotation quaternion
  71536. * @param result vector to store the result
  71537. * @returns the resulting vector
  71538. */
  71539. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  71540. /**
  71541. * Rotates a vector around a given point
  71542. * @param quaternion the rotation quaternion
  71543. * @param point the point to rotate around
  71544. * @param result vector to store the result
  71545. * @returns the resulting vector
  71546. */
  71547. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  71548. /**
  71549. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  71550. * The cross product is then orthogonal to both current and "other"
  71551. * @param other defines the right operand
  71552. * @returns the cross product
  71553. */
  71554. cross(other: Vector3): Vector3;
  71555. /**
  71556. * Normalize the current Vector3 with the given input length.
  71557. * Please note that this is an in place operation.
  71558. * @param len the length of the vector
  71559. * @returns the current updated Vector3
  71560. */
  71561. normalizeFromLength(len: number): Vector3;
  71562. /**
  71563. * Normalize the current Vector3 to a new vector
  71564. * @returns the new Vector3
  71565. */
  71566. normalizeToNew(): Vector3;
  71567. /**
  71568. * Normalize the current Vector3 to the reference
  71569. * @param reference define the Vector3 to update
  71570. * @returns the updated Vector3
  71571. */
  71572. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  71573. /**
  71574. * Creates a new Vector3 copied from the current Vector3
  71575. * @returns the new Vector3
  71576. */
  71577. clone(): Vector3;
  71578. /**
  71579. * Copies the given vector coordinates to the current Vector3 ones
  71580. * @param source defines the source Vector3
  71581. * @returns the current updated Vector3
  71582. */
  71583. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  71584. /**
  71585. * Copies the given floats to the current Vector3 coordinates
  71586. * @param x defines the x coordinate of the operand
  71587. * @param y defines the y coordinate of the operand
  71588. * @param z defines the z coordinate of the operand
  71589. * @returns the current updated Vector3
  71590. */
  71591. copyFromFloats(x: number, y: number, z: number): Vector3;
  71592. /**
  71593. * Copies the given floats to the current Vector3 coordinates
  71594. * @param x defines the x coordinate of the operand
  71595. * @param y defines the y coordinate of the operand
  71596. * @param z defines the z coordinate of the operand
  71597. * @returns the current updated Vector3
  71598. */
  71599. set(x: number, y: number, z: number): Vector3;
  71600. /**
  71601. * Copies the given float to the current Vector3 coordinates
  71602. * @param v defines the x, y and z coordinates of the operand
  71603. * @returns the current updated Vector3
  71604. */
  71605. setAll(v: number): Vector3;
  71606. /**
  71607. * Get the clip factor between two vectors
  71608. * @param vector0 defines the first operand
  71609. * @param vector1 defines the second operand
  71610. * @param axis defines the axis to use
  71611. * @param size defines the size along the axis
  71612. * @returns the clip factor
  71613. */
  71614. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  71615. /**
  71616. * Get angle between two vectors
  71617. * @param vector0 angle between vector0 and vector1
  71618. * @param vector1 angle between vector0 and vector1
  71619. * @param normal direction of the normal
  71620. * @return the angle between vector0 and vector1
  71621. */
  71622. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  71623. /**
  71624. * Returns a new Vector3 set from the index "offset" of the given array
  71625. * @param array defines the source array
  71626. * @param offset defines the offset in the source array
  71627. * @returns the new Vector3
  71628. */
  71629. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  71630. /**
  71631. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  71632. * @param array defines the source array
  71633. * @param offset defines the offset in the source array
  71634. * @returns the new Vector3
  71635. * @deprecated Please use FromArray instead.
  71636. */
  71637. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  71638. /**
  71639. * Sets the given vector "result" with the element values from the index "offset" of the given array
  71640. * @param array defines the source array
  71641. * @param offset defines the offset in the source array
  71642. * @param result defines the Vector3 where to store the result
  71643. */
  71644. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  71645. /**
  71646. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  71647. * @param array defines the source array
  71648. * @param offset defines the offset in the source array
  71649. * @param result defines the Vector3 where to store the result
  71650. * @deprecated Please use FromArrayToRef instead.
  71651. */
  71652. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  71653. /**
  71654. * Sets the given vector "result" with the given floats.
  71655. * @param x defines the x coordinate of the source
  71656. * @param y defines the y coordinate of the source
  71657. * @param z defines the z coordinate of the source
  71658. * @param result defines the Vector3 where to store the result
  71659. */
  71660. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  71661. /**
  71662. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  71663. * @returns a new empty Vector3
  71664. */
  71665. static Zero(): Vector3;
  71666. /**
  71667. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  71668. * @returns a new unit Vector3
  71669. */
  71670. static One(): Vector3;
  71671. /**
  71672. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  71673. * @returns a new up Vector3
  71674. */
  71675. static Up(): Vector3;
  71676. /**
  71677. * Gets a up Vector3 that must not be updated
  71678. */
  71679. static readonly UpReadOnly: DeepImmutable<Vector3>;
  71680. /**
  71681. * Gets a zero Vector3 that must not be updated
  71682. */
  71683. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  71684. /**
  71685. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  71686. * @returns a new down Vector3
  71687. */
  71688. static Down(): Vector3;
  71689. /**
  71690. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  71691. * @returns a new forward Vector3
  71692. */
  71693. static Forward(): Vector3;
  71694. /**
  71695. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  71696. * @returns a new forward Vector3
  71697. */
  71698. static Backward(): Vector3;
  71699. /**
  71700. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  71701. * @returns a new right Vector3
  71702. */
  71703. static Right(): Vector3;
  71704. /**
  71705. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  71706. * @returns a new left Vector3
  71707. */
  71708. static Left(): Vector3;
  71709. /**
  71710. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  71711. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  71712. * @param vector defines the Vector3 to transform
  71713. * @param transformation defines the transformation matrix
  71714. * @returns the transformed Vector3
  71715. */
  71716. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  71717. /**
  71718. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  71719. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  71720. * @param vector defines the Vector3 to transform
  71721. * @param transformation defines the transformation matrix
  71722. * @param result defines the Vector3 where to store the result
  71723. */
  71724. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  71725. /**
  71726. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  71727. * This method computes tranformed coordinates only, not transformed direction vectors
  71728. * @param x define the x coordinate of the source vector
  71729. * @param y define the y coordinate of the source vector
  71730. * @param z define the z coordinate of the source vector
  71731. * @param transformation defines the transformation matrix
  71732. * @param result defines the Vector3 where to store the result
  71733. */
  71734. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  71735. /**
  71736. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  71737. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  71738. * @param vector defines the Vector3 to transform
  71739. * @param transformation defines the transformation matrix
  71740. * @returns the new Vector3
  71741. */
  71742. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  71743. /**
  71744. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  71745. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  71746. * @param vector defines the Vector3 to transform
  71747. * @param transformation defines the transformation matrix
  71748. * @param result defines the Vector3 where to store the result
  71749. */
  71750. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  71751. /**
  71752. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  71753. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  71754. * @param x define the x coordinate of the source vector
  71755. * @param y define the y coordinate of the source vector
  71756. * @param z define the z coordinate of the source vector
  71757. * @param transformation defines the transformation matrix
  71758. * @param result defines the Vector3 where to store the result
  71759. */
  71760. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  71761. /**
  71762. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  71763. * @param value1 defines the first control point
  71764. * @param value2 defines the second control point
  71765. * @param value3 defines the third control point
  71766. * @param value4 defines the fourth control point
  71767. * @param amount defines the amount on the spline to use
  71768. * @returns the new Vector3
  71769. */
  71770. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  71771. /**
  71772. * 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"
  71773. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  71774. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  71775. * @param value defines the current value
  71776. * @param min defines the lower range value
  71777. * @param max defines the upper range value
  71778. * @returns the new Vector3
  71779. */
  71780. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  71781. /**
  71782. * 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"
  71783. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  71784. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  71785. * @param value defines the current value
  71786. * @param min defines the lower range value
  71787. * @param max defines the upper range value
  71788. * @param result defines the Vector3 where to store the result
  71789. */
  71790. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  71791. /**
  71792. * Checks if a given vector is inside a specific range
  71793. * @param v defines the vector to test
  71794. * @param min defines the minimum range
  71795. * @param max defines the maximum range
  71796. */
  71797. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  71798. /**
  71799. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  71800. * @param value1 defines the first control point
  71801. * @param tangent1 defines the first tangent vector
  71802. * @param value2 defines the second control point
  71803. * @param tangent2 defines the second tangent vector
  71804. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  71805. * @returns the new Vector3
  71806. */
  71807. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  71808. /**
  71809. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  71810. * @param start defines the start value
  71811. * @param end defines the end value
  71812. * @param amount max defines amount between both (between 0 and 1)
  71813. * @returns the new Vector3
  71814. */
  71815. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  71816. /**
  71817. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  71818. * @param start defines the start value
  71819. * @param end defines the end value
  71820. * @param amount max defines amount between both (between 0 and 1)
  71821. * @param result defines the Vector3 where to store the result
  71822. */
  71823. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  71824. /**
  71825. * Returns the dot product (float) between the vectors "left" and "right"
  71826. * @param left defines the left operand
  71827. * @param right defines the right operand
  71828. * @returns the dot product
  71829. */
  71830. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  71831. /**
  71832. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  71833. * The cross product is then orthogonal to both "left" and "right"
  71834. * @param left defines the left operand
  71835. * @param right defines the right operand
  71836. * @returns the cross product
  71837. */
  71838. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  71839. /**
  71840. * Sets the given vector "result" with the cross product of "left" and "right"
  71841. * The cross product is then orthogonal to both "left" and "right"
  71842. * @param left defines the left operand
  71843. * @param right defines the right operand
  71844. * @param result defines the Vector3 where to store the result
  71845. */
  71846. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  71847. /**
  71848. * Returns a new Vector3 as the normalization of the given vector
  71849. * @param vector defines the Vector3 to normalize
  71850. * @returns the new Vector3
  71851. */
  71852. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  71853. /**
  71854. * Sets the given vector "result" with the normalization of the given first vector
  71855. * @param vector defines the Vector3 to normalize
  71856. * @param result defines the Vector3 where to store the result
  71857. */
  71858. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  71859. /**
  71860. * Project a Vector3 onto screen space
  71861. * @param vector defines the Vector3 to project
  71862. * @param world defines the world matrix to use
  71863. * @param transform defines the transform (view x projection) matrix to use
  71864. * @param viewport defines the screen viewport to use
  71865. * @returns the new Vector3
  71866. */
  71867. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  71868. /** @hidden */
  71869. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  71870. /**
  71871. * Unproject from screen space to object space
  71872. * @param source defines the screen space Vector3 to use
  71873. * @param viewportWidth defines the current width of the viewport
  71874. * @param viewportHeight defines the current height of the viewport
  71875. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71876. * @param transform defines the transform (view x projection) matrix to use
  71877. * @returns the new Vector3
  71878. */
  71879. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  71880. /**
  71881. * Unproject from screen space to object space
  71882. * @param source defines the screen space Vector3 to use
  71883. * @param viewportWidth defines the current width of the viewport
  71884. * @param viewportHeight defines the current height of the viewport
  71885. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71886. * @param view defines the view matrix to use
  71887. * @param projection defines the projection matrix to use
  71888. * @returns the new Vector3
  71889. */
  71890. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  71891. /**
  71892. * Unproject from screen space to object space
  71893. * @param source defines the screen space Vector3 to use
  71894. * @param viewportWidth defines the current width of the viewport
  71895. * @param viewportHeight defines the current height of the viewport
  71896. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71897. * @param view defines the view matrix to use
  71898. * @param projection defines the projection matrix to use
  71899. * @param result defines the Vector3 where to store the result
  71900. */
  71901. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  71902. /**
  71903. * Unproject from screen space to object space
  71904. * @param sourceX defines the screen space x coordinate to use
  71905. * @param sourceY defines the screen space y coordinate to use
  71906. * @param sourceZ defines the screen space z coordinate to use
  71907. * @param viewportWidth defines the current width of the viewport
  71908. * @param viewportHeight defines the current height of the viewport
  71909. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71910. * @param view defines the view matrix to use
  71911. * @param projection defines the projection matrix to use
  71912. * @param result defines the Vector3 where to store the result
  71913. */
  71914. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  71915. /**
  71916. * Gets the minimal coordinate values between two Vector3
  71917. * @param left defines the first operand
  71918. * @param right defines the second operand
  71919. * @returns the new Vector3
  71920. */
  71921. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  71922. /**
  71923. * Gets the maximal coordinate values between two Vector3
  71924. * @param left defines the first operand
  71925. * @param right defines the second operand
  71926. * @returns the new Vector3
  71927. */
  71928. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  71929. /**
  71930. * Returns the distance between the vectors "value1" and "value2"
  71931. * @param value1 defines the first operand
  71932. * @param value2 defines the second operand
  71933. * @returns the distance
  71934. */
  71935. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  71936. /**
  71937. * Returns the squared distance between the vectors "value1" and "value2"
  71938. * @param value1 defines the first operand
  71939. * @param value2 defines the second operand
  71940. * @returns the squared distance
  71941. */
  71942. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  71943. /**
  71944. * Returns a new Vector3 located at the center between "value1" and "value2"
  71945. * @param value1 defines the first operand
  71946. * @param value2 defines the second operand
  71947. * @returns the new Vector3
  71948. */
  71949. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  71950. /**
  71951. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  71952. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  71953. * to something in order to rotate it from its local system to the given target system
  71954. * Note: axis1, axis2 and axis3 are normalized during this operation
  71955. * @param axis1 defines the first axis
  71956. * @param axis2 defines the second axis
  71957. * @param axis3 defines the third axis
  71958. * @returns a new Vector3
  71959. */
  71960. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  71961. /**
  71962. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  71963. * @param axis1 defines the first axis
  71964. * @param axis2 defines the second axis
  71965. * @param axis3 defines the third axis
  71966. * @param ref defines the Vector3 where to store the result
  71967. */
  71968. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  71969. }
  71970. /**
  71971. * Vector4 class created for EulerAngle class conversion to Quaternion
  71972. */
  71973. export class Vector4 {
  71974. /** x value of the vector */
  71975. x: number;
  71976. /** y value of the vector */
  71977. y: number;
  71978. /** z value of the vector */
  71979. z: number;
  71980. /** w value of the vector */
  71981. w: number;
  71982. /**
  71983. * Creates a Vector4 object from the given floats.
  71984. * @param x x value of the vector
  71985. * @param y y value of the vector
  71986. * @param z z value of the vector
  71987. * @param w w value of the vector
  71988. */
  71989. constructor(
  71990. /** x value of the vector */
  71991. x: number,
  71992. /** y value of the vector */
  71993. y: number,
  71994. /** z value of the vector */
  71995. z: number,
  71996. /** w value of the vector */
  71997. w: number);
  71998. /**
  71999. * Returns the string with the Vector4 coordinates.
  72000. * @returns a string containing all the vector values
  72001. */
  72002. toString(): string;
  72003. /**
  72004. * Returns the string "Vector4".
  72005. * @returns "Vector4"
  72006. */
  72007. getClassName(): string;
  72008. /**
  72009. * Returns the Vector4 hash code.
  72010. * @returns a unique hash code
  72011. */
  72012. getHashCode(): number;
  72013. /**
  72014. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  72015. * @returns the resulting array
  72016. */
  72017. asArray(): number[];
  72018. /**
  72019. * Populates the given array from the given index with the Vector4 coordinates.
  72020. * @param array array to populate
  72021. * @param index index of the array to start at (default: 0)
  72022. * @returns the Vector4.
  72023. */
  72024. toArray(array: FloatArray, index?: number): Vector4;
  72025. /**
  72026. * Adds the given vector to the current Vector4.
  72027. * @param otherVector the vector to add
  72028. * @returns the updated Vector4.
  72029. */
  72030. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  72031. /**
  72032. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  72033. * @param otherVector the vector to add
  72034. * @returns the resulting vector
  72035. */
  72036. add(otherVector: DeepImmutable<Vector4>): Vector4;
  72037. /**
  72038. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  72039. * @param otherVector the vector to add
  72040. * @param result the vector to store the result
  72041. * @returns the current Vector4.
  72042. */
  72043. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  72044. /**
  72045. * Subtract in place the given vector from the current Vector4.
  72046. * @param otherVector the vector to subtract
  72047. * @returns the updated Vector4.
  72048. */
  72049. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  72050. /**
  72051. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  72052. * @param otherVector the vector to add
  72053. * @returns the new vector with the result
  72054. */
  72055. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  72056. /**
  72057. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  72058. * @param otherVector the vector to subtract
  72059. * @param result the vector to store the result
  72060. * @returns the current Vector4.
  72061. */
  72062. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  72063. /**
  72064. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  72065. */
  72066. /**
  72067. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  72068. * @param x value to subtract
  72069. * @param y value to subtract
  72070. * @param z value to subtract
  72071. * @param w value to subtract
  72072. * @returns new vector containing the result
  72073. */
  72074. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  72075. /**
  72076. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  72077. * @param x value to subtract
  72078. * @param y value to subtract
  72079. * @param z value to subtract
  72080. * @param w value to subtract
  72081. * @param result the vector to store the result in
  72082. * @returns the current Vector4.
  72083. */
  72084. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  72085. /**
  72086. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  72087. * @returns a new vector with the negated values
  72088. */
  72089. negate(): Vector4;
  72090. /**
  72091. * Multiplies the current Vector4 coordinates by scale (float).
  72092. * @param scale the number to scale with
  72093. * @returns the updated Vector4.
  72094. */
  72095. scaleInPlace(scale: number): Vector4;
  72096. /**
  72097. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  72098. * @param scale the number to scale with
  72099. * @returns a new vector with the result
  72100. */
  72101. scale(scale: number): Vector4;
  72102. /**
  72103. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  72104. * @param scale the number to scale with
  72105. * @param result a vector to store the result in
  72106. * @returns the current Vector4.
  72107. */
  72108. scaleToRef(scale: number, result: Vector4): Vector4;
  72109. /**
  72110. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  72111. * @param scale defines the scale factor
  72112. * @param result defines the Vector4 object where to store the result
  72113. * @returns the unmodified current Vector4
  72114. */
  72115. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  72116. /**
  72117. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  72118. * @param otherVector the vector to compare against
  72119. * @returns true if they are equal
  72120. */
  72121. equals(otherVector: DeepImmutable<Vector4>): boolean;
  72122. /**
  72123. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  72124. * @param otherVector vector to compare against
  72125. * @param epsilon (Default: very small number)
  72126. * @returns true if they are equal
  72127. */
  72128. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  72129. /**
  72130. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  72131. * @param x x value to compare against
  72132. * @param y y value to compare against
  72133. * @param z z value to compare against
  72134. * @param w w value to compare against
  72135. * @returns true if equal
  72136. */
  72137. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  72138. /**
  72139. * Multiplies in place the current Vector4 by the given one.
  72140. * @param otherVector vector to multiple with
  72141. * @returns the updated Vector4.
  72142. */
  72143. multiplyInPlace(otherVector: Vector4): Vector4;
  72144. /**
  72145. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  72146. * @param otherVector vector to multiple with
  72147. * @returns resulting new vector
  72148. */
  72149. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  72150. /**
  72151. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  72152. * @param otherVector vector to multiple with
  72153. * @param result vector to store the result
  72154. * @returns the current Vector4.
  72155. */
  72156. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  72157. /**
  72158. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  72159. * @param x x value multiply with
  72160. * @param y y value multiply with
  72161. * @param z z value multiply with
  72162. * @param w w value multiply with
  72163. * @returns resulting new vector
  72164. */
  72165. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  72166. /**
  72167. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  72168. * @param otherVector vector to devide with
  72169. * @returns resulting new vector
  72170. */
  72171. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  72172. /**
  72173. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  72174. * @param otherVector vector to devide with
  72175. * @param result vector to store the result
  72176. * @returns the current Vector4.
  72177. */
  72178. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  72179. /**
  72180. * Divides the current Vector3 coordinates by the given ones.
  72181. * @param otherVector vector to devide with
  72182. * @returns the updated Vector3.
  72183. */
  72184. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  72185. /**
  72186. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  72187. * @param other defines the second operand
  72188. * @returns the current updated Vector4
  72189. */
  72190. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  72191. /**
  72192. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  72193. * @param other defines the second operand
  72194. * @returns the current updated Vector4
  72195. */
  72196. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  72197. /**
  72198. * Gets a new Vector4 from current Vector4 floored values
  72199. * @returns a new Vector4
  72200. */
  72201. floor(): Vector4;
  72202. /**
  72203. * Gets a new Vector4 from current Vector3 floored values
  72204. * @returns a new Vector4
  72205. */
  72206. fract(): Vector4;
  72207. /**
  72208. * Returns the Vector4 length (float).
  72209. * @returns the length
  72210. */
  72211. length(): number;
  72212. /**
  72213. * Returns the Vector4 squared length (float).
  72214. * @returns the length squared
  72215. */
  72216. lengthSquared(): number;
  72217. /**
  72218. * Normalizes in place the Vector4.
  72219. * @returns the updated Vector4.
  72220. */
  72221. normalize(): Vector4;
  72222. /**
  72223. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  72224. * @returns this converted to a new vector3
  72225. */
  72226. toVector3(): Vector3;
  72227. /**
  72228. * Returns a new Vector4 copied from the current one.
  72229. * @returns the new cloned vector
  72230. */
  72231. clone(): Vector4;
  72232. /**
  72233. * Updates the current Vector4 with the given one coordinates.
  72234. * @param source the source vector to copy from
  72235. * @returns the updated Vector4.
  72236. */
  72237. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  72238. /**
  72239. * Updates the current Vector4 coordinates with the given floats.
  72240. * @param x float to copy from
  72241. * @param y float to copy from
  72242. * @param z float to copy from
  72243. * @param w float to copy from
  72244. * @returns the updated Vector4.
  72245. */
  72246. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  72247. /**
  72248. * Updates the current Vector4 coordinates with the given floats.
  72249. * @param x float to set from
  72250. * @param y float to set from
  72251. * @param z float to set from
  72252. * @param w float to set from
  72253. * @returns the updated Vector4.
  72254. */
  72255. set(x: number, y: number, z: number, w: number): Vector4;
  72256. /**
  72257. * Copies the given float to the current Vector3 coordinates
  72258. * @param v defines the x, y, z and w coordinates of the operand
  72259. * @returns the current updated Vector3
  72260. */
  72261. setAll(v: number): Vector4;
  72262. /**
  72263. * Returns a new Vector4 set from the starting index of the given array.
  72264. * @param array the array to pull values from
  72265. * @param offset the offset into the array to start at
  72266. * @returns the new vector
  72267. */
  72268. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  72269. /**
  72270. * Updates the given vector "result" from the starting index of the given array.
  72271. * @param array the array to pull values from
  72272. * @param offset the offset into the array to start at
  72273. * @param result the vector to store the result in
  72274. */
  72275. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  72276. /**
  72277. * Updates the given vector "result" from the starting index of the given Float32Array.
  72278. * @param array the array to pull values from
  72279. * @param offset the offset into the array to start at
  72280. * @param result the vector to store the result in
  72281. */
  72282. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  72283. /**
  72284. * Updates the given vector "result" coordinates from the given floats.
  72285. * @param x float to set from
  72286. * @param y float to set from
  72287. * @param z float to set from
  72288. * @param w float to set from
  72289. * @param result the vector to the floats in
  72290. */
  72291. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  72292. /**
  72293. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  72294. * @returns the new vector
  72295. */
  72296. static Zero(): Vector4;
  72297. /**
  72298. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  72299. * @returns the new vector
  72300. */
  72301. static One(): Vector4;
  72302. /**
  72303. * Returns a new normalized Vector4 from the given one.
  72304. * @param vector the vector to normalize
  72305. * @returns the vector
  72306. */
  72307. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  72308. /**
  72309. * Updates the given vector "result" from the normalization of the given one.
  72310. * @param vector the vector to normalize
  72311. * @param result the vector to store the result in
  72312. */
  72313. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  72314. /**
  72315. * Returns a vector with the minimum values from the left and right vectors
  72316. * @param left left vector to minimize
  72317. * @param right right vector to minimize
  72318. * @returns a new vector with the minimum of the left and right vector values
  72319. */
  72320. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  72321. /**
  72322. * Returns a vector with the maximum values from the left and right vectors
  72323. * @param left left vector to maximize
  72324. * @param right right vector to maximize
  72325. * @returns a new vector with the maximum of the left and right vector values
  72326. */
  72327. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  72328. /**
  72329. * Returns the distance (float) between the vectors "value1" and "value2".
  72330. * @param value1 value to calulate the distance between
  72331. * @param value2 value to calulate the distance between
  72332. * @return the distance between the two vectors
  72333. */
  72334. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  72335. /**
  72336. * Returns the squared distance (float) between the vectors "value1" and "value2".
  72337. * @param value1 value to calulate the distance between
  72338. * @param value2 value to calulate the distance between
  72339. * @return the distance between the two vectors squared
  72340. */
  72341. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  72342. /**
  72343. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  72344. * @param value1 value to calulate the center between
  72345. * @param value2 value to calulate the center between
  72346. * @return the center between the two vectors
  72347. */
  72348. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  72349. /**
  72350. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  72351. * This methods computes transformed normalized direction vectors only.
  72352. * @param vector the vector to transform
  72353. * @param transformation the transformation matrix to apply
  72354. * @returns the new vector
  72355. */
  72356. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  72357. /**
  72358. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  72359. * This methods computes transformed normalized direction vectors only.
  72360. * @param vector the vector to transform
  72361. * @param transformation the transformation matrix to apply
  72362. * @param result the vector to store the result in
  72363. */
  72364. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  72365. /**
  72366. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  72367. * This methods computes transformed normalized direction vectors only.
  72368. * @param x value to transform
  72369. * @param y value to transform
  72370. * @param z value to transform
  72371. * @param w value to transform
  72372. * @param transformation the transformation matrix to apply
  72373. * @param result the vector to store the results in
  72374. */
  72375. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  72376. /**
  72377. * Creates a new Vector4 from a Vector3
  72378. * @param source defines the source data
  72379. * @param w defines the 4th component (default is 0)
  72380. * @returns a new Vector4
  72381. */
  72382. static FromVector3(source: Vector3, w?: number): Vector4;
  72383. }
  72384. /**
  72385. * Class used to store quaternion data
  72386. * @see https://en.wikipedia.org/wiki/Quaternion
  72387. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  72388. */
  72389. export class Quaternion {
  72390. /** defines the first component (0 by default) */
  72391. x: number;
  72392. /** defines the second component (0 by default) */
  72393. y: number;
  72394. /** defines the third component (0 by default) */
  72395. z: number;
  72396. /** defines the fourth component (1.0 by default) */
  72397. w: number;
  72398. /**
  72399. * Creates a new Quaternion from the given floats
  72400. * @param x defines the first component (0 by default)
  72401. * @param y defines the second component (0 by default)
  72402. * @param z defines the third component (0 by default)
  72403. * @param w defines the fourth component (1.0 by default)
  72404. */
  72405. constructor(
  72406. /** defines the first component (0 by default) */
  72407. x?: number,
  72408. /** defines the second component (0 by default) */
  72409. y?: number,
  72410. /** defines the third component (0 by default) */
  72411. z?: number,
  72412. /** defines the fourth component (1.0 by default) */
  72413. w?: number);
  72414. /**
  72415. * Gets a string representation for the current quaternion
  72416. * @returns a string with the Quaternion coordinates
  72417. */
  72418. toString(): string;
  72419. /**
  72420. * Gets the class name of the quaternion
  72421. * @returns the string "Quaternion"
  72422. */
  72423. getClassName(): string;
  72424. /**
  72425. * Gets a hash code for this quaternion
  72426. * @returns the quaternion hash code
  72427. */
  72428. getHashCode(): number;
  72429. /**
  72430. * Copy the quaternion to an array
  72431. * @returns a new array populated with 4 elements from the quaternion coordinates
  72432. */
  72433. asArray(): number[];
  72434. /**
  72435. * Check if two quaternions are equals
  72436. * @param otherQuaternion defines the second operand
  72437. * @return true if the current quaternion and the given one coordinates are strictly equals
  72438. */
  72439. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  72440. /**
  72441. * Clone the current quaternion
  72442. * @returns a new quaternion copied from the current one
  72443. */
  72444. clone(): Quaternion;
  72445. /**
  72446. * Copy a quaternion to the current one
  72447. * @param other defines the other quaternion
  72448. * @returns the updated current quaternion
  72449. */
  72450. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  72451. /**
  72452. * Updates the current quaternion with the given float coordinates
  72453. * @param x defines the x coordinate
  72454. * @param y defines the y coordinate
  72455. * @param z defines the z coordinate
  72456. * @param w defines the w coordinate
  72457. * @returns the updated current quaternion
  72458. */
  72459. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  72460. /**
  72461. * Updates the current quaternion from the given float coordinates
  72462. * @param x defines the x coordinate
  72463. * @param y defines the y coordinate
  72464. * @param z defines the z coordinate
  72465. * @param w defines the w coordinate
  72466. * @returns the updated current quaternion
  72467. */
  72468. set(x: number, y: number, z: number, w: number): Quaternion;
  72469. /**
  72470. * Adds two quaternions
  72471. * @param other defines the second operand
  72472. * @returns a new quaternion as the addition result of the given one and the current quaternion
  72473. */
  72474. add(other: DeepImmutable<Quaternion>): Quaternion;
  72475. /**
  72476. * Add a quaternion to the current one
  72477. * @param other defines the quaternion to add
  72478. * @returns the current quaternion
  72479. */
  72480. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  72481. /**
  72482. * Subtract two quaternions
  72483. * @param other defines the second operand
  72484. * @returns a new quaternion as the subtraction result of the given one from the current one
  72485. */
  72486. subtract(other: Quaternion): Quaternion;
  72487. /**
  72488. * Multiplies the current quaternion by a scale factor
  72489. * @param value defines the scale factor
  72490. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  72491. */
  72492. scale(value: number): Quaternion;
  72493. /**
  72494. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  72495. * @param scale defines the scale factor
  72496. * @param result defines the Quaternion object where to store the result
  72497. * @returns the unmodified current quaternion
  72498. */
  72499. scaleToRef(scale: number, result: Quaternion): Quaternion;
  72500. /**
  72501. * Multiplies in place the current quaternion by a scale factor
  72502. * @param value defines the scale factor
  72503. * @returns the current modified quaternion
  72504. */
  72505. scaleInPlace(value: number): Quaternion;
  72506. /**
  72507. * Scale the current quaternion values by a factor and add the result to a given quaternion
  72508. * @param scale defines the scale factor
  72509. * @param result defines the Quaternion object where to store the result
  72510. * @returns the unmodified current quaternion
  72511. */
  72512. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  72513. /**
  72514. * Multiplies two quaternions
  72515. * @param q1 defines the second operand
  72516. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  72517. */
  72518. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  72519. /**
  72520. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  72521. * @param q1 defines the second operand
  72522. * @param result defines the target quaternion
  72523. * @returns the current quaternion
  72524. */
  72525. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  72526. /**
  72527. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  72528. * @param q1 defines the second operand
  72529. * @returns the currentupdated quaternion
  72530. */
  72531. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  72532. /**
  72533. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  72534. * @param ref defines the target quaternion
  72535. * @returns the current quaternion
  72536. */
  72537. conjugateToRef(ref: Quaternion): Quaternion;
  72538. /**
  72539. * Conjugates in place (1-q) the current quaternion
  72540. * @returns the current updated quaternion
  72541. */
  72542. conjugateInPlace(): Quaternion;
  72543. /**
  72544. * Conjugates in place (1-q) the current quaternion
  72545. * @returns a new quaternion
  72546. */
  72547. conjugate(): Quaternion;
  72548. /**
  72549. * Gets length of current quaternion
  72550. * @returns the quaternion length (float)
  72551. */
  72552. length(): number;
  72553. /**
  72554. * Normalize in place the current quaternion
  72555. * @returns the current updated quaternion
  72556. */
  72557. normalize(): Quaternion;
  72558. /**
  72559. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  72560. * @param order is a reserved parameter and is ignore for now
  72561. * @returns a new Vector3 containing the Euler angles
  72562. */
  72563. toEulerAngles(order?: string): Vector3;
  72564. /**
  72565. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  72566. * @param result defines the vector which will be filled with the Euler angles
  72567. * @param order is a reserved parameter and is ignore for now
  72568. * @returns the current unchanged quaternion
  72569. */
  72570. toEulerAnglesToRef(result: Vector3): Quaternion;
  72571. /**
  72572. * Updates the given rotation matrix with the current quaternion values
  72573. * @param result defines the target matrix
  72574. * @returns the current unchanged quaternion
  72575. */
  72576. toRotationMatrix(result: Matrix): Quaternion;
  72577. /**
  72578. * Updates the current quaternion from the given rotation matrix values
  72579. * @param matrix defines the source matrix
  72580. * @returns the current updated quaternion
  72581. */
  72582. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  72583. /**
  72584. * Creates a new quaternion from a rotation matrix
  72585. * @param matrix defines the source matrix
  72586. * @returns a new quaternion created from the given rotation matrix values
  72587. */
  72588. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  72589. /**
  72590. * Updates the given quaternion with the given rotation matrix values
  72591. * @param matrix defines the source matrix
  72592. * @param result defines the target quaternion
  72593. */
  72594. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  72595. /**
  72596. * Returns the dot product (float) between the quaternions "left" and "right"
  72597. * @param left defines the left operand
  72598. * @param right defines the right operand
  72599. * @returns the dot product
  72600. */
  72601. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  72602. /**
  72603. * Checks if the two quaternions are close to each other
  72604. * @param quat0 defines the first quaternion to check
  72605. * @param quat1 defines the second quaternion to check
  72606. * @returns true if the two quaternions are close to each other
  72607. */
  72608. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  72609. /**
  72610. * Creates an empty quaternion
  72611. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  72612. */
  72613. static Zero(): Quaternion;
  72614. /**
  72615. * Inverse a given quaternion
  72616. * @param q defines the source quaternion
  72617. * @returns a new quaternion as the inverted current quaternion
  72618. */
  72619. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  72620. /**
  72621. * Inverse a given quaternion
  72622. * @param q defines the source quaternion
  72623. * @param result the quaternion the result will be stored in
  72624. * @returns the result quaternion
  72625. */
  72626. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  72627. /**
  72628. * Creates an identity quaternion
  72629. * @returns the identity quaternion
  72630. */
  72631. static Identity(): Quaternion;
  72632. /**
  72633. * Gets a boolean indicating if the given quaternion is identity
  72634. * @param quaternion defines the quaternion to check
  72635. * @returns true if the quaternion is identity
  72636. */
  72637. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  72638. /**
  72639. * Creates a quaternion from a rotation around an axis
  72640. * @param axis defines the axis to use
  72641. * @param angle defines the angle to use
  72642. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  72643. */
  72644. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  72645. /**
  72646. * Creates a rotation around an axis and stores it into the given quaternion
  72647. * @param axis defines the axis to use
  72648. * @param angle defines the angle to use
  72649. * @param result defines the target quaternion
  72650. * @returns the target quaternion
  72651. */
  72652. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  72653. /**
  72654. * Creates a new quaternion from data stored into an array
  72655. * @param array defines the data source
  72656. * @param offset defines the offset in the source array where the data starts
  72657. * @returns a new quaternion
  72658. */
  72659. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  72660. /**
  72661. * Create a quaternion from Euler rotation angles
  72662. * @param x Pitch
  72663. * @param y Yaw
  72664. * @param z Roll
  72665. * @returns the new Quaternion
  72666. */
  72667. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  72668. /**
  72669. * Updates a quaternion from Euler rotation angles
  72670. * @param x Pitch
  72671. * @param y Yaw
  72672. * @param z Roll
  72673. * @param result the quaternion to store the result
  72674. * @returns the updated quaternion
  72675. */
  72676. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  72677. /**
  72678. * Create a quaternion from Euler rotation vector
  72679. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  72680. * @returns the new Quaternion
  72681. */
  72682. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  72683. /**
  72684. * Updates a quaternion from Euler rotation vector
  72685. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  72686. * @param result the quaternion to store the result
  72687. * @returns the updated quaternion
  72688. */
  72689. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  72690. /**
  72691. * Creates a new quaternion from the given Euler float angles (y, x, z)
  72692. * @param yaw defines the rotation around Y axis
  72693. * @param pitch defines the rotation around X axis
  72694. * @param roll defines the rotation around Z axis
  72695. * @returns the new quaternion
  72696. */
  72697. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  72698. /**
  72699. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  72700. * @param yaw defines the rotation around Y axis
  72701. * @param pitch defines the rotation around X axis
  72702. * @param roll defines the rotation around Z axis
  72703. * @param result defines the target quaternion
  72704. */
  72705. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  72706. /**
  72707. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  72708. * @param alpha defines the rotation around first axis
  72709. * @param beta defines the rotation around second axis
  72710. * @param gamma defines the rotation around third axis
  72711. * @returns the new quaternion
  72712. */
  72713. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  72714. /**
  72715. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  72716. * @param alpha defines the rotation around first axis
  72717. * @param beta defines the rotation around second axis
  72718. * @param gamma defines the rotation around third axis
  72719. * @param result defines the target quaternion
  72720. */
  72721. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  72722. /**
  72723. * 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)
  72724. * @param axis1 defines the first axis
  72725. * @param axis2 defines the second axis
  72726. * @param axis3 defines the third axis
  72727. * @returns the new quaternion
  72728. */
  72729. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  72730. /**
  72731. * 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
  72732. * @param axis1 defines the first axis
  72733. * @param axis2 defines the second axis
  72734. * @param axis3 defines the third axis
  72735. * @param ref defines the target quaternion
  72736. */
  72737. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  72738. /**
  72739. * Interpolates between two quaternions
  72740. * @param left defines first quaternion
  72741. * @param right defines second quaternion
  72742. * @param amount defines the gradient to use
  72743. * @returns the new interpolated quaternion
  72744. */
  72745. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  72746. /**
  72747. * Interpolates between two quaternions and stores it into a target quaternion
  72748. * @param left defines first quaternion
  72749. * @param right defines second quaternion
  72750. * @param amount defines the gradient to use
  72751. * @param result defines the target quaternion
  72752. */
  72753. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  72754. /**
  72755. * Interpolate between two quaternions using Hermite interpolation
  72756. * @param value1 defines first quaternion
  72757. * @param tangent1 defines the incoming tangent
  72758. * @param value2 defines second quaternion
  72759. * @param tangent2 defines the outgoing tangent
  72760. * @param amount defines the target quaternion
  72761. * @returns the new interpolated quaternion
  72762. */
  72763. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  72764. }
  72765. /**
  72766. * Class used to store matrix data (4x4)
  72767. */
  72768. export class Matrix {
  72769. private static _updateFlagSeed;
  72770. private static _identityReadOnly;
  72771. private _isIdentity;
  72772. private _isIdentityDirty;
  72773. private _isIdentity3x2;
  72774. private _isIdentity3x2Dirty;
  72775. /**
  72776. * Gets the update flag of the matrix which is an unique number for the matrix.
  72777. * It will be incremented every time the matrix data change.
  72778. * You can use it to speed the comparison between two versions of the same matrix.
  72779. */
  72780. updateFlag: number;
  72781. private readonly _m;
  72782. /**
  72783. * Gets the internal data of the matrix
  72784. */
  72785. readonly m: DeepImmutable<Float32Array>;
  72786. /** @hidden */
  72787. _markAsUpdated(): void;
  72788. /** @hidden */
  72789. private _updateIdentityStatus;
  72790. /**
  72791. * Creates an empty matrix (filled with zeros)
  72792. */
  72793. constructor();
  72794. /**
  72795. * Check if the current matrix is identity
  72796. * @returns true is the matrix is the identity matrix
  72797. */
  72798. isIdentity(): boolean;
  72799. /**
  72800. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  72801. * @returns true is the matrix is the identity matrix
  72802. */
  72803. isIdentityAs3x2(): boolean;
  72804. /**
  72805. * Gets the determinant of the matrix
  72806. * @returns the matrix determinant
  72807. */
  72808. determinant(): number;
  72809. /**
  72810. * Returns the matrix as a Float32Array
  72811. * @returns the matrix underlying array
  72812. */
  72813. toArray(): DeepImmutable<Float32Array>;
  72814. /**
  72815. * Returns the matrix as a Float32Array
  72816. * @returns the matrix underlying array.
  72817. */
  72818. asArray(): DeepImmutable<Float32Array>;
  72819. /**
  72820. * Inverts the current matrix in place
  72821. * @returns the current inverted matrix
  72822. */
  72823. invert(): Matrix;
  72824. /**
  72825. * Sets all the matrix elements to zero
  72826. * @returns the current matrix
  72827. */
  72828. reset(): Matrix;
  72829. /**
  72830. * Adds the current matrix with a second one
  72831. * @param other defines the matrix to add
  72832. * @returns a new matrix as the addition of the current matrix and the given one
  72833. */
  72834. add(other: DeepImmutable<Matrix>): Matrix;
  72835. /**
  72836. * Sets the given matrix "result" to the addition of the current matrix and the given one
  72837. * @param other defines the matrix to add
  72838. * @param result defines the target matrix
  72839. * @returns the current matrix
  72840. */
  72841. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  72842. /**
  72843. * Adds in place the given matrix to the current matrix
  72844. * @param other defines the second operand
  72845. * @returns the current updated matrix
  72846. */
  72847. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  72848. /**
  72849. * Sets the given matrix to the current inverted Matrix
  72850. * @param other defines the target matrix
  72851. * @returns the unmodified current matrix
  72852. */
  72853. invertToRef(other: Matrix): Matrix;
  72854. /**
  72855. * add a value at the specified position in the current Matrix
  72856. * @param index the index of the value within the matrix. between 0 and 15.
  72857. * @param value the value to be added
  72858. * @returns the current updated matrix
  72859. */
  72860. addAtIndex(index: number, value: number): Matrix;
  72861. /**
  72862. * mutiply the specified position in the current Matrix by a value
  72863. * @param index the index of the value within the matrix. between 0 and 15.
  72864. * @param value the value to be added
  72865. * @returns the current updated matrix
  72866. */
  72867. multiplyAtIndex(index: number, value: number): Matrix;
  72868. /**
  72869. * Inserts the translation vector (using 3 floats) in the current matrix
  72870. * @param x defines the 1st component of the translation
  72871. * @param y defines the 2nd component of the translation
  72872. * @param z defines the 3rd component of the translation
  72873. * @returns the current updated matrix
  72874. */
  72875. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  72876. /**
  72877. * Adds the translation vector (using 3 floats) in the current matrix
  72878. * @param x defines the 1st component of the translation
  72879. * @param y defines the 2nd component of the translation
  72880. * @param z defines the 3rd component of the translation
  72881. * @returns the current updated matrix
  72882. */
  72883. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  72884. /**
  72885. * Inserts the translation vector in the current matrix
  72886. * @param vector3 defines the translation to insert
  72887. * @returns the current updated matrix
  72888. */
  72889. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  72890. /**
  72891. * Gets the translation value of the current matrix
  72892. * @returns a new Vector3 as the extracted translation from the matrix
  72893. */
  72894. getTranslation(): Vector3;
  72895. /**
  72896. * Fill a Vector3 with the extracted translation from the matrix
  72897. * @param result defines the Vector3 where to store the translation
  72898. * @returns the current matrix
  72899. */
  72900. getTranslationToRef(result: Vector3): Matrix;
  72901. /**
  72902. * Remove rotation and scaling part from the matrix
  72903. * @returns the updated matrix
  72904. */
  72905. removeRotationAndScaling(): Matrix;
  72906. /**
  72907. * Multiply two matrices
  72908. * @param other defines the second operand
  72909. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  72910. */
  72911. multiply(other: DeepImmutable<Matrix>): Matrix;
  72912. /**
  72913. * Copy the current matrix from the given one
  72914. * @param other defines the source matrix
  72915. * @returns the current updated matrix
  72916. */
  72917. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  72918. /**
  72919. * Populates the given array from the starting index with the current matrix values
  72920. * @param array defines the target array
  72921. * @param offset defines the offset in the target array where to start storing values
  72922. * @returns the current matrix
  72923. */
  72924. copyToArray(array: Float32Array, offset?: number): Matrix;
  72925. /**
  72926. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  72927. * @param other defines the second operand
  72928. * @param result defines the matrix where to store the multiplication
  72929. * @returns the current matrix
  72930. */
  72931. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  72932. /**
  72933. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  72934. * @param other defines the second operand
  72935. * @param result defines the array where to store the multiplication
  72936. * @param offset defines the offset in the target array where to start storing values
  72937. * @returns the current matrix
  72938. */
  72939. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  72940. /**
  72941. * Check equality between this matrix and a second one
  72942. * @param value defines the second matrix to compare
  72943. * @returns true is the current matrix and the given one values are strictly equal
  72944. */
  72945. equals(value: DeepImmutable<Matrix>): boolean;
  72946. /**
  72947. * Clone the current matrix
  72948. * @returns a new matrix from the current matrix
  72949. */
  72950. clone(): Matrix;
  72951. /**
  72952. * Returns the name of the current matrix class
  72953. * @returns the string "Matrix"
  72954. */
  72955. getClassName(): string;
  72956. /**
  72957. * Gets the hash code of the current matrix
  72958. * @returns the hash code
  72959. */
  72960. getHashCode(): number;
  72961. /**
  72962. * Decomposes the current Matrix into a translation, rotation and scaling components
  72963. * @param scale defines the scale vector3 given as a reference to update
  72964. * @param rotation defines the rotation quaternion given as a reference to update
  72965. * @param translation defines the translation vector3 given as a reference to update
  72966. * @returns true if operation was successful
  72967. */
  72968. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  72969. /**
  72970. * Gets specific row of the matrix
  72971. * @param index defines the number of the row to get
  72972. * @returns the index-th row of the current matrix as a new Vector4
  72973. */
  72974. getRow(index: number): Nullable<Vector4>;
  72975. /**
  72976. * Sets the index-th row of the current matrix to the vector4 values
  72977. * @param index defines the number of the row to set
  72978. * @param row defines the target vector4
  72979. * @returns the updated current matrix
  72980. */
  72981. setRow(index: number, row: Vector4): Matrix;
  72982. /**
  72983. * Compute the transpose of the matrix
  72984. * @returns the new transposed matrix
  72985. */
  72986. transpose(): Matrix;
  72987. /**
  72988. * Compute the transpose of the matrix and store it in a given matrix
  72989. * @param result defines the target matrix
  72990. * @returns the current matrix
  72991. */
  72992. transposeToRef(result: Matrix): Matrix;
  72993. /**
  72994. * Sets the index-th row of the current matrix with the given 4 x float values
  72995. * @param index defines the row index
  72996. * @param x defines the x component to set
  72997. * @param y defines the y component to set
  72998. * @param z defines the z component to set
  72999. * @param w defines the w component to set
  73000. * @returns the updated current matrix
  73001. */
  73002. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  73003. /**
  73004. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  73005. * @param scale defines the scale factor
  73006. * @returns a new matrix
  73007. */
  73008. scale(scale: number): Matrix;
  73009. /**
  73010. * Scale the current matrix values by a factor to a given result matrix
  73011. * @param scale defines the scale factor
  73012. * @param result defines the matrix to store the result
  73013. * @returns the current matrix
  73014. */
  73015. scaleToRef(scale: number, result: Matrix): Matrix;
  73016. /**
  73017. * Scale the current matrix values by a factor and add the result to a given matrix
  73018. * @param scale defines the scale factor
  73019. * @param result defines the Matrix to store the result
  73020. * @returns the current matrix
  73021. */
  73022. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  73023. /**
  73024. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  73025. * @param ref matrix to store the result
  73026. */
  73027. toNormalMatrix(ref: Matrix): void;
  73028. /**
  73029. * Gets only rotation part of the current matrix
  73030. * @returns a new matrix sets to the extracted rotation matrix from the current one
  73031. */
  73032. getRotationMatrix(): Matrix;
  73033. /**
  73034. * Extracts the rotation matrix from the current one and sets it as the given "result"
  73035. * @param result defines the target matrix to store data to
  73036. * @returns the current matrix
  73037. */
  73038. getRotationMatrixToRef(result: Matrix): Matrix;
  73039. /**
  73040. * Toggles model matrix from being right handed to left handed in place and vice versa
  73041. */
  73042. toggleModelMatrixHandInPlace(): void;
  73043. /**
  73044. * Toggles projection matrix from being right handed to left handed in place and vice versa
  73045. */
  73046. toggleProjectionMatrixHandInPlace(): void;
  73047. /**
  73048. * Creates a matrix from an array
  73049. * @param array defines the source array
  73050. * @param offset defines an offset in the source array
  73051. * @returns a new Matrix set from the starting index of the given array
  73052. */
  73053. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  73054. /**
  73055. * Copy the content of an array into a given matrix
  73056. * @param array defines the source array
  73057. * @param offset defines an offset in the source array
  73058. * @param result defines the target matrix
  73059. */
  73060. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  73061. /**
  73062. * Stores an array into a matrix after having multiplied each component by a given factor
  73063. * @param array defines the source array
  73064. * @param offset defines the offset in the source array
  73065. * @param scale defines the scaling factor
  73066. * @param result defines the target matrix
  73067. */
  73068. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  73069. /**
  73070. * Gets an identity matrix that must not be updated
  73071. */
  73072. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  73073. /**
  73074. * Stores a list of values (16) inside a given matrix
  73075. * @param initialM11 defines 1st value of 1st row
  73076. * @param initialM12 defines 2nd value of 1st row
  73077. * @param initialM13 defines 3rd value of 1st row
  73078. * @param initialM14 defines 4th value of 1st row
  73079. * @param initialM21 defines 1st value of 2nd row
  73080. * @param initialM22 defines 2nd value of 2nd row
  73081. * @param initialM23 defines 3rd value of 2nd row
  73082. * @param initialM24 defines 4th value of 2nd row
  73083. * @param initialM31 defines 1st value of 3rd row
  73084. * @param initialM32 defines 2nd value of 3rd row
  73085. * @param initialM33 defines 3rd value of 3rd row
  73086. * @param initialM34 defines 4th value of 3rd row
  73087. * @param initialM41 defines 1st value of 4th row
  73088. * @param initialM42 defines 2nd value of 4th row
  73089. * @param initialM43 defines 3rd value of 4th row
  73090. * @param initialM44 defines 4th value of 4th row
  73091. * @param result defines the target matrix
  73092. */
  73093. 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;
  73094. /**
  73095. * Creates new matrix from a list of values (16)
  73096. * @param initialM11 defines 1st value of 1st row
  73097. * @param initialM12 defines 2nd value of 1st row
  73098. * @param initialM13 defines 3rd value of 1st row
  73099. * @param initialM14 defines 4th value of 1st row
  73100. * @param initialM21 defines 1st value of 2nd row
  73101. * @param initialM22 defines 2nd value of 2nd row
  73102. * @param initialM23 defines 3rd value of 2nd row
  73103. * @param initialM24 defines 4th value of 2nd row
  73104. * @param initialM31 defines 1st value of 3rd row
  73105. * @param initialM32 defines 2nd value of 3rd row
  73106. * @param initialM33 defines 3rd value of 3rd row
  73107. * @param initialM34 defines 4th value of 3rd row
  73108. * @param initialM41 defines 1st value of 4th row
  73109. * @param initialM42 defines 2nd value of 4th row
  73110. * @param initialM43 defines 3rd value of 4th row
  73111. * @param initialM44 defines 4th value of 4th row
  73112. * @returns the new matrix
  73113. */
  73114. 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;
  73115. /**
  73116. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  73117. * @param scale defines the scale vector3
  73118. * @param rotation defines the rotation quaternion
  73119. * @param translation defines the translation vector3
  73120. * @returns a new matrix
  73121. */
  73122. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  73123. /**
  73124. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  73125. * @param scale defines the scale vector3
  73126. * @param rotation defines the rotation quaternion
  73127. * @param translation defines the translation vector3
  73128. * @param result defines the target matrix
  73129. */
  73130. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  73131. /**
  73132. * Creates a new identity matrix
  73133. * @returns a new identity matrix
  73134. */
  73135. static Identity(): Matrix;
  73136. /**
  73137. * Creates a new identity matrix and stores the result in a given matrix
  73138. * @param result defines the target matrix
  73139. */
  73140. static IdentityToRef(result: Matrix): void;
  73141. /**
  73142. * Creates a new zero matrix
  73143. * @returns a new zero matrix
  73144. */
  73145. static Zero(): Matrix;
  73146. /**
  73147. * Creates a new rotation matrix for "angle" radians around the X axis
  73148. * @param angle defines the angle (in radians) to use
  73149. * @return the new matrix
  73150. */
  73151. static RotationX(angle: number): Matrix;
  73152. /**
  73153. * Creates a new matrix as the invert of a given matrix
  73154. * @param source defines the source matrix
  73155. * @returns the new matrix
  73156. */
  73157. static Invert(source: DeepImmutable<Matrix>): Matrix;
  73158. /**
  73159. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  73160. * @param angle defines the angle (in radians) to use
  73161. * @param result defines the target matrix
  73162. */
  73163. static RotationXToRef(angle: number, result: Matrix): void;
  73164. /**
  73165. * Creates a new rotation matrix for "angle" radians around the Y axis
  73166. * @param angle defines the angle (in radians) to use
  73167. * @return the new matrix
  73168. */
  73169. static RotationY(angle: number): Matrix;
  73170. /**
  73171. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  73172. * @param angle defines the angle (in radians) to use
  73173. * @param result defines the target matrix
  73174. */
  73175. static RotationYToRef(angle: number, result: Matrix): void;
  73176. /**
  73177. * Creates a new rotation matrix for "angle" radians around the Z axis
  73178. * @param angle defines the angle (in radians) to use
  73179. * @return the new matrix
  73180. */
  73181. static RotationZ(angle: number): Matrix;
  73182. /**
  73183. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  73184. * @param angle defines the angle (in radians) to use
  73185. * @param result defines the target matrix
  73186. */
  73187. static RotationZToRef(angle: number, result: Matrix): void;
  73188. /**
  73189. * Creates a new rotation matrix for "angle" radians around the given axis
  73190. * @param axis defines the axis to use
  73191. * @param angle defines the angle (in radians) to use
  73192. * @return the new matrix
  73193. */
  73194. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  73195. /**
  73196. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  73197. * @param axis defines the axis to use
  73198. * @param angle defines the angle (in radians) to use
  73199. * @param result defines the target matrix
  73200. */
  73201. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  73202. /**
  73203. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  73204. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  73205. * @param from defines the vector to align
  73206. * @param to defines the vector to align to
  73207. * @param result defines the target matrix
  73208. */
  73209. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  73210. /**
  73211. * Creates a rotation matrix
  73212. * @param yaw defines the yaw angle in radians (Y axis)
  73213. * @param pitch defines the pitch angle in radians (X axis)
  73214. * @param roll defines the roll angle in radians (X axis)
  73215. * @returns the new rotation matrix
  73216. */
  73217. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  73218. /**
  73219. * Creates a rotation matrix and stores it in a given matrix
  73220. * @param yaw defines the yaw angle in radians (Y axis)
  73221. * @param pitch defines the pitch angle in radians (X axis)
  73222. * @param roll defines the roll angle in radians (X axis)
  73223. * @param result defines the target matrix
  73224. */
  73225. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  73226. /**
  73227. * Creates a scaling matrix
  73228. * @param x defines the scale factor on X axis
  73229. * @param y defines the scale factor on Y axis
  73230. * @param z defines the scale factor on Z axis
  73231. * @returns the new matrix
  73232. */
  73233. static Scaling(x: number, y: number, z: number): Matrix;
  73234. /**
  73235. * Creates a scaling matrix and stores it in a given matrix
  73236. * @param x defines the scale factor on X axis
  73237. * @param y defines the scale factor on Y axis
  73238. * @param z defines the scale factor on Z axis
  73239. * @param result defines the target matrix
  73240. */
  73241. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  73242. /**
  73243. * Creates a translation matrix
  73244. * @param x defines the translation on X axis
  73245. * @param y defines the translation on Y axis
  73246. * @param z defines the translationon Z axis
  73247. * @returns the new matrix
  73248. */
  73249. static Translation(x: number, y: number, z: number): Matrix;
  73250. /**
  73251. * Creates a translation matrix and stores it in a given matrix
  73252. * @param x defines the translation on X axis
  73253. * @param y defines the translation on Y axis
  73254. * @param z defines the translationon Z axis
  73255. * @param result defines the target matrix
  73256. */
  73257. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  73258. /**
  73259. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  73260. * @param startValue defines the start value
  73261. * @param endValue defines the end value
  73262. * @param gradient defines the gradient factor
  73263. * @returns the new matrix
  73264. */
  73265. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  73266. /**
  73267. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  73268. * @param startValue defines the start value
  73269. * @param endValue defines the end value
  73270. * @param gradient defines the gradient factor
  73271. * @param result defines the Matrix object where to store data
  73272. */
  73273. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  73274. /**
  73275. * Builds a new matrix whose values are computed by:
  73276. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  73277. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  73278. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  73279. * @param startValue defines the first matrix
  73280. * @param endValue defines the second matrix
  73281. * @param gradient defines the gradient between the two matrices
  73282. * @returns the new matrix
  73283. */
  73284. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  73285. /**
  73286. * Update a matrix to values which are computed by:
  73287. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  73288. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  73289. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  73290. * @param startValue defines the first matrix
  73291. * @param endValue defines the second matrix
  73292. * @param gradient defines the gradient between the two matrices
  73293. * @param result defines the target matrix
  73294. */
  73295. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  73296. /**
  73297. * 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"
  73298. * This function works in left handed mode
  73299. * @param eye defines the final position of the entity
  73300. * @param target defines where the entity should look at
  73301. * @param up defines the up vector for the entity
  73302. * @returns the new matrix
  73303. */
  73304. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  73305. /**
  73306. * 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".
  73307. * This function works in left handed mode
  73308. * @param eye defines the final position of the entity
  73309. * @param target defines where the entity should look at
  73310. * @param up defines the up vector for the entity
  73311. * @param result defines the target matrix
  73312. */
  73313. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  73314. /**
  73315. * 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"
  73316. * This function works in right handed mode
  73317. * @param eye defines the final position of the entity
  73318. * @param target defines where the entity should look at
  73319. * @param up defines the up vector for the entity
  73320. * @returns the new matrix
  73321. */
  73322. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  73323. /**
  73324. * 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".
  73325. * This function works in right handed mode
  73326. * @param eye defines the final position of the entity
  73327. * @param target defines where the entity should look at
  73328. * @param up defines the up vector for the entity
  73329. * @param result defines the target matrix
  73330. */
  73331. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  73332. /**
  73333. * Create a left-handed orthographic projection matrix
  73334. * @param width defines the viewport width
  73335. * @param height defines the viewport height
  73336. * @param znear defines the near clip plane
  73337. * @param zfar defines the far clip plane
  73338. * @returns a new matrix as a left-handed orthographic projection matrix
  73339. */
  73340. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  73341. /**
  73342. * Store a left-handed orthographic projection to a given matrix
  73343. * @param width defines the viewport width
  73344. * @param height defines the viewport height
  73345. * @param znear defines the near clip plane
  73346. * @param zfar defines the far clip plane
  73347. * @param result defines the target matrix
  73348. */
  73349. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  73350. /**
  73351. * Create a left-handed orthographic projection matrix
  73352. * @param left defines the viewport left coordinate
  73353. * @param right defines the viewport right coordinate
  73354. * @param bottom defines the viewport bottom coordinate
  73355. * @param top defines the viewport top coordinate
  73356. * @param znear defines the near clip plane
  73357. * @param zfar defines the far clip plane
  73358. * @returns a new matrix as a left-handed orthographic projection matrix
  73359. */
  73360. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  73361. /**
  73362. * Stores a left-handed orthographic projection into a given matrix
  73363. * @param left defines the viewport left coordinate
  73364. * @param right defines the viewport right coordinate
  73365. * @param bottom defines the viewport bottom coordinate
  73366. * @param top defines the viewport top coordinate
  73367. * @param znear defines the near clip plane
  73368. * @param zfar defines the far clip plane
  73369. * @param result defines the target matrix
  73370. */
  73371. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  73372. /**
  73373. * Creates a right-handed orthographic projection matrix
  73374. * @param left defines the viewport left coordinate
  73375. * @param right defines the viewport right coordinate
  73376. * @param bottom defines the viewport bottom coordinate
  73377. * @param top defines the viewport top coordinate
  73378. * @param znear defines the near clip plane
  73379. * @param zfar defines the far clip plane
  73380. * @returns a new matrix as a right-handed orthographic projection matrix
  73381. */
  73382. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  73383. /**
  73384. * Stores a right-handed orthographic projection into a given matrix
  73385. * @param left defines the viewport left coordinate
  73386. * @param right defines the viewport right coordinate
  73387. * @param bottom defines the viewport bottom coordinate
  73388. * @param top defines the viewport top coordinate
  73389. * @param znear defines the near clip plane
  73390. * @param zfar defines the far clip plane
  73391. * @param result defines the target matrix
  73392. */
  73393. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  73394. /**
  73395. * Creates a left-handed perspective projection matrix
  73396. * @param width defines the viewport width
  73397. * @param height defines the viewport height
  73398. * @param znear defines the near clip plane
  73399. * @param zfar defines the far clip plane
  73400. * @returns a new matrix as a left-handed perspective projection matrix
  73401. */
  73402. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  73403. /**
  73404. * Creates a left-handed perspective projection matrix
  73405. * @param fov defines the horizontal field of view
  73406. * @param aspect defines the aspect ratio
  73407. * @param znear defines the near clip plane
  73408. * @param zfar defines the far clip plane
  73409. * @returns a new matrix as a left-handed perspective projection matrix
  73410. */
  73411. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  73412. /**
  73413. * Stores a left-handed perspective projection into a given matrix
  73414. * @param fov defines the horizontal field of view
  73415. * @param aspect defines the aspect ratio
  73416. * @param znear defines the near clip plane
  73417. * @param zfar defines the far clip plane
  73418. * @param result defines the target matrix
  73419. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  73420. */
  73421. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  73422. /**
  73423. * Stores a left-handed perspective projection into a given matrix with depth reversed
  73424. * @param fov defines the horizontal field of view
  73425. * @param aspect defines the aspect ratio
  73426. * @param znear defines the near clip plane
  73427. * @param zfar not used as infinity is used as far clip
  73428. * @param result defines the target matrix
  73429. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  73430. */
  73431. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  73432. /**
  73433. * Creates a right-handed perspective projection matrix
  73434. * @param fov defines the horizontal field of view
  73435. * @param aspect defines the aspect ratio
  73436. * @param znear defines the near clip plane
  73437. * @param zfar defines the far clip plane
  73438. * @returns a new matrix as a right-handed perspective projection matrix
  73439. */
  73440. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  73441. /**
  73442. * Stores a right-handed perspective projection into a given matrix
  73443. * @param fov defines the horizontal field of view
  73444. * @param aspect defines the aspect ratio
  73445. * @param znear defines the near clip plane
  73446. * @param zfar defines the far clip plane
  73447. * @param result defines the target matrix
  73448. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  73449. */
  73450. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  73451. /**
  73452. * Stores a right-handed perspective projection into a given matrix
  73453. * @param fov defines the horizontal field of view
  73454. * @param aspect defines the aspect ratio
  73455. * @param znear defines the near clip plane
  73456. * @param zfar not used as infinity is used as far clip
  73457. * @param result defines the target matrix
  73458. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  73459. */
  73460. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  73461. /**
  73462. * Stores a perspective projection for WebVR info a given matrix
  73463. * @param fov defines the field of view
  73464. * @param znear defines the near clip plane
  73465. * @param zfar defines the far clip plane
  73466. * @param result defines the target matrix
  73467. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  73468. */
  73469. static PerspectiveFovWebVRToRef(fov: {
  73470. upDegrees: number;
  73471. downDegrees: number;
  73472. leftDegrees: number;
  73473. rightDegrees: number;
  73474. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  73475. /**
  73476. * Computes a complete transformation matrix
  73477. * @param viewport defines the viewport to use
  73478. * @param world defines the world matrix
  73479. * @param view defines the view matrix
  73480. * @param projection defines the projection matrix
  73481. * @param zmin defines the near clip plane
  73482. * @param zmax defines the far clip plane
  73483. * @returns the transformation matrix
  73484. */
  73485. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  73486. /**
  73487. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  73488. * @param matrix defines the matrix to use
  73489. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  73490. */
  73491. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  73492. /**
  73493. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  73494. * @param matrix defines the matrix to use
  73495. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  73496. */
  73497. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  73498. /**
  73499. * Compute the transpose of a given matrix
  73500. * @param matrix defines the matrix to transpose
  73501. * @returns the new matrix
  73502. */
  73503. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  73504. /**
  73505. * Compute the transpose of a matrix and store it in a target matrix
  73506. * @param matrix defines the matrix to transpose
  73507. * @param result defines the target matrix
  73508. */
  73509. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  73510. /**
  73511. * Computes a reflection matrix from a plane
  73512. * @param plane defines the reflection plane
  73513. * @returns a new matrix
  73514. */
  73515. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  73516. /**
  73517. * Computes a reflection matrix from a plane
  73518. * @param plane defines the reflection plane
  73519. * @param result defines the target matrix
  73520. */
  73521. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  73522. /**
  73523. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  73524. * @param xaxis defines the value of the 1st axis
  73525. * @param yaxis defines the value of the 2nd axis
  73526. * @param zaxis defines the value of the 3rd axis
  73527. * @param result defines the target matrix
  73528. */
  73529. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  73530. /**
  73531. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  73532. * @param quat defines the quaternion to use
  73533. * @param result defines the target matrix
  73534. */
  73535. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  73536. }
  73537. /**
  73538. * @hidden
  73539. */
  73540. export class TmpVectors {
  73541. static Vector2: Vector2[];
  73542. static Vector3: Vector3[];
  73543. static Vector4: Vector4[];
  73544. static Quaternion: Quaternion[];
  73545. static Matrix: Matrix[];
  73546. }
  73547. }
  73548. declare module BABYLON {
  73549. /**
  73550. * Defines potential orientation for back face culling
  73551. */
  73552. export enum Orientation {
  73553. /**
  73554. * Clockwise
  73555. */
  73556. CW = 0,
  73557. /** Counter clockwise */
  73558. CCW = 1
  73559. }
  73560. /** Class used to represent a Bezier curve */
  73561. export class BezierCurve {
  73562. /**
  73563. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  73564. * @param t defines the time
  73565. * @param x1 defines the left coordinate on X axis
  73566. * @param y1 defines the left coordinate on Y axis
  73567. * @param x2 defines the right coordinate on X axis
  73568. * @param y2 defines the right coordinate on Y axis
  73569. * @returns the interpolated value
  73570. */
  73571. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  73572. }
  73573. /**
  73574. * Defines angle representation
  73575. */
  73576. export class Angle {
  73577. private _radians;
  73578. /**
  73579. * Creates an Angle object of "radians" radians (float).
  73580. * @param radians the angle in radians
  73581. */
  73582. constructor(radians: number);
  73583. /**
  73584. * Get value in degrees
  73585. * @returns the Angle value in degrees (float)
  73586. */
  73587. degrees(): number;
  73588. /**
  73589. * Get value in radians
  73590. * @returns the Angle value in radians (float)
  73591. */
  73592. radians(): number;
  73593. /**
  73594. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  73595. * @param a defines first vector
  73596. * @param b defines second vector
  73597. * @returns a new Angle
  73598. */
  73599. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  73600. /**
  73601. * Gets a new Angle object from the given float in radians
  73602. * @param radians defines the angle value in radians
  73603. * @returns a new Angle
  73604. */
  73605. static FromRadians(radians: number): Angle;
  73606. /**
  73607. * Gets a new Angle object from the given float in degrees
  73608. * @param degrees defines the angle value in degrees
  73609. * @returns a new Angle
  73610. */
  73611. static FromDegrees(degrees: number): Angle;
  73612. }
  73613. /**
  73614. * This represents an arc in a 2d space.
  73615. */
  73616. export class Arc2 {
  73617. /** Defines the start point of the arc */
  73618. startPoint: Vector2;
  73619. /** Defines the mid point of the arc */
  73620. midPoint: Vector2;
  73621. /** Defines the end point of the arc */
  73622. endPoint: Vector2;
  73623. /**
  73624. * Defines the center point of the arc.
  73625. */
  73626. centerPoint: Vector2;
  73627. /**
  73628. * Defines the radius of the arc.
  73629. */
  73630. radius: number;
  73631. /**
  73632. * Defines the angle of the arc (from mid point to end point).
  73633. */
  73634. angle: Angle;
  73635. /**
  73636. * Defines the start angle of the arc (from start point to middle point).
  73637. */
  73638. startAngle: Angle;
  73639. /**
  73640. * Defines the orientation of the arc (clock wise/counter clock wise).
  73641. */
  73642. orientation: Orientation;
  73643. /**
  73644. * Creates an Arc object from the three given points : start, middle and end.
  73645. * @param startPoint Defines the start point of the arc
  73646. * @param midPoint Defines the midlle point of the arc
  73647. * @param endPoint Defines the end point of the arc
  73648. */
  73649. constructor(
  73650. /** Defines the start point of the arc */
  73651. startPoint: Vector2,
  73652. /** Defines the mid point of the arc */
  73653. midPoint: Vector2,
  73654. /** Defines the end point of the arc */
  73655. endPoint: Vector2);
  73656. }
  73657. /**
  73658. * Represents a 2D path made up of multiple 2D points
  73659. */
  73660. export class Path2 {
  73661. private _points;
  73662. private _length;
  73663. /**
  73664. * If the path start and end point are the same
  73665. */
  73666. closed: boolean;
  73667. /**
  73668. * Creates a Path2 object from the starting 2D coordinates x and y.
  73669. * @param x the starting points x value
  73670. * @param y the starting points y value
  73671. */
  73672. constructor(x: number, y: number);
  73673. /**
  73674. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  73675. * @param x the added points x value
  73676. * @param y the added points y value
  73677. * @returns the updated Path2.
  73678. */
  73679. addLineTo(x: number, y: number): Path2;
  73680. /**
  73681. * 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.
  73682. * @param midX middle point x value
  73683. * @param midY middle point y value
  73684. * @param endX end point x value
  73685. * @param endY end point y value
  73686. * @param numberOfSegments (default: 36)
  73687. * @returns the updated Path2.
  73688. */
  73689. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  73690. /**
  73691. * Closes the Path2.
  73692. * @returns the Path2.
  73693. */
  73694. close(): Path2;
  73695. /**
  73696. * Gets the sum of the distance between each sequential point in the path
  73697. * @returns the Path2 total length (float).
  73698. */
  73699. length(): number;
  73700. /**
  73701. * Gets the points which construct the path
  73702. * @returns the Path2 internal array of points.
  73703. */
  73704. getPoints(): Vector2[];
  73705. /**
  73706. * Retreives the point at the distance aways from the starting point
  73707. * @param normalizedLengthPosition the length along the path to retreive the point from
  73708. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  73709. */
  73710. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  73711. /**
  73712. * Creates a new path starting from an x and y position
  73713. * @param x starting x value
  73714. * @param y starting y value
  73715. * @returns a new Path2 starting at the coordinates (x, y).
  73716. */
  73717. static StartingAt(x: number, y: number): Path2;
  73718. }
  73719. /**
  73720. * Represents a 3D path made up of multiple 3D points
  73721. */
  73722. export class Path3D {
  73723. /**
  73724. * an array of Vector3, the curve axis of the Path3D
  73725. */
  73726. path: Vector3[];
  73727. private _curve;
  73728. private _distances;
  73729. private _tangents;
  73730. private _normals;
  73731. private _binormals;
  73732. private _raw;
  73733. private _alignTangentsWithPath;
  73734. private readonly _pointAtData;
  73735. /**
  73736. * new Path3D(path, normal, raw)
  73737. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  73738. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  73739. * @param path an array of Vector3, the curve axis of the Path3D
  73740. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  73741. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  73742. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  73743. */
  73744. constructor(
  73745. /**
  73746. * an array of Vector3, the curve axis of the Path3D
  73747. */
  73748. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  73749. /**
  73750. * Returns the Path3D array of successive Vector3 designing its curve.
  73751. * @returns the Path3D array of successive Vector3 designing its curve.
  73752. */
  73753. getCurve(): Vector3[];
  73754. /**
  73755. * Returns the Path3D array of successive Vector3 designing its curve.
  73756. * @returns the Path3D array of successive Vector3 designing its curve.
  73757. */
  73758. getPoints(): Vector3[];
  73759. /**
  73760. * @returns the computed length (float) of the path.
  73761. */
  73762. length(): number;
  73763. /**
  73764. * Returns an array populated with tangent vectors on each Path3D curve point.
  73765. * @returns an array populated with tangent vectors on each Path3D curve point.
  73766. */
  73767. getTangents(): Vector3[];
  73768. /**
  73769. * Returns an array populated with normal vectors on each Path3D curve point.
  73770. * @returns an array populated with normal vectors on each Path3D curve point.
  73771. */
  73772. getNormals(): Vector3[];
  73773. /**
  73774. * Returns an array populated with binormal vectors on each Path3D curve point.
  73775. * @returns an array populated with binormal vectors on each Path3D curve point.
  73776. */
  73777. getBinormals(): Vector3[];
  73778. /**
  73779. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  73780. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  73781. */
  73782. getDistances(): number[];
  73783. /**
  73784. * Returns an interpolated point along this path
  73785. * @param position the position of the point along this path, from 0.0 to 1.0
  73786. * @returns a new Vector3 as the point
  73787. */
  73788. getPointAt(position: number): Vector3;
  73789. /**
  73790. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  73791. * @param position the position of the point along this path, from 0.0 to 1.0
  73792. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  73793. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  73794. */
  73795. getTangentAt(position: number, interpolated?: boolean): Vector3;
  73796. /**
  73797. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  73798. * @param position the position of the point along this path, from 0.0 to 1.0
  73799. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  73800. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  73801. */
  73802. getNormalAt(position: number, interpolated?: boolean): Vector3;
  73803. /**
  73804. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  73805. * @param position the position of the point along this path, from 0.0 to 1.0
  73806. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  73807. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  73808. */
  73809. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  73810. /**
  73811. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  73812. * @param position the position of the point along this path, from 0.0 to 1.0
  73813. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  73814. */
  73815. getDistanceAt(position: number): number;
  73816. /**
  73817. * Returns the array index of the previous point of an interpolated point along this path
  73818. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  73819. * @returns the array index
  73820. */
  73821. getPreviousPointIndexAt(position: number): number;
  73822. /**
  73823. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  73824. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  73825. * @returns the sub position
  73826. */
  73827. getSubPositionAt(position: number): number;
  73828. /**
  73829. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  73830. * @param target the vector of which to get the closest position to
  73831. * @returns the position of the closest virtual point on this path to the target vector
  73832. */
  73833. getClosestPositionTo(target: Vector3): number;
  73834. /**
  73835. * Returns a sub path (slice) of this path
  73836. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  73837. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  73838. * @returns a sub path (slice) of this path
  73839. */
  73840. slice(start?: number, end?: number): Path3D;
  73841. /**
  73842. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  73843. * @param path path which all values are copied into the curves points
  73844. * @param firstNormal which should be projected onto the curve
  73845. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  73846. * @returns the same object updated.
  73847. */
  73848. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  73849. private _compute;
  73850. private _getFirstNonNullVector;
  73851. private _getLastNonNullVector;
  73852. private _normalVector;
  73853. /**
  73854. * Updates the point at data for an interpolated point along this curve
  73855. * @param position the position of the point along this curve, from 0.0 to 1.0
  73856. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  73857. * @returns the (updated) point at data
  73858. */
  73859. private _updatePointAtData;
  73860. /**
  73861. * Updates the point at data from the specified parameters
  73862. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  73863. * @param point the interpolated point
  73864. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  73865. */
  73866. private _setPointAtData;
  73867. /**
  73868. * Updates the point at interpolation matrix for the tangents, normals and binormals
  73869. */
  73870. private _updateInterpolationMatrix;
  73871. }
  73872. /**
  73873. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  73874. * A Curve3 is designed from a series of successive Vector3.
  73875. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  73876. */
  73877. export class Curve3 {
  73878. private _points;
  73879. private _length;
  73880. /**
  73881. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  73882. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  73883. * @param v1 (Vector3) the control point
  73884. * @param v2 (Vector3) the end point of the Quadratic Bezier
  73885. * @param nbPoints (integer) the wanted number of points in the curve
  73886. * @returns the created Curve3
  73887. */
  73888. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  73889. /**
  73890. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  73891. * @param v0 (Vector3) the origin point of the Cubic Bezier
  73892. * @param v1 (Vector3) the first control point
  73893. * @param v2 (Vector3) the second control point
  73894. * @param v3 (Vector3) the end point of the Cubic Bezier
  73895. * @param nbPoints (integer) the wanted number of points in the curve
  73896. * @returns the created Curve3
  73897. */
  73898. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  73899. /**
  73900. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  73901. * @param p1 (Vector3) the origin point of the Hermite Spline
  73902. * @param t1 (Vector3) the tangent vector at the origin point
  73903. * @param p2 (Vector3) the end point of the Hermite Spline
  73904. * @param t2 (Vector3) the tangent vector at the end point
  73905. * @param nbPoints (integer) the wanted number of points in the curve
  73906. * @returns the created Curve3
  73907. */
  73908. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  73909. /**
  73910. * Returns a Curve3 object along a CatmullRom Spline curve :
  73911. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  73912. * @param nbPoints (integer) the wanted number of points between each curve control points
  73913. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  73914. * @returns the created Curve3
  73915. */
  73916. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  73917. /**
  73918. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  73919. * A Curve3 is designed from a series of successive Vector3.
  73920. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  73921. * @param points points which make up the curve
  73922. */
  73923. constructor(points: Vector3[]);
  73924. /**
  73925. * @returns the Curve3 stored array of successive Vector3
  73926. */
  73927. getPoints(): Vector3[];
  73928. /**
  73929. * @returns the computed length (float) of the curve.
  73930. */
  73931. length(): number;
  73932. /**
  73933. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  73934. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  73935. * curveA and curveB keep unchanged.
  73936. * @param curve the curve to continue from this curve
  73937. * @returns the newly constructed curve
  73938. */
  73939. continue(curve: DeepImmutable<Curve3>): Curve3;
  73940. private _computeLength;
  73941. }
  73942. }
  73943. declare module BABYLON {
  73944. /**
  73945. * This represents the main contract an easing function should follow.
  73946. * Easing functions are used throughout the animation system.
  73947. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73948. */
  73949. export interface IEasingFunction {
  73950. /**
  73951. * Given an input gradient between 0 and 1, this returns the corrseponding value
  73952. * of the easing function.
  73953. * The link below provides some of the most common examples of easing functions.
  73954. * @see https://easings.net/
  73955. * @param gradient Defines the value between 0 and 1 we want the easing value for
  73956. * @returns the corresponding value on the curve defined by the easing function
  73957. */
  73958. ease(gradient: number): number;
  73959. }
  73960. /**
  73961. * Base class used for every default easing function.
  73962. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73963. */
  73964. export class EasingFunction implements IEasingFunction {
  73965. /**
  73966. * Interpolation follows the mathematical formula associated with the easing function.
  73967. */
  73968. static readonly EASINGMODE_EASEIN: number;
  73969. /**
  73970. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  73971. */
  73972. static readonly EASINGMODE_EASEOUT: number;
  73973. /**
  73974. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  73975. */
  73976. static readonly EASINGMODE_EASEINOUT: number;
  73977. private _easingMode;
  73978. /**
  73979. * Sets the easing mode of the current function.
  73980. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  73981. */
  73982. setEasingMode(easingMode: number): void;
  73983. /**
  73984. * Gets the current easing mode.
  73985. * @returns the easing mode
  73986. */
  73987. getEasingMode(): number;
  73988. /**
  73989. * @hidden
  73990. */
  73991. easeInCore(gradient: number): number;
  73992. /**
  73993. * Given an input gradient between 0 and 1, this returns the corresponding value
  73994. * of the easing function.
  73995. * @param gradient Defines the value between 0 and 1 we want the easing value for
  73996. * @returns the corresponding value on the curve defined by the easing function
  73997. */
  73998. ease(gradient: number): number;
  73999. }
  74000. /**
  74001. * Easing function with a circle shape (see link below).
  74002. * @see https://easings.net/#easeInCirc
  74003. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74004. */
  74005. export class CircleEase extends EasingFunction implements IEasingFunction {
  74006. /** @hidden */
  74007. easeInCore(gradient: number): number;
  74008. }
  74009. /**
  74010. * Easing function with a ease back shape (see link below).
  74011. * @see https://easings.net/#easeInBack
  74012. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74013. */
  74014. export class BackEase extends EasingFunction implements IEasingFunction {
  74015. /** Defines the amplitude of the function */
  74016. amplitude: number;
  74017. /**
  74018. * Instantiates a back ease easing
  74019. * @see https://easings.net/#easeInBack
  74020. * @param amplitude Defines the amplitude of the function
  74021. */
  74022. constructor(
  74023. /** Defines the amplitude of the function */
  74024. amplitude?: number);
  74025. /** @hidden */
  74026. easeInCore(gradient: number): number;
  74027. }
  74028. /**
  74029. * Easing function with a bouncing shape (see link below).
  74030. * @see https://easings.net/#easeInBounce
  74031. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74032. */
  74033. export class BounceEase extends EasingFunction implements IEasingFunction {
  74034. /** Defines the number of bounces */
  74035. bounces: number;
  74036. /** Defines the amplitude of the bounce */
  74037. bounciness: number;
  74038. /**
  74039. * Instantiates a bounce easing
  74040. * @see https://easings.net/#easeInBounce
  74041. * @param bounces Defines the number of bounces
  74042. * @param bounciness Defines the amplitude of the bounce
  74043. */
  74044. constructor(
  74045. /** Defines the number of bounces */
  74046. bounces?: number,
  74047. /** Defines the amplitude of the bounce */
  74048. bounciness?: number);
  74049. /** @hidden */
  74050. easeInCore(gradient: number): number;
  74051. }
  74052. /**
  74053. * Easing function with a power of 3 shape (see link below).
  74054. * @see https://easings.net/#easeInCubic
  74055. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74056. */
  74057. export class CubicEase extends EasingFunction implements IEasingFunction {
  74058. /** @hidden */
  74059. easeInCore(gradient: number): number;
  74060. }
  74061. /**
  74062. * Easing function with an elastic shape (see link below).
  74063. * @see https://easings.net/#easeInElastic
  74064. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74065. */
  74066. export class ElasticEase extends EasingFunction implements IEasingFunction {
  74067. /** Defines the number of oscillations*/
  74068. oscillations: number;
  74069. /** Defines the amplitude of the oscillations*/
  74070. springiness: number;
  74071. /**
  74072. * Instantiates an elastic easing function
  74073. * @see https://easings.net/#easeInElastic
  74074. * @param oscillations Defines the number of oscillations
  74075. * @param springiness Defines the amplitude of the oscillations
  74076. */
  74077. constructor(
  74078. /** Defines the number of oscillations*/
  74079. oscillations?: number,
  74080. /** Defines the amplitude of the oscillations*/
  74081. springiness?: number);
  74082. /** @hidden */
  74083. easeInCore(gradient: number): number;
  74084. }
  74085. /**
  74086. * Easing function with an exponential shape (see link below).
  74087. * @see https://easings.net/#easeInExpo
  74088. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74089. */
  74090. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  74091. /** Defines the exponent of the function */
  74092. exponent: number;
  74093. /**
  74094. * Instantiates an exponential easing function
  74095. * @see https://easings.net/#easeInExpo
  74096. * @param exponent Defines the exponent of the function
  74097. */
  74098. constructor(
  74099. /** Defines the exponent of the function */
  74100. exponent?: number);
  74101. /** @hidden */
  74102. easeInCore(gradient: number): number;
  74103. }
  74104. /**
  74105. * Easing function with a power shape (see link below).
  74106. * @see https://easings.net/#easeInQuad
  74107. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74108. */
  74109. export class PowerEase extends EasingFunction implements IEasingFunction {
  74110. /** Defines the power of the function */
  74111. power: number;
  74112. /**
  74113. * Instantiates an power base easing function
  74114. * @see https://easings.net/#easeInQuad
  74115. * @param power Defines the power of the function
  74116. */
  74117. constructor(
  74118. /** Defines the power of the function */
  74119. power?: number);
  74120. /** @hidden */
  74121. easeInCore(gradient: number): number;
  74122. }
  74123. /**
  74124. * Easing function with a power of 2 shape (see link below).
  74125. * @see https://easings.net/#easeInQuad
  74126. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74127. */
  74128. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  74129. /** @hidden */
  74130. easeInCore(gradient: number): number;
  74131. }
  74132. /**
  74133. * Easing function with a power of 4 shape (see link below).
  74134. * @see https://easings.net/#easeInQuart
  74135. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74136. */
  74137. export class QuarticEase extends EasingFunction implements IEasingFunction {
  74138. /** @hidden */
  74139. easeInCore(gradient: number): number;
  74140. }
  74141. /**
  74142. * Easing function with a power of 5 shape (see link below).
  74143. * @see https://easings.net/#easeInQuint
  74144. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74145. */
  74146. export class QuinticEase extends EasingFunction implements IEasingFunction {
  74147. /** @hidden */
  74148. easeInCore(gradient: number): number;
  74149. }
  74150. /**
  74151. * Easing function with a sin shape (see link below).
  74152. * @see https://easings.net/#easeInSine
  74153. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74154. */
  74155. export class SineEase extends EasingFunction implements IEasingFunction {
  74156. /** @hidden */
  74157. easeInCore(gradient: number): number;
  74158. }
  74159. /**
  74160. * Easing function with a bezier shape (see link below).
  74161. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  74162. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74163. */
  74164. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  74165. /** Defines the x component of the start tangent in the bezier curve */
  74166. x1: number;
  74167. /** Defines the y component of the start tangent in the bezier curve */
  74168. y1: number;
  74169. /** Defines the x component of the end tangent in the bezier curve */
  74170. x2: number;
  74171. /** Defines the y component of the end tangent in the bezier curve */
  74172. y2: number;
  74173. /**
  74174. * Instantiates a bezier function
  74175. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  74176. * @param x1 Defines the x component of the start tangent in the bezier curve
  74177. * @param y1 Defines the y component of the start tangent in the bezier curve
  74178. * @param x2 Defines the x component of the end tangent in the bezier curve
  74179. * @param y2 Defines the y component of the end tangent in the bezier curve
  74180. */
  74181. constructor(
  74182. /** Defines the x component of the start tangent in the bezier curve */
  74183. x1?: number,
  74184. /** Defines the y component of the start tangent in the bezier curve */
  74185. y1?: number,
  74186. /** Defines the x component of the end tangent in the bezier curve */
  74187. x2?: number,
  74188. /** Defines the y component of the end tangent in the bezier curve */
  74189. y2?: number);
  74190. /** @hidden */
  74191. easeInCore(gradient: number): number;
  74192. }
  74193. }
  74194. declare module BABYLON {
  74195. /**
  74196. * Class used to hold a RBG color
  74197. */
  74198. export class Color3 {
  74199. /**
  74200. * Defines the red component (between 0 and 1, default is 0)
  74201. */
  74202. r: number;
  74203. /**
  74204. * Defines the green component (between 0 and 1, default is 0)
  74205. */
  74206. g: number;
  74207. /**
  74208. * Defines the blue component (between 0 and 1, default is 0)
  74209. */
  74210. b: number;
  74211. /**
  74212. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  74213. * @param r defines the red component (between 0 and 1, default is 0)
  74214. * @param g defines the green component (between 0 and 1, default is 0)
  74215. * @param b defines the blue component (between 0 and 1, default is 0)
  74216. */
  74217. constructor(
  74218. /**
  74219. * Defines the red component (between 0 and 1, default is 0)
  74220. */
  74221. r?: number,
  74222. /**
  74223. * Defines the green component (between 0 and 1, default is 0)
  74224. */
  74225. g?: number,
  74226. /**
  74227. * Defines the blue component (between 0 and 1, default is 0)
  74228. */
  74229. b?: number);
  74230. /**
  74231. * Creates a string with the Color3 current values
  74232. * @returns the string representation of the Color3 object
  74233. */
  74234. toString(): string;
  74235. /**
  74236. * Returns the string "Color3"
  74237. * @returns "Color3"
  74238. */
  74239. getClassName(): string;
  74240. /**
  74241. * Compute the Color3 hash code
  74242. * @returns an unique number that can be used to hash Color3 objects
  74243. */
  74244. getHashCode(): number;
  74245. /**
  74246. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  74247. * @param array defines the array where to store the r,g,b components
  74248. * @param index defines an optional index in the target array to define where to start storing values
  74249. * @returns the current Color3 object
  74250. */
  74251. toArray(array: FloatArray, index?: number): Color3;
  74252. /**
  74253. * Returns a new Color4 object from the current Color3 and the given alpha
  74254. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  74255. * @returns a new Color4 object
  74256. */
  74257. toColor4(alpha?: number): Color4;
  74258. /**
  74259. * Returns a new array populated with 3 numeric elements : red, green and blue values
  74260. * @returns the new array
  74261. */
  74262. asArray(): number[];
  74263. /**
  74264. * Returns the luminance value
  74265. * @returns a float value
  74266. */
  74267. toLuminance(): number;
  74268. /**
  74269. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  74270. * @param otherColor defines the second operand
  74271. * @returns the new Color3 object
  74272. */
  74273. multiply(otherColor: DeepImmutable<Color3>): Color3;
  74274. /**
  74275. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  74276. * @param otherColor defines the second operand
  74277. * @param result defines the Color3 object where to store the result
  74278. * @returns the current Color3
  74279. */
  74280. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  74281. /**
  74282. * Determines equality between Color3 objects
  74283. * @param otherColor defines the second operand
  74284. * @returns true if the rgb values are equal to the given ones
  74285. */
  74286. equals(otherColor: DeepImmutable<Color3>): boolean;
  74287. /**
  74288. * Determines equality between the current Color3 object and a set of r,b,g values
  74289. * @param r defines the red component to check
  74290. * @param g defines the green component to check
  74291. * @param b defines the blue component to check
  74292. * @returns true if the rgb values are equal to the given ones
  74293. */
  74294. equalsFloats(r: number, g: number, b: number): boolean;
  74295. /**
  74296. * Multiplies in place each rgb value by scale
  74297. * @param scale defines the scaling factor
  74298. * @returns the updated Color3
  74299. */
  74300. scale(scale: number): Color3;
  74301. /**
  74302. * Multiplies the rgb values by scale and stores the result into "result"
  74303. * @param scale defines the scaling factor
  74304. * @param result defines the Color3 object where to store the result
  74305. * @returns the unmodified current Color3
  74306. */
  74307. scaleToRef(scale: number, result: Color3): Color3;
  74308. /**
  74309. * Scale the current Color3 values by a factor and add the result to a given Color3
  74310. * @param scale defines the scale factor
  74311. * @param result defines color to store the result into
  74312. * @returns the unmodified current Color3
  74313. */
  74314. scaleAndAddToRef(scale: number, result: Color3): Color3;
  74315. /**
  74316. * Clamps the rgb values by the min and max values and stores the result into "result"
  74317. * @param min defines minimum clamping value (default is 0)
  74318. * @param max defines maximum clamping value (default is 1)
  74319. * @param result defines color to store the result into
  74320. * @returns the original Color3
  74321. */
  74322. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  74323. /**
  74324. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  74325. * @param otherColor defines the second operand
  74326. * @returns the new Color3
  74327. */
  74328. add(otherColor: DeepImmutable<Color3>): Color3;
  74329. /**
  74330. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  74331. * @param otherColor defines the second operand
  74332. * @param result defines Color3 object to store the result into
  74333. * @returns the unmodified current Color3
  74334. */
  74335. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  74336. /**
  74337. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  74338. * @param otherColor defines the second operand
  74339. * @returns the new Color3
  74340. */
  74341. subtract(otherColor: DeepImmutable<Color3>): Color3;
  74342. /**
  74343. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  74344. * @param otherColor defines the second operand
  74345. * @param result defines Color3 object to store the result into
  74346. * @returns the unmodified current Color3
  74347. */
  74348. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  74349. /**
  74350. * Copy the current object
  74351. * @returns a new Color3 copied the current one
  74352. */
  74353. clone(): Color3;
  74354. /**
  74355. * Copies the rgb values from the source in the current Color3
  74356. * @param source defines the source Color3 object
  74357. * @returns the updated Color3 object
  74358. */
  74359. copyFrom(source: DeepImmutable<Color3>): Color3;
  74360. /**
  74361. * Updates the Color3 rgb values from the given floats
  74362. * @param r defines the red component to read from
  74363. * @param g defines the green component to read from
  74364. * @param b defines the blue component to read from
  74365. * @returns the current Color3 object
  74366. */
  74367. copyFromFloats(r: number, g: number, b: number): Color3;
  74368. /**
  74369. * Updates the Color3 rgb values from the given floats
  74370. * @param r defines the red component to read from
  74371. * @param g defines the green component to read from
  74372. * @param b defines the blue component to read from
  74373. * @returns the current Color3 object
  74374. */
  74375. set(r: number, g: number, b: number): Color3;
  74376. /**
  74377. * Compute the Color3 hexadecimal code as a string
  74378. * @returns a string containing the hexadecimal representation of the Color3 object
  74379. */
  74380. toHexString(): string;
  74381. /**
  74382. * Computes a new Color3 converted from the current one to linear space
  74383. * @returns a new Color3 object
  74384. */
  74385. toLinearSpace(): Color3;
  74386. /**
  74387. * Converts current color in rgb space to HSV values
  74388. * @returns a new color3 representing the HSV values
  74389. */
  74390. toHSV(): Color3;
  74391. /**
  74392. * Converts current color in rgb space to HSV values
  74393. * @param result defines the Color3 where to store the HSV values
  74394. */
  74395. toHSVToRef(result: Color3): void;
  74396. /**
  74397. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  74398. * @param convertedColor defines the Color3 object where to store the linear space version
  74399. * @returns the unmodified Color3
  74400. */
  74401. toLinearSpaceToRef(convertedColor: Color3): Color3;
  74402. /**
  74403. * Computes a new Color3 converted from the current one to gamma space
  74404. * @returns a new Color3 object
  74405. */
  74406. toGammaSpace(): Color3;
  74407. /**
  74408. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  74409. * @param convertedColor defines the Color3 object where to store the gamma space version
  74410. * @returns the unmodified Color3
  74411. */
  74412. toGammaSpaceToRef(convertedColor: Color3): Color3;
  74413. private static _BlackReadOnly;
  74414. /**
  74415. * Convert Hue, saturation and value to a Color3 (RGB)
  74416. * @param hue defines the hue
  74417. * @param saturation defines the saturation
  74418. * @param value defines the value
  74419. * @param result defines the Color3 where to store the RGB values
  74420. */
  74421. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  74422. /**
  74423. * Creates a new Color3 from the string containing valid hexadecimal values
  74424. * @param hex defines a string containing valid hexadecimal values
  74425. * @returns a new Color3 object
  74426. */
  74427. static FromHexString(hex: string): Color3;
  74428. /**
  74429. * Creates a new Color3 from the starting index of the given array
  74430. * @param array defines the source array
  74431. * @param offset defines an offset in the source array
  74432. * @returns a new Color3 object
  74433. */
  74434. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  74435. /**
  74436. * Creates a new Color3 from integer values (< 256)
  74437. * @param r defines the red component to read from (value between 0 and 255)
  74438. * @param g defines the green component to read from (value between 0 and 255)
  74439. * @param b defines the blue component to read from (value between 0 and 255)
  74440. * @returns a new Color3 object
  74441. */
  74442. static FromInts(r: number, g: number, b: number): Color3;
  74443. /**
  74444. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  74445. * @param start defines the start Color3 value
  74446. * @param end defines the end Color3 value
  74447. * @param amount defines the gradient value between start and end
  74448. * @returns a new Color3 object
  74449. */
  74450. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  74451. /**
  74452. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  74453. * @param left defines the start value
  74454. * @param right defines the end value
  74455. * @param amount defines the gradient factor
  74456. * @param result defines the Color3 object where to store the result
  74457. */
  74458. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  74459. /**
  74460. * Returns a Color3 value containing a red color
  74461. * @returns a new Color3 object
  74462. */
  74463. static Red(): Color3;
  74464. /**
  74465. * Returns a Color3 value containing a green color
  74466. * @returns a new Color3 object
  74467. */
  74468. static Green(): Color3;
  74469. /**
  74470. * Returns a Color3 value containing a blue color
  74471. * @returns a new Color3 object
  74472. */
  74473. static Blue(): Color3;
  74474. /**
  74475. * Returns a Color3 value containing a black color
  74476. * @returns a new Color3 object
  74477. */
  74478. static Black(): Color3;
  74479. /**
  74480. * Gets a Color3 value containing a black color that must not be updated
  74481. */
  74482. static readonly BlackReadOnly: DeepImmutable<Color3>;
  74483. /**
  74484. * Returns a Color3 value containing a white color
  74485. * @returns a new Color3 object
  74486. */
  74487. static White(): Color3;
  74488. /**
  74489. * Returns a Color3 value containing a purple color
  74490. * @returns a new Color3 object
  74491. */
  74492. static Purple(): Color3;
  74493. /**
  74494. * Returns a Color3 value containing a magenta color
  74495. * @returns a new Color3 object
  74496. */
  74497. static Magenta(): Color3;
  74498. /**
  74499. * Returns a Color3 value containing a yellow color
  74500. * @returns a new Color3 object
  74501. */
  74502. static Yellow(): Color3;
  74503. /**
  74504. * Returns a Color3 value containing a gray color
  74505. * @returns a new Color3 object
  74506. */
  74507. static Gray(): Color3;
  74508. /**
  74509. * Returns a Color3 value containing a teal color
  74510. * @returns a new Color3 object
  74511. */
  74512. static Teal(): Color3;
  74513. /**
  74514. * Returns a Color3 value containing a random color
  74515. * @returns a new Color3 object
  74516. */
  74517. static Random(): Color3;
  74518. }
  74519. /**
  74520. * Class used to hold a RBGA color
  74521. */
  74522. export class Color4 {
  74523. /**
  74524. * Defines the red component (between 0 and 1, default is 0)
  74525. */
  74526. r: number;
  74527. /**
  74528. * Defines the green component (between 0 and 1, default is 0)
  74529. */
  74530. g: number;
  74531. /**
  74532. * Defines the blue component (between 0 and 1, default is 0)
  74533. */
  74534. b: number;
  74535. /**
  74536. * Defines the alpha component (between 0 and 1, default is 1)
  74537. */
  74538. a: number;
  74539. /**
  74540. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  74541. * @param r defines the red component (between 0 and 1, default is 0)
  74542. * @param g defines the green component (between 0 and 1, default is 0)
  74543. * @param b defines the blue component (between 0 and 1, default is 0)
  74544. * @param a defines the alpha component (between 0 and 1, default is 1)
  74545. */
  74546. constructor(
  74547. /**
  74548. * Defines the red component (between 0 and 1, default is 0)
  74549. */
  74550. r?: number,
  74551. /**
  74552. * Defines the green component (between 0 and 1, default is 0)
  74553. */
  74554. g?: number,
  74555. /**
  74556. * Defines the blue component (between 0 and 1, default is 0)
  74557. */
  74558. b?: number,
  74559. /**
  74560. * Defines the alpha component (between 0 and 1, default is 1)
  74561. */
  74562. a?: number);
  74563. /**
  74564. * Adds in place the given Color4 values to the current Color4 object
  74565. * @param right defines the second operand
  74566. * @returns the current updated Color4 object
  74567. */
  74568. addInPlace(right: DeepImmutable<Color4>): Color4;
  74569. /**
  74570. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  74571. * @returns the new array
  74572. */
  74573. asArray(): number[];
  74574. /**
  74575. * Stores from the starting index in the given array the Color4 successive values
  74576. * @param array defines the array where to store the r,g,b components
  74577. * @param index defines an optional index in the target array to define where to start storing values
  74578. * @returns the current Color4 object
  74579. */
  74580. toArray(array: number[], index?: number): Color4;
  74581. /**
  74582. * Determines equality between Color4 objects
  74583. * @param otherColor defines the second operand
  74584. * @returns true if the rgba values are equal to the given ones
  74585. */
  74586. equals(otherColor: DeepImmutable<Color4>): boolean;
  74587. /**
  74588. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  74589. * @param right defines the second operand
  74590. * @returns a new Color4 object
  74591. */
  74592. add(right: DeepImmutable<Color4>): Color4;
  74593. /**
  74594. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  74595. * @param right defines the second operand
  74596. * @returns a new Color4 object
  74597. */
  74598. subtract(right: DeepImmutable<Color4>): Color4;
  74599. /**
  74600. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  74601. * @param right defines the second operand
  74602. * @param result defines the Color4 object where to store the result
  74603. * @returns the current Color4 object
  74604. */
  74605. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  74606. /**
  74607. * Creates a new Color4 with the current Color4 values multiplied by scale
  74608. * @param scale defines the scaling factor to apply
  74609. * @returns a new Color4 object
  74610. */
  74611. scale(scale: number): Color4;
  74612. /**
  74613. * Multiplies the current Color4 values by scale and stores the result in "result"
  74614. * @param scale defines the scaling factor to apply
  74615. * @param result defines the Color4 object where to store the result
  74616. * @returns the current unmodified Color4
  74617. */
  74618. scaleToRef(scale: number, result: Color4): Color4;
  74619. /**
  74620. * Scale the current Color4 values by a factor and add the result to a given Color4
  74621. * @param scale defines the scale factor
  74622. * @param result defines the Color4 object where to store the result
  74623. * @returns the unmodified current Color4
  74624. */
  74625. scaleAndAddToRef(scale: number, result: Color4): Color4;
  74626. /**
  74627. * Clamps the rgb values by the min and max values and stores the result into "result"
  74628. * @param min defines minimum clamping value (default is 0)
  74629. * @param max defines maximum clamping value (default is 1)
  74630. * @param result defines color to store the result into.
  74631. * @returns the cuurent Color4
  74632. */
  74633. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  74634. /**
  74635. * Multipy an Color4 value by another and return a new Color4 object
  74636. * @param color defines the Color4 value to multiply by
  74637. * @returns a new Color4 object
  74638. */
  74639. multiply(color: Color4): Color4;
  74640. /**
  74641. * Multipy a Color4 value by another and push the result in a reference value
  74642. * @param color defines the Color4 value to multiply by
  74643. * @param result defines the Color4 to fill the result in
  74644. * @returns the result Color4
  74645. */
  74646. multiplyToRef(color: Color4, result: Color4): Color4;
  74647. /**
  74648. * Creates a string with the Color4 current values
  74649. * @returns the string representation of the Color4 object
  74650. */
  74651. toString(): string;
  74652. /**
  74653. * Returns the string "Color4"
  74654. * @returns "Color4"
  74655. */
  74656. getClassName(): string;
  74657. /**
  74658. * Compute the Color4 hash code
  74659. * @returns an unique number that can be used to hash Color4 objects
  74660. */
  74661. getHashCode(): number;
  74662. /**
  74663. * Creates a new Color4 copied from the current one
  74664. * @returns a new Color4 object
  74665. */
  74666. clone(): Color4;
  74667. /**
  74668. * Copies the given Color4 values into the current one
  74669. * @param source defines the source Color4 object
  74670. * @returns the current updated Color4 object
  74671. */
  74672. copyFrom(source: Color4): Color4;
  74673. /**
  74674. * Copies the given float values into the current one
  74675. * @param r defines the red component to read from
  74676. * @param g defines the green component to read from
  74677. * @param b defines the blue component to read from
  74678. * @param a defines the alpha component to read from
  74679. * @returns the current updated Color4 object
  74680. */
  74681. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  74682. /**
  74683. * Copies the given float values into the current one
  74684. * @param r defines the red component to read from
  74685. * @param g defines the green component to read from
  74686. * @param b defines the blue component to read from
  74687. * @param a defines the alpha component to read from
  74688. * @returns the current updated Color4 object
  74689. */
  74690. set(r: number, g: number, b: number, a: number): Color4;
  74691. /**
  74692. * Compute the Color4 hexadecimal code as a string
  74693. * @returns a string containing the hexadecimal representation of the Color4 object
  74694. */
  74695. toHexString(): string;
  74696. /**
  74697. * Computes a new Color4 converted from the current one to linear space
  74698. * @returns a new Color4 object
  74699. */
  74700. toLinearSpace(): Color4;
  74701. /**
  74702. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  74703. * @param convertedColor defines the Color4 object where to store the linear space version
  74704. * @returns the unmodified Color4
  74705. */
  74706. toLinearSpaceToRef(convertedColor: Color4): Color4;
  74707. /**
  74708. * Computes a new Color4 converted from the current one to gamma space
  74709. * @returns a new Color4 object
  74710. */
  74711. toGammaSpace(): Color4;
  74712. /**
  74713. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  74714. * @param convertedColor defines the Color4 object where to store the gamma space version
  74715. * @returns the unmodified Color4
  74716. */
  74717. toGammaSpaceToRef(convertedColor: Color4): Color4;
  74718. /**
  74719. * Creates a new Color4 from the string containing valid hexadecimal values
  74720. * @param hex defines a string containing valid hexadecimal values
  74721. * @returns a new Color4 object
  74722. */
  74723. static FromHexString(hex: string): Color4;
  74724. /**
  74725. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  74726. * @param left defines the start value
  74727. * @param right defines the end value
  74728. * @param amount defines the gradient factor
  74729. * @returns a new Color4 object
  74730. */
  74731. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  74732. /**
  74733. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  74734. * @param left defines the start value
  74735. * @param right defines the end value
  74736. * @param amount defines the gradient factor
  74737. * @param result defines the Color4 object where to store data
  74738. */
  74739. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  74740. /**
  74741. * Creates a new Color4 from a Color3 and an alpha value
  74742. * @param color3 defines the source Color3 to read from
  74743. * @param alpha defines the alpha component (1.0 by default)
  74744. * @returns a new Color4 object
  74745. */
  74746. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  74747. /**
  74748. * Creates a new Color4 from the starting index element of the given array
  74749. * @param array defines the source array to read from
  74750. * @param offset defines the offset in the source array
  74751. * @returns a new Color4 object
  74752. */
  74753. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  74754. /**
  74755. * Creates a new Color3 from integer values (< 256)
  74756. * @param r defines the red component to read from (value between 0 and 255)
  74757. * @param g defines the green component to read from (value between 0 and 255)
  74758. * @param b defines the blue component to read from (value between 0 and 255)
  74759. * @param a defines the alpha component to read from (value between 0 and 255)
  74760. * @returns a new Color3 object
  74761. */
  74762. static FromInts(r: number, g: number, b: number, a: number): Color4;
  74763. /**
  74764. * Check the content of a given array and convert it to an array containing RGBA data
  74765. * If the original array was already containing count * 4 values then it is returned directly
  74766. * @param colors defines the array to check
  74767. * @param count defines the number of RGBA data to expect
  74768. * @returns an array containing count * 4 values (RGBA)
  74769. */
  74770. static CheckColors4(colors: number[], count: number): number[];
  74771. }
  74772. /**
  74773. * @hidden
  74774. */
  74775. export class TmpColors {
  74776. static Color3: Color3[];
  74777. static Color4: Color4[];
  74778. }
  74779. }
  74780. declare module BABYLON {
  74781. /**
  74782. * Defines an interface which represents an animation key frame
  74783. */
  74784. export interface IAnimationKey {
  74785. /**
  74786. * Frame of the key frame
  74787. */
  74788. frame: number;
  74789. /**
  74790. * Value at the specifies key frame
  74791. */
  74792. value: any;
  74793. /**
  74794. * The input tangent for the cubic hermite spline
  74795. */
  74796. inTangent?: any;
  74797. /**
  74798. * The output tangent for the cubic hermite spline
  74799. */
  74800. outTangent?: any;
  74801. /**
  74802. * The animation interpolation type
  74803. */
  74804. interpolation?: AnimationKeyInterpolation;
  74805. }
  74806. /**
  74807. * Enum for the animation key frame interpolation type
  74808. */
  74809. export enum AnimationKeyInterpolation {
  74810. /**
  74811. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  74812. */
  74813. STEP = 1
  74814. }
  74815. }
  74816. declare module BABYLON {
  74817. /**
  74818. * Represents the range of an animation
  74819. */
  74820. export class AnimationRange {
  74821. /**The name of the animation range**/
  74822. name: string;
  74823. /**The starting frame of the animation */
  74824. from: number;
  74825. /**The ending frame of the animation*/
  74826. to: number;
  74827. /**
  74828. * Initializes the range of an animation
  74829. * @param name The name of the animation range
  74830. * @param from The starting frame of the animation
  74831. * @param to The ending frame of the animation
  74832. */
  74833. constructor(
  74834. /**The name of the animation range**/
  74835. name: string,
  74836. /**The starting frame of the animation */
  74837. from: number,
  74838. /**The ending frame of the animation*/
  74839. to: number);
  74840. /**
  74841. * Makes a copy of the animation range
  74842. * @returns A copy of the animation range
  74843. */
  74844. clone(): AnimationRange;
  74845. }
  74846. }
  74847. declare module BABYLON {
  74848. /**
  74849. * Composed of a frame, and an action function
  74850. */
  74851. export class AnimationEvent {
  74852. /** The frame for which the event is triggered **/
  74853. frame: number;
  74854. /** The event to perform when triggered **/
  74855. action: (currentFrame: number) => void;
  74856. /** Specifies if the event should be triggered only once**/
  74857. onlyOnce?: boolean | undefined;
  74858. /**
  74859. * Specifies if the animation event is done
  74860. */
  74861. isDone: boolean;
  74862. /**
  74863. * Initializes the animation event
  74864. * @param frame The frame for which the event is triggered
  74865. * @param action The event to perform when triggered
  74866. * @param onlyOnce Specifies if the event should be triggered only once
  74867. */
  74868. constructor(
  74869. /** The frame for which the event is triggered **/
  74870. frame: number,
  74871. /** The event to perform when triggered **/
  74872. action: (currentFrame: number) => void,
  74873. /** Specifies if the event should be triggered only once**/
  74874. onlyOnce?: boolean | undefined);
  74875. /** @hidden */
  74876. _clone(): AnimationEvent;
  74877. }
  74878. }
  74879. declare module BABYLON {
  74880. /**
  74881. * Interface used to define a behavior
  74882. */
  74883. export interface Behavior<T> {
  74884. /** gets or sets behavior's name */
  74885. name: string;
  74886. /**
  74887. * Function called when the behavior needs to be initialized (after attaching it to a target)
  74888. */
  74889. init(): void;
  74890. /**
  74891. * Called when the behavior is attached to a target
  74892. * @param target defines the target where the behavior is attached to
  74893. */
  74894. attach(target: T): void;
  74895. /**
  74896. * Called when the behavior is detached from its target
  74897. */
  74898. detach(): void;
  74899. }
  74900. /**
  74901. * Interface implemented by classes supporting behaviors
  74902. */
  74903. export interface IBehaviorAware<T> {
  74904. /**
  74905. * Attach a behavior
  74906. * @param behavior defines the behavior to attach
  74907. * @returns the current host
  74908. */
  74909. addBehavior(behavior: Behavior<T>): T;
  74910. /**
  74911. * Remove a behavior from the current object
  74912. * @param behavior defines the behavior to detach
  74913. * @returns the current host
  74914. */
  74915. removeBehavior(behavior: Behavior<T>): T;
  74916. /**
  74917. * Gets a behavior using its name to search
  74918. * @param name defines the name to search
  74919. * @returns the behavior or null if not found
  74920. */
  74921. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  74922. }
  74923. }
  74924. declare module BABYLON {
  74925. /**
  74926. * Defines an array and its length.
  74927. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  74928. */
  74929. export interface ISmartArrayLike<T> {
  74930. /**
  74931. * The data of the array.
  74932. */
  74933. data: Array<T>;
  74934. /**
  74935. * The active length of the array.
  74936. */
  74937. length: number;
  74938. }
  74939. /**
  74940. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  74941. */
  74942. export class SmartArray<T> implements ISmartArrayLike<T> {
  74943. /**
  74944. * The full set of data from the array.
  74945. */
  74946. data: Array<T>;
  74947. /**
  74948. * The active length of the array.
  74949. */
  74950. length: number;
  74951. protected _id: number;
  74952. /**
  74953. * Instantiates a Smart Array.
  74954. * @param capacity defines the default capacity of the array.
  74955. */
  74956. constructor(capacity: number);
  74957. /**
  74958. * Pushes a value at the end of the active data.
  74959. * @param value defines the object to push in the array.
  74960. */
  74961. push(value: T): void;
  74962. /**
  74963. * Iterates over the active data and apply the lambda to them.
  74964. * @param func defines the action to apply on each value.
  74965. */
  74966. forEach(func: (content: T) => void): void;
  74967. /**
  74968. * Sorts the full sets of data.
  74969. * @param compareFn defines the comparison function to apply.
  74970. */
  74971. sort(compareFn: (a: T, b: T) => number): void;
  74972. /**
  74973. * Resets the active data to an empty array.
  74974. */
  74975. reset(): void;
  74976. /**
  74977. * Releases all the data from the array as well as the array.
  74978. */
  74979. dispose(): void;
  74980. /**
  74981. * Concats the active data with a given array.
  74982. * @param array defines the data to concatenate with.
  74983. */
  74984. concat(array: any): void;
  74985. /**
  74986. * Returns the position of a value in the active data.
  74987. * @param value defines the value to find the index for
  74988. * @returns the index if found in the active data otherwise -1
  74989. */
  74990. indexOf(value: T): number;
  74991. /**
  74992. * Returns whether an element is part of the active data.
  74993. * @param value defines the value to look for
  74994. * @returns true if found in the active data otherwise false
  74995. */
  74996. contains(value: T): boolean;
  74997. private static _GlobalId;
  74998. }
  74999. /**
  75000. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  75001. * The data in this array can only be present once
  75002. */
  75003. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  75004. private _duplicateId;
  75005. /**
  75006. * Pushes a value at the end of the active data.
  75007. * THIS DOES NOT PREVENT DUPPLICATE DATA
  75008. * @param value defines the object to push in the array.
  75009. */
  75010. push(value: T): void;
  75011. /**
  75012. * Pushes a value at the end of the active data.
  75013. * If the data is already present, it won t be added again
  75014. * @param value defines the object to push in the array.
  75015. * @returns true if added false if it was already present
  75016. */
  75017. pushNoDuplicate(value: T): boolean;
  75018. /**
  75019. * Resets the active data to an empty array.
  75020. */
  75021. reset(): void;
  75022. /**
  75023. * Concats the active data with a given array.
  75024. * This ensures no dupplicate will be present in the result.
  75025. * @param array defines the data to concatenate with.
  75026. */
  75027. concatWithNoDuplicate(array: any): void;
  75028. }
  75029. }
  75030. declare module BABYLON {
  75031. /**
  75032. * @ignore
  75033. * This is a list of all the different input types that are available in the application.
  75034. * Fo instance: ArcRotateCameraGamepadInput...
  75035. */
  75036. export var CameraInputTypes: {};
  75037. /**
  75038. * This is the contract to implement in order to create a new input class.
  75039. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  75040. */
  75041. export interface ICameraInput<TCamera extends Camera> {
  75042. /**
  75043. * Defines the camera the input is attached to.
  75044. */
  75045. camera: Nullable<TCamera>;
  75046. /**
  75047. * Gets the class name of the current intput.
  75048. * @returns the class name
  75049. */
  75050. getClassName(): string;
  75051. /**
  75052. * Get the friendly name associated with the input class.
  75053. * @returns the input friendly name
  75054. */
  75055. getSimpleName(): string;
  75056. /**
  75057. * Attach the input controls to a specific dom element to get the input from.
  75058. * @param element Defines the element the controls should be listened from
  75059. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75060. */
  75061. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75062. /**
  75063. * Detach the current controls from the specified dom element.
  75064. * @param element Defines the element to stop listening the inputs from
  75065. */
  75066. detachControl(element: Nullable<HTMLElement>): void;
  75067. /**
  75068. * Update the current camera state depending on the inputs that have been used this frame.
  75069. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  75070. */
  75071. checkInputs?: () => void;
  75072. }
  75073. /**
  75074. * Represents a map of input types to input instance or input index to input instance.
  75075. */
  75076. export interface CameraInputsMap<TCamera extends Camera> {
  75077. /**
  75078. * Accessor to the input by input type.
  75079. */
  75080. [name: string]: ICameraInput<TCamera>;
  75081. /**
  75082. * Accessor to the input by input index.
  75083. */
  75084. [idx: number]: ICameraInput<TCamera>;
  75085. }
  75086. /**
  75087. * This represents the input manager used within a camera.
  75088. * It helps dealing with all the different kind of input attached to a camera.
  75089. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75090. */
  75091. export class CameraInputsManager<TCamera extends Camera> {
  75092. /**
  75093. * Defines the list of inputs attahed to the camera.
  75094. */
  75095. attached: CameraInputsMap<TCamera>;
  75096. /**
  75097. * Defines the dom element the camera is collecting inputs from.
  75098. * This is null if the controls have not been attached.
  75099. */
  75100. attachedElement: Nullable<HTMLElement>;
  75101. /**
  75102. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75103. */
  75104. noPreventDefault: boolean;
  75105. /**
  75106. * Defined the camera the input manager belongs to.
  75107. */
  75108. camera: TCamera;
  75109. /**
  75110. * Update the current camera state depending on the inputs that have been used this frame.
  75111. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  75112. */
  75113. checkInputs: () => void;
  75114. /**
  75115. * Instantiate a new Camera Input Manager.
  75116. * @param camera Defines the camera the input manager blongs to
  75117. */
  75118. constructor(camera: TCamera);
  75119. /**
  75120. * Add an input method to a camera
  75121. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75122. * @param input camera input method
  75123. */
  75124. add(input: ICameraInput<TCamera>): void;
  75125. /**
  75126. * Remove a specific input method from a camera
  75127. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  75128. * @param inputToRemove camera input method
  75129. */
  75130. remove(inputToRemove: ICameraInput<TCamera>): void;
  75131. /**
  75132. * Remove a specific input type from a camera
  75133. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  75134. * @param inputType the type of the input to remove
  75135. */
  75136. removeByType(inputType: string): void;
  75137. private _addCheckInputs;
  75138. /**
  75139. * Attach the input controls to the currently attached dom element to listen the events from.
  75140. * @param input Defines the input to attach
  75141. */
  75142. attachInput(input: ICameraInput<TCamera>): void;
  75143. /**
  75144. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  75145. * @param element Defines the dom element to collect the events from
  75146. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75147. */
  75148. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  75149. /**
  75150. * Detach the current manager inputs controls from a specific dom element.
  75151. * @param element Defines the dom element to collect the events from
  75152. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  75153. */
  75154. detachElement(element: HTMLElement, disconnect?: boolean): void;
  75155. /**
  75156. * Rebuild the dynamic inputCheck function from the current list of
  75157. * defined inputs in the manager.
  75158. */
  75159. rebuildInputCheck(): void;
  75160. /**
  75161. * Remove all attached input methods from a camera
  75162. */
  75163. clear(): void;
  75164. /**
  75165. * Serialize the current input manager attached to a camera.
  75166. * This ensures than once parsed,
  75167. * the input associated to the camera will be identical to the current ones
  75168. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  75169. */
  75170. serialize(serializedCamera: any): void;
  75171. /**
  75172. * Parses an input manager serialized JSON to restore the previous list of inputs
  75173. * and states associated to a camera.
  75174. * @param parsedCamera Defines the JSON to parse
  75175. */
  75176. parse(parsedCamera: any): void;
  75177. }
  75178. }
  75179. declare module BABYLON {
  75180. /**
  75181. * Class used to store data that will be store in GPU memory
  75182. */
  75183. export class Buffer {
  75184. private _engine;
  75185. private _buffer;
  75186. /** @hidden */
  75187. _data: Nullable<DataArray>;
  75188. private _updatable;
  75189. private _instanced;
  75190. private _divisor;
  75191. /**
  75192. * Gets the byte stride.
  75193. */
  75194. readonly byteStride: number;
  75195. /**
  75196. * Constructor
  75197. * @param engine the engine
  75198. * @param data the data to use for this buffer
  75199. * @param updatable whether the data is updatable
  75200. * @param stride the stride (optional)
  75201. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  75202. * @param instanced whether the buffer is instanced (optional)
  75203. * @param useBytes set to true if the stride in in bytes (optional)
  75204. * @param divisor sets an optional divisor for instances (1 by default)
  75205. */
  75206. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  75207. /**
  75208. * Create a new VertexBuffer based on the current buffer
  75209. * @param kind defines the vertex buffer kind (position, normal, etc.)
  75210. * @param offset defines offset in the buffer (0 by default)
  75211. * @param size defines the size in floats of attributes (position is 3 for instance)
  75212. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  75213. * @param instanced defines if the vertex buffer contains indexed data
  75214. * @param useBytes defines if the offset and stride are in bytes *
  75215. * @param divisor sets an optional divisor for instances (1 by default)
  75216. * @returns the new vertex buffer
  75217. */
  75218. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  75219. /**
  75220. * Gets a boolean indicating if the Buffer is updatable?
  75221. * @returns true if the buffer is updatable
  75222. */
  75223. isUpdatable(): boolean;
  75224. /**
  75225. * Gets current buffer's data
  75226. * @returns a DataArray or null
  75227. */
  75228. getData(): Nullable<DataArray>;
  75229. /**
  75230. * Gets underlying native buffer
  75231. * @returns underlying native buffer
  75232. */
  75233. getBuffer(): Nullable<DataBuffer>;
  75234. /**
  75235. * Gets the stride in float32 units (i.e. byte stride / 4).
  75236. * May not be an integer if the byte stride is not divisible by 4.
  75237. * @returns the stride in float32 units
  75238. * @deprecated Please use byteStride instead.
  75239. */
  75240. getStrideSize(): number;
  75241. /**
  75242. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  75243. * @param data defines the data to store
  75244. */
  75245. create(data?: Nullable<DataArray>): void;
  75246. /** @hidden */
  75247. _rebuild(): void;
  75248. /**
  75249. * Update current buffer data
  75250. * @param data defines the data to store
  75251. */
  75252. update(data: DataArray): void;
  75253. /**
  75254. * Updates the data directly.
  75255. * @param data the new data
  75256. * @param offset the new offset
  75257. * @param vertexCount the vertex count (optional)
  75258. * @param useBytes set to true if the offset is in bytes
  75259. */
  75260. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  75261. /**
  75262. * Release all resources
  75263. */
  75264. dispose(): void;
  75265. }
  75266. /**
  75267. * Specialized buffer used to store vertex data
  75268. */
  75269. export class VertexBuffer {
  75270. /** @hidden */
  75271. _buffer: Buffer;
  75272. private _kind;
  75273. private _size;
  75274. private _ownsBuffer;
  75275. private _instanced;
  75276. private _instanceDivisor;
  75277. /**
  75278. * The byte type.
  75279. */
  75280. static readonly BYTE: number;
  75281. /**
  75282. * The unsigned byte type.
  75283. */
  75284. static readonly UNSIGNED_BYTE: number;
  75285. /**
  75286. * The short type.
  75287. */
  75288. static readonly SHORT: number;
  75289. /**
  75290. * The unsigned short type.
  75291. */
  75292. static readonly UNSIGNED_SHORT: number;
  75293. /**
  75294. * The integer type.
  75295. */
  75296. static readonly INT: number;
  75297. /**
  75298. * The unsigned integer type.
  75299. */
  75300. static readonly UNSIGNED_INT: number;
  75301. /**
  75302. * The float type.
  75303. */
  75304. static readonly FLOAT: number;
  75305. /**
  75306. * Gets or sets the instance divisor when in instanced mode
  75307. */
  75308. instanceDivisor: number;
  75309. /**
  75310. * Gets the byte stride.
  75311. */
  75312. readonly byteStride: number;
  75313. /**
  75314. * Gets the byte offset.
  75315. */
  75316. readonly byteOffset: number;
  75317. /**
  75318. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  75319. */
  75320. readonly normalized: boolean;
  75321. /**
  75322. * Gets the data type of each component in the array.
  75323. */
  75324. readonly type: number;
  75325. /**
  75326. * Constructor
  75327. * @param engine the engine
  75328. * @param data the data to use for this vertex buffer
  75329. * @param kind the vertex buffer kind
  75330. * @param updatable whether the data is updatable
  75331. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  75332. * @param stride the stride (optional)
  75333. * @param instanced whether the buffer is instanced (optional)
  75334. * @param offset the offset of the data (optional)
  75335. * @param size the number of components (optional)
  75336. * @param type the type of the component (optional)
  75337. * @param normalized whether the data contains normalized data (optional)
  75338. * @param useBytes set to true if stride and offset are in bytes (optional)
  75339. * @param divisor defines the instance divisor to use (1 by default)
  75340. */
  75341. 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);
  75342. /** @hidden */
  75343. _rebuild(): void;
  75344. /**
  75345. * Returns the kind of the VertexBuffer (string)
  75346. * @returns a string
  75347. */
  75348. getKind(): string;
  75349. /**
  75350. * Gets a boolean indicating if the VertexBuffer is updatable?
  75351. * @returns true if the buffer is updatable
  75352. */
  75353. isUpdatable(): boolean;
  75354. /**
  75355. * Gets current buffer's data
  75356. * @returns a DataArray or null
  75357. */
  75358. getData(): Nullable<DataArray>;
  75359. /**
  75360. * Gets underlying native buffer
  75361. * @returns underlying native buffer
  75362. */
  75363. getBuffer(): Nullable<DataBuffer>;
  75364. /**
  75365. * Gets the stride in float32 units (i.e. byte stride / 4).
  75366. * May not be an integer if the byte stride is not divisible by 4.
  75367. * @returns the stride in float32 units
  75368. * @deprecated Please use byteStride instead.
  75369. */
  75370. getStrideSize(): number;
  75371. /**
  75372. * Returns the offset as a multiple of the type byte length.
  75373. * @returns the offset in bytes
  75374. * @deprecated Please use byteOffset instead.
  75375. */
  75376. getOffset(): number;
  75377. /**
  75378. * Returns the number of components per vertex attribute (integer)
  75379. * @returns the size in float
  75380. */
  75381. getSize(): number;
  75382. /**
  75383. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  75384. * @returns true if this buffer is instanced
  75385. */
  75386. getIsInstanced(): boolean;
  75387. /**
  75388. * Returns the instancing divisor, zero for non-instanced (integer).
  75389. * @returns a number
  75390. */
  75391. getInstanceDivisor(): number;
  75392. /**
  75393. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  75394. * @param data defines the data to store
  75395. */
  75396. create(data?: DataArray): void;
  75397. /**
  75398. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  75399. * This function will create a new buffer if the current one is not updatable
  75400. * @param data defines the data to store
  75401. */
  75402. update(data: DataArray): void;
  75403. /**
  75404. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  75405. * Returns the directly updated WebGLBuffer.
  75406. * @param data the new data
  75407. * @param offset the new offset
  75408. * @param useBytes set to true if the offset is in bytes
  75409. */
  75410. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  75411. /**
  75412. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  75413. */
  75414. dispose(): void;
  75415. /**
  75416. * Enumerates each value of this vertex buffer as numbers.
  75417. * @param count the number of values to enumerate
  75418. * @param callback the callback function called for each value
  75419. */
  75420. forEach(count: number, callback: (value: number, index: number) => void): void;
  75421. /**
  75422. * Positions
  75423. */
  75424. static readonly PositionKind: string;
  75425. /**
  75426. * Normals
  75427. */
  75428. static readonly NormalKind: string;
  75429. /**
  75430. * Tangents
  75431. */
  75432. static readonly TangentKind: string;
  75433. /**
  75434. * Texture coordinates
  75435. */
  75436. static readonly UVKind: string;
  75437. /**
  75438. * Texture coordinates 2
  75439. */
  75440. static readonly UV2Kind: string;
  75441. /**
  75442. * Texture coordinates 3
  75443. */
  75444. static readonly UV3Kind: string;
  75445. /**
  75446. * Texture coordinates 4
  75447. */
  75448. static readonly UV4Kind: string;
  75449. /**
  75450. * Texture coordinates 5
  75451. */
  75452. static readonly UV5Kind: string;
  75453. /**
  75454. * Texture coordinates 6
  75455. */
  75456. static readonly UV6Kind: string;
  75457. /**
  75458. * Colors
  75459. */
  75460. static readonly ColorKind: string;
  75461. /**
  75462. * Matrix indices (for bones)
  75463. */
  75464. static readonly MatricesIndicesKind: string;
  75465. /**
  75466. * Matrix weights (for bones)
  75467. */
  75468. static readonly MatricesWeightsKind: string;
  75469. /**
  75470. * Additional matrix indices (for bones)
  75471. */
  75472. static readonly MatricesIndicesExtraKind: string;
  75473. /**
  75474. * Additional matrix weights (for bones)
  75475. */
  75476. static readonly MatricesWeightsExtraKind: string;
  75477. /**
  75478. * Deduces the stride given a kind.
  75479. * @param kind The kind string to deduce
  75480. * @returns The deduced stride
  75481. */
  75482. static DeduceStride(kind: string): number;
  75483. /**
  75484. * Gets the byte length of the given type.
  75485. * @param type the type
  75486. * @returns the number of bytes
  75487. */
  75488. static GetTypeByteLength(type: number): number;
  75489. /**
  75490. * Enumerates each value of the given parameters as numbers.
  75491. * @param data the data to enumerate
  75492. * @param byteOffset the byte offset of the data
  75493. * @param byteStride the byte stride of the data
  75494. * @param componentCount the number of components per element
  75495. * @param componentType the type of the component
  75496. * @param count the number of values to enumerate
  75497. * @param normalized whether the data is normalized
  75498. * @param callback the callback function called for each value
  75499. */
  75500. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  75501. private static _GetFloatValue;
  75502. }
  75503. }
  75504. declare module BABYLON {
  75505. /**
  75506. * @hidden
  75507. */
  75508. export class IntersectionInfo {
  75509. bu: Nullable<number>;
  75510. bv: Nullable<number>;
  75511. distance: number;
  75512. faceId: number;
  75513. subMeshId: number;
  75514. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  75515. }
  75516. }
  75517. declare module BABYLON {
  75518. /**
  75519. * Represens a plane by the equation ax + by + cz + d = 0
  75520. */
  75521. export class Plane {
  75522. private static _TmpMatrix;
  75523. /**
  75524. * Normal of the plane (a,b,c)
  75525. */
  75526. normal: Vector3;
  75527. /**
  75528. * d component of the plane
  75529. */
  75530. d: number;
  75531. /**
  75532. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  75533. * @param a a component of the plane
  75534. * @param b b component of the plane
  75535. * @param c c component of the plane
  75536. * @param d d component of the plane
  75537. */
  75538. constructor(a: number, b: number, c: number, d: number);
  75539. /**
  75540. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  75541. */
  75542. asArray(): number[];
  75543. /**
  75544. * @returns a new plane copied from the current Plane.
  75545. */
  75546. clone(): Plane;
  75547. /**
  75548. * @returns the string "Plane".
  75549. */
  75550. getClassName(): string;
  75551. /**
  75552. * @returns the Plane hash code.
  75553. */
  75554. getHashCode(): number;
  75555. /**
  75556. * Normalize the current Plane in place.
  75557. * @returns the updated Plane.
  75558. */
  75559. normalize(): Plane;
  75560. /**
  75561. * Applies a transformation the plane and returns the result
  75562. * @param transformation the transformation matrix to be applied to the plane
  75563. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  75564. */
  75565. transform(transformation: DeepImmutable<Matrix>): Plane;
  75566. /**
  75567. * Calcualtte the dot product between the point and the plane normal
  75568. * @param point point to calculate the dot product with
  75569. * @returns the dot product (float) of the point coordinates and the plane normal.
  75570. */
  75571. dotCoordinate(point: DeepImmutable<Vector3>): number;
  75572. /**
  75573. * Updates the current Plane from the plane defined by the three given points.
  75574. * @param point1 one of the points used to contruct the plane
  75575. * @param point2 one of the points used to contruct the plane
  75576. * @param point3 one of the points used to contruct the plane
  75577. * @returns the updated Plane.
  75578. */
  75579. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  75580. /**
  75581. * Checks if the plane is facing a given direction
  75582. * @param direction the direction to check if the plane is facing
  75583. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  75584. * @returns True is the vector "direction" is the same side than the plane normal.
  75585. */
  75586. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  75587. /**
  75588. * Calculates the distance to a point
  75589. * @param point point to calculate distance to
  75590. * @returns the signed distance (float) from the given point to the Plane.
  75591. */
  75592. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  75593. /**
  75594. * Creates a plane from an array
  75595. * @param array the array to create a plane from
  75596. * @returns a new Plane from the given array.
  75597. */
  75598. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  75599. /**
  75600. * Creates a plane from three points
  75601. * @param point1 point used to create the plane
  75602. * @param point2 point used to create the plane
  75603. * @param point3 point used to create the plane
  75604. * @returns a new Plane defined by the three given points.
  75605. */
  75606. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  75607. /**
  75608. * Creates a plane from an origin point and a normal
  75609. * @param origin origin of the plane to be constructed
  75610. * @param normal normal of the plane to be constructed
  75611. * @returns a new Plane the normal vector to this plane at the given origin point.
  75612. * Note : the vector "normal" is updated because normalized.
  75613. */
  75614. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  75615. /**
  75616. * Calculates the distance from a plane and a point
  75617. * @param origin origin of the plane to be constructed
  75618. * @param normal normal of the plane to be constructed
  75619. * @param point point to calculate distance to
  75620. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  75621. */
  75622. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  75623. }
  75624. }
  75625. declare module BABYLON {
  75626. /**
  75627. * Class used to store bounding sphere information
  75628. */
  75629. export class BoundingSphere {
  75630. /**
  75631. * Gets the center of the bounding sphere in local space
  75632. */
  75633. readonly center: Vector3;
  75634. /**
  75635. * Radius of the bounding sphere in local space
  75636. */
  75637. radius: number;
  75638. /**
  75639. * Gets the center of the bounding sphere in world space
  75640. */
  75641. readonly centerWorld: Vector3;
  75642. /**
  75643. * Radius of the bounding sphere in world space
  75644. */
  75645. radiusWorld: number;
  75646. /**
  75647. * Gets the minimum vector in local space
  75648. */
  75649. readonly minimum: Vector3;
  75650. /**
  75651. * Gets the maximum vector in local space
  75652. */
  75653. readonly maximum: Vector3;
  75654. private _worldMatrix;
  75655. private static readonly TmpVector3;
  75656. /**
  75657. * Creates a new bounding sphere
  75658. * @param min defines the minimum vector (in local space)
  75659. * @param max defines the maximum vector (in local space)
  75660. * @param worldMatrix defines the new world matrix
  75661. */
  75662. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  75663. /**
  75664. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  75665. * @param min defines the new minimum vector (in local space)
  75666. * @param max defines the new maximum vector (in local space)
  75667. * @param worldMatrix defines the new world matrix
  75668. */
  75669. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  75670. /**
  75671. * Scale the current bounding sphere by applying a scale factor
  75672. * @param factor defines the scale factor to apply
  75673. * @returns the current bounding box
  75674. */
  75675. scale(factor: number): BoundingSphere;
  75676. /**
  75677. * Gets the world matrix of the bounding box
  75678. * @returns a matrix
  75679. */
  75680. getWorldMatrix(): DeepImmutable<Matrix>;
  75681. /** @hidden */
  75682. _update(worldMatrix: DeepImmutable<Matrix>): void;
  75683. /**
  75684. * Tests if the bounding sphere is intersecting the frustum planes
  75685. * @param frustumPlanes defines the frustum planes to test
  75686. * @returns true if there is an intersection
  75687. */
  75688. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75689. /**
  75690. * Tests if the bounding sphere center is in between the frustum planes.
  75691. * Used for optimistic fast inclusion.
  75692. * @param frustumPlanes defines the frustum planes to test
  75693. * @returns true if the sphere center is in between the frustum planes
  75694. */
  75695. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75696. /**
  75697. * Tests if a point is inside the bounding sphere
  75698. * @param point defines the point to test
  75699. * @returns true if the point is inside the bounding sphere
  75700. */
  75701. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  75702. /**
  75703. * Checks if two sphere intersct
  75704. * @param sphere0 sphere 0
  75705. * @param sphere1 sphere 1
  75706. * @returns true if the speres intersect
  75707. */
  75708. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  75709. }
  75710. }
  75711. declare module BABYLON {
  75712. /**
  75713. * Class used to store bounding box information
  75714. */
  75715. export class BoundingBox implements ICullable {
  75716. /**
  75717. * Gets the 8 vectors representing the bounding box in local space
  75718. */
  75719. readonly vectors: Vector3[];
  75720. /**
  75721. * Gets the center of the bounding box in local space
  75722. */
  75723. readonly center: Vector3;
  75724. /**
  75725. * Gets the center of the bounding box in world space
  75726. */
  75727. readonly centerWorld: Vector3;
  75728. /**
  75729. * Gets the extend size in local space
  75730. */
  75731. readonly extendSize: Vector3;
  75732. /**
  75733. * Gets the extend size in world space
  75734. */
  75735. readonly extendSizeWorld: Vector3;
  75736. /**
  75737. * Gets the OBB (object bounding box) directions
  75738. */
  75739. readonly directions: Vector3[];
  75740. /**
  75741. * Gets the 8 vectors representing the bounding box in world space
  75742. */
  75743. readonly vectorsWorld: Vector3[];
  75744. /**
  75745. * Gets the minimum vector in world space
  75746. */
  75747. readonly minimumWorld: Vector3;
  75748. /**
  75749. * Gets the maximum vector in world space
  75750. */
  75751. readonly maximumWorld: Vector3;
  75752. /**
  75753. * Gets the minimum vector in local space
  75754. */
  75755. readonly minimum: Vector3;
  75756. /**
  75757. * Gets the maximum vector in local space
  75758. */
  75759. readonly maximum: Vector3;
  75760. private _worldMatrix;
  75761. private static readonly TmpVector3;
  75762. /**
  75763. * @hidden
  75764. */
  75765. _tag: number;
  75766. /**
  75767. * Creates a new bounding box
  75768. * @param min defines the minimum vector (in local space)
  75769. * @param max defines the maximum vector (in local space)
  75770. * @param worldMatrix defines the new world matrix
  75771. */
  75772. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  75773. /**
  75774. * Recreates the entire bounding box from scratch as if we call the constructor in place
  75775. * @param min defines the new minimum vector (in local space)
  75776. * @param max defines the new maximum vector (in local space)
  75777. * @param worldMatrix defines the new world matrix
  75778. */
  75779. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  75780. /**
  75781. * Scale the current bounding box by applying a scale factor
  75782. * @param factor defines the scale factor to apply
  75783. * @returns the current bounding box
  75784. */
  75785. scale(factor: number): BoundingBox;
  75786. /**
  75787. * Gets the world matrix of the bounding box
  75788. * @returns a matrix
  75789. */
  75790. getWorldMatrix(): DeepImmutable<Matrix>;
  75791. /** @hidden */
  75792. _update(world: DeepImmutable<Matrix>): void;
  75793. /**
  75794. * Tests if the bounding box is intersecting the frustum planes
  75795. * @param frustumPlanes defines the frustum planes to test
  75796. * @returns true if there is an intersection
  75797. */
  75798. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75799. /**
  75800. * Tests if the bounding box is entirely inside the frustum planes
  75801. * @param frustumPlanes defines the frustum planes to test
  75802. * @returns true if there is an inclusion
  75803. */
  75804. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75805. /**
  75806. * Tests if a point is inside the bounding box
  75807. * @param point defines the point to test
  75808. * @returns true if the point is inside the bounding box
  75809. */
  75810. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  75811. /**
  75812. * Tests if the bounding box intersects with a bounding sphere
  75813. * @param sphere defines the sphere to test
  75814. * @returns true if there is an intersection
  75815. */
  75816. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  75817. /**
  75818. * Tests if the bounding box intersects with a box defined by a min and max vectors
  75819. * @param min defines the min vector to use
  75820. * @param max defines the max vector to use
  75821. * @returns true if there is an intersection
  75822. */
  75823. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  75824. /**
  75825. * Tests if two bounding boxes are intersections
  75826. * @param box0 defines the first box to test
  75827. * @param box1 defines the second box to test
  75828. * @returns true if there is an intersection
  75829. */
  75830. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  75831. /**
  75832. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  75833. * @param minPoint defines the minimum vector of the bounding box
  75834. * @param maxPoint defines the maximum vector of the bounding box
  75835. * @param sphereCenter defines the sphere center
  75836. * @param sphereRadius defines the sphere radius
  75837. * @returns true if there is an intersection
  75838. */
  75839. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  75840. /**
  75841. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  75842. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  75843. * @param frustumPlanes defines the frustum planes to test
  75844. * @return true if there is an inclusion
  75845. */
  75846. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75847. /**
  75848. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  75849. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  75850. * @param frustumPlanes defines the frustum planes to test
  75851. * @return true if there is an intersection
  75852. */
  75853. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75854. }
  75855. }
  75856. declare module BABYLON {
  75857. /** @hidden */
  75858. export class Collider {
  75859. /** Define if a collision was found */
  75860. collisionFound: boolean;
  75861. /**
  75862. * Define last intersection point in local space
  75863. */
  75864. intersectionPoint: Vector3;
  75865. /**
  75866. * Define last collided mesh
  75867. */
  75868. collidedMesh: Nullable<AbstractMesh>;
  75869. private _collisionPoint;
  75870. private _planeIntersectionPoint;
  75871. private _tempVector;
  75872. private _tempVector2;
  75873. private _tempVector3;
  75874. private _tempVector4;
  75875. private _edge;
  75876. private _baseToVertex;
  75877. private _destinationPoint;
  75878. private _slidePlaneNormal;
  75879. private _displacementVector;
  75880. /** @hidden */
  75881. _radius: Vector3;
  75882. /** @hidden */
  75883. _retry: number;
  75884. private _velocity;
  75885. private _basePoint;
  75886. private _epsilon;
  75887. /** @hidden */
  75888. _velocityWorldLength: number;
  75889. /** @hidden */
  75890. _basePointWorld: Vector3;
  75891. private _velocityWorld;
  75892. private _normalizedVelocity;
  75893. /** @hidden */
  75894. _initialVelocity: Vector3;
  75895. /** @hidden */
  75896. _initialPosition: Vector3;
  75897. private _nearestDistance;
  75898. private _collisionMask;
  75899. collisionMask: number;
  75900. /**
  75901. * Gets the plane normal used to compute the sliding response (in local space)
  75902. */
  75903. readonly slidePlaneNormal: Vector3;
  75904. /** @hidden */
  75905. _initialize(source: Vector3, dir: Vector3, e: number): void;
  75906. /** @hidden */
  75907. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  75908. /** @hidden */
  75909. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  75910. /** @hidden */
  75911. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  75912. /** @hidden */
  75913. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  75914. /** @hidden */
  75915. _getResponse(pos: Vector3, vel: Vector3): void;
  75916. }
  75917. }
  75918. declare module BABYLON {
  75919. /**
  75920. * Interface for cullable objects
  75921. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  75922. */
  75923. export interface ICullable {
  75924. /**
  75925. * Checks if the object or part of the object is in the frustum
  75926. * @param frustumPlanes Camera near/planes
  75927. * @returns true if the object is in frustum otherwise false
  75928. */
  75929. isInFrustum(frustumPlanes: Plane[]): boolean;
  75930. /**
  75931. * Checks if a cullable object (mesh...) is in the camera frustum
  75932. * Unlike isInFrustum this cheks the full bounding box
  75933. * @param frustumPlanes Camera near/planes
  75934. * @returns true if the object is in frustum otherwise false
  75935. */
  75936. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  75937. }
  75938. /**
  75939. * Info for a bounding data of a mesh
  75940. */
  75941. export class BoundingInfo implements ICullable {
  75942. /**
  75943. * Bounding box for the mesh
  75944. */
  75945. readonly boundingBox: BoundingBox;
  75946. /**
  75947. * Bounding sphere for the mesh
  75948. */
  75949. readonly boundingSphere: BoundingSphere;
  75950. private _isLocked;
  75951. private static readonly TmpVector3;
  75952. /**
  75953. * Constructs bounding info
  75954. * @param minimum min vector of the bounding box/sphere
  75955. * @param maximum max vector of the bounding box/sphere
  75956. * @param worldMatrix defines the new world matrix
  75957. */
  75958. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  75959. /**
  75960. * Recreates the entire bounding info from scratch as if we call the constructor in place
  75961. * @param min defines the new minimum vector (in local space)
  75962. * @param max defines the new maximum vector (in local space)
  75963. * @param worldMatrix defines the new world matrix
  75964. */
  75965. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  75966. /**
  75967. * min vector of the bounding box/sphere
  75968. */
  75969. readonly minimum: Vector3;
  75970. /**
  75971. * max vector of the bounding box/sphere
  75972. */
  75973. readonly maximum: Vector3;
  75974. /**
  75975. * If the info is locked and won't be updated to avoid perf overhead
  75976. */
  75977. isLocked: boolean;
  75978. /**
  75979. * Updates the bounding sphere and box
  75980. * @param world world matrix to be used to update
  75981. */
  75982. update(world: DeepImmutable<Matrix>): void;
  75983. /**
  75984. * Recreate the bounding info to be centered around a specific point given a specific extend.
  75985. * @param center New center of the bounding info
  75986. * @param extend New extend of the bounding info
  75987. * @returns the current bounding info
  75988. */
  75989. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  75990. /**
  75991. * Scale the current bounding info by applying a scale factor
  75992. * @param factor defines the scale factor to apply
  75993. * @returns the current bounding info
  75994. */
  75995. scale(factor: number): BoundingInfo;
  75996. /**
  75997. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  75998. * @param frustumPlanes defines the frustum to test
  75999. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  76000. * @returns true if the bounding info is in the frustum planes
  76001. */
  76002. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  76003. /**
  76004. * Gets the world distance between the min and max points of the bounding box
  76005. */
  76006. readonly diagonalLength: number;
  76007. /**
  76008. * Checks if a cullable object (mesh...) is in the camera frustum
  76009. * Unlike isInFrustum this cheks the full bounding box
  76010. * @param frustumPlanes Camera near/planes
  76011. * @returns true if the object is in frustum otherwise false
  76012. */
  76013. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  76014. /** @hidden */
  76015. _checkCollision(collider: Collider): boolean;
  76016. /**
  76017. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  76018. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  76019. * @param point the point to check intersection with
  76020. * @returns if the point intersects
  76021. */
  76022. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  76023. /**
  76024. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  76025. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  76026. * @param boundingInfo the bounding info to check intersection with
  76027. * @param precise if the intersection should be done using OBB
  76028. * @returns if the bounding info intersects
  76029. */
  76030. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  76031. }
  76032. }
  76033. declare module BABYLON {
  76034. /**
  76035. * Extracts minimum and maximum values from a list of indexed positions
  76036. * @param positions defines the positions to use
  76037. * @param indices defines the indices to the positions
  76038. * @param indexStart defines the start index
  76039. * @param indexCount defines the end index
  76040. * @param bias defines bias value to add to the result
  76041. * @return minimum and maximum values
  76042. */
  76043. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  76044. minimum: Vector3;
  76045. maximum: Vector3;
  76046. };
  76047. /**
  76048. * Extracts minimum and maximum values from a list of positions
  76049. * @param positions defines the positions to use
  76050. * @param start defines the start index in the positions array
  76051. * @param count defines the number of positions to handle
  76052. * @param bias defines bias value to add to the result
  76053. * @param stride defines the stride size to use (distance between two positions in the positions array)
  76054. * @return minimum and maximum values
  76055. */
  76056. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  76057. minimum: Vector3;
  76058. maximum: Vector3;
  76059. };
  76060. }
  76061. declare module BABYLON {
  76062. /** @hidden */
  76063. export class WebGLDataBuffer extends DataBuffer {
  76064. private _buffer;
  76065. constructor(resource: WebGLBuffer);
  76066. readonly underlyingResource: any;
  76067. }
  76068. }
  76069. declare module BABYLON {
  76070. /** @hidden */
  76071. export class WebGLPipelineContext implements IPipelineContext {
  76072. engine: ThinEngine;
  76073. program: Nullable<WebGLProgram>;
  76074. context?: WebGLRenderingContext;
  76075. vertexShader?: WebGLShader;
  76076. fragmentShader?: WebGLShader;
  76077. isParallelCompiled: boolean;
  76078. onCompiled?: () => void;
  76079. transformFeedback?: WebGLTransformFeedback | null;
  76080. readonly isAsync: boolean;
  76081. readonly isReady: boolean;
  76082. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  76083. }
  76084. }
  76085. declare module BABYLON {
  76086. interface ThinEngine {
  76087. /**
  76088. * Create an uniform buffer
  76089. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  76090. * @param elements defines the content of the uniform buffer
  76091. * @returns the webGL uniform buffer
  76092. */
  76093. createUniformBuffer(elements: FloatArray): DataBuffer;
  76094. /**
  76095. * Create a dynamic uniform buffer
  76096. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  76097. * @param elements defines the content of the uniform buffer
  76098. * @returns the webGL uniform buffer
  76099. */
  76100. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  76101. /**
  76102. * Update an existing uniform buffer
  76103. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  76104. * @param uniformBuffer defines the target uniform buffer
  76105. * @param elements defines the content to update
  76106. * @param offset defines the offset in the uniform buffer where update should start
  76107. * @param count defines the size of the data to update
  76108. */
  76109. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  76110. /**
  76111. * Bind an uniform buffer to the current webGL context
  76112. * @param buffer defines the buffer to bind
  76113. */
  76114. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  76115. /**
  76116. * Bind a buffer to the current webGL context at a given location
  76117. * @param buffer defines the buffer to bind
  76118. * @param location defines the index where to bind the buffer
  76119. */
  76120. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  76121. /**
  76122. * Bind a specific block at a given index in a specific shader program
  76123. * @param pipelineContext defines the pipeline context to use
  76124. * @param blockName defines the block name
  76125. * @param index defines the index where to bind the block
  76126. */
  76127. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  76128. }
  76129. }
  76130. declare module BABYLON {
  76131. /**
  76132. * Uniform buffer objects.
  76133. *
  76134. * Handles blocks of uniform on the GPU.
  76135. *
  76136. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  76137. *
  76138. * For more information, please refer to :
  76139. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  76140. */
  76141. export class UniformBuffer {
  76142. private _engine;
  76143. private _buffer;
  76144. private _data;
  76145. private _bufferData;
  76146. private _dynamic?;
  76147. private _uniformLocations;
  76148. private _uniformSizes;
  76149. private _uniformLocationPointer;
  76150. private _needSync;
  76151. private _noUBO;
  76152. private _currentEffect;
  76153. /** @hidden */
  76154. _alreadyBound: boolean;
  76155. private static _MAX_UNIFORM_SIZE;
  76156. private static _tempBuffer;
  76157. /**
  76158. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  76159. * This is dynamic to allow compat with webgl 1 and 2.
  76160. * You will need to pass the name of the uniform as well as the value.
  76161. */
  76162. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  76163. /**
  76164. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  76165. * This is dynamic to allow compat with webgl 1 and 2.
  76166. * You will need to pass the name of the uniform as well as the value.
  76167. */
  76168. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  76169. /**
  76170. * Lambda to Update a single float in a uniform buffer.
  76171. * This is dynamic to allow compat with webgl 1 and 2.
  76172. * You will need to pass the name of the uniform as well as the value.
  76173. */
  76174. updateFloat: (name: string, x: number) => void;
  76175. /**
  76176. * Lambda to Update a vec2 of float in a uniform buffer.
  76177. * This is dynamic to allow compat with webgl 1 and 2.
  76178. * You will need to pass the name of the uniform as well as the value.
  76179. */
  76180. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  76181. /**
  76182. * Lambda to Update a vec3 of float in a uniform buffer.
  76183. * This is dynamic to allow compat with webgl 1 and 2.
  76184. * You will need to pass the name of the uniform as well as the value.
  76185. */
  76186. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  76187. /**
  76188. * Lambda to Update a vec4 of float in a uniform buffer.
  76189. * This is dynamic to allow compat with webgl 1 and 2.
  76190. * You will need to pass the name of the uniform as well as the value.
  76191. */
  76192. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  76193. /**
  76194. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  76195. * This is dynamic to allow compat with webgl 1 and 2.
  76196. * You will need to pass the name of the uniform as well as the value.
  76197. */
  76198. updateMatrix: (name: string, mat: Matrix) => void;
  76199. /**
  76200. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  76201. * This is dynamic to allow compat with webgl 1 and 2.
  76202. * You will need to pass the name of the uniform as well as the value.
  76203. */
  76204. updateVector3: (name: string, vector: Vector3) => void;
  76205. /**
  76206. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  76207. * This is dynamic to allow compat with webgl 1 and 2.
  76208. * You will need to pass the name of the uniform as well as the value.
  76209. */
  76210. updateVector4: (name: string, vector: Vector4) => void;
  76211. /**
  76212. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  76213. * This is dynamic to allow compat with webgl 1 and 2.
  76214. * You will need to pass the name of the uniform as well as the value.
  76215. */
  76216. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  76217. /**
  76218. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  76219. * This is dynamic to allow compat with webgl 1 and 2.
  76220. * You will need to pass the name of the uniform as well as the value.
  76221. */
  76222. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  76223. /**
  76224. * Instantiates a new Uniform buffer objects.
  76225. *
  76226. * Handles blocks of uniform on the GPU.
  76227. *
  76228. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  76229. *
  76230. * For more information, please refer to :
  76231. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  76232. * @param engine Define the engine the buffer is associated with
  76233. * @param data Define the data contained in the buffer
  76234. * @param dynamic Define if the buffer is updatable
  76235. */
  76236. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  76237. /**
  76238. * Indicates if the buffer is using the WebGL2 UBO implementation,
  76239. * or just falling back on setUniformXXX calls.
  76240. */
  76241. readonly useUbo: boolean;
  76242. /**
  76243. * Indicates if the WebGL underlying uniform buffer is in sync
  76244. * with the javascript cache data.
  76245. */
  76246. readonly isSync: boolean;
  76247. /**
  76248. * Indicates if the WebGL underlying uniform buffer is dynamic.
  76249. * Also, a dynamic UniformBuffer will disable cache verification and always
  76250. * update the underlying WebGL uniform buffer to the GPU.
  76251. * @returns if Dynamic, otherwise false
  76252. */
  76253. isDynamic(): boolean;
  76254. /**
  76255. * The data cache on JS side.
  76256. * @returns the underlying data as a float array
  76257. */
  76258. getData(): Float32Array;
  76259. /**
  76260. * The underlying WebGL Uniform buffer.
  76261. * @returns the webgl buffer
  76262. */
  76263. getBuffer(): Nullable<DataBuffer>;
  76264. /**
  76265. * std140 layout specifies how to align data within an UBO structure.
  76266. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  76267. * for specs.
  76268. */
  76269. private _fillAlignment;
  76270. /**
  76271. * Adds an uniform in the buffer.
  76272. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  76273. * for the layout to be correct !
  76274. * @param name Name of the uniform, as used in the uniform block in the shader.
  76275. * @param size Data size, or data directly.
  76276. */
  76277. addUniform(name: string, size: number | number[]): void;
  76278. /**
  76279. * Adds a Matrix 4x4 to the uniform buffer.
  76280. * @param name Name of the uniform, as used in the uniform block in the shader.
  76281. * @param mat A 4x4 matrix.
  76282. */
  76283. addMatrix(name: string, mat: Matrix): void;
  76284. /**
  76285. * Adds a vec2 to the uniform buffer.
  76286. * @param name Name of the uniform, as used in the uniform block in the shader.
  76287. * @param x Define the x component value of the vec2
  76288. * @param y Define the y component value of the vec2
  76289. */
  76290. addFloat2(name: string, x: number, y: number): void;
  76291. /**
  76292. * Adds a vec3 to the uniform buffer.
  76293. * @param name Name of the uniform, as used in the uniform block in the shader.
  76294. * @param x Define the x component value of the vec3
  76295. * @param y Define the y component value of the vec3
  76296. * @param z Define the z component value of the vec3
  76297. */
  76298. addFloat3(name: string, x: number, y: number, z: number): void;
  76299. /**
  76300. * Adds a vec3 to the uniform buffer.
  76301. * @param name Name of the uniform, as used in the uniform block in the shader.
  76302. * @param color Define the vec3 from a Color
  76303. */
  76304. addColor3(name: string, color: Color3): void;
  76305. /**
  76306. * Adds a vec4 to the uniform buffer.
  76307. * @param name Name of the uniform, as used in the uniform block in the shader.
  76308. * @param color Define the rgb components from a Color
  76309. * @param alpha Define the a component of the vec4
  76310. */
  76311. addColor4(name: string, color: Color3, alpha: number): void;
  76312. /**
  76313. * Adds a vec3 to the uniform buffer.
  76314. * @param name Name of the uniform, as used in the uniform block in the shader.
  76315. * @param vector Define the vec3 components from a Vector
  76316. */
  76317. addVector3(name: string, vector: Vector3): void;
  76318. /**
  76319. * Adds a Matrix 3x3 to the uniform buffer.
  76320. * @param name Name of the uniform, as used in the uniform block in the shader.
  76321. */
  76322. addMatrix3x3(name: string): void;
  76323. /**
  76324. * Adds a Matrix 2x2 to the uniform buffer.
  76325. * @param name Name of the uniform, as used in the uniform block in the shader.
  76326. */
  76327. addMatrix2x2(name: string): void;
  76328. /**
  76329. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  76330. */
  76331. create(): void;
  76332. /** @hidden */
  76333. _rebuild(): void;
  76334. /**
  76335. * Updates the WebGL Uniform Buffer on the GPU.
  76336. * If the `dynamic` flag is set to true, no cache comparison is done.
  76337. * Otherwise, the buffer will be updated only if the cache differs.
  76338. */
  76339. update(): void;
  76340. /**
  76341. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  76342. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  76343. * @param data Define the flattened data
  76344. * @param size Define the size of the data.
  76345. */
  76346. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  76347. private _valueCache;
  76348. private _cacheMatrix;
  76349. private _updateMatrix3x3ForUniform;
  76350. private _updateMatrix3x3ForEffect;
  76351. private _updateMatrix2x2ForEffect;
  76352. private _updateMatrix2x2ForUniform;
  76353. private _updateFloatForEffect;
  76354. private _updateFloatForUniform;
  76355. private _updateFloat2ForEffect;
  76356. private _updateFloat2ForUniform;
  76357. private _updateFloat3ForEffect;
  76358. private _updateFloat3ForUniform;
  76359. private _updateFloat4ForEffect;
  76360. private _updateFloat4ForUniform;
  76361. private _updateMatrixForEffect;
  76362. private _updateMatrixForUniform;
  76363. private _updateVector3ForEffect;
  76364. private _updateVector3ForUniform;
  76365. private _updateVector4ForEffect;
  76366. private _updateVector4ForUniform;
  76367. private _updateColor3ForEffect;
  76368. private _updateColor3ForUniform;
  76369. private _updateColor4ForEffect;
  76370. private _updateColor4ForUniform;
  76371. /**
  76372. * Sets a sampler uniform on the effect.
  76373. * @param name Define the name of the sampler.
  76374. * @param texture Define the texture to set in the sampler
  76375. */
  76376. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  76377. /**
  76378. * Directly updates the value of the uniform in the cache AND on the GPU.
  76379. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  76380. * @param data Define the flattened data
  76381. */
  76382. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  76383. /**
  76384. * Binds this uniform buffer to an effect.
  76385. * @param effect Define the effect to bind the buffer to
  76386. * @param name Name of the uniform block in the shader.
  76387. */
  76388. bindToEffect(effect: Effect, name: string): void;
  76389. /**
  76390. * Disposes the uniform buffer.
  76391. */
  76392. dispose(): void;
  76393. }
  76394. }
  76395. declare module BABYLON {
  76396. /**
  76397. * Enum that determines the text-wrapping mode to use.
  76398. */
  76399. export enum InspectableType {
  76400. /**
  76401. * Checkbox for booleans
  76402. */
  76403. Checkbox = 0,
  76404. /**
  76405. * Sliders for numbers
  76406. */
  76407. Slider = 1,
  76408. /**
  76409. * Vector3
  76410. */
  76411. Vector3 = 2,
  76412. /**
  76413. * Quaternions
  76414. */
  76415. Quaternion = 3,
  76416. /**
  76417. * Color3
  76418. */
  76419. Color3 = 4,
  76420. /**
  76421. * String
  76422. */
  76423. String = 5
  76424. }
  76425. /**
  76426. * Interface used to define custom inspectable properties.
  76427. * This interface is used by the inspector to display custom property grids
  76428. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  76429. */
  76430. export interface IInspectable {
  76431. /**
  76432. * Gets the label to display
  76433. */
  76434. label: string;
  76435. /**
  76436. * Gets the name of the property to edit
  76437. */
  76438. propertyName: string;
  76439. /**
  76440. * Gets the type of the editor to use
  76441. */
  76442. type: InspectableType;
  76443. /**
  76444. * Gets the minimum value of the property when using in "slider" mode
  76445. */
  76446. min?: number;
  76447. /**
  76448. * Gets the maximum value of the property when using in "slider" mode
  76449. */
  76450. max?: number;
  76451. /**
  76452. * Gets the setp to use when using in "slider" mode
  76453. */
  76454. step?: number;
  76455. }
  76456. }
  76457. declare module BABYLON {
  76458. /**
  76459. * Class used to provide helper for timing
  76460. */
  76461. export class TimingTools {
  76462. /**
  76463. * Polyfill for setImmediate
  76464. * @param action defines the action to execute after the current execution block
  76465. */
  76466. static SetImmediate(action: () => void): void;
  76467. }
  76468. }
  76469. declare module BABYLON {
  76470. /**
  76471. * Class used to enable instatition of objects by class name
  76472. */
  76473. export class InstantiationTools {
  76474. /**
  76475. * Use this object to register external classes like custom textures or material
  76476. * to allow the laoders to instantiate them
  76477. */
  76478. static RegisteredExternalClasses: {
  76479. [key: string]: Object;
  76480. };
  76481. /**
  76482. * Tries to instantiate a new object from a given class name
  76483. * @param className defines the class name to instantiate
  76484. * @returns the new object or null if the system was not able to do the instantiation
  76485. */
  76486. static Instantiate(className: string): any;
  76487. }
  76488. }
  76489. declare module BABYLON {
  76490. /**
  76491. * Define options used to create a depth texture
  76492. */
  76493. export class DepthTextureCreationOptions {
  76494. /** Specifies whether or not a stencil should be allocated in the texture */
  76495. generateStencil?: boolean;
  76496. /** Specifies whether or not bilinear filtering is enable on the texture */
  76497. bilinearFiltering?: boolean;
  76498. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  76499. comparisonFunction?: number;
  76500. /** Specifies if the created texture is a cube texture */
  76501. isCube?: boolean;
  76502. }
  76503. }
  76504. declare module BABYLON {
  76505. interface ThinEngine {
  76506. /**
  76507. * Creates a depth stencil cube texture.
  76508. * This is only available in WebGL 2.
  76509. * @param size The size of face edge in the cube texture.
  76510. * @param options The options defining the cube texture.
  76511. * @returns The cube texture
  76512. */
  76513. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  76514. /**
  76515. * Creates a cube texture
  76516. * @param rootUrl defines the url where the files to load is located
  76517. * @param scene defines the current scene
  76518. * @param files defines the list of files to load (1 per face)
  76519. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  76520. * @param onLoad defines an optional callback raised when the texture is loaded
  76521. * @param onError defines an optional callback raised if there is an issue to load the texture
  76522. * @param format defines the format of the data
  76523. * @param forcedExtension defines the extension to use to pick the right loader
  76524. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  76525. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  76526. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  76527. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  76528. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  76529. * @returns the cube texture as an InternalTexture
  76530. */
  76531. 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;
  76532. /**
  76533. * Creates a cube texture
  76534. * @param rootUrl defines the url where the files to load is located
  76535. * @param scene defines the current scene
  76536. * @param files defines the list of files to load (1 per face)
  76537. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  76538. * @param onLoad defines an optional callback raised when the texture is loaded
  76539. * @param onError defines an optional callback raised if there is an issue to load the texture
  76540. * @param format defines the format of the data
  76541. * @param forcedExtension defines the extension to use to pick the right loader
  76542. * @returns the cube texture as an InternalTexture
  76543. */
  76544. 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;
  76545. /**
  76546. * Creates a cube texture
  76547. * @param rootUrl defines the url where the files to load is located
  76548. * @param scene defines the current scene
  76549. * @param files defines the list of files to load (1 per face)
  76550. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  76551. * @param onLoad defines an optional callback raised when the texture is loaded
  76552. * @param onError defines an optional callback raised if there is an issue to load the texture
  76553. * @param format defines the format of the data
  76554. * @param forcedExtension defines the extension to use to pick the right loader
  76555. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  76556. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  76557. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  76558. * @returns the cube texture as an InternalTexture
  76559. */
  76560. 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;
  76561. /** @hidden */
  76562. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  76563. /** @hidden */
  76564. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  76565. /** @hidden */
  76566. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  76567. /** @hidden */
  76568. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  76569. /**
  76570. * @hidden
  76571. */
  76572. _setCubeMapTextureParams(loadMipmap: boolean): void;
  76573. }
  76574. }
  76575. declare module BABYLON {
  76576. /**
  76577. * Class for creating a cube texture
  76578. */
  76579. export class CubeTexture extends BaseTexture {
  76580. private _delayedOnLoad;
  76581. /**
  76582. * The url of the texture
  76583. */
  76584. url: string;
  76585. /**
  76586. * Gets or sets the center of the bounding box associated with the cube texture.
  76587. * It must define where the camera used to render the texture was set
  76588. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  76589. */
  76590. boundingBoxPosition: Vector3;
  76591. private _boundingBoxSize;
  76592. /**
  76593. * Gets or sets the size of the bounding box associated with the cube texture
  76594. * When defined, the cubemap will switch to local mode
  76595. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  76596. * @example https://www.babylonjs-playground.com/#RNASML
  76597. */
  76598. /**
  76599. * Returns the bounding box size
  76600. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  76601. */
  76602. boundingBoxSize: Vector3;
  76603. protected _rotationY: number;
  76604. /**
  76605. * Sets texture matrix rotation angle around Y axis in radians.
  76606. */
  76607. /**
  76608. * Gets texture matrix rotation angle around Y axis radians.
  76609. */
  76610. rotationY: number;
  76611. /**
  76612. * Are mip maps generated for this texture or not.
  76613. */
  76614. readonly noMipmap: boolean;
  76615. private _noMipmap;
  76616. private _files;
  76617. protected _forcedExtension: Nullable<string>;
  76618. private _extensions;
  76619. private _textureMatrix;
  76620. private _format;
  76621. private _createPolynomials;
  76622. /** @hidden */
  76623. _prefiltered: boolean;
  76624. /**
  76625. * Creates a cube texture from an array of image urls
  76626. * @param files defines an array of image urls
  76627. * @param scene defines the hosting scene
  76628. * @param noMipmap specifies if mip maps are not used
  76629. * @returns a cube texture
  76630. */
  76631. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  76632. /**
  76633. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  76634. * @param url defines the url of the prefiltered texture
  76635. * @param scene defines the scene the texture is attached to
  76636. * @param forcedExtension defines the extension of the file if different from the url
  76637. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  76638. * @return the prefiltered texture
  76639. */
  76640. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  76641. /**
  76642. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  76643. * as prefiltered data.
  76644. * @param rootUrl defines the url of the texture or the root name of the six images
  76645. * @param scene defines the scene the texture is attached to
  76646. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  76647. * @param noMipmap defines if mipmaps should be created or not
  76648. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  76649. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  76650. * @param onError defines a callback triggered in case of error during load
  76651. * @param format defines the internal format to use for the texture once loaded
  76652. * @param prefiltered defines whether or not the texture is created from prefiltered data
  76653. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  76654. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  76655. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  76656. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  76657. * @return the cube texture
  76658. */
  76659. 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);
  76660. /**
  76661. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  76662. */
  76663. readonly isPrefiltered: boolean;
  76664. /**
  76665. * Get the current class name of the texture useful for serialization or dynamic coding.
  76666. * @returns "CubeTexture"
  76667. */
  76668. getClassName(): string;
  76669. /**
  76670. * Update the url (and optional buffer) of this texture if url was null during construction.
  76671. * @param url the url of the texture
  76672. * @param forcedExtension defines the extension to use
  76673. * @param onLoad callback called when the texture is loaded (defaults to null)
  76674. */
  76675. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  76676. /**
  76677. * Delays loading of the cube texture
  76678. * @param forcedExtension defines the extension to use
  76679. */
  76680. delayLoad(forcedExtension?: string): void;
  76681. /**
  76682. * Returns the reflection texture matrix
  76683. * @returns the reflection texture matrix
  76684. */
  76685. getReflectionTextureMatrix(): Matrix;
  76686. /**
  76687. * Sets the reflection texture matrix
  76688. * @param value Reflection texture matrix
  76689. */
  76690. setReflectionTextureMatrix(value: Matrix): void;
  76691. /**
  76692. * Parses text to create a cube texture
  76693. * @param parsedTexture define the serialized text to read from
  76694. * @param scene defines the hosting scene
  76695. * @param rootUrl defines the root url of the cube texture
  76696. * @returns a cube texture
  76697. */
  76698. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  76699. /**
  76700. * Makes a clone, or deep copy, of the cube texture
  76701. * @returns a new cube texture
  76702. */
  76703. clone(): CubeTexture;
  76704. }
  76705. }
  76706. declare module BABYLON {
  76707. /**
  76708. * Manages the defines for the Material
  76709. */
  76710. export class MaterialDefines {
  76711. /** @hidden */
  76712. protected _keys: string[];
  76713. private _isDirty;
  76714. /** @hidden */
  76715. _renderId: number;
  76716. /** @hidden */
  76717. _areLightsDirty: boolean;
  76718. /** @hidden */
  76719. _areLightsDisposed: boolean;
  76720. /** @hidden */
  76721. _areAttributesDirty: boolean;
  76722. /** @hidden */
  76723. _areTexturesDirty: boolean;
  76724. /** @hidden */
  76725. _areFresnelDirty: boolean;
  76726. /** @hidden */
  76727. _areMiscDirty: boolean;
  76728. /** @hidden */
  76729. _areImageProcessingDirty: boolean;
  76730. /** @hidden */
  76731. _normals: boolean;
  76732. /** @hidden */
  76733. _uvs: boolean;
  76734. /** @hidden */
  76735. _needNormals: boolean;
  76736. /** @hidden */
  76737. _needUVs: boolean;
  76738. [id: string]: any;
  76739. /**
  76740. * Specifies if the material needs to be re-calculated
  76741. */
  76742. readonly isDirty: boolean;
  76743. /**
  76744. * Marks the material to indicate that it has been re-calculated
  76745. */
  76746. markAsProcessed(): void;
  76747. /**
  76748. * Marks the material to indicate that it needs to be re-calculated
  76749. */
  76750. markAsUnprocessed(): void;
  76751. /**
  76752. * Marks the material to indicate all of its defines need to be re-calculated
  76753. */
  76754. markAllAsDirty(): void;
  76755. /**
  76756. * Marks the material to indicate that image processing needs to be re-calculated
  76757. */
  76758. markAsImageProcessingDirty(): void;
  76759. /**
  76760. * Marks the material to indicate the lights need to be re-calculated
  76761. * @param disposed Defines whether the light is dirty due to dispose or not
  76762. */
  76763. markAsLightDirty(disposed?: boolean): void;
  76764. /**
  76765. * Marks the attribute state as changed
  76766. */
  76767. markAsAttributesDirty(): void;
  76768. /**
  76769. * Marks the texture state as changed
  76770. */
  76771. markAsTexturesDirty(): void;
  76772. /**
  76773. * Marks the fresnel state as changed
  76774. */
  76775. markAsFresnelDirty(): void;
  76776. /**
  76777. * Marks the misc state as changed
  76778. */
  76779. markAsMiscDirty(): void;
  76780. /**
  76781. * Rebuilds the material defines
  76782. */
  76783. rebuild(): void;
  76784. /**
  76785. * Specifies if two material defines are equal
  76786. * @param other - A material define instance to compare to
  76787. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  76788. */
  76789. isEqual(other: MaterialDefines): boolean;
  76790. /**
  76791. * Clones this instance's defines to another instance
  76792. * @param other - material defines to clone values to
  76793. */
  76794. cloneTo(other: MaterialDefines): void;
  76795. /**
  76796. * Resets the material define values
  76797. */
  76798. reset(): void;
  76799. /**
  76800. * Converts the material define values to a string
  76801. * @returns - String of material define information
  76802. */
  76803. toString(): string;
  76804. }
  76805. }
  76806. declare module BABYLON {
  76807. /**
  76808. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  76809. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  76810. * 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;
  76811. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  76812. */
  76813. export class ColorCurves {
  76814. private _dirty;
  76815. private _tempColor;
  76816. private _globalCurve;
  76817. private _highlightsCurve;
  76818. private _midtonesCurve;
  76819. private _shadowsCurve;
  76820. private _positiveCurve;
  76821. private _negativeCurve;
  76822. private _globalHue;
  76823. private _globalDensity;
  76824. private _globalSaturation;
  76825. private _globalExposure;
  76826. /**
  76827. * Gets the global Hue value.
  76828. * 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).
  76829. */
  76830. /**
  76831. * Sets the global Hue value.
  76832. * 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).
  76833. */
  76834. globalHue: number;
  76835. /**
  76836. * Gets the global Density value.
  76837. * 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.
  76838. * Values less than zero provide a filter of opposite hue.
  76839. */
  76840. /**
  76841. * Sets the global Density value.
  76842. * 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.
  76843. * Values less than zero provide a filter of opposite hue.
  76844. */
  76845. globalDensity: number;
  76846. /**
  76847. * Gets the global Saturation value.
  76848. * 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.
  76849. */
  76850. /**
  76851. * Sets the global Saturation value.
  76852. * 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.
  76853. */
  76854. globalSaturation: number;
  76855. /**
  76856. * Gets the global Exposure value.
  76857. * 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.
  76858. */
  76859. /**
  76860. * Sets the global Exposure value.
  76861. * 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.
  76862. */
  76863. globalExposure: number;
  76864. private _highlightsHue;
  76865. private _highlightsDensity;
  76866. private _highlightsSaturation;
  76867. private _highlightsExposure;
  76868. /**
  76869. * Gets the highlights Hue value.
  76870. * 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).
  76871. */
  76872. /**
  76873. * Sets the highlights Hue value.
  76874. * 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).
  76875. */
  76876. highlightsHue: number;
  76877. /**
  76878. * Gets the highlights Density value.
  76879. * 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.
  76880. * Values less than zero provide a filter of opposite hue.
  76881. */
  76882. /**
  76883. * Sets the highlights Density value.
  76884. * 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.
  76885. * Values less than zero provide a filter of opposite hue.
  76886. */
  76887. highlightsDensity: number;
  76888. /**
  76889. * Gets the highlights Saturation value.
  76890. * 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.
  76891. */
  76892. /**
  76893. * Sets the highlights Saturation value.
  76894. * 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.
  76895. */
  76896. highlightsSaturation: number;
  76897. /**
  76898. * Gets the highlights Exposure value.
  76899. * 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.
  76900. */
  76901. /**
  76902. * Sets the highlights Exposure value.
  76903. * 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.
  76904. */
  76905. highlightsExposure: number;
  76906. private _midtonesHue;
  76907. private _midtonesDensity;
  76908. private _midtonesSaturation;
  76909. private _midtonesExposure;
  76910. /**
  76911. * Gets the midtones Hue value.
  76912. * 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).
  76913. */
  76914. /**
  76915. * Sets the midtones Hue value.
  76916. * 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).
  76917. */
  76918. midtonesHue: number;
  76919. /**
  76920. * Gets the midtones Density value.
  76921. * 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.
  76922. * Values less than zero provide a filter of opposite hue.
  76923. */
  76924. /**
  76925. * Sets the midtones Density value.
  76926. * 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.
  76927. * Values less than zero provide a filter of opposite hue.
  76928. */
  76929. midtonesDensity: number;
  76930. /**
  76931. * Gets the midtones Saturation value.
  76932. * 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.
  76933. */
  76934. /**
  76935. * Sets the midtones Saturation value.
  76936. * 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.
  76937. */
  76938. midtonesSaturation: number;
  76939. /**
  76940. * Gets the midtones Exposure value.
  76941. * 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.
  76942. */
  76943. /**
  76944. * Sets the midtones Exposure value.
  76945. * 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.
  76946. */
  76947. midtonesExposure: number;
  76948. private _shadowsHue;
  76949. private _shadowsDensity;
  76950. private _shadowsSaturation;
  76951. private _shadowsExposure;
  76952. /**
  76953. * Gets the shadows Hue value.
  76954. * 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).
  76955. */
  76956. /**
  76957. * Sets the shadows Hue value.
  76958. * 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).
  76959. */
  76960. shadowsHue: number;
  76961. /**
  76962. * Gets the shadows Density value.
  76963. * 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.
  76964. * Values less than zero provide a filter of opposite hue.
  76965. */
  76966. /**
  76967. * Sets the shadows Density value.
  76968. * 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.
  76969. * Values less than zero provide a filter of opposite hue.
  76970. */
  76971. shadowsDensity: number;
  76972. /**
  76973. * Gets the shadows Saturation value.
  76974. * 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.
  76975. */
  76976. /**
  76977. * Sets the shadows Saturation value.
  76978. * 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.
  76979. */
  76980. shadowsSaturation: number;
  76981. /**
  76982. * Gets the shadows Exposure value.
  76983. * 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.
  76984. */
  76985. /**
  76986. * Sets the shadows Exposure value.
  76987. * 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.
  76988. */
  76989. shadowsExposure: number;
  76990. /**
  76991. * Returns the class name
  76992. * @returns The class name
  76993. */
  76994. getClassName(): string;
  76995. /**
  76996. * Binds the color curves to the shader.
  76997. * @param colorCurves The color curve to bind
  76998. * @param effect The effect to bind to
  76999. * @param positiveUniform The positive uniform shader parameter
  77000. * @param neutralUniform The neutral uniform shader parameter
  77001. * @param negativeUniform The negative uniform shader parameter
  77002. */
  77003. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  77004. /**
  77005. * Prepare the list of uniforms associated with the ColorCurves effects.
  77006. * @param uniformsList The list of uniforms used in the effect
  77007. */
  77008. static PrepareUniforms(uniformsList: string[]): void;
  77009. /**
  77010. * Returns color grading data based on a hue, density, saturation and exposure value.
  77011. * @param filterHue The hue of the color filter.
  77012. * @param filterDensity The density of the color filter.
  77013. * @param saturation The saturation.
  77014. * @param exposure The exposure.
  77015. * @param result The result data container.
  77016. */
  77017. private getColorGradingDataToRef;
  77018. /**
  77019. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  77020. * @param value The input slider value in range [-100,100].
  77021. * @returns Adjusted value.
  77022. */
  77023. private static applyColorGradingSliderNonlinear;
  77024. /**
  77025. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  77026. * @param hue The hue (H) input.
  77027. * @param saturation The saturation (S) input.
  77028. * @param brightness The brightness (B) input.
  77029. * @result An RGBA color represented as Vector4.
  77030. */
  77031. private static fromHSBToRef;
  77032. /**
  77033. * Returns a value clamped between min and max
  77034. * @param value The value to clamp
  77035. * @param min The minimum of value
  77036. * @param max The maximum of value
  77037. * @returns The clamped value.
  77038. */
  77039. private static clamp;
  77040. /**
  77041. * Clones the current color curve instance.
  77042. * @return The cloned curves
  77043. */
  77044. clone(): ColorCurves;
  77045. /**
  77046. * Serializes the current color curve instance to a json representation.
  77047. * @return a JSON representation
  77048. */
  77049. serialize(): any;
  77050. /**
  77051. * Parses the color curve from a json representation.
  77052. * @param source the JSON source to parse
  77053. * @return The parsed curves
  77054. */
  77055. static Parse(source: any): ColorCurves;
  77056. }
  77057. }
  77058. declare module BABYLON {
  77059. /**
  77060. * Interface to follow in your material defines to integrate easily the
  77061. * Image proccessing functions.
  77062. * @hidden
  77063. */
  77064. export interface IImageProcessingConfigurationDefines {
  77065. IMAGEPROCESSING: boolean;
  77066. VIGNETTE: boolean;
  77067. VIGNETTEBLENDMODEMULTIPLY: boolean;
  77068. VIGNETTEBLENDMODEOPAQUE: boolean;
  77069. TONEMAPPING: boolean;
  77070. TONEMAPPING_ACES: boolean;
  77071. CONTRAST: boolean;
  77072. EXPOSURE: boolean;
  77073. COLORCURVES: boolean;
  77074. COLORGRADING: boolean;
  77075. COLORGRADING3D: boolean;
  77076. SAMPLER3DGREENDEPTH: boolean;
  77077. SAMPLER3DBGRMAP: boolean;
  77078. IMAGEPROCESSINGPOSTPROCESS: boolean;
  77079. }
  77080. /**
  77081. * @hidden
  77082. */
  77083. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  77084. IMAGEPROCESSING: boolean;
  77085. VIGNETTE: boolean;
  77086. VIGNETTEBLENDMODEMULTIPLY: boolean;
  77087. VIGNETTEBLENDMODEOPAQUE: boolean;
  77088. TONEMAPPING: boolean;
  77089. TONEMAPPING_ACES: boolean;
  77090. CONTRAST: boolean;
  77091. COLORCURVES: boolean;
  77092. COLORGRADING: boolean;
  77093. COLORGRADING3D: boolean;
  77094. SAMPLER3DGREENDEPTH: boolean;
  77095. SAMPLER3DBGRMAP: boolean;
  77096. IMAGEPROCESSINGPOSTPROCESS: boolean;
  77097. EXPOSURE: boolean;
  77098. constructor();
  77099. }
  77100. /**
  77101. * This groups together the common properties used for image processing either in direct forward pass
  77102. * or through post processing effect depending on the use of the image processing pipeline in your scene
  77103. * or not.
  77104. */
  77105. export class ImageProcessingConfiguration {
  77106. /**
  77107. * Default tone mapping applied in BabylonJS.
  77108. */
  77109. static readonly TONEMAPPING_STANDARD: number;
  77110. /**
  77111. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  77112. * to other engines rendering to increase portability.
  77113. */
  77114. static readonly TONEMAPPING_ACES: number;
  77115. /**
  77116. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  77117. */
  77118. colorCurves: Nullable<ColorCurves>;
  77119. private _colorCurvesEnabled;
  77120. /**
  77121. * Gets wether the color curves effect is enabled.
  77122. */
  77123. /**
  77124. * Sets wether the color curves effect is enabled.
  77125. */
  77126. colorCurvesEnabled: boolean;
  77127. private _colorGradingTexture;
  77128. /**
  77129. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  77130. */
  77131. /**
  77132. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  77133. */
  77134. colorGradingTexture: Nullable<BaseTexture>;
  77135. private _colorGradingEnabled;
  77136. /**
  77137. * Gets wether the color grading effect is enabled.
  77138. */
  77139. /**
  77140. * Sets wether the color grading effect is enabled.
  77141. */
  77142. colorGradingEnabled: boolean;
  77143. private _colorGradingWithGreenDepth;
  77144. /**
  77145. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  77146. */
  77147. /**
  77148. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  77149. */
  77150. colorGradingWithGreenDepth: boolean;
  77151. private _colorGradingBGR;
  77152. /**
  77153. * Gets wether the color grading texture contains BGR values.
  77154. */
  77155. /**
  77156. * Sets wether the color grading texture contains BGR values.
  77157. */
  77158. colorGradingBGR: boolean;
  77159. /** @hidden */
  77160. _exposure: number;
  77161. /**
  77162. * Gets the Exposure used in the effect.
  77163. */
  77164. /**
  77165. * Sets the Exposure used in the effect.
  77166. */
  77167. exposure: number;
  77168. private _toneMappingEnabled;
  77169. /**
  77170. * Gets wether the tone mapping effect is enabled.
  77171. */
  77172. /**
  77173. * Sets wether the tone mapping effect is enabled.
  77174. */
  77175. toneMappingEnabled: boolean;
  77176. private _toneMappingType;
  77177. /**
  77178. * Gets the type of tone mapping effect.
  77179. */
  77180. /**
  77181. * Sets the type of tone mapping effect used in BabylonJS.
  77182. */
  77183. toneMappingType: number;
  77184. protected _contrast: number;
  77185. /**
  77186. * Gets the contrast used in the effect.
  77187. */
  77188. /**
  77189. * Sets the contrast used in the effect.
  77190. */
  77191. contrast: number;
  77192. /**
  77193. * Vignette stretch size.
  77194. */
  77195. vignetteStretch: number;
  77196. /**
  77197. * Vignette centre X Offset.
  77198. */
  77199. vignetteCentreX: number;
  77200. /**
  77201. * Vignette centre Y Offset.
  77202. */
  77203. vignetteCentreY: number;
  77204. /**
  77205. * Vignette weight or intensity of the vignette effect.
  77206. */
  77207. vignetteWeight: number;
  77208. /**
  77209. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  77210. * if vignetteEnabled is set to true.
  77211. */
  77212. vignetteColor: Color4;
  77213. /**
  77214. * Camera field of view used by the Vignette effect.
  77215. */
  77216. vignetteCameraFov: number;
  77217. private _vignetteBlendMode;
  77218. /**
  77219. * Gets the vignette blend mode allowing different kind of effect.
  77220. */
  77221. /**
  77222. * Sets the vignette blend mode allowing different kind of effect.
  77223. */
  77224. vignetteBlendMode: number;
  77225. private _vignetteEnabled;
  77226. /**
  77227. * Gets wether the vignette effect is enabled.
  77228. */
  77229. /**
  77230. * Sets wether the vignette effect is enabled.
  77231. */
  77232. vignetteEnabled: boolean;
  77233. private _applyByPostProcess;
  77234. /**
  77235. * Gets wether the image processing is applied through a post process or not.
  77236. */
  77237. /**
  77238. * Sets wether the image processing is applied through a post process or not.
  77239. */
  77240. applyByPostProcess: boolean;
  77241. private _isEnabled;
  77242. /**
  77243. * Gets wether the image processing is enabled or not.
  77244. */
  77245. /**
  77246. * Sets wether the image processing is enabled or not.
  77247. */
  77248. isEnabled: boolean;
  77249. /**
  77250. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  77251. */
  77252. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  77253. /**
  77254. * Method called each time the image processing information changes requires to recompile the effect.
  77255. */
  77256. protected _updateParameters(): void;
  77257. /**
  77258. * Gets the current class name.
  77259. * @return "ImageProcessingConfiguration"
  77260. */
  77261. getClassName(): string;
  77262. /**
  77263. * Prepare the list of uniforms associated with the Image Processing effects.
  77264. * @param uniforms The list of uniforms used in the effect
  77265. * @param defines the list of defines currently in use
  77266. */
  77267. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  77268. /**
  77269. * Prepare the list of samplers associated with the Image Processing effects.
  77270. * @param samplersList The list of uniforms used in the effect
  77271. * @param defines the list of defines currently in use
  77272. */
  77273. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  77274. /**
  77275. * Prepare the list of defines associated to the shader.
  77276. * @param defines the list of defines to complete
  77277. * @param forPostProcess Define if we are currently in post process mode or not
  77278. */
  77279. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  77280. /**
  77281. * Returns true if all the image processing information are ready.
  77282. * @returns True if ready, otherwise, false
  77283. */
  77284. isReady(): boolean;
  77285. /**
  77286. * Binds the image processing to the shader.
  77287. * @param effect The effect to bind to
  77288. * @param overrideAspectRatio Override the aspect ratio of the effect
  77289. */
  77290. bind(effect: Effect, overrideAspectRatio?: number): void;
  77291. /**
  77292. * Clones the current image processing instance.
  77293. * @return The cloned image processing
  77294. */
  77295. clone(): ImageProcessingConfiguration;
  77296. /**
  77297. * Serializes the current image processing instance to a json representation.
  77298. * @return a JSON representation
  77299. */
  77300. serialize(): any;
  77301. /**
  77302. * Parses the image processing from a json representation.
  77303. * @param source the JSON source to parse
  77304. * @return The parsed image processing
  77305. */
  77306. static Parse(source: any): ImageProcessingConfiguration;
  77307. private static _VIGNETTEMODE_MULTIPLY;
  77308. private static _VIGNETTEMODE_OPAQUE;
  77309. /**
  77310. * Used to apply the vignette as a mix with the pixel color.
  77311. */
  77312. static readonly VIGNETTEMODE_MULTIPLY: number;
  77313. /**
  77314. * Used to apply the vignette as a replacement of the pixel color.
  77315. */
  77316. static readonly VIGNETTEMODE_OPAQUE: number;
  77317. }
  77318. }
  77319. declare module BABYLON {
  77320. /** @hidden */
  77321. export var postprocessVertexShader: {
  77322. name: string;
  77323. shader: string;
  77324. };
  77325. }
  77326. declare module BABYLON {
  77327. interface ThinEngine {
  77328. /**
  77329. * Creates a new render target texture
  77330. * @param size defines the size of the texture
  77331. * @param options defines the options used to create the texture
  77332. * @returns a new render target texture stored in an InternalTexture
  77333. */
  77334. createRenderTargetTexture(size: number | {
  77335. width: number;
  77336. height: number;
  77337. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  77338. /**
  77339. * Creates a depth stencil texture.
  77340. * This is only available in WebGL 2 or with the depth texture extension available.
  77341. * @param size The size of face edge in the texture.
  77342. * @param options The options defining the texture.
  77343. * @returns The texture
  77344. */
  77345. createDepthStencilTexture(size: number | {
  77346. width: number;
  77347. height: number;
  77348. }, options: DepthTextureCreationOptions): InternalTexture;
  77349. /** @hidden */
  77350. _createDepthStencilTexture(size: number | {
  77351. width: number;
  77352. height: number;
  77353. }, options: DepthTextureCreationOptions): InternalTexture;
  77354. }
  77355. }
  77356. declare module BABYLON {
  77357. /** Defines supported spaces */
  77358. export enum Space {
  77359. /** Local (object) space */
  77360. LOCAL = 0,
  77361. /** World space */
  77362. WORLD = 1,
  77363. /** Bone space */
  77364. BONE = 2
  77365. }
  77366. /** Defines the 3 main axes */
  77367. export class Axis {
  77368. /** X axis */
  77369. static X: Vector3;
  77370. /** Y axis */
  77371. static Y: Vector3;
  77372. /** Z axis */
  77373. static Z: Vector3;
  77374. }
  77375. }
  77376. declare module BABYLON {
  77377. /**
  77378. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  77379. * This is the base of the follow, arc rotate cameras and Free camera
  77380. * @see http://doc.babylonjs.com/features/cameras
  77381. */
  77382. export class TargetCamera extends Camera {
  77383. private static _RigCamTransformMatrix;
  77384. private static _TargetTransformMatrix;
  77385. private static _TargetFocalPoint;
  77386. /**
  77387. * Define the current direction the camera is moving to
  77388. */
  77389. cameraDirection: Vector3;
  77390. /**
  77391. * Define the current rotation the camera is rotating to
  77392. */
  77393. cameraRotation: Vector2;
  77394. /**
  77395. * When set, the up vector of the camera will be updated by the rotation of the camera
  77396. */
  77397. updateUpVectorFromRotation: boolean;
  77398. private _tmpQuaternion;
  77399. /**
  77400. * Define the current rotation of the camera
  77401. */
  77402. rotation: Vector3;
  77403. /**
  77404. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  77405. */
  77406. rotationQuaternion: Quaternion;
  77407. /**
  77408. * Define the current speed of the camera
  77409. */
  77410. speed: number;
  77411. /**
  77412. * Add constraint to the camera to prevent it to move freely in all directions and
  77413. * around all axis.
  77414. */
  77415. noRotationConstraint: boolean;
  77416. /**
  77417. * Define the current target of the camera as an object or a position.
  77418. */
  77419. lockedTarget: any;
  77420. /** @hidden */
  77421. _currentTarget: Vector3;
  77422. /** @hidden */
  77423. _initialFocalDistance: number;
  77424. /** @hidden */
  77425. _viewMatrix: Matrix;
  77426. /** @hidden */
  77427. _camMatrix: Matrix;
  77428. /** @hidden */
  77429. _cameraTransformMatrix: Matrix;
  77430. /** @hidden */
  77431. _cameraRotationMatrix: Matrix;
  77432. /** @hidden */
  77433. _referencePoint: Vector3;
  77434. /** @hidden */
  77435. _transformedReferencePoint: Vector3;
  77436. protected _globalCurrentTarget: Vector3;
  77437. protected _globalCurrentUpVector: Vector3;
  77438. /** @hidden */
  77439. _reset: () => void;
  77440. private _defaultUp;
  77441. /**
  77442. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  77443. * This is the base of the follow, arc rotate cameras and Free camera
  77444. * @see http://doc.babylonjs.com/features/cameras
  77445. * @param name Defines the name of the camera in the scene
  77446. * @param position Defines the start position of the camera in the scene
  77447. * @param scene Defines the scene the camera belongs to
  77448. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  77449. */
  77450. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  77451. /**
  77452. * Gets the position in front of the camera at a given distance.
  77453. * @param distance The distance from the camera we want the position to be
  77454. * @returns the position
  77455. */
  77456. getFrontPosition(distance: number): Vector3;
  77457. /** @hidden */
  77458. _getLockedTargetPosition(): Nullable<Vector3>;
  77459. private _storedPosition;
  77460. private _storedRotation;
  77461. private _storedRotationQuaternion;
  77462. /**
  77463. * Store current camera state of the camera (fov, position, rotation, etc..)
  77464. * @returns the camera
  77465. */
  77466. storeState(): Camera;
  77467. /**
  77468. * Restored camera state. You must call storeState() first
  77469. * @returns whether it was successful or not
  77470. * @hidden
  77471. */
  77472. _restoreStateValues(): boolean;
  77473. /** @hidden */
  77474. _initCache(): void;
  77475. /** @hidden */
  77476. _updateCache(ignoreParentClass?: boolean): void;
  77477. /** @hidden */
  77478. _isSynchronizedViewMatrix(): boolean;
  77479. /** @hidden */
  77480. _computeLocalCameraSpeed(): number;
  77481. /**
  77482. * Defines the target the camera should look at.
  77483. * @param target Defines the new target as a Vector or a mesh
  77484. */
  77485. setTarget(target: Vector3): void;
  77486. /**
  77487. * Return the current target position of the camera. This value is expressed in local space.
  77488. * @returns the target position
  77489. */
  77490. getTarget(): Vector3;
  77491. /** @hidden */
  77492. _decideIfNeedsToMove(): boolean;
  77493. /** @hidden */
  77494. _updatePosition(): void;
  77495. /** @hidden */
  77496. _checkInputs(): void;
  77497. protected _updateCameraRotationMatrix(): void;
  77498. /**
  77499. * 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)
  77500. * @returns the current camera
  77501. */
  77502. private _rotateUpVectorWithCameraRotationMatrix;
  77503. private _cachedRotationZ;
  77504. private _cachedQuaternionRotationZ;
  77505. /** @hidden */
  77506. _getViewMatrix(): Matrix;
  77507. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  77508. /**
  77509. * @hidden
  77510. */
  77511. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  77512. /**
  77513. * @hidden
  77514. */
  77515. _updateRigCameras(): void;
  77516. private _getRigCamPositionAndTarget;
  77517. /**
  77518. * Gets the current object class name.
  77519. * @return the class name
  77520. */
  77521. getClassName(): string;
  77522. }
  77523. }
  77524. declare module BABYLON {
  77525. /**
  77526. * Gather the list of keyboard event types as constants.
  77527. */
  77528. export class KeyboardEventTypes {
  77529. /**
  77530. * The keydown event is fired when a key becomes active (pressed).
  77531. */
  77532. static readonly KEYDOWN: number;
  77533. /**
  77534. * The keyup event is fired when a key has been released.
  77535. */
  77536. static readonly KEYUP: number;
  77537. }
  77538. /**
  77539. * This class is used to store keyboard related info for the onKeyboardObservable event.
  77540. */
  77541. export class KeyboardInfo {
  77542. /**
  77543. * Defines the type of event (KeyboardEventTypes)
  77544. */
  77545. type: number;
  77546. /**
  77547. * Defines the related dom event
  77548. */
  77549. event: KeyboardEvent;
  77550. /**
  77551. * Instantiates a new keyboard info.
  77552. * This class is used to store keyboard related info for the onKeyboardObservable event.
  77553. * @param type Defines the type of event (KeyboardEventTypes)
  77554. * @param event Defines the related dom event
  77555. */
  77556. constructor(
  77557. /**
  77558. * Defines the type of event (KeyboardEventTypes)
  77559. */
  77560. type: number,
  77561. /**
  77562. * Defines the related dom event
  77563. */
  77564. event: KeyboardEvent);
  77565. }
  77566. /**
  77567. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  77568. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  77569. */
  77570. export class KeyboardInfoPre extends KeyboardInfo {
  77571. /**
  77572. * Defines the type of event (KeyboardEventTypes)
  77573. */
  77574. type: number;
  77575. /**
  77576. * Defines the related dom event
  77577. */
  77578. event: KeyboardEvent;
  77579. /**
  77580. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  77581. */
  77582. skipOnPointerObservable: boolean;
  77583. /**
  77584. * Instantiates a new keyboard pre info.
  77585. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  77586. * @param type Defines the type of event (KeyboardEventTypes)
  77587. * @param event Defines the related dom event
  77588. */
  77589. constructor(
  77590. /**
  77591. * Defines the type of event (KeyboardEventTypes)
  77592. */
  77593. type: number,
  77594. /**
  77595. * Defines the related dom event
  77596. */
  77597. event: KeyboardEvent);
  77598. }
  77599. }
  77600. declare module BABYLON {
  77601. /**
  77602. * Manage the keyboard inputs to control the movement of a free camera.
  77603. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77604. */
  77605. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  77606. /**
  77607. * Defines the camera the input is attached to.
  77608. */
  77609. camera: FreeCamera;
  77610. /**
  77611. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  77612. */
  77613. keysUp: number[];
  77614. /**
  77615. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  77616. */
  77617. keysDown: number[];
  77618. /**
  77619. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  77620. */
  77621. keysLeft: number[];
  77622. /**
  77623. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  77624. */
  77625. keysRight: number[];
  77626. private _keys;
  77627. private _onCanvasBlurObserver;
  77628. private _onKeyboardObserver;
  77629. private _engine;
  77630. private _scene;
  77631. /**
  77632. * Attach the input controls to a specific dom element to get the input from.
  77633. * @param element Defines the element the controls should be listened from
  77634. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77635. */
  77636. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77637. /**
  77638. * Detach the current controls from the specified dom element.
  77639. * @param element Defines the element to stop listening the inputs from
  77640. */
  77641. detachControl(element: Nullable<HTMLElement>): void;
  77642. /**
  77643. * Update the current camera state depending on the inputs that have been used this frame.
  77644. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  77645. */
  77646. checkInputs(): void;
  77647. /**
  77648. * Gets the class name of the current intput.
  77649. * @returns the class name
  77650. */
  77651. getClassName(): string;
  77652. /** @hidden */
  77653. _onLostFocus(): void;
  77654. /**
  77655. * Get the friendly name associated with the input class.
  77656. * @returns the input friendly name
  77657. */
  77658. getSimpleName(): string;
  77659. }
  77660. }
  77661. declare module BABYLON {
  77662. /**
  77663. * Interface describing all the common properties and methods a shadow light needs to implement.
  77664. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  77665. * as well as binding the different shadow properties to the effects.
  77666. */
  77667. export interface IShadowLight extends Light {
  77668. /**
  77669. * The light id in the scene (used in scene.findLighById for instance)
  77670. */
  77671. id: string;
  77672. /**
  77673. * The position the shdow will be casted from.
  77674. */
  77675. position: Vector3;
  77676. /**
  77677. * In 2d mode (needCube being false), the direction used to cast the shadow.
  77678. */
  77679. direction: Vector3;
  77680. /**
  77681. * The transformed position. Position of the light in world space taking parenting in account.
  77682. */
  77683. transformedPosition: Vector3;
  77684. /**
  77685. * The transformed direction. Direction of the light in world space taking parenting in account.
  77686. */
  77687. transformedDirection: Vector3;
  77688. /**
  77689. * The friendly name of the light in the scene.
  77690. */
  77691. name: string;
  77692. /**
  77693. * Defines the shadow projection clipping minimum z value.
  77694. */
  77695. shadowMinZ: number;
  77696. /**
  77697. * Defines the shadow projection clipping maximum z value.
  77698. */
  77699. shadowMaxZ: number;
  77700. /**
  77701. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  77702. * @returns true if the information has been computed, false if it does not need to (no parenting)
  77703. */
  77704. computeTransformedInformation(): boolean;
  77705. /**
  77706. * Gets the scene the light belongs to.
  77707. * @returns The scene
  77708. */
  77709. getScene(): Scene;
  77710. /**
  77711. * Callback defining a custom Projection Matrix Builder.
  77712. * This can be used to override the default projection matrix computation.
  77713. */
  77714. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  77715. /**
  77716. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  77717. * @param matrix The materix to updated with the projection information
  77718. * @param viewMatrix The transform matrix of the light
  77719. * @param renderList The list of mesh to render in the map
  77720. * @returns The current light
  77721. */
  77722. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  77723. /**
  77724. * Gets the current depth scale used in ESM.
  77725. * @returns The scale
  77726. */
  77727. getDepthScale(): number;
  77728. /**
  77729. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  77730. * @returns true if a cube texture needs to be use
  77731. */
  77732. needCube(): boolean;
  77733. /**
  77734. * Detects if the projection matrix requires to be recomputed this frame.
  77735. * @returns true if it requires to be recomputed otherwise, false.
  77736. */
  77737. needProjectionMatrixCompute(): boolean;
  77738. /**
  77739. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  77740. */
  77741. forceProjectionMatrixCompute(): void;
  77742. /**
  77743. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  77744. * @param faceIndex The index of the face we are computed the direction to generate shadow
  77745. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  77746. */
  77747. getShadowDirection(faceIndex?: number): Vector3;
  77748. /**
  77749. * Gets the minZ used for shadow according to both the scene and the light.
  77750. * @param activeCamera The camera we are returning the min for
  77751. * @returns the depth min z
  77752. */
  77753. getDepthMinZ(activeCamera: Camera): number;
  77754. /**
  77755. * Gets the maxZ used for shadow according to both the scene and the light.
  77756. * @param activeCamera The camera we are returning the max for
  77757. * @returns the depth max z
  77758. */
  77759. getDepthMaxZ(activeCamera: Camera): number;
  77760. }
  77761. /**
  77762. * Base implementation IShadowLight
  77763. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  77764. */
  77765. export abstract class ShadowLight extends Light implements IShadowLight {
  77766. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  77767. protected _position: Vector3;
  77768. protected _setPosition(value: Vector3): void;
  77769. /**
  77770. * Sets the position the shadow will be casted from. Also use as the light position for both
  77771. * point and spot lights.
  77772. */
  77773. /**
  77774. * Sets the position the shadow will be casted from. Also use as the light position for both
  77775. * point and spot lights.
  77776. */
  77777. position: Vector3;
  77778. protected _direction: Vector3;
  77779. protected _setDirection(value: Vector3): void;
  77780. /**
  77781. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  77782. * Also use as the light direction on spot and directional lights.
  77783. */
  77784. /**
  77785. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  77786. * Also use as the light direction on spot and directional lights.
  77787. */
  77788. direction: Vector3;
  77789. private _shadowMinZ;
  77790. /**
  77791. * Gets the shadow projection clipping minimum z value.
  77792. */
  77793. /**
  77794. * Sets the shadow projection clipping minimum z value.
  77795. */
  77796. shadowMinZ: number;
  77797. private _shadowMaxZ;
  77798. /**
  77799. * Sets the shadow projection clipping maximum z value.
  77800. */
  77801. /**
  77802. * Gets the shadow projection clipping maximum z value.
  77803. */
  77804. shadowMaxZ: number;
  77805. /**
  77806. * Callback defining a custom Projection Matrix Builder.
  77807. * This can be used to override the default projection matrix computation.
  77808. */
  77809. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  77810. /**
  77811. * The transformed position. Position of the light in world space taking parenting in account.
  77812. */
  77813. transformedPosition: Vector3;
  77814. /**
  77815. * The transformed direction. Direction of the light in world space taking parenting in account.
  77816. */
  77817. transformedDirection: Vector3;
  77818. private _needProjectionMatrixCompute;
  77819. /**
  77820. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  77821. * @returns true if the information has been computed, false if it does not need to (no parenting)
  77822. */
  77823. computeTransformedInformation(): boolean;
  77824. /**
  77825. * Return the depth scale used for the shadow map.
  77826. * @returns the depth scale.
  77827. */
  77828. getDepthScale(): number;
  77829. /**
  77830. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  77831. * @param faceIndex The index of the face we are computed the direction to generate shadow
  77832. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  77833. */
  77834. getShadowDirection(faceIndex?: number): Vector3;
  77835. /**
  77836. * Returns the ShadowLight absolute position in the World.
  77837. * @returns the position vector in world space
  77838. */
  77839. getAbsolutePosition(): Vector3;
  77840. /**
  77841. * Sets the ShadowLight direction toward the passed target.
  77842. * @param target The point to target in local space
  77843. * @returns the updated ShadowLight direction
  77844. */
  77845. setDirectionToTarget(target: Vector3): Vector3;
  77846. /**
  77847. * Returns the light rotation in euler definition.
  77848. * @returns the x y z rotation in local space.
  77849. */
  77850. getRotation(): Vector3;
  77851. /**
  77852. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  77853. * @returns true if a cube texture needs to be use
  77854. */
  77855. needCube(): boolean;
  77856. /**
  77857. * Detects if the projection matrix requires to be recomputed this frame.
  77858. * @returns true if it requires to be recomputed otherwise, false.
  77859. */
  77860. needProjectionMatrixCompute(): boolean;
  77861. /**
  77862. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  77863. */
  77864. forceProjectionMatrixCompute(): void;
  77865. /** @hidden */
  77866. _initCache(): void;
  77867. /** @hidden */
  77868. _isSynchronized(): boolean;
  77869. /**
  77870. * Computes the world matrix of the node
  77871. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  77872. * @returns the world matrix
  77873. */
  77874. computeWorldMatrix(force?: boolean): Matrix;
  77875. /**
  77876. * Gets the minZ used for shadow according to both the scene and the light.
  77877. * @param activeCamera The camera we are returning the min for
  77878. * @returns the depth min z
  77879. */
  77880. getDepthMinZ(activeCamera: Camera): number;
  77881. /**
  77882. * Gets the maxZ used for shadow according to both the scene and the light.
  77883. * @param activeCamera The camera we are returning the max for
  77884. * @returns the depth max z
  77885. */
  77886. getDepthMaxZ(activeCamera: Camera): number;
  77887. /**
  77888. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  77889. * @param matrix The materix to updated with the projection information
  77890. * @param viewMatrix The transform matrix of the light
  77891. * @param renderList The list of mesh to render in the map
  77892. * @returns The current light
  77893. */
  77894. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  77895. }
  77896. }
  77897. declare module BABYLON {
  77898. /**
  77899. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  77900. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  77901. */
  77902. export class EffectFallbacks implements IEffectFallbacks {
  77903. private _defines;
  77904. private _currentRank;
  77905. private _maxRank;
  77906. private _mesh;
  77907. /**
  77908. * Removes the fallback from the bound mesh.
  77909. */
  77910. unBindMesh(): void;
  77911. /**
  77912. * Adds a fallback on the specified property.
  77913. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  77914. * @param define The name of the define in the shader
  77915. */
  77916. addFallback(rank: number, define: string): void;
  77917. /**
  77918. * Sets the mesh to use CPU skinning when needing to fallback.
  77919. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  77920. * @param mesh The mesh to use the fallbacks.
  77921. */
  77922. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  77923. /**
  77924. * Checks to see if more fallbacks are still availible.
  77925. */
  77926. readonly hasMoreFallbacks: boolean;
  77927. /**
  77928. * Removes the defines that should be removed when falling back.
  77929. * @param currentDefines defines the current define statements for the shader.
  77930. * @param effect defines the current effect we try to compile
  77931. * @returns The resulting defines with defines of the current rank removed.
  77932. */
  77933. reduce(currentDefines: string, effect: Effect): string;
  77934. }
  77935. }
  77936. declare module BABYLON {
  77937. /**
  77938. * "Static Class" containing the most commonly used helper while dealing with material for
  77939. * rendering purpose.
  77940. *
  77941. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  77942. *
  77943. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  77944. */
  77945. export class MaterialHelper {
  77946. /**
  77947. * Bind the current view position to an effect.
  77948. * @param effect The effect to be bound
  77949. * @param scene The scene the eyes position is used from
  77950. */
  77951. static BindEyePosition(effect: Effect, scene: Scene): void;
  77952. /**
  77953. * Helps preparing the defines values about the UVs in used in the effect.
  77954. * UVs are shared as much as we can accross channels in the shaders.
  77955. * @param texture The texture we are preparing the UVs for
  77956. * @param defines The defines to update
  77957. * @param key The channel key "diffuse", "specular"... used in the shader
  77958. */
  77959. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  77960. /**
  77961. * Binds a texture matrix value to its corrsponding uniform
  77962. * @param texture The texture to bind the matrix for
  77963. * @param uniformBuffer The uniform buffer receivin the data
  77964. * @param key The channel key "diffuse", "specular"... used in the shader
  77965. */
  77966. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  77967. /**
  77968. * Gets the current status of the fog (should it be enabled?)
  77969. * @param mesh defines the mesh to evaluate for fog support
  77970. * @param scene defines the hosting scene
  77971. * @returns true if fog must be enabled
  77972. */
  77973. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  77974. /**
  77975. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  77976. * @param mesh defines the current mesh
  77977. * @param scene defines the current scene
  77978. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  77979. * @param pointsCloud defines if point cloud rendering has to be turned on
  77980. * @param fogEnabled defines if fog has to be turned on
  77981. * @param alphaTest defines if alpha testing has to be turned on
  77982. * @param defines defines the current list of defines
  77983. */
  77984. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  77985. /**
  77986. * Helper used to prepare the list of defines associated with frame values for shader compilation
  77987. * @param scene defines the current scene
  77988. * @param engine defines the current engine
  77989. * @param defines specifies the list of active defines
  77990. * @param useInstances defines if instances have to be turned on
  77991. * @param useClipPlane defines if clip plane have to be turned on
  77992. */
  77993. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  77994. /**
  77995. * Prepares the defines for bones
  77996. * @param mesh The mesh containing the geometry data we will draw
  77997. * @param defines The defines to update
  77998. */
  77999. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  78000. /**
  78001. * Prepares the defines for morph targets
  78002. * @param mesh The mesh containing the geometry data we will draw
  78003. * @param defines The defines to update
  78004. */
  78005. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  78006. /**
  78007. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  78008. * @param mesh The mesh containing the geometry data we will draw
  78009. * @param defines The defines to update
  78010. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  78011. * @param useBones Precise whether bones should be used or not (override mesh info)
  78012. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  78013. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  78014. * @returns false if defines are considered not dirty and have not been checked
  78015. */
  78016. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  78017. /**
  78018. * Prepares the defines related to multiview
  78019. * @param scene The scene we are intending to draw
  78020. * @param defines The defines to update
  78021. */
  78022. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  78023. /**
  78024. * Prepares the defines related to the light information passed in parameter
  78025. * @param scene The scene we are intending to draw
  78026. * @param mesh The mesh the effect is compiling for
  78027. * @param light The light the effect is compiling for
  78028. * @param lightIndex The index of the light
  78029. * @param defines The defines to update
  78030. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  78031. * @param state Defines the current state regarding what is needed (normals, etc...)
  78032. */
  78033. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  78034. needNormals: boolean;
  78035. needRebuild: boolean;
  78036. shadowEnabled: boolean;
  78037. specularEnabled: boolean;
  78038. lightmapMode: boolean;
  78039. }): void;
  78040. /**
  78041. * Prepares the defines related to the light information passed in parameter
  78042. * @param scene The scene we are intending to draw
  78043. * @param mesh The mesh the effect is compiling for
  78044. * @param defines The defines to update
  78045. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  78046. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  78047. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  78048. * @returns true if normals will be required for the rest of the effect
  78049. */
  78050. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  78051. /**
  78052. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  78053. * @param lightIndex defines the light index
  78054. * @param uniformsList The uniform list
  78055. * @param samplersList The sampler list
  78056. * @param projectedLightTexture defines if projected texture must be used
  78057. * @param uniformBuffersList defines an optional list of uniform buffers
  78058. */
  78059. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  78060. /**
  78061. * Prepares the uniforms and samplers list to be used in the effect
  78062. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  78063. * @param samplersList The sampler list
  78064. * @param defines The defines helping in the list generation
  78065. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  78066. */
  78067. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  78068. /**
  78069. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  78070. * @param defines The defines to update while falling back
  78071. * @param fallbacks The authorized effect fallbacks
  78072. * @param maxSimultaneousLights The maximum number of lights allowed
  78073. * @param rank the current rank of the Effect
  78074. * @returns The newly affected rank
  78075. */
  78076. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  78077. private static _TmpMorphInfluencers;
  78078. /**
  78079. * Prepares the list of attributes required for morph targets according to the effect defines.
  78080. * @param attribs The current list of supported attribs
  78081. * @param mesh The mesh to prepare the morph targets attributes for
  78082. * @param influencers The number of influencers
  78083. */
  78084. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  78085. /**
  78086. * Prepares the list of attributes required for morph targets according to the effect defines.
  78087. * @param attribs The current list of supported attribs
  78088. * @param mesh The mesh to prepare the morph targets attributes for
  78089. * @param defines The current Defines of the effect
  78090. */
  78091. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  78092. /**
  78093. * Prepares the list of attributes required for bones according to the effect defines.
  78094. * @param attribs The current list of supported attribs
  78095. * @param mesh The mesh to prepare the bones attributes for
  78096. * @param defines The current Defines of the effect
  78097. * @param fallbacks The current efffect fallback strategy
  78098. */
  78099. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  78100. /**
  78101. * Check and prepare the list of attributes required for instances according to the effect defines.
  78102. * @param attribs The current list of supported attribs
  78103. * @param defines The current MaterialDefines of the effect
  78104. */
  78105. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  78106. /**
  78107. * Add the list of attributes required for instances to the attribs array.
  78108. * @param attribs The current list of supported attribs
  78109. */
  78110. static PushAttributesForInstances(attribs: string[]): void;
  78111. /**
  78112. * Binds the light information to the effect.
  78113. * @param light The light containing the generator
  78114. * @param effect The effect we are binding the data to
  78115. * @param lightIndex The light index in the effect used to render
  78116. */
  78117. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  78118. /**
  78119. * Binds the lights information from the scene to the effect for the given mesh.
  78120. * @param light Light to bind
  78121. * @param lightIndex Light index
  78122. * @param scene The scene where the light belongs to
  78123. * @param effect The effect we are binding the data to
  78124. * @param useSpecular Defines if specular is supported
  78125. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  78126. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  78127. */
  78128. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  78129. /**
  78130. * Binds the lights information from the scene to the effect for the given mesh.
  78131. * @param scene The scene the lights belongs to
  78132. * @param mesh The mesh we are binding the information to render
  78133. * @param effect The effect we are binding the data to
  78134. * @param defines The generated defines for the effect
  78135. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  78136. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  78137. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  78138. */
  78139. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  78140. private static _tempFogColor;
  78141. /**
  78142. * Binds the fog information from the scene to the effect for the given mesh.
  78143. * @param scene The scene the lights belongs to
  78144. * @param mesh The mesh we are binding the information to render
  78145. * @param effect The effect we are binding the data to
  78146. * @param linearSpace Defines if the fog effect is applied in linear space
  78147. */
  78148. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  78149. /**
  78150. * Binds the bones information from the mesh to the effect.
  78151. * @param mesh The mesh we are binding the information to render
  78152. * @param effect The effect we are binding the data to
  78153. */
  78154. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  78155. /**
  78156. * Binds the morph targets information from the mesh to the effect.
  78157. * @param abstractMesh The mesh we are binding the information to render
  78158. * @param effect The effect we are binding the data to
  78159. */
  78160. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  78161. /**
  78162. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  78163. * @param defines The generated defines used in the effect
  78164. * @param effect The effect we are binding the data to
  78165. * @param scene The scene we are willing to render with logarithmic scale for
  78166. */
  78167. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  78168. /**
  78169. * Binds the clip plane information from the scene to the effect.
  78170. * @param scene The scene the clip plane information are extracted from
  78171. * @param effect The effect we are binding the data to
  78172. */
  78173. static BindClipPlane(effect: Effect, scene: Scene): void;
  78174. }
  78175. }
  78176. declare module BABYLON {
  78177. /** @hidden */
  78178. export var packingFunctions: {
  78179. name: string;
  78180. shader: string;
  78181. };
  78182. }
  78183. declare module BABYLON {
  78184. /** @hidden */
  78185. export var shadowMapPixelShader: {
  78186. name: string;
  78187. shader: string;
  78188. };
  78189. }
  78190. declare module BABYLON {
  78191. /** @hidden */
  78192. export var bonesDeclaration: {
  78193. name: string;
  78194. shader: string;
  78195. };
  78196. }
  78197. declare module BABYLON {
  78198. /** @hidden */
  78199. export var morphTargetsVertexGlobalDeclaration: {
  78200. name: string;
  78201. shader: string;
  78202. };
  78203. }
  78204. declare module BABYLON {
  78205. /** @hidden */
  78206. export var morphTargetsVertexDeclaration: {
  78207. name: string;
  78208. shader: string;
  78209. };
  78210. }
  78211. declare module BABYLON {
  78212. /** @hidden */
  78213. export var instancesDeclaration: {
  78214. name: string;
  78215. shader: string;
  78216. };
  78217. }
  78218. declare module BABYLON {
  78219. /** @hidden */
  78220. export var helperFunctions: {
  78221. name: string;
  78222. shader: string;
  78223. };
  78224. }
  78225. declare module BABYLON {
  78226. /** @hidden */
  78227. export var morphTargetsVertex: {
  78228. name: string;
  78229. shader: string;
  78230. };
  78231. }
  78232. declare module BABYLON {
  78233. /** @hidden */
  78234. export var instancesVertex: {
  78235. name: string;
  78236. shader: string;
  78237. };
  78238. }
  78239. declare module BABYLON {
  78240. /** @hidden */
  78241. export var bonesVertex: {
  78242. name: string;
  78243. shader: string;
  78244. };
  78245. }
  78246. declare module BABYLON {
  78247. /** @hidden */
  78248. export var shadowMapVertexShader: {
  78249. name: string;
  78250. shader: string;
  78251. };
  78252. }
  78253. declare module BABYLON {
  78254. /** @hidden */
  78255. export var depthBoxBlurPixelShader: {
  78256. name: string;
  78257. shader: string;
  78258. };
  78259. }
  78260. declare module BABYLON {
  78261. /**
  78262. * Defines the options associated with the creation of a custom shader for a shadow generator.
  78263. */
  78264. export interface ICustomShaderOptions {
  78265. /**
  78266. * Gets or sets the custom shader name to use
  78267. */
  78268. shaderName: string;
  78269. /**
  78270. * The list of attribute names used in the shader
  78271. */
  78272. attributes?: string[];
  78273. /**
  78274. * The list of unifrom names used in the shader
  78275. */
  78276. uniforms?: string[];
  78277. /**
  78278. * The list of sampler names used in the shader
  78279. */
  78280. samplers?: string[];
  78281. /**
  78282. * The list of defines used in the shader
  78283. */
  78284. defines?: string[];
  78285. }
  78286. /**
  78287. * Interface to implement to create a shadow generator compatible with BJS.
  78288. */
  78289. export interface IShadowGenerator {
  78290. /**
  78291. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  78292. * @returns The render target texture if present otherwise, null
  78293. */
  78294. getShadowMap(): Nullable<RenderTargetTexture>;
  78295. /**
  78296. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  78297. * @returns The render target texture if the shadow map is present otherwise, null
  78298. */
  78299. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  78300. /**
  78301. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  78302. * @param subMesh The submesh we want to render in the shadow map
  78303. * @param useInstances Defines wether will draw in the map using instances
  78304. * @returns true if ready otherwise, false
  78305. */
  78306. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  78307. /**
  78308. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  78309. * @param defines Defines of the material we want to update
  78310. * @param lightIndex Index of the light in the enabled light list of the material
  78311. */
  78312. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  78313. /**
  78314. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  78315. * defined in the generator but impacting the effect).
  78316. * It implies the unifroms available on the materials are the standard BJS ones.
  78317. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  78318. * @param effect The effect we are binfing the information for
  78319. */
  78320. bindShadowLight(lightIndex: string, effect: Effect): void;
  78321. /**
  78322. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  78323. * (eq to shadow prjection matrix * light transform matrix)
  78324. * @returns The transform matrix used to create the shadow map
  78325. */
  78326. getTransformMatrix(): Matrix;
  78327. /**
  78328. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  78329. * Cube and 2D textures for instance.
  78330. */
  78331. recreateShadowMap(): void;
  78332. /**
  78333. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  78334. * @param onCompiled Callback triggered at the and of the effects compilation
  78335. * @param options Sets of optional options forcing the compilation with different modes
  78336. */
  78337. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  78338. useInstances: boolean;
  78339. }>): void;
  78340. /**
  78341. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  78342. * @param options Sets of optional options forcing the compilation with different modes
  78343. * @returns A promise that resolves when the compilation completes
  78344. */
  78345. forceCompilationAsync(options?: Partial<{
  78346. useInstances: boolean;
  78347. }>): Promise<void>;
  78348. /**
  78349. * Serializes the shadow generator setup to a json object.
  78350. * @returns The serialized JSON object
  78351. */
  78352. serialize(): any;
  78353. /**
  78354. * Disposes the Shadow map and related Textures and effects.
  78355. */
  78356. dispose(): void;
  78357. }
  78358. /**
  78359. * Default implementation IShadowGenerator.
  78360. * This is the main object responsible of generating shadows in the framework.
  78361. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  78362. */
  78363. export class ShadowGenerator implements IShadowGenerator {
  78364. /**
  78365. * Shadow generator mode None: no filtering applied.
  78366. */
  78367. static readonly FILTER_NONE: number;
  78368. /**
  78369. * Shadow generator mode ESM: Exponential Shadow Mapping.
  78370. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  78371. */
  78372. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  78373. /**
  78374. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  78375. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  78376. */
  78377. static readonly FILTER_POISSONSAMPLING: number;
  78378. /**
  78379. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  78380. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  78381. */
  78382. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  78383. /**
  78384. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  78385. * edge artifacts on steep falloff.
  78386. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  78387. */
  78388. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  78389. /**
  78390. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  78391. * edge artifacts on steep falloff.
  78392. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  78393. */
  78394. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  78395. /**
  78396. * Shadow generator mode PCF: Percentage Closer Filtering
  78397. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  78398. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  78399. */
  78400. static readonly FILTER_PCF: number;
  78401. /**
  78402. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  78403. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  78404. * Contact Hardening
  78405. */
  78406. static readonly FILTER_PCSS: number;
  78407. /**
  78408. * Reserved for PCF and PCSS
  78409. * Highest Quality.
  78410. *
  78411. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  78412. *
  78413. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  78414. */
  78415. static readonly QUALITY_HIGH: number;
  78416. /**
  78417. * Reserved for PCF and PCSS
  78418. * Good tradeoff for quality/perf cross devices
  78419. *
  78420. * Execute PCF on a 3*3 kernel.
  78421. *
  78422. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  78423. */
  78424. static readonly QUALITY_MEDIUM: number;
  78425. /**
  78426. * Reserved for PCF and PCSS
  78427. * The lowest quality but the fastest.
  78428. *
  78429. * Execute PCF on a 1*1 kernel.
  78430. *
  78431. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  78432. */
  78433. static readonly QUALITY_LOW: number;
  78434. /** Gets or sets the custom shader name to use */
  78435. customShaderOptions: ICustomShaderOptions;
  78436. /**
  78437. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  78438. */
  78439. onBeforeShadowMapRenderObservable: Observable<Effect>;
  78440. /**
  78441. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  78442. */
  78443. onAfterShadowMapRenderObservable: Observable<Effect>;
  78444. /**
  78445. * Observable triggered before a mesh is rendered in the shadow map.
  78446. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  78447. */
  78448. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  78449. /**
  78450. * Observable triggered after a mesh is rendered in the shadow map.
  78451. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  78452. */
  78453. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  78454. private _bias;
  78455. /**
  78456. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  78457. */
  78458. /**
  78459. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  78460. */
  78461. bias: number;
  78462. private _normalBias;
  78463. /**
  78464. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  78465. */
  78466. /**
  78467. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  78468. */
  78469. normalBias: number;
  78470. private _blurBoxOffset;
  78471. /**
  78472. * Gets the blur box offset: offset applied during the blur pass.
  78473. * Only useful if useKernelBlur = false
  78474. */
  78475. /**
  78476. * Sets the blur box offset: offset applied during the blur pass.
  78477. * Only useful if useKernelBlur = false
  78478. */
  78479. blurBoxOffset: number;
  78480. private _blurScale;
  78481. /**
  78482. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  78483. * 2 means half of the size.
  78484. */
  78485. /**
  78486. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  78487. * 2 means half of the size.
  78488. */
  78489. blurScale: number;
  78490. private _blurKernel;
  78491. /**
  78492. * Gets the blur kernel: kernel size of the blur pass.
  78493. * Only useful if useKernelBlur = true
  78494. */
  78495. /**
  78496. * Sets the blur kernel: kernel size of the blur pass.
  78497. * Only useful if useKernelBlur = true
  78498. */
  78499. blurKernel: number;
  78500. private _useKernelBlur;
  78501. /**
  78502. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  78503. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  78504. */
  78505. /**
  78506. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  78507. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  78508. */
  78509. useKernelBlur: boolean;
  78510. private _depthScale;
  78511. /**
  78512. * Gets the depth scale used in ESM mode.
  78513. */
  78514. /**
  78515. * Sets the depth scale used in ESM mode.
  78516. * This can override the scale stored on the light.
  78517. */
  78518. depthScale: number;
  78519. private _filter;
  78520. /**
  78521. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  78522. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  78523. */
  78524. /**
  78525. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  78526. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  78527. */
  78528. filter: number;
  78529. /**
  78530. * Gets if the current filter is set to Poisson Sampling.
  78531. */
  78532. /**
  78533. * Sets the current filter to Poisson Sampling.
  78534. */
  78535. usePoissonSampling: boolean;
  78536. /**
  78537. * Gets if the current filter is set to ESM.
  78538. */
  78539. /**
  78540. * Sets the current filter is to ESM.
  78541. */
  78542. useExponentialShadowMap: boolean;
  78543. /**
  78544. * Gets if the current filter is set to filtered ESM.
  78545. */
  78546. /**
  78547. * Gets if the current filter is set to filtered ESM.
  78548. */
  78549. useBlurExponentialShadowMap: boolean;
  78550. /**
  78551. * Gets if the current filter is set to "close ESM" (using the inverse of the
  78552. * exponential to prevent steep falloff artifacts).
  78553. */
  78554. /**
  78555. * Sets the current filter to "close ESM" (using the inverse of the
  78556. * exponential to prevent steep falloff artifacts).
  78557. */
  78558. useCloseExponentialShadowMap: boolean;
  78559. /**
  78560. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  78561. * exponential to prevent steep falloff artifacts).
  78562. */
  78563. /**
  78564. * Sets the current filter to filtered "close ESM" (using the inverse of the
  78565. * exponential to prevent steep falloff artifacts).
  78566. */
  78567. useBlurCloseExponentialShadowMap: boolean;
  78568. /**
  78569. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  78570. */
  78571. /**
  78572. * Sets the current filter to "PCF" (percentage closer filtering).
  78573. */
  78574. usePercentageCloserFiltering: boolean;
  78575. private _filteringQuality;
  78576. /**
  78577. * Gets the PCF or PCSS Quality.
  78578. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  78579. */
  78580. /**
  78581. * Sets the PCF or PCSS Quality.
  78582. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  78583. */
  78584. filteringQuality: number;
  78585. /**
  78586. * Gets if the current filter is set to "PCSS" (contact hardening).
  78587. */
  78588. /**
  78589. * Sets the current filter to "PCSS" (contact hardening).
  78590. */
  78591. useContactHardeningShadow: boolean;
  78592. private _contactHardeningLightSizeUVRatio;
  78593. /**
  78594. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  78595. * Using a ratio helps keeping shape stability independently of the map size.
  78596. *
  78597. * It does not account for the light projection as it was having too much
  78598. * instability during the light setup or during light position changes.
  78599. *
  78600. * Only valid if useContactHardeningShadow is true.
  78601. */
  78602. /**
  78603. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  78604. * Using a ratio helps keeping shape stability independently of the map size.
  78605. *
  78606. * It does not account for the light projection as it was having too much
  78607. * instability during the light setup or during light position changes.
  78608. *
  78609. * Only valid if useContactHardeningShadow is true.
  78610. */
  78611. contactHardeningLightSizeUVRatio: number;
  78612. private _darkness;
  78613. /** Gets or sets the actual darkness of a shadow */
  78614. darkness: number;
  78615. /**
  78616. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  78617. * 0 means strongest and 1 would means no shadow.
  78618. * @returns the darkness.
  78619. */
  78620. getDarkness(): number;
  78621. /**
  78622. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  78623. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  78624. * @returns the shadow generator allowing fluent coding.
  78625. */
  78626. setDarkness(darkness: number): ShadowGenerator;
  78627. private _transparencyShadow;
  78628. /** Gets or sets the ability to have transparent shadow */
  78629. transparencyShadow: boolean;
  78630. /**
  78631. * Sets the ability to have transparent shadow (boolean).
  78632. * @param transparent True if transparent else False
  78633. * @returns the shadow generator allowing fluent coding
  78634. */
  78635. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  78636. private _shadowMap;
  78637. private _shadowMap2;
  78638. /**
  78639. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  78640. * @returns The render target texture if present otherwise, null
  78641. */
  78642. getShadowMap(): Nullable<RenderTargetTexture>;
  78643. /**
  78644. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  78645. * @returns The render target texture if the shadow map is present otherwise, null
  78646. */
  78647. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  78648. /**
  78649. * Gets the class name of that object
  78650. * @returns "ShadowGenerator"
  78651. */
  78652. getClassName(): string;
  78653. /**
  78654. * Helper function to add a mesh and its descendants to the list of shadow casters.
  78655. * @param mesh Mesh to add
  78656. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  78657. * @returns the Shadow Generator itself
  78658. */
  78659. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  78660. /**
  78661. * Helper function to remove a mesh and its descendants from the list of shadow casters
  78662. * @param mesh Mesh to remove
  78663. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  78664. * @returns the Shadow Generator itself
  78665. */
  78666. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  78667. /**
  78668. * Controls the extent to which the shadows fade out at the edge of the frustum
  78669. * Used only by directionals and spots
  78670. */
  78671. frustumEdgeFalloff: number;
  78672. private _light;
  78673. /**
  78674. * Returns the associated light object.
  78675. * @returns the light generating the shadow
  78676. */
  78677. getLight(): IShadowLight;
  78678. /**
  78679. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  78680. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  78681. * It might on the other hand introduce peter panning.
  78682. */
  78683. forceBackFacesOnly: boolean;
  78684. private _scene;
  78685. private _lightDirection;
  78686. private _effect;
  78687. private _viewMatrix;
  78688. private _projectionMatrix;
  78689. private _transformMatrix;
  78690. private _cachedPosition;
  78691. private _cachedDirection;
  78692. private _cachedDefines;
  78693. private _currentRenderID;
  78694. private _boxBlurPostprocess;
  78695. private _kernelBlurXPostprocess;
  78696. private _kernelBlurYPostprocess;
  78697. private _blurPostProcesses;
  78698. private _mapSize;
  78699. private _currentFaceIndex;
  78700. private _currentFaceIndexCache;
  78701. private _textureType;
  78702. private _defaultTextureMatrix;
  78703. private _storedUniqueId;
  78704. /** @hidden */
  78705. static _SceneComponentInitialization: (scene: Scene) => void;
  78706. /**
  78707. * Creates a ShadowGenerator object.
  78708. * A ShadowGenerator is the required tool to use the shadows.
  78709. * Each light casting shadows needs to use its own ShadowGenerator.
  78710. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  78711. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  78712. * @param light The light object generating the shadows.
  78713. * @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.
  78714. */
  78715. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  78716. private _initializeGenerator;
  78717. private _initializeShadowMap;
  78718. private _initializeBlurRTTAndPostProcesses;
  78719. private _renderForShadowMap;
  78720. private _renderSubMeshForShadowMap;
  78721. private _applyFilterValues;
  78722. /**
  78723. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  78724. * @param onCompiled Callback triggered at the and of the effects compilation
  78725. * @param options Sets of optional options forcing the compilation with different modes
  78726. */
  78727. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  78728. useInstances: boolean;
  78729. }>): void;
  78730. /**
  78731. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  78732. * @param options Sets of optional options forcing the compilation with different modes
  78733. * @returns A promise that resolves when the compilation completes
  78734. */
  78735. forceCompilationAsync(options?: Partial<{
  78736. useInstances: boolean;
  78737. }>): Promise<void>;
  78738. /**
  78739. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  78740. * @param subMesh The submesh we want to render in the shadow map
  78741. * @param useInstances Defines wether will draw in the map using instances
  78742. * @returns true if ready otherwise, false
  78743. */
  78744. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  78745. /**
  78746. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  78747. * @param defines Defines of the material we want to update
  78748. * @param lightIndex Index of the light in the enabled light list of the material
  78749. */
  78750. prepareDefines(defines: any, lightIndex: number): void;
  78751. /**
  78752. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  78753. * defined in the generator but impacting the effect).
  78754. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  78755. * @param effect The effect we are binfing the information for
  78756. */
  78757. bindShadowLight(lightIndex: string, effect: Effect): void;
  78758. /**
  78759. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  78760. * (eq to shadow prjection matrix * light transform matrix)
  78761. * @returns The transform matrix used to create the shadow map
  78762. */
  78763. getTransformMatrix(): Matrix;
  78764. /**
  78765. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  78766. * Cube and 2D textures for instance.
  78767. */
  78768. recreateShadowMap(): void;
  78769. private _disposeBlurPostProcesses;
  78770. private _disposeRTTandPostProcesses;
  78771. /**
  78772. * Disposes the ShadowGenerator.
  78773. * Returns nothing.
  78774. */
  78775. dispose(): void;
  78776. /**
  78777. * Serializes the shadow generator setup to a json object.
  78778. * @returns The serialized JSON object
  78779. */
  78780. serialize(): any;
  78781. /**
  78782. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  78783. * @param parsedShadowGenerator The JSON object to parse
  78784. * @param scene The scene to create the shadow map for
  78785. * @returns The parsed shadow generator
  78786. */
  78787. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  78788. }
  78789. }
  78790. declare module BABYLON {
  78791. /**
  78792. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  78793. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  78794. * 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.
  78795. */
  78796. export abstract class Light extends Node {
  78797. /**
  78798. * Falloff Default: light is falling off following the material specification:
  78799. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  78800. */
  78801. static readonly FALLOFF_DEFAULT: number;
  78802. /**
  78803. * Falloff Physical: light is falling off following the inverse squared distance law.
  78804. */
  78805. static readonly FALLOFF_PHYSICAL: number;
  78806. /**
  78807. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  78808. * to enhance interoperability with other engines.
  78809. */
  78810. static readonly FALLOFF_GLTF: number;
  78811. /**
  78812. * Falloff Standard: light is falling off like in the standard material
  78813. * to enhance interoperability with other materials.
  78814. */
  78815. static readonly FALLOFF_STANDARD: number;
  78816. /**
  78817. * If every light affecting the material is in this lightmapMode,
  78818. * material.lightmapTexture adds or multiplies
  78819. * (depends on material.useLightmapAsShadowmap)
  78820. * after every other light calculations.
  78821. */
  78822. static readonly LIGHTMAP_DEFAULT: number;
  78823. /**
  78824. * material.lightmapTexture as only diffuse lighting from this light
  78825. * adds only specular lighting from this light
  78826. * adds dynamic shadows
  78827. */
  78828. static readonly LIGHTMAP_SPECULAR: number;
  78829. /**
  78830. * material.lightmapTexture as only lighting
  78831. * no light calculation from this light
  78832. * only adds dynamic shadows from this light
  78833. */
  78834. static readonly LIGHTMAP_SHADOWSONLY: number;
  78835. /**
  78836. * Each light type uses the default quantity according to its type:
  78837. * point/spot lights use luminous intensity
  78838. * directional lights use illuminance
  78839. */
  78840. static readonly INTENSITYMODE_AUTOMATIC: number;
  78841. /**
  78842. * lumen (lm)
  78843. */
  78844. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  78845. /**
  78846. * candela (lm/sr)
  78847. */
  78848. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  78849. /**
  78850. * lux (lm/m^2)
  78851. */
  78852. static readonly INTENSITYMODE_ILLUMINANCE: number;
  78853. /**
  78854. * nit (cd/m^2)
  78855. */
  78856. static readonly INTENSITYMODE_LUMINANCE: number;
  78857. /**
  78858. * Light type const id of the point light.
  78859. */
  78860. static readonly LIGHTTYPEID_POINTLIGHT: number;
  78861. /**
  78862. * Light type const id of the directional light.
  78863. */
  78864. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  78865. /**
  78866. * Light type const id of the spot light.
  78867. */
  78868. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  78869. /**
  78870. * Light type const id of the hemispheric light.
  78871. */
  78872. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  78873. /**
  78874. * Diffuse gives the basic color to an object.
  78875. */
  78876. diffuse: Color3;
  78877. /**
  78878. * Specular produces a highlight color on an object.
  78879. * Note: This is note affecting PBR materials.
  78880. */
  78881. specular: Color3;
  78882. /**
  78883. * Defines the falloff type for this light. This lets overrriding how punctual light are
  78884. * falling off base on range or angle.
  78885. * This can be set to any values in Light.FALLOFF_x.
  78886. *
  78887. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  78888. * other types of materials.
  78889. */
  78890. falloffType: number;
  78891. /**
  78892. * Strength of the light.
  78893. * Note: By default it is define in the framework own unit.
  78894. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  78895. */
  78896. intensity: number;
  78897. private _range;
  78898. protected _inverseSquaredRange: number;
  78899. /**
  78900. * Defines how far from the source the light is impacting in scene units.
  78901. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  78902. */
  78903. /**
  78904. * Defines how far from the source the light is impacting in scene units.
  78905. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  78906. */
  78907. range: number;
  78908. /**
  78909. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  78910. * of light.
  78911. */
  78912. private _photometricScale;
  78913. private _intensityMode;
  78914. /**
  78915. * Gets the photometric scale used to interpret the intensity.
  78916. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  78917. */
  78918. /**
  78919. * Sets the photometric scale used to interpret the intensity.
  78920. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  78921. */
  78922. intensityMode: number;
  78923. private _radius;
  78924. /**
  78925. * Gets the light radius used by PBR Materials to simulate soft area lights.
  78926. */
  78927. /**
  78928. * sets the light radius used by PBR Materials to simulate soft area lights.
  78929. */
  78930. radius: number;
  78931. private _renderPriority;
  78932. /**
  78933. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  78934. * exceeding the number allowed of the materials.
  78935. */
  78936. renderPriority: number;
  78937. private _shadowEnabled;
  78938. /**
  78939. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  78940. * the current shadow generator.
  78941. */
  78942. /**
  78943. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  78944. * the current shadow generator.
  78945. */
  78946. shadowEnabled: boolean;
  78947. private _includedOnlyMeshes;
  78948. /**
  78949. * Gets the only meshes impacted by this light.
  78950. */
  78951. /**
  78952. * Sets the only meshes impacted by this light.
  78953. */
  78954. includedOnlyMeshes: AbstractMesh[];
  78955. private _excludedMeshes;
  78956. /**
  78957. * Gets the meshes not impacted by this light.
  78958. */
  78959. /**
  78960. * Sets the meshes not impacted by this light.
  78961. */
  78962. excludedMeshes: AbstractMesh[];
  78963. private _excludeWithLayerMask;
  78964. /**
  78965. * Gets the layer id use to find what meshes are not impacted by the light.
  78966. * Inactive if 0
  78967. */
  78968. /**
  78969. * Sets the layer id use to find what meshes are not impacted by the light.
  78970. * Inactive if 0
  78971. */
  78972. excludeWithLayerMask: number;
  78973. private _includeOnlyWithLayerMask;
  78974. /**
  78975. * Gets the layer id use to find what meshes are impacted by the light.
  78976. * Inactive if 0
  78977. */
  78978. /**
  78979. * Sets the layer id use to find what meshes are impacted by the light.
  78980. * Inactive if 0
  78981. */
  78982. includeOnlyWithLayerMask: number;
  78983. private _lightmapMode;
  78984. /**
  78985. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  78986. */
  78987. /**
  78988. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  78989. */
  78990. lightmapMode: number;
  78991. /**
  78992. * Shadow generator associted to the light.
  78993. * @hidden Internal use only.
  78994. */
  78995. _shadowGenerator: Nullable<IShadowGenerator>;
  78996. /**
  78997. * @hidden Internal use only.
  78998. */
  78999. _excludedMeshesIds: string[];
  79000. /**
  79001. * @hidden Internal use only.
  79002. */
  79003. _includedOnlyMeshesIds: string[];
  79004. /**
  79005. * The current light unifom buffer.
  79006. * @hidden Internal use only.
  79007. */
  79008. _uniformBuffer: UniformBuffer;
  79009. /** @hidden */
  79010. _renderId: number;
  79011. /**
  79012. * Creates a Light object in the scene.
  79013. * Documentation : https://doc.babylonjs.com/babylon101/lights
  79014. * @param name The firendly name of the light
  79015. * @param scene The scene the light belongs too
  79016. */
  79017. constructor(name: string, scene: Scene);
  79018. protected abstract _buildUniformLayout(): void;
  79019. /**
  79020. * Sets the passed Effect "effect" with the Light information.
  79021. * @param effect The effect to update
  79022. * @param lightIndex The index of the light in the effect to update
  79023. * @returns The light
  79024. */
  79025. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  79026. /**
  79027. * Sets the passed Effect "effect" with the Light textures.
  79028. * @param effect The effect to update
  79029. * @param lightIndex The index of the light in the effect to update
  79030. * @returns The light
  79031. */
  79032. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  79033. /**
  79034. * Binds the lights information from the scene to the effect for the given mesh.
  79035. * @param lightIndex Light index
  79036. * @param scene The scene where the light belongs to
  79037. * @param effect The effect we are binding the data to
  79038. * @param useSpecular Defines if specular is supported
  79039. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  79040. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  79041. */
  79042. bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  79043. /**
  79044. * Sets the passed Effect "effect" with the Light information.
  79045. * @param effect The effect to update
  79046. * @param lightDataUniformName The uniform used to store light data (position or direction)
  79047. * @returns The light
  79048. */
  79049. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  79050. /**
  79051. * Returns the string "Light".
  79052. * @returns the class name
  79053. */
  79054. getClassName(): string;
  79055. /** @hidden */
  79056. readonly _isLight: boolean;
  79057. /**
  79058. * Converts the light information to a readable string for debug purpose.
  79059. * @param fullDetails Supports for multiple levels of logging within scene loading
  79060. * @returns the human readable light info
  79061. */
  79062. toString(fullDetails?: boolean): string;
  79063. /** @hidden */
  79064. protected _syncParentEnabledState(): void;
  79065. /**
  79066. * Set the enabled state of this node.
  79067. * @param value - the new enabled state
  79068. */
  79069. setEnabled(value: boolean): void;
  79070. /**
  79071. * Returns the Light associated shadow generator if any.
  79072. * @return the associated shadow generator.
  79073. */
  79074. getShadowGenerator(): Nullable<IShadowGenerator>;
  79075. /**
  79076. * Returns a Vector3, the absolute light position in the World.
  79077. * @returns the world space position of the light
  79078. */
  79079. getAbsolutePosition(): Vector3;
  79080. /**
  79081. * Specifies if the light will affect the passed mesh.
  79082. * @param mesh The mesh to test against the light
  79083. * @return true the mesh is affected otherwise, false.
  79084. */
  79085. canAffectMesh(mesh: AbstractMesh): boolean;
  79086. /**
  79087. * Sort function to order lights for rendering.
  79088. * @param a First Light object to compare to second.
  79089. * @param b Second Light object to compare first.
  79090. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  79091. */
  79092. static CompareLightsPriority(a: Light, b: Light): number;
  79093. /**
  79094. * Releases resources associated with this node.
  79095. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  79096. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  79097. */
  79098. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  79099. /**
  79100. * Returns the light type ID (integer).
  79101. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  79102. */
  79103. getTypeID(): number;
  79104. /**
  79105. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  79106. * @returns the scaled intensity in intensity mode unit
  79107. */
  79108. getScaledIntensity(): number;
  79109. /**
  79110. * Returns a new Light object, named "name", from the current one.
  79111. * @param name The name of the cloned light
  79112. * @returns the new created light
  79113. */
  79114. clone(name: string): Nullable<Light>;
  79115. /**
  79116. * Serializes the current light into a Serialization object.
  79117. * @returns the serialized object.
  79118. */
  79119. serialize(): any;
  79120. /**
  79121. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  79122. * This new light is named "name" and added to the passed scene.
  79123. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  79124. * @param name The friendly name of the light
  79125. * @param scene The scene the new light will belong to
  79126. * @returns the constructor function
  79127. */
  79128. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  79129. /**
  79130. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  79131. * @param parsedLight The JSON representation of the light
  79132. * @param scene The scene to create the parsed light in
  79133. * @returns the created light after parsing
  79134. */
  79135. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  79136. private _hookArrayForExcluded;
  79137. private _hookArrayForIncludedOnly;
  79138. private _resyncMeshes;
  79139. /**
  79140. * Forces the meshes to update their light related information in their rendering used effects
  79141. * @hidden Internal Use Only
  79142. */
  79143. _markMeshesAsLightDirty(): void;
  79144. /**
  79145. * Recomputes the cached photometric scale if needed.
  79146. */
  79147. private _computePhotometricScale;
  79148. /**
  79149. * Returns the Photometric Scale according to the light type and intensity mode.
  79150. */
  79151. private _getPhotometricScale;
  79152. /**
  79153. * Reorder the light in the scene according to their defined priority.
  79154. * @hidden Internal Use Only
  79155. */
  79156. _reorderLightsInScene(): void;
  79157. /**
  79158. * Prepares the list of defines specific to the light type.
  79159. * @param defines the list of defines
  79160. * @param lightIndex defines the index of the light for the effect
  79161. */
  79162. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  79163. }
  79164. }
  79165. declare module BABYLON {
  79166. /**
  79167. * Interface used to define Action
  79168. */
  79169. export interface IAction {
  79170. /**
  79171. * Trigger for the action
  79172. */
  79173. trigger: number;
  79174. /** Options of the trigger */
  79175. triggerOptions: any;
  79176. /**
  79177. * Gets the trigger parameters
  79178. * @returns the trigger parameters
  79179. */
  79180. getTriggerParameter(): any;
  79181. /**
  79182. * Internal only - executes current action event
  79183. * @hidden
  79184. */
  79185. _executeCurrent(evt?: ActionEvent): void;
  79186. /**
  79187. * Serialize placeholder for child classes
  79188. * @param parent of child
  79189. * @returns the serialized object
  79190. */
  79191. serialize(parent: any): any;
  79192. /**
  79193. * Internal only
  79194. * @hidden
  79195. */
  79196. _prepare(): void;
  79197. /**
  79198. * Internal only - manager for action
  79199. * @hidden
  79200. */
  79201. _actionManager: AbstractActionManager;
  79202. /**
  79203. * Adds action to chain of actions, may be a DoNothingAction
  79204. * @param action defines the next action to execute
  79205. * @returns The action passed in
  79206. * @see https://www.babylonjs-playground.com/#1T30HR#0
  79207. */
  79208. then(action: IAction): IAction;
  79209. }
  79210. /**
  79211. * The action to be carried out following a trigger
  79212. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  79213. */
  79214. export class Action implements IAction {
  79215. /** the trigger, with or without parameters, for the action */
  79216. triggerOptions: any;
  79217. /**
  79218. * Trigger for the action
  79219. */
  79220. trigger: number;
  79221. /**
  79222. * Internal only - manager for action
  79223. * @hidden
  79224. */
  79225. _actionManager: ActionManager;
  79226. private _nextActiveAction;
  79227. private _child;
  79228. private _condition?;
  79229. private _triggerParameter;
  79230. /**
  79231. * An event triggered prior to action being executed.
  79232. */
  79233. onBeforeExecuteObservable: Observable<Action>;
  79234. /**
  79235. * Creates a new Action
  79236. * @param triggerOptions the trigger, with or without parameters, for the action
  79237. * @param condition an optional determinant of action
  79238. */
  79239. constructor(
  79240. /** the trigger, with or without parameters, for the action */
  79241. triggerOptions: any, condition?: Condition);
  79242. /**
  79243. * Internal only
  79244. * @hidden
  79245. */
  79246. _prepare(): void;
  79247. /**
  79248. * Gets the trigger parameters
  79249. * @returns the trigger parameters
  79250. */
  79251. getTriggerParameter(): any;
  79252. /**
  79253. * Internal only - executes current action event
  79254. * @hidden
  79255. */
  79256. _executeCurrent(evt?: ActionEvent): void;
  79257. /**
  79258. * Execute placeholder for child classes
  79259. * @param evt optional action event
  79260. */
  79261. execute(evt?: ActionEvent): void;
  79262. /**
  79263. * Skips to next active action
  79264. */
  79265. skipToNextActiveAction(): void;
  79266. /**
  79267. * Adds action to chain of actions, may be a DoNothingAction
  79268. * @param action defines the next action to execute
  79269. * @returns The action passed in
  79270. * @see https://www.babylonjs-playground.com/#1T30HR#0
  79271. */
  79272. then(action: Action): Action;
  79273. /**
  79274. * Internal only
  79275. * @hidden
  79276. */
  79277. _getProperty(propertyPath: string): string;
  79278. /**
  79279. * Internal only
  79280. * @hidden
  79281. */
  79282. _getEffectiveTarget(target: any, propertyPath: string): any;
  79283. /**
  79284. * Serialize placeholder for child classes
  79285. * @param parent of child
  79286. * @returns the serialized object
  79287. */
  79288. serialize(parent: any): any;
  79289. /**
  79290. * Internal only called by serialize
  79291. * @hidden
  79292. */
  79293. protected _serialize(serializedAction: any, parent?: any): any;
  79294. /**
  79295. * Internal only
  79296. * @hidden
  79297. */
  79298. static _SerializeValueAsString: (value: any) => string;
  79299. /**
  79300. * Internal only
  79301. * @hidden
  79302. */
  79303. static _GetTargetProperty: (target: Node | Scene) => {
  79304. name: string;
  79305. targetType: string;
  79306. value: string;
  79307. };
  79308. }
  79309. }
  79310. declare module BABYLON {
  79311. /**
  79312. * A Condition applied to an Action
  79313. */
  79314. export class Condition {
  79315. /**
  79316. * Internal only - manager for action
  79317. * @hidden
  79318. */
  79319. _actionManager: ActionManager;
  79320. /**
  79321. * Internal only
  79322. * @hidden
  79323. */
  79324. _evaluationId: number;
  79325. /**
  79326. * Internal only
  79327. * @hidden
  79328. */
  79329. _currentResult: boolean;
  79330. /**
  79331. * Creates a new Condition
  79332. * @param actionManager the manager of the action the condition is applied to
  79333. */
  79334. constructor(actionManager: ActionManager);
  79335. /**
  79336. * Check if the current condition is valid
  79337. * @returns a boolean
  79338. */
  79339. isValid(): boolean;
  79340. /**
  79341. * Internal only
  79342. * @hidden
  79343. */
  79344. _getProperty(propertyPath: string): string;
  79345. /**
  79346. * Internal only
  79347. * @hidden
  79348. */
  79349. _getEffectiveTarget(target: any, propertyPath: string): any;
  79350. /**
  79351. * Serialize placeholder for child classes
  79352. * @returns the serialized object
  79353. */
  79354. serialize(): any;
  79355. /**
  79356. * Internal only
  79357. * @hidden
  79358. */
  79359. protected _serialize(serializedCondition: any): any;
  79360. }
  79361. /**
  79362. * Defines specific conditional operators as extensions of Condition
  79363. */
  79364. export class ValueCondition extends Condition {
  79365. /** path to specify the property of the target the conditional operator uses */
  79366. propertyPath: string;
  79367. /** the value compared by the conditional operator against the current value of the property */
  79368. value: any;
  79369. /** the conditional operator, default ValueCondition.IsEqual */
  79370. operator: number;
  79371. /**
  79372. * Internal only
  79373. * @hidden
  79374. */
  79375. private static _IsEqual;
  79376. /**
  79377. * Internal only
  79378. * @hidden
  79379. */
  79380. private static _IsDifferent;
  79381. /**
  79382. * Internal only
  79383. * @hidden
  79384. */
  79385. private static _IsGreater;
  79386. /**
  79387. * Internal only
  79388. * @hidden
  79389. */
  79390. private static _IsLesser;
  79391. /**
  79392. * returns the number for IsEqual
  79393. */
  79394. static readonly IsEqual: number;
  79395. /**
  79396. * Returns the number for IsDifferent
  79397. */
  79398. static readonly IsDifferent: number;
  79399. /**
  79400. * Returns the number for IsGreater
  79401. */
  79402. static readonly IsGreater: number;
  79403. /**
  79404. * Returns the number for IsLesser
  79405. */
  79406. static readonly IsLesser: number;
  79407. /**
  79408. * Internal only The action manager for the condition
  79409. * @hidden
  79410. */
  79411. _actionManager: ActionManager;
  79412. /**
  79413. * Internal only
  79414. * @hidden
  79415. */
  79416. private _target;
  79417. /**
  79418. * Internal only
  79419. * @hidden
  79420. */
  79421. private _effectiveTarget;
  79422. /**
  79423. * Internal only
  79424. * @hidden
  79425. */
  79426. private _property;
  79427. /**
  79428. * Creates a new ValueCondition
  79429. * @param actionManager manager for the action the condition applies to
  79430. * @param target for the action
  79431. * @param propertyPath path to specify the property of the target the conditional operator uses
  79432. * @param value the value compared by the conditional operator against the current value of the property
  79433. * @param operator the conditional operator, default ValueCondition.IsEqual
  79434. */
  79435. constructor(actionManager: ActionManager, target: any,
  79436. /** path to specify the property of the target the conditional operator uses */
  79437. propertyPath: string,
  79438. /** the value compared by the conditional operator against the current value of the property */
  79439. value: any,
  79440. /** the conditional operator, default ValueCondition.IsEqual */
  79441. operator?: number);
  79442. /**
  79443. * Compares the given value with the property value for the specified conditional operator
  79444. * @returns the result of the comparison
  79445. */
  79446. isValid(): boolean;
  79447. /**
  79448. * Serialize the ValueCondition into a JSON compatible object
  79449. * @returns serialization object
  79450. */
  79451. serialize(): any;
  79452. /**
  79453. * Gets the name of the conditional operator for the ValueCondition
  79454. * @param operator the conditional operator
  79455. * @returns the name
  79456. */
  79457. static GetOperatorName(operator: number): string;
  79458. }
  79459. /**
  79460. * Defines a predicate condition as an extension of Condition
  79461. */
  79462. export class PredicateCondition extends Condition {
  79463. /** defines the predicate function used to validate the condition */
  79464. predicate: () => boolean;
  79465. /**
  79466. * Internal only - manager for action
  79467. * @hidden
  79468. */
  79469. _actionManager: ActionManager;
  79470. /**
  79471. * Creates a new PredicateCondition
  79472. * @param actionManager manager for the action the condition applies to
  79473. * @param predicate defines the predicate function used to validate the condition
  79474. */
  79475. constructor(actionManager: ActionManager,
  79476. /** defines the predicate function used to validate the condition */
  79477. predicate: () => boolean);
  79478. /**
  79479. * @returns the validity of the predicate condition
  79480. */
  79481. isValid(): boolean;
  79482. }
  79483. /**
  79484. * Defines a state condition as an extension of Condition
  79485. */
  79486. export class StateCondition extends Condition {
  79487. /** Value to compare with target state */
  79488. value: string;
  79489. /**
  79490. * Internal only - manager for action
  79491. * @hidden
  79492. */
  79493. _actionManager: ActionManager;
  79494. /**
  79495. * Internal only
  79496. * @hidden
  79497. */
  79498. private _target;
  79499. /**
  79500. * Creates a new StateCondition
  79501. * @param actionManager manager for the action the condition applies to
  79502. * @param target of the condition
  79503. * @param value to compare with target state
  79504. */
  79505. constructor(actionManager: ActionManager, target: any,
  79506. /** Value to compare with target state */
  79507. value: string);
  79508. /**
  79509. * Gets a boolean indicating if the current condition is met
  79510. * @returns the validity of the state
  79511. */
  79512. isValid(): boolean;
  79513. /**
  79514. * Serialize the StateCondition into a JSON compatible object
  79515. * @returns serialization object
  79516. */
  79517. serialize(): any;
  79518. }
  79519. }
  79520. declare module BABYLON {
  79521. /**
  79522. * This defines an action responsible to toggle a boolean once triggered.
  79523. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79524. */
  79525. export class SwitchBooleanAction extends Action {
  79526. /**
  79527. * The path to the boolean property in the target object
  79528. */
  79529. propertyPath: string;
  79530. private _target;
  79531. private _effectiveTarget;
  79532. private _property;
  79533. /**
  79534. * Instantiate the action
  79535. * @param triggerOptions defines the trigger options
  79536. * @param target defines the object containing the boolean
  79537. * @param propertyPath defines the path to the boolean property in the target object
  79538. * @param condition defines the trigger related conditions
  79539. */
  79540. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  79541. /** @hidden */
  79542. _prepare(): void;
  79543. /**
  79544. * Execute the action toggle the boolean value.
  79545. */
  79546. execute(): void;
  79547. /**
  79548. * Serializes the actions and its related information.
  79549. * @param parent defines the object to serialize in
  79550. * @returns the serialized object
  79551. */
  79552. serialize(parent: any): any;
  79553. }
  79554. /**
  79555. * This defines an action responsible to set a the state field of the target
  79556. * to a desired value once triggered.
  79557. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79558. */
  79559. export class SetStateAction extends Action {
  79560. /**
  79561. * The value to store in the state field.
  79562. */
  79563. value: string;
  79564. private _target;
  79565. /**
  79566. * Instantiate the action
  79567. * @param triggerOptions defines the trigger options
  79568. * @param target defines the object containing the state property
  79569. * @param value defines the value to store in the state field
  79570. * @param condition defines the trigger related conditions
  79571. */
  79572. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  79573. /**
  79574. * Execute the action and store the value on the target state property.
  79575. */
  79576. execute(): void;
  79577. /**
  79578. * Serializes the actions and its related information.
  79579. * @param parent defines the object to serialize in
  79580. * @returns the serialized object
  79581. */
  79582. serialize(parent: any): any;
  79583. }
  79584. /**
  79585. * This defines an action responsible to set a property of the target
  79586. * to a desired value once triggered.
  79587. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79588. */
  79589. export class SetValueAction extends Action {
  79590. /**
  79591. * The path of the property to set in the target.
  79592. */
  79593. propertyPath: string;
  79594. /**
  79595. * The value to set in the property
  79596. */
  79597. value: any;
  79598. private _target;
  79599. private _effectiveTarget;
  79600. private _property;
  79601. /**
  79602. * Instantiate the action
  79603. * @param triggerOptions defines the trigger options
  79604. * @param target defines the object containing the property
  79605. * @param propertyPath defines the path of the property to set in the target
  79606. * @param value defines the value to set in the property
  79607. * @param condition defines the trigger related conditions
  79608. */
  79609. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  79610. /** @hidden */
  79611. _prepare(): void;
  79612. /**
  79613. * Execute the action and set the targetted property to the desired value.
  79614. */
  79615. execute(): void;
  79616. /**
  79617. * Serializes the actions and its related information.
  79618. * @param parent defines the object to serialize in
  79619. * @returns the serialized object
  79620. */
  79621. serialize(parent: any): any;
  79622. }
  79623. /**
  79624. * This defines an action responsible to increment the target value
  79625. * to a desired value once triggered.
  79626. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79627. */
  79628. export class IncrementValueAction extends Action {
  79629. /**
  79630. * The path of the property to increment in the target.
  79631. */
  79632. propertyPath: string;
  79633. /**
  79634. * The value we should increment the property by.
  79635. */
  79636. value: any;
  79637. private _target;
  79638. private _effectiveTarget;
  79639. private _property;
  79640. /**
  79641. * Instantiate the action
  79642. * @param triggerOptions defines the trigger options
  79643. * @param target defines the object containing the property
  79644. * @param propertyPath defines the path of the property to increment in the target
  79645. * @param value defines the value value we should increment the property by
  79646. * @param condition defines the trigger related conditions
  79647. */
  79648. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  79649. /** @hidden */
  79650. _prepare(): void;
  79651. /**
  79652. * Execute the action and increment the target of the value amount.
  79653. */
  79654. execute(): void;
  79655. /**
  79656. * Serializes the actions and its related information.
  79657. * @param parent defines the object to serialize in
  79658. * @returns the serialized object
  79659. */
  79660. serialize(parent: any): any;
  79661. }
  79662. /**
  79663. * This defines an action responsible to start an animation once triggered.
  79664. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79665. */
  79666. export class PlayAnimationAction extends Action {
  79667. /**
  79668. * Where the animation should start (animation frame)
  79669. */
  79670. from: number;
  79671. /**
  79672. * Where the animation should stop (animation frame)
  79673. */
  79674. to: number;
  79675. /**
  79676. * Define if the animation should loop or stop after the first play.
  79677. */
  79678. loop?: boolean;
  79679. private _target;
  79680. /**
  79681. * Instantiate the action
  79682. * @param triggerOptions defines the trigger options
  79683. * @param target defines the target animation or animation name
  79684. * @param from defines from where the animation should start (animation frame)
  79685. * @param end defines where the animation should stop (animation frame)
  79686. * @param loop defines if the animation should loop or stop after the first play
  79687. * @param condition defines the trigger related conditions
  79688. */
  79689. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  79690. /** @hidden */
  79691. _prepare(): void;
  79692. /**
  79693. * Execute the action and play the animation.
  79694. */
  79695. execute(): void;
  79696. /**
  79697. * Serializes the actions and its related information.
  79698. * @param parent defines the object to serialize in
  79699. * @returns the serialized object
  79700. */
  79701. serialize(parent: any): any;
  79702. }
  79703. /**
  79704. * This defines an action responsible to stop an animation once triggered.
  79705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79706. */
  79707. export class StopAnimationAction extends Action {
  79708. private _target;
  79709. /**
  79710. * Instantiate the action
  79711. * @param triggerOptions defines the trigger options
  79712. * @param target defines the target animation or animation name
  79713. * @param condition defines the trigger related conditions
  79714. */
  79715. constructor(triggerOptions: any, target: any, condition?: Condition);
  79716. /** @hidden */
  79717. _prepare(): void;
  79718. /**
  79719. * Execute the action and stop the animation.
  79720. */
  79721. execute(): void;
  79722. /**
  79723. * Serializes the actions and its related information.
  79724. * @param parent defines the object to serialize in
  79725. * @returns the serialized object
  79726. */
  79727. serialize(parent: any): any;
  79728. }
  79729. /**
  79730. * This defines an action responsible that does nothing once triggered.
  79731. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79732. */
  79733. export class DoNothingAction extends Action {
  79734. /**
  79735. * Instantiate the action
  79736. * @param triggerOptions defines the trigger options
  79737. * @param condition defines the trigger related conditions
  79738. */
  79739. constructor(triggerOptions?: any, condition?: Condition);
  79740. /**
  79741. * Execute the action and do nothing.
  79742. */
  79743. execute(): void;
  79744. /**
  79745. * Serializes the actions and its related information.
  79746. * @param parent defines the object to serialize in
  79747. * @returns the serialized object
  79748. */
  79749. serialize(parent: any): any;
  79750. }
  79751. /**
  79752. * This defines an action responsible to trigger several actions once triggered.
  79753. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79754. */
  79755. export class CombineAction extends Action {
  79756. /**
  79757. * The list of aggregated animations to run.
  79758. */
  79759. children: Action[];
  79760. /**
  79761. * Instantiate the action
  79762. * @param triggerOptions defines the trigger options
  79763. * @param children defines the list of aggregated animations to run
  79764. * @param condition defines the trigger related conditions
  79765. */
  79766. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  79767. /** @hidden */
  79768. _prepare(): void;
  79769. /**
  79770. * Execute the action and executes all the aggregated actions.
  79771. */
  79772. execute(evt: ActionEvent): void;
  79773. /**
  79774. * Serializes the actions and its related information.
  79775. * @param parent defines the object to serialize in
  79776. * @returns the serialized object
  79777. */
  79778. serialize(parent: any): any;
  79779. }
  79780. /**
  79781. * This defines an action responsible to run code (external event) once triggered.
  79782. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79783. */
  79784. export class ExecuteCodeAction extends Action {
  79785. /**
  79786. * The callback function to run.
  79787. */
  79788. func: (evt: ActionEvent) => void;
  79789. /**
  79790. * Instantiate the action
  79791. * @param triggerOptions defines the trigger options
  79792. * @param func defines the callback function to run
  79793. * @param condition defines the trigger related conditions
  79794. */
  79795. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  79796. /**
  79797. * Execute the action and run the attached code.
  79798. */
  79799. execute(evt: ActionEvent): void;
  79800. }
  79801. /**
  79802. * This defines an action responsible to set the parent property of the target once triggered.
  79803. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79804. */
  79805. export class SetParentAction extends Action {
  79806. private _parent;
  79807. private _target;
  79808. /**
  79809. * Instantiate the action
  79810. * @param triggerOptions defines the trigger options
  79811. * @param target defines the target containing the parent property
  79812. * @param parent defines from where the animation should start (animation frame)
  79813. * @param condition defines the trigger related conditions
  79814. */
  79815. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  79816. /** @hidden */
  79817. _prepare(): void;
  79818. /**
  79819. * Execute the action and set the parent property.
  79820. */
  79821. execute(): void;
  79822. /**
  79823. * Serializes the actions and its related information.
  79824. * @param parent defines the object to serialize in
  79825. * @returns the serialized object
  79826. */
  79827. serialize(parent: any): any;
  79828. }
  79829. }
  79830. declare module BABYLON {
  79831. /**
  79832. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  79833. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  79834. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79835. */
  79836. export class ActionManager extends AbstractActionManager {
  79837. /**
  79838. * Nothing
  79839. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79840. */
  79841. static readonly NothingTrigger: number;
  79842. /**
  79843. * On pick
  79844. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79845. */
  79846. static readonly OnPickTrigger: number;
  79847. /**
  79848. * On left pick
  79849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79850. */
  79851. static readonly OnLeftPickTrigger: number;
  79852. /**
  79853. * On right pick
  79854. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79855. */
  79856. static readonly OnRightPickTrigger: number;
  79857. /**
  79858. * On center pick
  79859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79860. */
  79861. static readonly OnCenterPickTrigger: number;
  79862. /**
  79863. * On pick down
  79864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79865. */
  79866. static readonly OnPickDownTrigger: number;
  79867. /**
  79868. * On double pick
  79869. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79870. */
  79871. static readonly OnDoublePickTrigger: number;
  79872. /**
  79873. * On pick up
  79874. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79875. */
  79876. static readonly OnPickUpTrigger: number;
  79877. /**
  79878. * On pick out.
  79879. * This trigger will only be raised if you also declared a OnPickDown
  79880. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79881. */
  79882. static readonly OnPickOutTrigger: number;
  79883. /**
  79884. * On long press
  79885. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79886. */
  79887. static readonly OnLongPressTrigger: number;
  79888. /**
  79889. * On pointer over
  79890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79891. */
  79892. static readonly OnPointerOverTrigger: number;
  79893. /**
  79894. * On pointer out
  79895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79896. */
  79897. static readonly OnPointerOutTrigger: number;
  79898. /**
  79899. * On every frame
  79900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79901. */
  79902. static readonly OnEveryFrameTrigger: number;
  79903. /**
  79904. * On intersection enter
  79905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79906. */
  79907. static readonly OnIntersectionEnterTrigger: number;
  79908. /**
  79909. * On intersection exit
  79910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79911. */
  79912. static readonly OnIntersectionExitTrigger: number;
  79913. /**
  79914. * On key down
  79915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79916. */
  79917. static readonly OnKeyDownTrigger: number;
  79918. /**
  79919. * On key up
  79920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79921. */
  79922. static readonly OnKeyUpTrigger: number;
  79923. private _scene;
  79924. /**
  79925. * Creates a new action manager
  79926. * @param scene defines the hosting scene
  79927. */
  79928. constructor(scene: Scene);
  79929. /**
  79930. * Releases all associated resources
  79931. */
  79932. dispose(): void;
  79933. /**
  79934. * Gets hosting scene
  79935. * @returns the hosting scene
  79936. */
  79937. getScene(): Scene;
  79938. /**
  79939. * Does this action manager handles actions of any of the given triggers
  79940. * @param triggers defines the triggers to be tested
  79941. * @return a boolean indicating whether one (or more) of the triggers is handled
  79942. */
  79943. hasSpecificTriggers(triggers: number[]): boolean;
  79944. /**
  79945. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  79946. * speed.
  79947. * @param triggerA defines the trigger to be tested
  79948. * @param triggerB defines the trigger to be tested
  79949. * @return a boolean indicating whether one (or more) of the triggers is handled
  79950. */
  79951. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  79952. /**
  79953. * Does this action manager handles actions of a given trigger
  79954. * @param trigger defines the trigger to be tested
  79955. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  79956. * @return whether the trigger is handled
  79957. */
  79958. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  79959. /**
  79960. * Does this action manager has pointer triggers
  79961. */
  79962. readonly hasPointerTriggers: boolean;
  79963. /**
  79964. * Does this action manager has pick triggers
  79965. */
  79966. readonly hasPickTriggers: boolean;
  79967. /**
  79968. * Registers an action to this action manager
  79969. * @param action defines the action to be registered
  79970. * @return the action amended (prepared) after registration
  79971. */
  79972. registerAction(action: IAction): Nullable<IAction>;
  79973. /**
  79974. * Unregisters an action to this action manager
  79975. * @param action defines the action to be unregistered
  79976. * @return a boolean indicating whether the action has been unregistered
  79977. */
  79978. unregisterAction(action: IAction): Boolean;
  79979. /**
  79980. * Process a specific trigger
  79981. * @param trigger defines the trigger to process
  79982. * @param evt defines the event details to be processed
  79983. */
  79984. processTrigger(trigger: number, evt?: IActionEvent): void;
  79985. /** @hidden */
  79986. _getEffectiveTarget(target: any, propertyPath: string): any;
  79987. /** @hidden */
  79988. _getProperty(propertyPath: string): string;
  79989. /**
  79990. * Serialize this manager to a JSON object
  79991. * @param name defines the property name to store this manager
  79992. * @returns a JSON representation of this manager
  79993. */
  79994. serialize(name: string): any;
  79995. /**
  79996. * Creates a new ActionManager from a JSON data
  79997. * @param parsedActions defines the JSON data to read from
  79998. * @param object defines the hosting mesh
  79999. * @param scene defines the hosting scene
  80000. */
  80001. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  80002. /**
  80003. * Get a trigger name by index
  80004. * @param trigger defines the trigger index
  80005. * @returns a trigger name
  80006. */
  80007. static GetTriggerName(trigger: number): string;
  80008. }
  80009. }
  80010. declare module BABYLON {
  80011. /**
  80012. * Class representing a ray with position and direction
  80013. */
  80014. export class Ray {
  80015. /** origin point */
  80016. origin: Vector3;
  80017. /** direction */
  80018. direction: Vector3;
  80019. /** length of the ray */
  80020. length: number;
  80021. private static readonly TmpVector3;
  80022. private _tmpRay;
  80023. /**
  80024. * Creates a new ray
  80025. * @param origin origin point
  80026. * @param direction direction
  80027. * @param length length of the ray
  80028. */
  80029. constructor(
  80030. /** origin point */
  80031. origin: Vector3,
  80032. /** direction */
  80033. direction: Vector3,
  80034. /** length of the ray */
  80035. length?: number);
  80036. /**
  80037. * Checks if the ray intersects a box
  80038. * @param minimum bound of the box
  80039. * @param maximum bound of the box
  80040. * @param intersectionTreshold extra extend to be added to the box in all direction
  80041. * @returns if the box was hit
  80042. */
  80043. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  80044. /**
  80045. * Checks if the ray intersects a box
  80046. * @param box the bounding box to check
  80047. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  80048. * @returns if the box was hit
  80049. */
  80050. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  80051. /**
  80052. * If the ray hits a sphere
  80053. * @param sphere the bounding sphere to check
  80054. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  80055. * @returns true if it hits the sphere
  80056. */
  80057. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  80058. /**
  80059. * If the ray hits a triange
  80060. * @param vertex0 triangle vertex
  80061. * @param vertex1 triangle vertex
  80062. * @param vertex2 triangle vertex
  80063. * @returns intersection information if hit
  80064. */
  80065. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  80066. /**
  80067. * Checks if ray intersects a plane
  80068. * @param plane the plane to check
  80069. * @returns the distance away it was hit
  80070. */
  80071. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  80072. /**
  80073. * Calculate the intercept of a ray on a given axis
  80074. * @param axis to check 'x' | 'y' | 'z'
  80075. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  80076. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  80077. */
  80078. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  80079. /**
  80080. * Checks if ray intersects a mesh
  80081. * @param mesh the mesh to check
  80082. * @param fastCheck if only the bounding box should checked
  80083. * @returns picking info of the intersecton
  80084. */
  80085. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  80086. /**
  80087. * Checks if ray intersects a mesh
  80088. * @param meshes the meshes to check
  80089. * @param fastCheck if only the bounding box should checked
  80090. * @param results array to store result in
  80091. * @returns Array of picking infos
  80092. */
  80093. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  80094. private _comparePickingInfo;
  80095. private static smallnum;
  80096. private static rayl;
  80097. /**
  80098. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  80099. * @param sega the first point of the segment to test the intersection against
  80100. * @param segb the second point of the segment to test the intersection against
  80101. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  80102. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  80103. */
  80104. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  80105. /**
  80106. * Update the ray from viewport position
  80107. * @param x position
  80108. * @param y y position
  80109. * @param viewportWidth viewport width
  80110. * @param viewportHeight viewport height
  80111. * @param world world matrix
  80112. * @param view view matrix
  80113. * @param projection projection matrix
  80114. * @returns this ray updated
  80115. */
  80116. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  80117. /**
  80118. * Creates a ray with origin and direction of 0,0,0
  80119. * @returns the new ray
  80120. */
  80121. static Zero(): Ray;
  80122. /**
  80123. * Creates a new ray from screen space and viewport
  80124. * @param x position
  80125. * @param y y position
  80126. * @param viewportWidth viewport width
  80127. * @param viewportHeight viewport height
  80128. * @param world world matrix
  80129. * @param view view matrix
  80130. * @param projection projection matrix
  80131. * @returns new ray
  80132. */
  80133. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  80134. /**
  80135. * 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
  80136. * transformed to the given world matrix.
  80137. * @param origin The origin point
  80138. * @param end The end point
  80139. * @param world a matrix to transform the ray to. Default is the identity matrix.
  80140. * @returns the new ray
  80141. */
  80142. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  80143. /**
  80144. * Transforms a ray by a matrix
  80145. * @param ray ray to transform
  80146. * @param matrix matrix to apply
  80147. * @returns the resulting new ray
  80148. */
  80149. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  80150. /**
  80151. * Transforms a ray by a matrix
  80152. * @param ray ray to transform
  80153. * @param matrix matrix to apply
  80154. * @param result ray to store result in
  80155. */
  80156. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  80157. /**
  80158. * Unproject a ray from screen space to object space
  80159. * @param sourceX defines the screen space x coordinate to use
  80160. * @param sourceY defines the screen space y coordinate to use
  80161. * @param viewportWidth defines the current width of the viewport
  80162. * @param viewportHeight defines the current height of the viewport
  80163. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80164. * @param view defines the view matrix to use
  80165. * @param projection defines the projection matrix to use
  80166. */
  80167. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  80168. }
  80169. /**
  80170. * Type used to define predicate used to select faces when a mesh intersection is detected
  80171. */
  80172. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  80173. interface Scene {
  80174. /** @hidden */
  80175. _tempPickingRay: Nullable<Ray>;
  80176. /** @hidden */
  80177. _cachedRayForTransform: Ray;
  80178. /** @hidden */
  80179. _pickWithRayInverseMatrix: Matrix;
  80180. /** @hidden */
  80181. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  80182. /** @hidden */
  80183. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  80184. }
  80185. }
  80186. declare module BABYLON {
  80187. /**
  80188. * Groups all the scene component constants in one place to ease maintenance.
  80189. * @hidden
  80190. */
  80191. export class SceneComponentConstants {
  80192. static readonly NAME_EFFECTLAYER: string;
  80193. static readonly NAME_LAYER: string;
  80194. static readonly NAME_LENSFLARESYSTEM: string;
  80195. static readonly NAME_BOUNDINGBOXRENDERER: string;
  80196. static readonly NAME_PARTICLESYSTEM: string;
  80197. static readonly NAME_GAMEPAD: string;
  80198. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  80199. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  80200. static readonly NAME_DEPTHRENDERER: string;
  80201. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  80202. static readonly NAME_SPRITE: string;
  80203. static readonly NAME_OUTLINERENDERER: string;
  80204. static readonly NAME_PROCEDURALTEXTURE: string;
  80205. static readonly NAME_SHADOWGENERATOR: string;
  80206. static readonly NAME_OCTREE: string;
  80207. static readonly NAME_PHYSICSENGINE: string;
  80208. static readonly NAME_AUDIO: string;
  80209. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  80210. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  80211. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  80212. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  80213. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  80214. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  80215. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  80216. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  80217. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  80218. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  80219. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  80220. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  80221. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  80222. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  80223. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  80224. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  80225. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  80226. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  80227. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  80228. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  80229. static readonly STEP_AFTERRENDER_AUDIO: number;
  80230. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  80231. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  80232. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  80233. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  80234. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  80235. static readonly STEP_POINTERMOVE_SPRITE: number;
  80236. static readonly STEP_POINTERDOWN_SPRITE: number;
  80237. static readonly STEP_POINTERUP_SPRITE: number;
  80238. }
  80239. /**
  80240. * This represents a scene component.
  80241. *
  80242. * This is used to decouple the dependency the scene is having on the different workloads like
  80243. * layers, post processes...
  80244. */
  80245. export interface ISceneComponent {
  80246. /**
  80247. * The name of the component. Each component must have a unique name.
  80248. */
  80249. name: string;
  80250. /**
  80251. * The scene the component belongs to.
  80252. */
  80253. scene: Scene;
  80254. /**
  80255. * Register the component to one instance of a scene.
  80256. */
  80257. register(): void;
  80258. /**
  80259. * Rebuilds the elements related to this component in case of
  80260. * context lost for instance.
  80261. */
  80262. rebuild(): void;
  80263. /**
  80264. * Disposes the component and the associated ressources.
  80265. */
  80266. dispose(): void;
  80267. }
  80268. /**
  80269. * This represents a SERIALIZABLE scene component.
  80270. *
  80271. * This extends Scene Component to add Serialization methods on top.
  80272. */
  80273. export interface ISceneSerializableComponent extends ISceneComponent {
  80274. /**
  80275. * Adds all the elements from the container to the scene
  80276. * @param container the container holding the elements
  80277. */
  80278. addFromContainer(container: AbstractScene): void;
  80279. /**
  80280. * Removes all the elements in the container from the scene
  80281. * @param container contains the elements to remove
  80282. * @param dispose if the removed element should be disposed (default: false)
  80283. */
  80284. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  80285. /**
  80286. * Serializes the component data to the specified json object
  80287. * @param serializationObject The object to serialize to
  80288. */
  80289. serialize(serializationObject: any): void;
  80290. }
  80291. /**
  80292. * Strong typing of a Mesh related stage step action
  80293. */
  80294. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  80295. /**
  80296. * Strong typing of a Evaluate Sub Mesh related stage step action
  80297. */
  80298. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  80299. /**
  80300. * Strong typing of a Active Mesh related stage step action
  80301. */
  80302. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  80303. /**
  80304. * Strong typing of a Camera related stage step action
  80305. */
  80306. export type CameraStageAction = (camera: Camera) => void;
  80307. /**
  80308. * Strong typing of a Camera Frame buffer related stage step action
  80309. */
  80310. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  80311. /**
  80312. * Strong typing of a Render Target related stage step action
  80313. */
  80314. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  80315. /**
  80316. * Strong typing of a RenderingGroup related stage step action
  80317. */
  80318. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  80319. /**
  80320. * Strong typing of a Mesh Render related stage step action
  80321. */
  80322. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  80323. /**
  80324. * Strong typing of a simple stage step action
  80325. */
  80326. export type SimpleStageAction = () => void;
  80327. /**
  80328. * Strong typing of a render target action.
  80329. */
  80330. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  80331. /**
  80332. * Strong typing of a pointer move action.
  80333. */
  80334. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  80335. /**
  80336. * Strong typing of a pointer up/down action.
  80337. */
  80338. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  80339. /**
  80340. * Representation of a stage in the scene (Basically a list of ordered steps)
  80341. * @hidden
  80342. */
  80343. export class Stage<T extends Function> extends Array<{
  80344. index: number;
  80345. component: ISceneComponent;
  80346. action: T;
  80347. }> {
  80348. /**
  80349. * Hide ctor from the rest of the world.
  80350. * @param items The items to add.
  80351. */
  80352. private constructor();
  80353. /**
  80354. * Creates a new Stage.
  80355. * @returns A new instance of a Stage
  80356. */
  80357. static Create<T extends Function>(): Stage<T>;
  80358. /**
  80359. * Registers a step in an ordered way in the targeted stage.
  80360. * @param index Defines the position to register the step in
  80361. * @param component Defines the component attached to the step
  80362. * @param action Defines the action to launch during the step
  80363. */
  80364. registerStep(index: number, component: ISceneComponent, action: T): void;
  80365. /**
  80366. * Clears all the steps from the stage.
  80367. */
  80368. clear(): void;
  80369. }
  80370. }
  80371. declare module BABYLON {
  80372. interface Scene {
  80373. /** @hidden */
  80374. _pointerOverSprite: Nullable<Sprite>;
  80375. /** @hidden */
  80376. _pickedDownSprite: Nullable<Sprite>;
  80377. /** @hidden */
  80378. _tempSpritePickingRay: Nullable<Ray>;
  80379. /**
  80380. * All of the sprite managers added to this scene
  80381. * @see http://doc.babylonjs.com/babylon101/sprites
  80382. */
  80383. spriteManagers: Array<ISpriteManager>;
  80384. /**
  80385. * An event triggered when sprites rendering is about to start
  80386. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  80387. */
  80388. onBeforeSpritesRenderingObservable: Observable<Scene>;
  80389. /**
  80390. * An event triggered when sprites rendering is done
  80391. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  80392. */
  80393. onAfterSpritesRenderingObservable: Observable<Scene>;
  80394. /** @hidden */
  80395. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  80396. /** Launch a ray to try to pick a sprite in the scene
  80397. * @param x position on screen
  80398. * @param y position on screen
  80399. * @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
  80400. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  80401. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  80402. * @returns a PickingInfo
  80403. */
  80404. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  80405. /** Use the given ray to pick a sprite in the scene
  80406. * @param ray The ray (in world space) to use to pick meshes
  80407. * @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
  80408. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  80409. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  80410. * @returns a PickingInfo
  80411. */
  80412. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  80413. /** @hidden */
  80414. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  80415. /** Launch a ray to try to pick sprites in the scene
  80416. * @param x position on screen
  80417. * @param y position on screen
  80418. * @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
  80419. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  80420. * @returns a PickingInfo array
  80421. */
  80422. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  80423. /** Use the given ray to pick sprites in the scene
  80424. * @param ray The ray (in world space) to use to pick meshes
  80425. * @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
  80426. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  80427. * @returns a PickingInfo array
  80428. */
  80429. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  80430. /**
  80431. * Force the sprite under the pointer
  80432. * @param sprite defines the sprite to use
  80433. */
  80434. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  80435. /**
  80436. * Gets the sprite under the pointer
  80437. * @returns a Sprite or null if no sprite is under the pointer
  80438. */
  80439. getPointerOverSprite(): Nullable<Sprite>;
  80440. }
  80441. /**
  80442. * Defines the sprite scene component responsible to manage sprites
  80443. * in a given scene.
  80444. */
  80445. export class SpriteSceneComponent implements ISceneComponent {
  80446. /**
  80447. * The component name helpfull to identify the component in the list of scene components.
  80448. */
  80449. readonly name: string;
  80450. /**
  80451. * The scene the component belongs to.
  80452. */
  80453. scene: Scene;
  80454. /** @hidden */
  80455. private _spritePredicate;
  80456. /**
  80457. * Creates a new instance of the component for the given scene
  80458. * @param scene Defines the scene to register the component in
  80459. */
  80460. constructor(scene: Scene);
  80461. /**
  80462. * Registers the component in a given scene
  80463. */
  80464. register(): void;
  80465. /**
  80466. * Rebuilds the elements related to this component in case of
  80467. * context lost for instance.
  80468. */
  80469. rebuild(): void;
  80470. /**
  80471. * Disposes the component and the associated ressources.
  80472. */
  80473. dispose(): void;
  80474. private _pickSpriteButKeepRay;
  80475. private _pointerMove;
  80476. private _pointerDown;
  80477. private _pointerUp;
  80478. }
  80479. }
  80480. declare module BABYLON {
  80481. /** @hidden */
  80482. export var fogFragmentDeclaration: {
  80483. name: string;
  80484. shader: string;
  80485. };
  80486. }
  80487. declare module BABYLON {
  80488. /** @hidden */
  80489. export var fogFragment: {
  80490. name: string;
  80491. shader: string;
  80492. };
  80493. }
  80494. declare module BABYLON {
  80495. /** @hidden */
  80496. export var spritesPixelShader: {
  80497. name: string;
  80498. shader: string;
  80499. };
  80500. }
  80501. declare module BABYLON {
  80502. /** @hidden */
  80503. export var fogVertexDeclaration: {
  80504. name: string;
  80505. shader: string;
  80506. };
  80507. }
  80508. declare module BABYLON {
  80509. /** @hidden */
  80510. export var spritesVertexShader: {
  80511. name: string;
  80512. shader: string;
  80513. };
  80514. }
  80515. declare module BABYLON {
  80516. /**
  80517. * Defines the minimum interface to fullfil in order to be a sprite manager.
  80518. */
  80519. export interface ISpriteManager extends IDisposable {
  80520. /**
  80521. * Restricts the camera to viewing objects with the same layerMask.
  80522. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  80523. */
  80524. layerMask: number;
  80525. /**
  80526. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  80527. */
  80528. isPickable: boolean;
  80529. /**
  80530. * Specifies the rendering group id for this mesh (0 by default)
  80531. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  80532. */
  80533. renderingGroupId: number;
  80534. /**
  80535. * Defines the list of sprites managed by the manager.
  80536. */
  80537. sprites: Array<Sprite>;
  80538. /**
  80539. * Tests the intersection of a sprite with a specific ray.
  80540. * @param ray The ray we are sending to test the collision
  80541. * @param camera The camera space we are sending rays in
  80542. * @param predicate A predicate allowing excluding sprites from the list of object to test
  80543. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  80544. * @returns picking info or null.
  80545. */
  80546. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  80547. /**
  80548. * Intersects the sprites with a ray
  80549. * @param ray defines the ray to intersect with
  80550. * @param camera defines the current active camera
  80551. * @param predicate defines a predicate used to select candidate sprites
  80552. * @returns null if no hit or a PickingInfo array
  80553. */
  80554. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  80555. /**
  80556. * Renders the list of sprites on screen.
  80557. */
  80558. render(): void;
  80559. }
  80560. /**
  80561. * Class used to manage multiple sprites on the same spritesheet
  80562. * @see http://doc.babylonjs.com/babylon101/sprites
  80563. */
  80564. export class SpriteManager implements ISpriteManager {
  80565. /** defines the manager's name */
  80566. name: string;
  80567. /** Gets the list of sprites */
  80568. sprites: Sprite[];
  80569. /** Gets or sets the rendering group id (0 by default) */
  80570. renderingGroupId: number;
  80571. /** Gets or sets camera layer mask */
  80572. layerMask: number;
  80573. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  80574. fogEnabled: boolean;
  80575. /** Gets or sets a boolean indicating if the sprites are pickable */
  80576. isPickable: boolean;
  80577. /** Defines the default width of a cell in the spritesheet */
  80578. cellWidth: number;
  80579. /** Defines the default height of a cell in the spritesheet */
  80580. cellHeight: number;
  80581. /** Associative array from JSON sprite data file */
  80582. private _cellData;
  80583. /** Array of sprite names from JSON sprite data file */
  80584. private _spriteMap;
  80585. /** True when packed cell data from JSON file is ready*/
  80586. private _packedAndReady;
  80587. /**
  80588. * An event triggered when the manager is disposed.
  80589. */
  80590. onDisposeObservable: Observable<SpriteManager>;
  80591. private _onDisposeObserver;
  80592. /**
  80593. * Callback called when the manager is disposed
  80594. */
  80595. onDispose: () => void;
  80596. private _capacity;
  80597. private _fromPacked;
  80598. private _spriteTexture;
  80599. private _epsilon;
  80600. private _scene;
  80601. private _vertexData;
  80602. private _buffer;
  80603. private _vertexBuffers;
  80604. private _indexBuffer;
  80605. private _effectBase;
  80606. private _effectFog;
  80607. /**
  80608. * Gets or sets the spritesheet texture
  80609. */
  80610. texture: Texture;
  80611. /**
  80612. * Creates a new sprite manager
  80613. * @param name defines the manager's name
  80614. * @param imgUrl defines the sprite sheet url
  80615. * @param capacity defines the maximum allowed number of sprites
  80616. * @param cellSize defines the size of a sprite cell
  80617. * @param scene defines the hosting scene
  80618. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  80619. * @param samplingMode defines the smapling mode to use with spritesheet
  80620. * @param fromPacked set to false; do not alter
  80621. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  80622. */
  80623. constructor(
  80624. /** defines the manager's name */
  80625. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  80626. private _makePacked;
  80627. private _appendSpriteVertex;
  80628. /**
  80629. * Intersects the sprites with a ray
  80630. * @param ray defines the ray to intersect with
  80631. * @param camera defines the current active camera
  80632. * @param predicate defines a predicate used to select candidate sprites
  80633. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  80634. * @returns null if no hit or a PickingInfo
  80635. */
  80636. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  80637. /**
  80638. * Intersects the sprites with a ray
  80639. * @param ray defines the ray to intersect with
  80640. * @param camera defines the current active camera
  80641. * @param predicate defines a predicate used to select candidate sprites
  80642. * @returns null if no hit or a PickingInfo array
  80643. */
  80644. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  80645. /**
  80646. * Render all child sprites
  80647. */
  80648. render(): void;
  80649. /**
  80650. * Release associated resources
  80651. */
  80652. dispose(): void;
  80653. }
  80654. }
  80655. declare module BABYLON {
  80656. /**
  80657. * Class used to represent a sprite
  80658. * @see http://doc.babylonjs.com/babylon101/sprites
  80659. */
  80660. export class Sprite {
  80661. /** defines the name */
  80662. name: string;
  80663. /** Gets or sets the current world position */
  80664. position: Vector3;
  80665. /** Gets or sets the main color */
  80666. color: Color4;
  80667. /** Gets or sets the width */
  80668. width: number;
  80669. /** Gets or sets the height */
  80670. height: number;
  80671. /** Gets or sets rotation angle */
  80672. angle: number;
  80673. /** Gets or sets the cell index in the sprite sheet */
  80674. cellIndex: number;
  80675. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  80676. cellRef: string;
  80677. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  80678. invertU: number;
  80679. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  80680. invertV: number;
  80681. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  80682. disposeWhenFinishedAnimating: boolean;
  80683. /** Gets the list of attached animations */
  80684. animations: Animation[];
  80685. /** Gets or sets a boolean indicating if the sprite can be picked */
  80686. isPickable: boolean;
  80687. /**
  80688. * Gets or sets the associated action manager
  80689. */
  80690. actionManager: Nullable<ActionManager>;
  80691. private _animationStarted;
  80692. private _loopAnimation;
  80693. private _fromIndex;
  80694. private _toIndex;
  80695. private _delay;
  80696. private _direction;
  80697. private _manager;
  80698. private _time;
  80699. private _onAnimationEnd;
  80700. /**
  80701. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  80702. */
  80703. isVisible: boolean;
  80704. /**
  80705. * Gets or sets the sprite size
  80706. */
  80707. size: number;
  80708. /**
  80709. * Creates a new Sprite
  80710. * @param name defines the name
  80711. * @param manager defines the manager
  80712. */
  80713. constructor(
  80714. /** defines the name */
  80715. name: string, manager: ISpriteManager);
  80716. /**
  80717. * Starts an animation
  80718. * @param from defines the initial key
  80719. * @param to defines the end key
  80720. * @param loop defines if the animation must loop
  80721. * @param delay defines the start delay (in ms)
  80722. * @param onAnimationEnd defines a callback to call when animation ends
  80723. */
  80724. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  80725. /** Stops current animation (if any) */
  80726. stopAnimation(): void;
  80727. /** @hidden */
  80728. _animate(deltaTime: number): void;
  80729. /** Release associated resources */
  80730. dispose(): void;
  80731. }
  80732. }
  80733. declare module BABYLON {
  80734. /**
  80735. * Information about the result of picking within a scene
  80736. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  80737. */
  80738. export class PickingInfo {
  80739. /** @hidden */
  80740. _pickingUnavailable: boolean;
  80741. /**
  80742. * If the pick collided with an object
  80743. */
  80744. hit: boolean;
  80745. /**
  80746. * Distance away where the pick collided
  80747. */
  80748. distance: number;
  80749. /**
  80750. * The location of pick collision
  80751. */
  80752. pickedPoint: Nullable<Vector3>;
  80753. /**
  80754. * The mesh corresponding the the pick collision
  80755. */
  80756. pickedMesh: Nullable<AbstractMesh>;
  80757. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  80758. bu: number;
  80759. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  80760. bv: number;
  80761. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  80762. faceId: number;
  80763. /** Id of the the submesh that was picked */
  80764. subMeshId: number;
  80765. /** If a sprite was picked, this will be the sprite the pick collided with */
  80766. pickedSprite: Nullable<Sprite>;
  80767. /**
  80768. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  80769. */
  80770. originMesh: Nullable<AbstractMesh>;
  80771. /**
  80772. * The ray that was used to perform the picking.
  80773. */
  80774. ray: Nullable<Ray>;
  80775. /**
  80776. * Gets the normal correspodning to the face the pick collided with
  80777. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  80778. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  80779. * @returns The normal correspodning to the face the pick collided with
  80780. */
  80781. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  80782. /**
  80783. * Gets the texture coordinates of where the pick occured
  80784. * @returns the vector containing the coordnates of the texture
  80785. */
  80786. getTextureCoordinates(): Nullable<Vector2>;
  80787. }
  80788. }
  80789. declare module BABYLON {
  80790. /**
  80791. * Gather the list of pointer event types as constants.
  80792. */
  80793. export class PointerEventTypes {
  80794. /**
  80795. * 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.
  80796. */
  80797. static readonly POINTERDOWN: number;
  80798. /**
  80799. * The pointerup event is fired when a pointer is no longer active.
  80800. */
  80801. static readonly POINTERUP: number;
  80802. /**
  80803. * The pointermove event is fired when a pointer changes coordinates.
  80804. */
  80805. static readonly POINTERMOVE: number;
  80806. /**
  80807. * The pointerwheel event is fired when a mouse wheel has been rotated.
  80808. */
  80809. static readonly POINTERWHEEL: number;
  80810. /**
  80811. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  80812. */
  80813. static readonly POINTERPICK: number;
  80814. /**
  80815. * The pointertap event is fired when a the object has been touched and released without drag.
  80816. */
  80817. static readonly POINTERTAP: number;
  80818. /**
  80819. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  80820. */
  80821. static readonly POINTERDOUBLETAP: number;
  80822. }
  80823. /**
  80824. * Base class of pointer info types.
  80825. */
  80826. export class PointerInfoBase {
  80827. /**
  80828. * Defines the type of event (PointerEventTypes)
  80829. */
  80830. type: number;
  80831. /**
  80832. * Defines the related dom event
  80833. */
  80834. event: PointerEvent | MouseWheelEvent;
  80835. /**
  80836. * Instantiates the base class of pointers info.
  80837. * @param type Defines the type of event (PointerEventTypes)
  80838. * @param event Defines the related dom event
  80839. */
  80840. constructor(
  80841. /**
  80842. * Defines the type of event (PointerEventTypes)
  80843. */
  80844. type: number,
  80845. /**
  80846. * Defines the related dom event
  80847. */
  80848. event: PointerEvent | MouseWheelEvent);
  80849. }
  80850. /**
  80851. * This class is used to store pointer related info for the onPrePointerObservable event.
  80852. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  80853. */
  80854. export class PointerInfoPre extends PointerInfoBase {
  80855. /**
  80856. * Ray from a pointer if availible (eg. 6dof controller)
  80857. */
  80858. ray: Nullable<Ray>;
  80859. /**
  80860. * Defines the local position of the pointer on the canvas.
  80861. */
  80862. localPosition: Vector2;
  80863. /**
  80864. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  80865. */
  80866. skipOnPointerObservable: boolean;
  80867. /**
  80868. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  80869. * @param type Defines the type of event (PointerEventTypes)
  80870. * @param event Defines the related dom event
  80871. * @param localX Defines the local x coordinates of the pointer when the event occured
  80872. * @param localY Defines the local y coordinates of the pointer when the event occured
  80873. */
  80874. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  80875. }
  80876. /**
  80877. * This type contains all the data related to a pointer event in Babylon.js.
  80878. * 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.
  80879. */
  80880. export class PointerInfo extends PointerInfoBase {
  80881. /**
  80882. * Defines the picking info associated to the info (if any)\
  80883. */
  80884. pickInfo: Nullable<PickingInfo>;
  80885. /**
  80886. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  80887. * @param type Defines the type of event (PointerEventTypes)
  80888. * @param event Defines the related dom event
  80889. * @param pickInfo Defines the picking info associated to the info (if any)\
  80890. */
  80891. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  80892. /**
  80893. * Defines the picking info associated to the info (if any)\
  80894. */
  80895. pickInfo: Nullable<PickingInfo>);
  80896. }
  80897. /**
  80898. * Data relating to a touch event on the screen.
  80899. */
  80900. export interface PointerTouch {
  80901. /**
  80902. * X coordinate of touch.
  80903. */
  80904. x: number;
  80905. /**
  80906. * Y coordinate of touch.
  80907. */
  80908. y: number;
  80909. /**
  80910. * Id of touch. Unique for each finger.
  80911. */
  80912. pointerId: number;
  80913. /**
  80914. * Event type passed from DOM.
  80915. */
  80916. type: any;
  80917. }
  80918. }
  80919. declare module BABYLON {
  80920. /**
  80921. * Manage the mouse inputs to control the movement of a free camera.
  80922. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80923. */
  80924. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  80925. /**
  80926. * Define if touch is enabled in the mouse input
  80927. */
  80928. touchEnabled: boolean;
  80929. /**
  80930. * Defines the camera the input is attached to.
  80931. */
  80932. camera: FreeCamera;
  80933. /**
  80934. * Defines the buttons associated with the input to handle camera move.
  80935. */
  80936. buttons: number[];
  80937. /**
  80938. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  80939. */
  80940. angularSensibility: number;
  80941. private _pointerInput;
  80942. private _onMouseMove;
  80943. private _observer;
  80944. private previousPosition;
  80945. /**
  80946. * Observable for when a pointer move event occurs containing the move offset
  80947. */
  80948. onPointerMovedObservable: Observable<{
  80949. offsetX: number;
  80950. offsetY: number;
  80951. }>;
  80952. /**
  80953. * @hidden
  80954. * If the camera should be rotated automatically based on pointer movement
  80955. */
  80956. _allowCameraRotation: boolean;
  80957. /**
  80958. * Manage the mouse inputs to control the movement of a free camera.
  80959. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80960. * @param touchEnabled Defines if touch is enabled or not
  80961. */
  80962. constructor(
  80963. /**
  80964. * Define if touch is enabled in the mouse input
  80965. */
  80966. touchEnabled?: boolean);
  80967. /**
  80968. * Attach the input controls to a specific dom element to get the input from.
  80969. * @param element Defines the element the controls should be listened from
  80970. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80971. */
  80972. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80973. /**
  80974. * Called on JS contextmenu event.
  80975. * Override this method to provide functionality.
  80976. */
  80977. protected onContextMenu(evt: PointerEvent): void;
  80978. /**
  80979. * Detach the current controls from the specified dom element.
  80980. * @param element Defines the element to stop listening the inputs from
  80981. */
  80982. detachControl(element: Nullable<HTMLElement>): void;
  80983. /**
  80984. * Gets the class name of the current intput.
  80985. * @returns the class name
  80986. */
  80987. getClassName(): string;
  80988. /**
  80989. * Get the friendly name associated with the input class.
  80990. * @returns the input friendly name
  80991. */
  80992. getSimpleName(): string;
  80993. }
  80994. }
  80995. declare module BABYLON {
  80996. /**
  80997. * Manage the touch inputs to control the movement of a free camera.
  80998. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80999. */
  81000. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  81001. /**
  81002. * Defines the camera the input is attached to.
  81003. */
  81004. camera: FreeCamera;
  81005. /**
  81006. * Defines the touch sensibility for rotation.
  81007. * The higher the faster.
  81008. */
  81009. touchAngularSensibility: number;
  81010. /**
  81011. * Defines the touch sensibility for move.
  81012. * The higher the faster.
  81013. */
  81014. touchMoveSensibility: number;
  81015. private _offsetX;
  81016. private _offsetY;
  81017. private _pointerPressed;
  81018. private _pointerInput;
  81019. private _observer;
  81020. private _onLostFocus;
  81021. /**
  81022. * Attach the input controls to a specific dom element to get the input from.
  81023. * @param element Defines the element the controls should be listened from
  81024. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  81025. */
  81026. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  81027. /**
  81028. * Detach the current controls from the specified dom element.
  81029. * @param element Defines the element to stop listening the inputs from
  81030. */
  81031. detachControl(element: Nullable<HTMLElement>): void;
  81032. /**
  81033. * Update the current camera state depending on the inputs that have been used this frame.
  81034. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  81035. */
  81036. checkInputs(): void;
  81037. /**
  81038. * Gets the class name of the current intput.
  81039. * @returns the class name
  81040. */
  81041. getClassName(): string;
  81042. /**
  81043. * Get the friendly name associated with the input class.
  81044. * @returns the input friendly name
  81045. */
  81046. getSimpleName(): string;
  81047. }
  81048. }
  81049. declare module BABYLON {
  81050. /**
  81051. * Default Inputs manager for the FreeCamera.
  81052. * It groups all the default supported inputs for ease of use.
  81053. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  81054. */
  81055. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  81056. /**
  81057. * @hidden
  81058. */
  81059. _mouseInput: Nullable<FreeCameraMouseInput>;
  81060. /**
  81061. * Instantiates a new FreeCameraInputsManager.
  81062. * @param camera Defines the camera the inputs belong to
  81063. */
  81064. constructor(camera: FreeCamera);
  81065. /**
  81066. * Add keyboard input support to the input manager.
  81067. * @returns the current input manager
  81068. */
  81069. addKeyboard(): FreeCameraInputsManager;
  81070. /**
  81071. * Add mouse input support to the input manager.
  81072. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  81073. * @returns the current input manager
  81074. */
  81075. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  81076. /**
  81077. * Removes the mouse input support from the manager
  81078. * @returns the current input manager
  81079. */
  81080. removeMouse(): FreeCameraInputsManager;
  81081. /**
  81082. * Add touch input support to the input manager.
  81083. * @returns the current input manager
  81084. */
  81085. addTouch(): FreeCameraInputsManager;
  81086. /**
  81087. * Remove all attached input methods from a camera
  81088. */
  81089. clear(): void;
  81090. }
  81091. }
  81092. declare module BABYLON {
  81093. /**
  81094. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  81095. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  81096. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  81097. */
  81098. export class FreeCamera extends TargetCamera {
  81099. /**
  81100. * Define the collision ellipsoid of the camera.
  81101. * This is helpful to simulate a camera body like the player body around the camera
  81102. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  81103. */
  81104. ellipsoid: Vector3;
  81105. /**
  81106. * Define an offset for the position of the ellipsoid around the camera.
  81107. * This can be helpful to determine the center of the body near the gravity center of the body
  81108. * instead of its head.
  81109. */
  81110. ellipsoidOffset: Vector3;
  81111. /**
  81112. * Enable or disable collisions of the camera with the rest of the scene objects.
  81113. */
  81114. checkCollisions: boolean;
  81115. /**
  81116. * Enable or disable gravity on the camera.
  81117. */
  81118. applyGravity: boolean;
  81119. /**
  81120. * Define the input manager associated to the camera.
  81121. */
  81122. inputs: FreeCameraInputsManager;
  81123. /**
  81124. * Gets the input sensibility for a mouse input. (default is 2000.0)
  81125. * Higher values reduce sensitivity.
  81126. */
  81127. /**
  81128. * Sets the input sensibility for a mouse input. (default is 2000.0)
  81129. * Higher values reduce sensitivity.
  81130. */
  81131. angularSensibility: number;
  81132. /**
  81133. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  81134. */
  81135. keysUp: number[];
  81136. /**
  81137. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  81138. */
  81139. keysDown: number[];
  81140. /**
  81141. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  81142. */
  81143. keysLeft: number[];
  81144. /**
  81145. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  81146. */
  81147. keysRight: number[];
  81148. /**
  81149. * Event raised when the camera collide with a mesh in the scene.
  81150. */
  81151. onCollide: (collidedMesh: AbstractMesh) => void;
  81152. private _collider;
  81153. private _needMoveForGravity;
  81154. private _oldPosition;
  81155. private _diffPosition;
  81156. private _newPosition;
  81157. /** @hidden */
  81158. _localDirection: Vector3;
  81159. /** @hidden */
  81160. _transformedDirection: Vector3;
  81161. /**
  81162. * Instantiates a Free Camera.
  81163. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  81164. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  81165. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  81166. * @param name Define the name of the camera in the scene
  81167. * @param position Define the start position of the camera in the scene
  81168. * @param scene Define the scene the camera belongs to
  81169. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  81170. */
  81171. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  81172. /**
  81173. * Attached controls to the current camera.
  81174. * @param element Defines the element the controls should be listened from
  81175. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  81176. */
  81177. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  81178. /**
  81179. * Detach the current controls from the camera.
  81180. * The camera will stop reacting to inputs.
  81181. * @param element Defines the element to stop listening the inputs from
  81182. */
  81183. detachControl(element: HTMLElement): void;
  81184. private _collisionMask;
  81185. /**
  81186. * Define a collision mask to limit the list of object the camera can collide with
  81187. */
  81188. collisionMask: number;
  81189. /** @hidden */
  81190. _collideWithWorld(displacement: Vector3): void;
  81191. private _onCollisionPositionChange;
  81192. /** @hidden */
  81193. _checkInputs(): void;
  81194. /** @hidden */
  81195. _decideIfNeedsToMove(): boolean;
  81196. /** @hidden */
  81197. _updatePosition(): void;
  81198. /**
  81199. * Destroy the camera and release the current resources hold by it.
  81200. */
  81201. dispose(): void;
  81202. /**
  81203. * Gets the current object class name.
  81204. * @return the class name
  81205. */
  81206. getClassName(): string;
  81207. }
  81208. }
  81209. declare module BABYLON {
  81210. /**
  81211. * Represents a gamepad control stick position
  81212. */
  81213. export class StickValues {
  81214. /**
  81215. * The x component of the control stick
  81216. */
  81217. x: number;
  81218. /**
  81219. * The y component of the control stick
  81220. */
  81221. y: number;
  81222. /**
  81223. * Initializes the gamepad x and y control stick values
  81224. * @param x The x component of the gamepad control stick value
  81225. * @param y The y component of the gamepad control stick value
  81226. */
  81227. constructor(
  81228. /**
  81229. * The x component of the control stick
  81230. */
  81231. x: number,
  81232. /**
  81233. * The y component of the control stick
  81234. */
  81235. y: number);
  81236. }
  81237. /**
  81238. * An interface which manages callbacks for gamepad button changes
  81239. */
  81240. export interface GamepadButtonChanges {
  81241. /**
  81242. * Called when a gamepad has been changed
  81243. */
  81244. changed: boolean;
  81245. /**
  81246. * Called when a gamepad press event has been triggered
  81247. */
  81248. pressChanged: boolean;
  81249. /**
  81250. * Called when a touch event has been triggered
  81251. */
  81252. touchChanged: boolean;
  81253. /**
  81254. * Called when a value has changed
  81255. */
  81256. valueChanged: boolean;
  81257. }
  81258. /**
  81259. * Represents a gamepad
  81260. */
  81261. export class Gamepad {
  81262. /**
  81263. * The id of the gamepad
  81264. */
  81265. id: string;
  81266. /**
  81267. * The index of the gamepad
  81268. */
  81269. index: number;
  81270. /**
  81271. * The browser gamepad
  81272. */
  81273. browserGamepad: any;
  81274. /**
  81275. * Specifies what type of gamepad this represents
  81276. */
  81277. type: number;
  81278. private _leftStick;
  81279. private _rightStick;
  81280. /** @hidden */
  81281. _isConnected: boolean;
  81282. private _leftStickAxisX;
  81283. private _leftStickAxisY;
  81284. private _rightStickAxisX;
  81285. private _rightStickAxisY;
  81286. /**
  81287. * Triggered when the left control stick has been changed
  81288. */
  81289. private _onleftstickchanged;
  81290. /**
  81291. * Triggered when the right control stick has been changed
  81292. */
  81293. private _onrightstickchanged;
  81294. /**
  81295. * Represents a gamepad controller
  81296. */
  81297. static GAMEPAD: number;
  81298. /**
  81299. * Represents a generic controller
  81300. */
  81301. static GENERIC: number;
  81302. /**
  81303. * Represents an XBox controller
  81304. */
  81305. static XBOX: number;
  81306. /**
  81307. * Represents a pose-enabled controller
  81308. */
  81309. static POSE_ENABLED: number;
  81310. /**
  81311. * Represents an Dual Shock controller
  81312. */
  81313. static DUALSHOCK: number;
  81314. /**
  81315. * Specifies whether the left control stick should be Y-inverted
  81316. */
  81317. protected _invertLeftStickY: boolean;
  81318. /**
  81319. * Specifies if the gamepad has been connected
  81320. */
  81321. readonly isConnected: boolean;
  81322. /**
  81323. * Initializes the gamepad
  81324. * @param id The id of the gamepad
  81325. * @param index The index of the gamepad
  81326. * @param browserGamepad The browser gamepad
  81327. * @param leftStickX The x component of the left joystick
  81328. * @param leftStickY The y component of the left joystick
  81329. * @param rightStickX The x component of the right joystick
  81330. * @param rightStickY The y component of the right joystick
  81331. */
  81332. constructor(
  81333. /**
  81334. * The id of the gamepad
  81335. */
  81336. id: string,
  81337. /**
  81338. * The index of the gamepad
  81339. */
  81340. index: number,
  81341. /**
  81342. * The browser gamepad
  81343. */
  81344. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  81345. /**
  81346. * Callback triggered when the left joystick has changed
  81347. * @param callback
  81348. */
  81349. onleftstickchanged(callback: (values: StickValues) => void): void;
  81350. /**
  81351. * Callback triggered when the right joystick has changed
  81352. * @param callback
  81353. */
  81354. onrightstickchanged(callback: (values: StickValues) => void): void;
  81355. /**
  81356. * Gets the left joystick
  81357. */
  81358. /**
  81359. * Sets the left joystick values
  81360. */
  81361. leftStick: StickValues;
  81362. /**
  81363. * Gets the right joystick
  81364. */
  81365. /**
  81366. * Sets the right joystick value
  81367. */
  81368. rightStick: StickValues;
  81369. /**
  81370. * Updates the gamepad joystick positions
  81371. */
  81372. update(): void;
  81373. /**
  81374. * Disposes the gamepad
  81375. */
  81376. dispose(): void;
  81377. }
  81378. /**
  81379. * Represents a generic gamepad
  81380. */
  81381. export class GenericPad extends Gamepad {
  81382. private _buttons;
  81383. private _onbuttondown;
  81384. private _onbuttonup;
  81385. /**
  81386. * Observable triggered when a button has been pressed
  81387. */
  81388. onButtonDownObservable: Observable<number>;
  81389. /**
  81390. * Observable triggered when a button has been released
  81391. */
  81392. onButtonUpObservable: Observable<number>;
  81393. /**
  81394. * Callback triggered when a button has been pressed
  81395. * @param callback Called when a button has been pressed
  81396. */
  81397. onbuttondown(callback: (buttonPressed: number) => void): void;
  81398. /**
  81399. * Callback triggered when a button has been released
  81400. * @param callback Called when a button has been released
  81401. */
  81402. onbuttonup(callback: (buttonReleased: number) => void): void;
  81403. /**
  81404. * Initializes the generic gamepad
  81405. * @param id The id of the generic gamepad
  81406. * @param index The index of the generic gamepad
  81407. * @param browserGamepad The browser gamepad
  81408. */
  81409. constructor(id: string, index: number, browserGamepad: any);
  81410. private _setButtonValue;
  81411. /**
  81412. * Updates the generic gamepad
  81413. */
  81414. update(): void;
  81415. /**
  81416. * Disposes the generic gamepad
  81417. */
  81418. dispose(): void;
  81419. }
  81420. }
  81421. declare module BABYLON {
  81422. interface Engine {
  81423. /**
  81424. * Creates a raw texture
  81425. * @param data defines the data to store in the texture
  81426. * @param width defines the width of the texture
  81427. * @param height defines the height of the texture
  81428. * @param format defines the format of the data
  81429. * @param generateMipMaps defines if the engine should generate the mip levels
  81430. * @param invertY defines if data must be stored with Y axis inverted
  81431. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  81432. * @param compression defines the compression used (null by default)
  81433. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  81434. * @returns the raw texture inside an InternalTexture
  81435. */
  81436. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  81437. /**
  81438. * Update a raw texture
  81439. * @param texture defines the texture to update
  81440. * @param data defines the data to store in the texture
  81441. * @param format defines the format of the data
  81442. * @param invertY defines if data must be stored with Y axis inverted
  81443. */
  81444. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  81445. /**
  81446. * Update a raw texture
  81447. * @param texture defines the texture to update
  81448. * @param data defines the data to store in the texture
  81449. * @param format defines the format of the data
  81450. * @param invertY defines if data must be stored with Y axis inverted
  81451. * @param compression defines the compression used (null by default)
  81452. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  81453. */
  81454. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  81455. /**
  81456. * Creates a new raw cube texture
  81457. * @param data defines the array of data to use to create each face
  81458. * @param size defines the size of the textures
  81459. * @param format defines the format of the data
  81460. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  81461. * @param generateMipMaps defines if the engine should generate the mip levels
  81462. * @param invertY defines if data must be stored with Y axis inverted
  81463. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  81464. * @param compression defines the compression used (null by default)
  81465. * @returns the cube texture as an InternalTexture
  81466. */
  81467. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  81468. /**
  81469. * Update a raw cube texture
  81470. * @param texture defines the texture to udpdate
  81471. * @param data defines the data to store
  81472. * @param format defines the data format
  81473. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  81474. * @param invertY defines if data must be stored with Y axis inverted
  81475. */
  81476. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  81477. /**
  81478. * Update a raw cube texture
  81479. * @param texture defines the texture to udpdate
  81480. * @param data defines the data to store
  81481. * @param format defines the data format
  81482. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  81483. * @param invertY defines if data must be stored with Y axis inverted
  81484. * @param compression defines the compression used (null by default)
  81485. */
  81486. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  81487. /**
  81488. * Update a raw cube texture
  81489. * @param texture defines the texture to udpdate
  81490. * @param data defines the data to store
  81491. * @param format defines the data format
  81492. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  81493. * @param invertY defines if data must be stored with Y axis inverted
  81494. * @param compression defines the compression used (null by default)
  81495. * @param level defines which level of the texture to update
  81496. */
  81497. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  81498. /**
  81499. * Creates a new raw cube texture from a specified url
  81500. * @param url defines the url where the data is located
  81501. * @param scene defines the current scene
  81502. * @param size defines the size of the textures
  81503. * @param format defines the format of the data
  81504. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  81505. * @param noMipmap defines if the engine should avoid generating the mip levels
  81506. * @param callback defines a callback used to extract texture data from loaded data
  81507. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  81508. * @param onLoad defines a callback called when texture is loaded
  81509. * @param onError defines a callback called if there is an error
  81510. * @returns the cube texture as an InternalTexture
  81511. */
  81512. 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;
  81513. /**
  81514. * Creates a new raw cube texture from a specified url
  81515. * @param url defines the url where the data is located
  81516. * @param scene defines the current scene
  81517. * @param size defines the size of the textures
  81518. * @param format defines the format of the data
  81519. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  81520. * @param noMipmap defines if the engine should avoid generating the mip levels
  81521. * @param callback defines a callback used to extract texture data from loaded data
  81522. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  81523. * @param onLoad defines a callback called when texture is loaded
  81524. * @param onError defines a callback called if there is an error
  81525. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  81526. * @param invertY defines if data must be stored with Y axis inverted
  81527. * @returns the cube texture as an InternalTexture
  81528. */
  81529. 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;
  81530. /**
  81531. * Creates a new raw 3D texture
  81532. * @param data defines the data used to create the texture
  81533. * @param width defines the width of the texture
  81534. * @param height defines the height of the texture
  81535. * @param depth defines the depth of the texture
  81536. * @param format defines the format of the texture
  81537. * @param generateMipMaps defines if the engine must generate mip levels
  81538. * @param invertY defines if data must be stored with Y axis inverted
  81539. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  81540. * @param compression defines the compressed used (can be null)
  81541. * @param textureType defines the compressed used (can be null)
  81542. * @returns a new raw 3D texture (stored in an InternalTexture)
  81543. */
  81544. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  81545. /**
  81546. * Update a raw 3D texture
  81547. * @param texture defines the texture to update
  81548. * @param data defines the data to store
  81549. * @param format defines the data format
  81550. * @param invertY defines if data must be stored with Y axis inverted
  81551. */
  81552. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  81553. /**
  81554. * Update a raw 3D texture
  81555. * @param texture defines the texture to update
  81556. * @param data defines the data to store
  81557. * @param format defines the data format
  81558. * @param invertY defines if data must be stored with Y axis inverted
  81559. * @param compression defines the used compression (can be null)
  81560. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  81561. */
  81562. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  81563. /**
  81564. * Creates a new raw 2D array texture
  81565. * @param data defines the data used to create the texture
  81566. * @param width defines the width of the texture
  81567. * @param height defines the height of the texture
  81568. * @param depth defines the number of layers of the texture
  81569. * @param format defines the format of the texture
  81570. * @param generateMipMaps defines if the engine must generate mip levels
  81571. * @param invertY defines if data must be stored with Y axis inverted
  81572. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  81573. * @param compression defines the compressed used (can be null)
  81574. * @param textureType defines the compressed used (can be null)
  81575. * @returns a new raw 2D array texture (stored in an InternalTexture)
  81576. */
  81577. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  81578. /**
  81579. * Update a raw 2D array texture
  81580. * @param texture defines the texture to update
  81581. * @param data defines the data to store
  81582. * @param format defines the data format
  81583. * @param invertY defines if data must be stored with Y axis inverted
  81584. */
  81585. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  81586. /**
  81587. * Update a raw 2D array texture
  81588. * @param texture defines the texture to update
  81589. * @param data defines the data to store
  81590. * @param format defines the data format
  81591. * @param invertY defines if data must be stored with Y axis inverted
  81592. * @param compression defines the used compression (can be null)
  81593. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  81594. */
  81595. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  81596. }
  81597. }
  81598. declare module BABYLON {
  81599. /**
  81600. * Raw texture can help creating a texture directly from an array of data.
  81601. * This can be super useful if you either get the data from an uncompressed source or
  81602. * if you wish to create your texture pixel by pixel.
  81603. */
  81604. export class RawTexture extends Texture {
  81605. /**
  81606. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  81607. */
  81608. format: number;
  81609. private _engine;
  81610. /**
  81611. * Instantiates a new RawTexture.
  81612. * Raw texture can help creating a texture directly from an array of data.
  81613. * This can be super useful if you either get the data from an uncompressed source or
  81614. * if you wish to create your texture pixel by pixel.
  81615. * @param data define the array of data to use to create the texture
  81616. * @param width define the width of the texture
  81617. * @param height define the height of the texture
  81618. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  81619. * @param scene define the scene the texture belongs to
  81620. * @param generateMipMaps define whether mip maps should be generated or not
  81621. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81622. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81623. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  81624. */
  81625. constructor(data: ArrayBufferView, width: number, height: number,
  81626. /**
  81627. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  81628. */
  81629. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  81630. /**
  81631. * Updates the texture underlying data.
  81632. * @param data Define the new data of the texture
  81633. */
  81634. update(data: ArrayBufferView): void;
  81635. /**
  81636. * Creates a luminance texture from some data.
  81637. * @param data Define the texture data
  81638. * @param width Define the width of the texture
  81639. * @param height Define the height of the texture
  81640. * @param scene Define the scene the texture belongs to
  81641. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81642. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81643. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81644. * @returns the luminance texture
  81645. */
  81646. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  81647. /**
  81648. * Creates a luminance alpha texture from some data.
  81649. * @param data Define the texture data
  81650. * @param width Define the width of the texture
  81651. * @param height Define the height of the texture
  81652. * @param scene Define the scene the texture belongs to
  81653. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81654. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81655. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81656. * @returns the luminance alpha texture
  81657. */
  81658. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  81659. /**
  81660. * Creates an alpha texture from some data.
  81661. * @param data Define the texture data
  81662. * @param width Define the width of the texture
  81663. * @param height Define the height of the texture
  81664. * @param scene Define the scene the texture belongs to
  81665. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81666. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81667. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81668. * @returns the alpha texture
  81669. */
  81670. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  81671. /**
  81672. * Creates a RGB texture from some data.
  81673. * @param data Define the texture data
  81674. * @param width Define the width of the texture
  81675. * @param height Define the height of the texture
  81676. * @param scene Define the scene the texture belongs to
  81677. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81678. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81679. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81680. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  81681. * @returns the RGB alpha texture
  81682. */
  81683. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  81684. /**
  81685. * Creates a RGBA texture from some data.
  81686. * @param data Define the texture data
  81687. * @param width Define the width of the texture
  81688. * @param height Define the height of the texture
  81689. * @param scene Define the scene the texture belongs to
  81690. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81691. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81692. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81693. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  81694. * @returns the RGBA texture
  81695. */
  81696. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  81697. /**
  81698. * Creates a R texture from some data.
  81699. * @param data Define the texture data
  81700. * @param width Define the width of the texture
  81701. * @param height Define the height of the texture
  81702. * @param scene Define the scene the texture belongs to
  81703. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81704. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81705. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81706. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  81707. * @returns the R texture
  81708. */
  81709. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  81710. }
  81711. }
  81712. declare module BABYLON {
  81713. /**
  81714. * Interface for the size containing width and height
  81715. */
  81716. export interface ISize {
  81717. /**
  81718. * Width
  81719. */
  81720. width: number;
  81721. /**
  81722. * Heighht
  81723. */
  81724. height: number;
  81725. }
  81726. /**
  81727. * Size containing widht and height
  81728. */
  81729. export class Size implements ISize {
  81730. /**
  81731. * Width
  81732. */
  81733. width: number;
  81734. /**
  81735. * Height
  81736. */
  81737. height: number;
  81738. /**
  81739. * Creates a Size object from the given width and height (floats).
  81740. * @param width width of the new size
  81741. * @param height height of the new size
  81742. */
  81743. constructor(width: number, height: number);
  81744. /**
  81745. * Returns a string with the Size width and height
  81746. * @returns a string with the Size width and height
  81747. */
  81748. toString(): string;
  81749. /**
  81750. * "Size"
  81751. * @returns the string "Size"
  81752. */
  81753. getClassName(): string;
  81754. /**
  81755. * Returns the Size hash code.
  81756. * @returns a hash code for a unique width and height
  81757. */
  81758. getHashCode(): number;
  81759. /**
  81760. * Updates the current size from the given one.
  81761. * @param src the given size
  81762. */
  81763. copyFrom(src: Size): void;
  81764. /**
  81765. * Updates in place the current Size from the given floats.
  81766. * @param width width of the new size
  81767. * @param height height of the new size
  81768. * @returns the updated Size.
  81769. */
  81770. copyFromFloats(width: number, height: number): Size;
  81771. /**
  81772. * Updates in place the current Size from the given floats.
  81773. * @param width width to set
  81774. * @param height height to set
  81775. * @returns the updated Size.
  81776. */
  81777. set(width: number, height: number): Size;
  81778. /**
  81779. * Multiplies the width and height by numbers
  81780. * @param w factor to multiple the width by
  81781. * @param h factor to multiple the height by
  81782. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  81783. */
  81784. multiplyByFloats(w: number, h: number): Size;
  81785. /**
  81786. * Clones the size
  81787. * @returns a new Size copied from the given one.
  81788. */
  81789. clone(): Size;
  81790. /**
  81791. * True if the current Size and the given one width and height are strictly equal.
  81792. * @param other the other size to compare against
  81793. * @returns True if the current Size and the given one width and height are strictly equal.
  81794. */
  81795. equals(other: Size): boolean;
  81796. /**
  81797. * The surface of the Size : width * height (float).
  81798. */
  81799. readonly surface: number;
  81800. /**
  81801. * Create a new size of zero
  81802. * @returns a new Size set to (0.0, 0.0)
  81803. */
  81804. static Zero(): Size;
  81805. /**
  81806. * Sums the width and height of two sizes
  81807. * @param otherSize size to add to this size
  81808. * @returns a new Size set as the addition result of the current Size and the given one.
  81809. */
  81810. add(otherSize: Size): Size;
  81811. /**
  81812. * Subtracts the width and height of two
  81813. * @param otherSize size to subtract to this size
  81814. * @returns a new Size set as the subtraction result of the given one from the current Size.
  81815. */
  81816. subtract(otherSize: Size): Size;
  81817. /**
  81818. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  81819. * @param start starting size to lerp between
  81820. * @param end end size to lerp between
  81821. * @param amount amount to lerp between the start and end values
  81822. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  81823. */
  81824. static Lerp(start: Size, end: Size, amount: number): Size;
  81825. }
  81826. }
  81827. declare module BABYLON {
  81828. /**
  81829. * Defines a runtime animation
  81830. */
  81831. export class RuntimeAnimation {
  81832. private _events;
  81833. /**
  81834. * The current frame of the runtime animation
  81835. */
  81836. private _currentFrame;
  81837. /**
  81838. * The animation used by the runtime animation
  81839. */
  81840. private _animation;
  81841. /**
  81842. * The target of the runtime animation
  81843. */
  81844. private _target;
  81845. /**
  81846. * The initiating animatable
  81847. */
  81848. private _host;
  81849. /**
  81850. * The original value of the runtime animation
  81851. */
  81852. private _originalValue;
  81853. /**
  81854. * The original blend value of the runtime animation
  81855. */
  81856. private _originalBlendValue;
  81857. /**
  81858. * The offsets cache of the runtime animation
  81859. */
  81860. private _offsetsCache;
  81861. /**
  81862. * The high limits cache of the runtime animation
  81863. */
  81864. private _highLimitsCache;
  81865. /**
  81866. * Specifies if the runtime animation has been stopped
  81867. */
  81868. private _stopped;
  81869. /**
  81870. * The blending factor of the runtime animation
  81871. */
  81872. private _blendingFactor;
  81873. /**
  81874. * The BabylonJS scene
  81875. */
  81876. private _scene;
  81877. /**
  81878. * The current value of the runtime animation
  81879. */
  81880. private _currentValue;
  81881. /** @hidden */
  81882. _animationState: _IAnimationState;
  81883. /**
  81884. * The active target of the runtime animation
  81885. */
  81886. private _activeTargets;
  81887. private _currentActiveTarget;
  81888. private _directTarget;
  81889. /**
  81890. * The target path of the runtime animation
  81891. */
  81892. private _targetPath;
  81893. /**
  81894. * The weight of the runtime animation
  81895. */
  81896. private _weight;
  81897. /**
  81898. * The ratio offset of the runtime animation
  81899. */
  81900. private _ratioOffset;
  81901. /**
  81902. * The previous delay of the runtime animation
  81903. */
  81904. private _previousDelay;
  81905. /**
  81906. * The previous ratio of the runtime animation
  81907. */
  81908. private _previousRatio;
  81909. private _enableBlending;
  81910. private _keys;
  81911. private _minFrame;
  81912. private _maxFrame;
  81913. private _minValue;
  81914. private _maxValue;
  81915. private _targetIsArray;
  81916. /**
  81917. * Gets the current frame of the runtime animation
  81918. */
  81919. readonly currentFrame: number;
  81920. /**
  81921. * Gets the weight of the runtime animation
  81922. */
  81923. readonly weight: number;
  81924. /**
  81925. * Gets the current value of the runtime animation
  81926. */
  81927. readonly currentValue: any;
  81928. /**
  81929. * Gets the target path of the runtime animation
  81930. */
  81931. readonly targetPath: string;
  81932. /**
  81933. * Gets the actual target of the runtime animation
  81934. */
  81935. readonly target: any;
  81936. /** @hidden */
  81937. _onLoop: () => void;
  81938. /**
  81939. * Create a new RuntimeAnimation object
  81940. * @param target defines the target of the animation
  81941. * @param animation defines the source animation object
  81942. * @param scene defines the hosting scene
  81943. * @param host defines the initiating Animatable
  81944. */
  81945. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  81946. private _preparePath;
  81947. /**
  81948. * Gets the animation from the runtime animation
  81949. */
  81950. readonly animation: Animation;
  81951. /**
  81952. * Resets the runtime animation to the beginning
  81953. * @param restoreOriginal defines whether to restore the target property to the original value
  81954. */
  81955. reset(restoreOriginal?: boolean): void;
  81956. /**
  81957. * Specifies if the runtime animation is stopped
  81958. * @returns Boolean specifying if the runtime animation is stopped
  81959. */
  81960. isStopped(): boolean;
  81961. /**
  81962. * Disposes of the runtime animation
  81963. */
  81964. dispose(): void;
  81965. /**
  81966. * Apply the interpolated value to the target
  81967. * @param currentValue defines the value computed by the animation
  81968. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  81969. */
  81970. setValue(currentValue: any, weight: number): void;
  81971. private _getOriginalValues;
  81972. private _setValue;
  81973. /**
  81974. * Gets the loop pmode of the runtime animation
  81975. * @returns Loop Mode
  81976. */
  81977. private _getCorrectLoopMode;
  81978. /**
  81979. * Move the current animation to a given frame
  81980. * @param frame defines the frame to move to
  81981. */
  81982. goToFrame(frame: number): void;
  81983. /**
  81984. * @hidden Internal use only
  81985. */
  81986. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  81987. /**
  81988. * Execute the current animation
  81989. * @param delay defines the delay to add to the current frame
  81990. * @param from defines the lower bound of the animation range
  81991. * @param to defines the upper bound of the animation range
  81992. * @param loop defines if the current animation must loop
  81993. * @param speedRatio defines the current speed ratio
  81994. * @param weight defines the weight of the animation (default is -1 so no weight)
  81995. * @param onLoop optional callback called when animation loops
  81996. * @returns a boolean indicating if the animation is running
  81997. */
  81998. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  81999. }
  82000. }
  82001. declare module BABYLON {
  82002. /**
  82003. * Class used to store an actual running animation
  82004. */
  82005. export class Animatable {
  82006. /** defines the target object */
  82007. target: any;
  82008. /** defines the starting frame number (default is 0) */
  82009. fromFrame: number;
  82010. /** defines the ending frame number (default is 100) */
  82011. toFrame: number;
  82012. /** defines if the animation must loop (default is false) */
  82013. loopAnimation: boolean;
  82014. /** defines a callback to call when animation ends if it is not looping */
  82015. onAnimationEnd?: (() => void) | null | undefined;
  82016. /** defines a callback to call when animation loops */
  82017. onAnimationLoop?: (() => void) | null | undefined;
  82018. private _localDelayOffset;
  82019. private _pausedDelay;
  82020. private _runtimeAnimations;
  82021. private _paused;
  82022. private _scene;
  82023. private _speedRatio;
  82024. private _weight;
  82025. private _syncRoot;
  82026. /**
  82027. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  82028. * This will only apply for non looping animation (default is true)
  82029. */
  82030. disposeOnEnd: boolean;
  82031. /**
  82032. * Gets a boolean indicating if the animation has started
  82033. */
  82034. animationStarted: boolean;
  82035. /**
  82036. * Observer raised when the animation ends
  82037. */
  82038. onAnimationEndObservable: Observable<Animatable>;
  82039. /**
  82040. * Observer raised when the animation loops
  82041. */
  82042. onAnimationLoopObservable: Observable<Animatable>;
  82043. /**
  82044. * Gets the root Animatable used to synchronize and normalize animations
  82045. */
  82046. readonly syncRoot: Nullable<Animatable>;
  82047. /**
  82048. * Gets the current frame of the first RuntimeAnimation
  82049. * Used to synchronize Animatables
  82050. */
  82051. readonly masterFrame: number;
  82052. /**
  82053. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  82054. */
  82055. weight: number;
  82056. /**
  82057. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  82058. */
  82059. speedRatio: number;
  82060. /**
  82061. * Creates a new Animatable
  82062. * @param scene defines the hosting scene
  82063. * @param target defines the target object
  82064. * @param fromFrame defines the starting frame number (default is 0)
  82065. * @param toFrame defines the ending frame number (default is 100)
  82066. * @param loopAnimation defines if the animation must loop (default is false)
  82067. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  82068. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  82069. * @param animations defines a group of animation to add to the new Animatable
  82070. * @param onAnimationLoop defines a callback to call when animation loops
  82071. */
  82072. constructor(scene: Scene,
  82073. /** defines the target object */
  82074. target: any,
  82075. /** defines the starting frame number (default is 0) */
  82076. fromFrame?: number,
  82077. /** defines the ending frame number (default is 100) */
  82078. toFrame?: number,
  82079. /** defines if the animation must loop (default is false) */
  82080. loopAnimation?: boolean, speedRatio?: number,
  82081. /** defines a callback to call when animation ends if it is not looping */
  82082. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  82083. /** defines a callback to call when animation loops */
  82084. onAnimationLoop?: (() => void) | null | undefined);
  82085. /**
  82086. * Synchronize and normalize current Animatable with a source Animatable
  82087. * This is useful when using animation weights and when animations are not of the same length
  82088. * @param root defines the root Animatable to synchronize with
  82089. * @returns the current Animatable
  82090. */
  82091. syncWith(root: Animatable): Animatable;
  82092. /**
  82093. * Gets the list of runtime animations
  82094. * @returns an array of RuntimeAnimation
  82095. */
  82096. getAnimations(): RuntimeAnimation[];
  82097. /**
  82098. * Adds more animations to the current animatable
  82099. * @param target defines the target of the animations
  82100. * @param animations defines the new animations to add
  82101. */
  82102. appendAnimations(target: any, animations: Animation[]): void;
  82103. /**
  82104. * Gets the source animation for a specific property
  82105. * @param property defines the propertyu to look for
  82106. * @returns null or the source animation for the given property
  82107. */
  82108. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  82109. /**
  82110. * Gets the runtime animation for a specific property
  82111. * @param property defines the propertyu to look for
  82112. * @returns null or the runtime animation for the given property
  82113. */
  82114. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  82115. /**
  82116. * Resets the animatable to its original state
  82117. */
  82118. reset(): void;
  82119. /**
  82120. * Allows the animatable to blend with current running animations
  82121. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  82122. * @param blendingSpeed defines the blending speed to use
  82123. */
  82124. enableBlending(blendingSpeed: number): void;
  82125. /**
  82126. * Disable animation blending
  82127. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  82128. */
  82129. disableBlending(): void;
  82130. /**
  82131. * Jump directly to a given frame
  82132. * @param frame defines the frame to jump to
  82133. */
  82134. goToFrame(frame: number): void;
  82135. /**
  82136. * Pause the animation
  82137. */
  82138. pause(): void;
  82139. /**
  82140. * Restart the animation
  82141. */
  82142. restart(): void;
  82143. private _raiseOnAnimationEnd;
  82144. /**
  82145. * Stop and delete the current animation
  82146. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  82147. * @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)
  82148. */
  82149. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  82150. /**
  82151. * Wait asynchronously for the animation to end
  82152. * @returns a promise which will be fullfilled when the animation ends
  82153. */
  82154. waitAsync(): Promise<Animatable>;
  82155. /** @hidden */
  82156. _animate(delay: number): boolean;
  82157. }
  82158. interface Scene {
  82159. /** @hidden */
  82160. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  82161. /** @hidden */
  82162. _processLateAnimationBindingsForMatrices(holder: {
  82163. totalWeight: number;
  82164. animations: RuntimeAnimation[];
  82165. originalValue: Matrix;
  82166. }): any;
  82167. /** @hidden */
  82168. _processLateAnimationBindingsForQuaternions(holder: {
  82169. totalWeight: number;
  82170. animations: RuntimeAnimation[];
  82171. originalValue: Quaternion;
  82172. }, refQuaternion: Quaternion): Quaternion;
  82173. /** @hidden */
  82174. _processLateAnimationBindings(): void;
  82175. /**
  82176. * Will start the animation sequence of a given target
  82177. * @param target defines the target
  82178. * @param from defines from which frame should animation start
  82179. * @param to defines until which frame should animation run.
  82180. * @param weight defines the weight to apply to the animation (1.0 by default)
  82181. * @param loop defines if the animation loops
  82182. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  82183. * @param onAnimationEnd defines the function to be executed when the animation ends
  82184. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  82185. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  82186. * @param onAnimationLoop defines the callback to call when an animation loops
  82187. * @returns the animatable object created for this animation
  82188. */
  82189. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  82190. /**
  82191. * Will start the animation sequence of a given target
  82192. * @param target defines the target
  82193. * @param from defines from which frame should animation start
  82194. * @param to defines until which frame should animation run.
  82195. * @param loop defines if the animation loops
  82196. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  82197. * @param onAnimationEnd defines the function to be executed when the animation ends
  82198. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  82199. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  82200. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  82201. * @param onAnimationLoop defines the callback to call when an animation loops
  82202. * @returns the animatable object created for this animation
  82203. */
  82204. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  82205. /**
  82206. * Will start the animation sequence of a given target and its hierarchy
  82207. * @param target defines the target
  82208. * @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.
  82209. * @param from defines from which frame should animation start
  82210. * @param to defines until which frame should animation run.
  82211. * @param loop defines if the animation loops
  82212. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  82213. * @param onAnimationEnd defines the function to be executed when the animation ends
  82214. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  82215. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  82216. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  82217. * @param onAnimationLoop defines the callback to call when an animation loops
  82218. * @returns the list of created animatables
  82219. */
  82220. 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[];
  82221. /**
  82222. * Begin a new animation on a given node
  82223. * @param target defines the target where the animation will take place
  82224. * @param animations defines the list of animations to start
  82225. * @param from defines the initial value
  82226. * @param to defines the final value
  82227. * @param loop defines if you want animation to loop (off by default)
  82228. * @param speedRatio defines the speed ratio to apply to all animations
  82229. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  82230. * @param onAnimationLoop defines the callback to call when an animation loops
  82231. * @returns the list of created animatables
  82232. */
  82233. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  82234. /**
  82235. * Begin a new animation on a given node and its hierarchy
  82236. * @param target defines the root node where the animation will take place
  82237. * @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.
  82238. * @param animations defines the list of animations to start
  82239. * @param from defines the initial value
  82240. * @param to defines the final value
  82241. * @param loop defines if you want animation to loop (off by default)
  82242. * @param speedRatio defines the speed ratio to apply to all animations
  82243. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  82244. * @param onAnimationLoop defines the callback to call when an animation loops
  82245. * @returns the list of animatables created for all nodes
  82246. */
  82247. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  82248. /**
  82249. * Gets the animatable associated with a specific target
  82250. * @param target defines the target of the animatable
  82251. * @returns the required animatable if found
  82252. */
  82253. getAnimatableByTarget(target: any): Nullable<Animatable>;
  82254. /**
  82255. * Gets all animatables associated with a given target
  82256. * @param target defines the target to look animatables for
  82257. * @returns an array of Animatables
  82258. */
  82259. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  82260. /**
  82261. * Stops and removes all animations that have been applied to the scene
  82262. */
  82263. stopAllAnimations(): void;
  82264. /**
  82265. * Gets the current delta time used by animation engine
  82266. */
  82267. deltaTime: number;
  82268. }
  82269. interface Bone {
  82270. /**
  82271. * Copy an animation range from another bone
  82272. * @param source defines the source bone
  82273. * @param rangeName defines the range name to copy
  82274. * @param frameOffset defines the frame offset
  82275. * @param rescaleAsRequired defines if rescaling must be applied if required
  82276. * @param skelDimensionsRatio defines the scaling ratio
  82277. * @returns true if operation was successful
  82278. */
  82279. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  82280. }
  82281. }
  82282. declare module BABYLON {
  82283. /**
  82284. * Class used to override all child animations of a given target
  82285. */
  82286. export class AnimationPropertiesOverride {
  82287. /**
  82288. * Gets or sets a value indicating if animation blending must be used
  82289. */
  82290. enableBlending: boolean;
  82291. /**
  82292. * Gets or sets the blending speed to use when enableBlending is true
  82293. */
  82294. blendingSpeed: number;
  82295. /**
  82296. * Gets or sets the default loop mode to use
  82297. */
  82298. loopMode: number;
  82299. }
  82300. }
  82301. declare module BABYLON {
  82302. /**
  82303. * Class used to handle skinning animations
  82304. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  82305. */
  82306. export class Skeleton implements IAnimatable {
  82307. /** defines the skeleton name */
  82308. name: string;
  82309. /** defines the skeleton Id */
  82310. id: string;
  82311. /**
  82312. * Defines the list of child bones
  82313. */
  82314. bones: Bone[];
  82315. /**
  82316. * Defines an estimate of the dimension of the skeleton at rest
  82317. */
  82318. dimensionsAtRest: Vector3;
  82319. /**
  82320. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  82321. */
  82322. needInitialSkinMatrix: boolean;
  82323. /**
  82324. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  82325. */
  82326. overrideMesh: Nullable<AbstractMesh>;
  82327. /**
  82328. * Gets the list of animations attached to this skeleton
  82329. */
  82330. animations: Array<Animation>;
  82331. private _scene;
  82332. private _isDirty;
  82333. private _transformMatrices;
  82334. private _transformMatrixTexture;
  82335. private _meshesWithPoseMatrix;
  82336. private _animatables;
  82337. private _identity;
  82338. private _synchronizedWithMesh;
  82339. private _ranges;
  82340. private _lastAbsoluteTransformsUpdateId;
  82341. private _canUseTextureForBones;
  82342. private _uniqueId;
  82343. /** @hidden */
  82344. _numBonesWithLinkedTransformNode: number;
  82345. /** @hidden */
  82346. _hasWaitingData: Nullable<boolean>;
  82347. /**
  82348. * Specifies if the skeleton should be serialized
  82349. */
  82350. doNotSerialize: boolean;
  82351. private _useTextureToStoreBoneMatrices;
  82352. /**
  82353. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  82354. * Please note that this option is not available if the hardware does not support it
  82355. */
  82356. useTextureToStoreBoneMatrices: boolean;
  82357. private _animationPropertiesOverride;
  82358. /**
  82359. * Gets or sets the animation properties override
  82360. */
  82361. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  82362. /**
  82363. * List of inspectable custom properties (used by the Inspector)
  82364. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  82365. */
  82366. inspectableCustomProperties: IInspectable[];
  82367. /**
  82368. * An observable triggered before computing the skeleton's matrices
  82369. */
  82370. onBeforeComputeObservable: Observable<Skeleton>;
  82371. /**
  82372. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  82373. */
  82374. readonly isUsingTextureForMatrices: boolean;
  82375. /**
  82376. * Gets the unique ID of this skeleton
  82377. */
  82378. readonly uniqueId: number;
  82379. /**
  82380. * Creates a new skeleton
  82381. * @param name defines the skeleton name
  82382. * @param id defines the skeleton Id
  82383. * @param scene defines the hosting scene
  82384. */
  82385. constructor(
  82386. /** defines the skeleton name */
  82387. name: string,
  82388. /** defines the skeleton Id */
  82389. id: string, scene: Scene);
  82390. /**
  82391. * Gets the current object class name.
  82392. * @return the class name
  82393. */
  82394. getClassName(): string;
  82395. /**
  82396. * Returns an array containing the root bones
  82397. * @returns an array containing the root bones
  82398. */
  82399. getChildren(): Array<Bone>;
  82400. /**
  82401. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  82402. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  82403. * @returns a Float32Array containing matrices data
  82404. */
  82405. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  82406. /**
  82407. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  82408. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  82409. * @returns a raw texture containing the data
  82410. */
  82411. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  82412. /**
  82413. * Gets the current hosting scene
  82414. * @returns a scene object
  82415. */
  82416. getScene(): Scene;
  82417. /**
  82418. * Gets a string representing the current skeleton data
  82419. * @param fullDetails defines a boolean indicating if we want a verbose version
  82420. * @returns a string representing the current skeleton data
  82421. */
  82422. toString(fullDetails?: boolean): string;
  82423. /**
  82424. * Get bone's index searching by name
  82425. * @param name defines bone's name to search for
  82426. * @return the indice of the bone. Returns -1 if not found
  82427. */
  82428. getBoneIndexByName(name: string): number;
  82429. /**
  82430. * Creater a new animation range
  82431. * @param name defines the name of the range
  82432. * @param from defines the start key
  82433. * @param to defines the end key
  82434. */
  82435. createAnimationRange(name: string, from: number, to: number): void;
  82436. /**
  82437. * Delete a specific animation range
  82438. * @param name defines the name of the range
  82439. * @param deleteFrames defines if frames must be removed as well
  82440. */
  82441. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  82442. /**
  82443. * Gets a specific animation range
  82444. * @param name defines the name of the range to look for
  82445. * @returns the requested animation range or null if not found
  82446. */
  82447. getAnimationRange(name: string): Nullable<AnimationRange>;
  82448. /**
  82449. * Gets the list of all animation ranges defined on this skeleton
  82450. * @returns an array
  82451. */
  82452. getAnimationRanges(): Nullable<AnimationRange>[];
  82453. /**
  82454. * Copy animation range from a source skeleton.
  82455. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  82456. * @param source defines the source skeleton
  82457. * @param name defines the name of the range to copy
  82458. * @param rescaleAsRequired defines if rescaling must be applied if required
  82459. * @returns true if operation was successful
  82460. */
  82461. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  82462. /**
  82463. * Forces the skeleton to go to rest pose
  82464. */
  82465. returnToRest(): void;
  82466. private _getHighestAnimationFrame;
  82467. /**
  82468. * Begin a specific animation range
  82469. * @param name defines the name of the range to start
  82470. * @param loop defines if looping must be turned on (false by default)
  82471. * @param speedRatio defines the speed ratio to apply (1 by default)
  82472. * @param onAnimationEnd defines a callback which will be called when animation will end
  82473. * @returns a new animatable
  82474. */
  82475. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  82476. /** @hidden */
  82477. _markAsDirty(): void;
  82478. /** @hidden */
  82479. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  82480. /** @hidden */
  82481. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  82482. private _computeTransformMatrices;
  82483. /**
  82484. * Build all resources required to render a skeleton
  82485. */
  82486. prepare(): void;
  82487. /**
  82488. * Gets the list of animatables currently running for this skeleton
  82489. * @returns an array of animatables
  82490. */
  82491. getAnimatables(): IAnimatable[];
  82492. /**
  82493. * Clone the current skeleton
  82494. * @param name defines the name of the new skeleton
  82495. * @param id defines the id of the new skeleton
  82496. * @returns the new skeleton
  82497. */
  82498. clone(name: string, id?: string): Skeleton;
  82499. /**
  82500. * Enable animation blending for this skeleton
  82501. * @param blendingSpeed defines the blending speed to apply
  82502. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  82503. */
  82504. enableBlending(blendingSpeed?: number): void;
  82505. /**
  82506. * Releases all resources associated with the current skeleton
  82507. */
  82508. dispose(): void;
  82509. /**
  82510. * Serialize the skeleton in a JSON object
  82511. * @returns a JSON object
  82512. */
  82513. serialize(): any;
  82514. /**
  82515. * Creates a new skeleton from serialized data
  82516. * @param parsedSkeleton defines the serialized data
  82517. * @param scene defines the hosting scene
  82518. * @returns a new skeleton
  82519. */
  82520. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  82521. /**
  82522. * Compute all node absolute transforms
  82523. * @param forceUpdate defines if computation must be done even if cache is up to date
  82524. */
  82525. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  82526. /**
  82527. * Gets the root pose matrix
  82528. * @returns a matrix
  82529. */
  82530. getPoseMatrix(): Nullable<Matrix>;
  82531. /**
  82532. * Sorts bones per internal index
  82533. */
  82534. sortBones(): void;
  82535. private _sortBones;
  82536. }
  82537. }
  82538. declare module BABYLON {
  82539. /**
  82540. * Class used to store bone information
  82541. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  82542. */
  82543. export class Bone extends Node {
  82544. /**
  82545. * defines the bone name
  82546. */
  82547. name: string;
  82548. private static _tmpVecs;
  82549. private static _tmpQuat;
  82550. private static _tmpMats;
  82551. /**
  82552. * Gets the list of child bones
  82553. */
  82554. children: Bone[];
  82555. /** Gets the animations associated with this bone */
  82556. animations: Animation[];
  82557. /**
  82558. * Gets or sets bone length
  82559. */
  82560. length: number;
  82561. /**
  82562. * @hidden Internal only
  82563. * Set this value to map this bone to a different index in the transform matrices
  82564. * Set this value to -1 to exclude the bone from the transform matrices
  82565. */
  82566. _index: Nullable<number>;
  82567. private _skeleton;
  82568. private _localMatrix;
  82569. private _restPose;
  82570. private _baseMatrix;
  82571. private _absoluteTransform;
  82572. private _invertedAbsoluteTransform;
  82573. private _parent;
  82574. private _scalingDeterminant;
  82575. private _worldTransform;
  82576. private _localScaling;
  82577. private _localRotation;
  82578. private _localPosition;
  82579. private _needToDecompose;
  82580. private _needToCompose;
  82581. /** @hidden */
  82582. _linkedTransformNode: Nullable<TransformNode>;
  82583. /** @hidden */
  82584. _waitingTransformNodeId: Nullable<string>;
  82585. /** @hidden */
  82586. /** @hidden */
  82587. _matrix: Matrix;
  82588. /**
  82589. * Create a new bone
  82590. * @param name defines the bone name
  82591. * @param skeleton defines the parent skeleton
  82592. * @param parentBone defines the parent (can be null if the bone is the root)
  82593. * @param localMatrix defines the local matrix
  82594. * @param restPose defines the rest pose matrix
  82595. * @param baseMatrix defines the base matrix
  82596. * @param index defines index of the bone in the hiearchy
  82597. */
  82598. constructor(
  82599. /**
  82600. * defines the bone name
  82601. */
  82602. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  82603. /**
  82604. * Gets the current object class name.
  82605. * @return the class name
  82606. */
  82607. getClassName(): string;
  82608. /**
  82609. * Gets the parent skeleton
  82610. * @returns a skeleton
  82611. */
  82612. getSkeleton(): Skeleton;
  82613. /**
  82614. * Gets parent bone
  82615. * @returns a bone or null if the bone is the root of the bone hierarchy
  82616. */
  82617. getParent(): Nullable<Bone>;
  82618. /**
  82619. * Returns an array containing the root bones
  82620. * @returns an array containing the root bones
  82621. */
  82622. getChildren(): Array<Bone>;
  82623. /**
  82624. * Gets the node index in matrix array generated for rendering
  82625. * @returns the node index
  82626. */
  82627. getIndex(): number;
  82628. /**
  82629. * Sets the parent bone
  82630. * @param parent defines the parent (can be null if the bone is the root)
  82631. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  82632. */
  82633. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  82634. /**
  82635. * Gets the local matrix
  82636. * @returns a matrix
  82637. */
  82638. getLocalMatrix(): Matrix;
  82639. /**
  82640. * Gets the base matrix (initial matrix which remains unchanged)
  82641. * @returns a matrix
  82642. */
  82643. getBaseMatrix(): Matrix;
  82644. /**
  82645. * Gets the rest pose matrix
  82646. * @returns a matrix
  82647. */
  82648. getRestPose(): Matrix;
  82649. /**
  82650. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  82651. */
  82652. getWorldMatrix(): Matrix;
  82653. /**
  82654. * Sets the local matrix to rest pose matrix
  82655. */
  82656. returnToRest(): void;
  82657. /**
  82658. * Gets the inverse of the absolute transform matrix.
  82659. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  82660. * @returns a matrix
  82661. */
  82662. getInvertedAbsoluteTransform(): Matrix;
  82663. /**
  82664. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  82665. * @returns a matrix
  82666. */
  82667. getAbsoluteTransform(): Matrix;
  82668. /**
  82669. * Links with the given transform node.
  82670. * The local matrix of this bone is copied from the transform node every frame.
  82671. * @param transformNode defines the transform node to link to
  82672. */
  82673. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  82674. /**
  82675. * Gets the node used to drive the bone's transformation
  82676. * @returns a transform node or null
  82677. */
  82678. getTransformNode(): Nullable<TransformNode>;
  82679. /** Gets or sets current position (in local space) */
  82680. position: Vector3;
  82681. /** Gets or sets current rotation (in local space) */
  82682. rotation: Vector3;
  82683. /** Gets or sets current rotation quaternion (in local space) */
  82684. rotationQuaternion: Quaternion;
  82685. /** Gets or sets current scaling (in local space) */
  82686. scaling: Vector3;
  82687. /**
  82688. * Gets the animation properties override
  82689. */
  82690. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  82691. private _decompose;
  82692. private _compose;
  82693. /**
  82694. * Update the base and local matrices
  82695. * @param matrix defines the new base or local matrix
  82696. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  82697. * @param updateLocalMatrix defines if the local matrix should be updated
  82698. */
  82699. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  82700. /** @hidden */
  82701. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  82702. /**
  82703. * Flag the bone as dirty (Forcing it to update everything)
  82704. */
  82705. markAsDirty(): void;
  82706. /** @hidden */
  82707. _markAsDirtyAndCompose(): void;
  82708. private _markAsDirtyAndDecompose;
  82709. /**
  82710. * Translate the bone in local or world space
  82711. * @param vec The amount to translate the bone
  82712. * @param space The space that the translation is in
  82713. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82714. */
  82715. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  82716. /**
  82717. * Set the postion of the bone in local or world space
  82718. * @param position The position to set the bone
  82719. * @param space The space that the position is in
  82720. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82721. */
  82722. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  82723. /**
  82724. * Set the absolute position of the bone (world space)
  82725. * @param position The position to set the bone
  82726. * @param mesh The mesh that this bone is attached to
  82727. */
  82728. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  82729. /**
  82730. * Scale the bone on the x, y and z axes (in local space)
  82731. * @param x The amount to scale the bone on the x axis
  82732. * @param y The amount to scale the bone on the y axis
  82733. * @param z The amount to scale the bone on the z axis
  82734. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  82735. */
  82736. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  82737. /**
  82738. * Set the bone scaling in local space
  82739. * @param scale defines the scaling vector
  82740. */
  82741. setScale(scale: Vector3): void;
  82742. /**
  82743. * Gets the current scaling in local space
  82744. * @returns the current scaling vector
  82745. */
  82746. getScale(): Vector3;
  82747. /**
  82748. * Gets the current scaling in local space and stores it in a target vector
  82749. * @param result defines the target vector
  82750. */
  82751. getScaleToRef(result: Vector3): void;
  82752. /**
  82753. * Set the yaw, pitch, and roll of the bone in local or world space
  82754. * @param yaw The rotation of the bone on the y axis
  82755. * @param pitch The rotation of the bone on the x axis
  82756. * @param roll The rotation of the bone on the z axis
  82757. * @param space The space that the axes of rotation are in
  82758. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82759. */
  82760. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  82761. /**
  82762. * Add a rotation to the bone on an axis in local or world space
  82763. * @param axis The axis to rotate the bone on
  82764. * @param amount The amount to rotate the bone
  82765. * @param space The space that the axis is in
  82766. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82767. */
  82768. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  82769. /**
  82770. * Set the rotation of the bone to a particular axis angle in local or world space
  82771. * @param axis The axis to rotate the bone on
  82772. * @param angle The angle that the bone should be rotated to
  82773. * @param space The space that the axis is in
  82774. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82775. */
  82776. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  82777. /**
  82778. * Set the euler rotation of the bone in local of world space
  82779. * @param rotation The euler rotation that the bone should be set to
  82780. * @param space The space that the rotation is in
  82781. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82782. */
  82783. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  82784. /**
  82785. * Set the quaternion rotation of the bone in local of world space
  82786. * @param quat The quaternion rotation that the bone should be set to
  82787. * @param space The space that the rotation is in
  82788. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82789. */
  82790. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  82791. /**
  82792. * Set the rotation matrix of the bone in local of world space
  82793. * @param rotMat The rotation matrix that the bone should be set to
  82794. * @param space The space that the rotation is in
  82795. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82796. */
  82797. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  82798. private _rotateWithMatrix;
  82799. private _getNegativeRotationToRef;
  82800. /**
  82801. * Get the position of the bone in local or world space
  82802. * @param space The space that the returned position is in
  82803. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82804. * @returns The position of the bone
  82805. */
  82806. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  82807. /**
  82808. * Copy the position of the bone to a vector3 in local or world space
  82809. * @param space The space that the returned position is in
  82810. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82811. * @param result The vector3 to copy the position to
  82812. */
  82813. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  82814. /**
  82815. * Get the absolute position of the bone (world space)
  82816. * @param mesh The mesh that this bone is attached to
  82817. * @returns The absolute position of the bone
  82818. */
  82819. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  82820. /**
  82821. * Copy the absolute position of the bone (world space) to the result param
  82822. * @param mesh The mesh that this bone is attached to
  82823. * @param result The vector3 to copy the absolute position to
  82824. */
  82825. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  82826. /**
  82827. * Compute the absolute transforms of this bone and its children
  82828. */
  82829. computeAbsoluteTransforms(): void;
  82830. /**
  82831. * Get the world direction from an axis that is in the local space of the bone
  82832. * @param localAxis The local direction that is used to compute the world direction
  82833. * @param mesh The mesh that this bone is attached to
  82834. * @returns The world direction
  82835. */
  82836. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  82837. /**
  82838. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  82839. * @param localAxis The local direction that is used to compute the world direction
  82840. * @param mesh The mesh that this bone is attached to
  82841. * @param result The vector3 that the world direction will be copied to
  82842. */
  82843. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82844. /**
  82845. * Get the euler rotation of the bone in local or world space
  82846. * @param space The space that the rotation should be in
  82847. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82848. * @returns The euler rotation
  82849. */
  82850. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  82851. /**
  82852. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  82853. * @param space The space that the rotation should be in
  82854. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82855. * @param result The vector3 that the rotation should be copied to
  82856. */
  82857. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82858. /**
  82859. * Get the quaternion rotation of the bone in either local or world space
  82860. * @param space The space that the rotation should be in
  82861. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82862. * @returns The quaternion rotation
  82863. */
  82864. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  82865. /**
  82866. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  82867. * @param space The space that the rotation should be in
  82868. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82869. * @param result The quaternion that the rotation should be copied to
  82870. */
  82871. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  82872. /**
  82873. * Get the rotation matrix of the bone in local or world space
  82874. * @param space The space that the rotation should be in
  82875. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82876. * @returns The rotation matrix
  82877. */
  82878. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  82879. /**
  82880. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  82881. * @param space The space that the rotation should be in
  82882. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82883. * @param result The quaternion that the rotation should be copied to
  82884. */
  82885. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  82886. /**
  82887. * Get the world position of a point that is in the local space of the bone
  82888. * @param position The local position
  82889. * @param mesh The mesh that this bone is attached to
  82890. * @returns The world position
  82891. */
  82892. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  82893. /**
  82894. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  82895. * @param position The local position
  82896. * @param mesh The mesh that this bone is attached to
  82897. * @param result The vector3 that the world position should be copied to
  82898. */
  82899. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82900. /**
  82901. * Get the local position of a point that is in world space
  82902. * @param position The world position
  82903. * @param mesh The mesh that this bone is attached to
  82904. * @returns The local position
  82905. */
  82906. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  82907. /**
  82908. * Get the local position of a point that is in world space and copy it to the result param
  82909. * @param position The world position
  82910. * @param mesh The mesh that this bone is attached to
  82911. * @param result The vector3 that the local position should be copied to
  82912. */
  82913. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82914. }
  82915. }
  82916. declare module BABYLON {
  82917. /**
  82918. * 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.
  82919. * @see https://doc.babylonjs.com/how_to/transformnode
  82920. */
  82921. export class TransformNode extends Node {
  82922. /**
  82923. * Object will not rotate to face the camera
  82924. */
  82925. static BILLBOARDMODE_NONE: number;
  82926. /**
  82927. * Object will rotate to face the camera but only on the x axis
  82928. */
  82929. static BILLBOARDMODE_X: number;
  82930. /**
  82931. * Object will rotate to face the camera but only on the y axis
  82932. */
  82933. static BILLBOARDMODE_Y: number;
  82934. /**
  82935. * Object will rotate to face the camera but only on the z axis
  82936. */
  82937. static BILLBOARDMODE_Z: number;
  82938. /**
  82939. * Object will rotate to face the camera
  82940. */
  82941. static BILLBOARDMODE_ALL: number;
  82942. /**
  82943. * Object will rotate to face the camera's position instead of orientation
  82944. */
  82945. static BILLBOARDMODE_USE_POSITION: number;
  82946. private _forward;
  82947. private _forwardInverted;
  82948. private _up;
  82949. private _right;
  82950. private _rightInverted;
  82951. private _position;
  82952. private _rotation;
  82953. private _rotationQuaternion;
  82954. protected _scaling: Vector3;
  82955. protected _isDirty: boolean;
  82956. private _transformToBoneReferal;
  82957. private _isAbsoluteSynced;
  82958. private _billboardMode;
  82959. /**
  82960. * Gets or sets the billboard mode. Default is 0.
  82961. *
  82962. * | Value | Type | Description |
  82963. * | --- | --- | --- |
  82964. * | 0 | BILLBOARDMODE_NONE | |
  82965. * | 1 | BILLBOARDMODE_X | |
  82966. * | 2 | BILLBOARDMODE_Y | |
  82967. * | 4 | BILLBOARDMODE_Z | |
  82968. * | 7 | BILLBOARDMODE_ALL | |
  82969. *
  82970. */
  82971. billboardMode: number;
  82972. private _preserveParentRotationForBillboard;
  82973. /**
  82974. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  82975. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  82976. */
  82977. preserveParentRotationForBillboard: boolean;
  82978. /**
  82979. * 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
  82980. */
  82981. scalingDeterminant: number;
  82982. private _infiniteDistance;
  82983. /**
  82984. * Gets or sets the distance of the object to max, often used by skybox
  82985. */
  82986. infiniteDistance: boolean;
  82987. /**
  82988. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  82989. * By default the system will update normals to compensate
  82990. */
  82991. ignoreNonUniformScaling: boolean;
  82992. /**
  82993. * 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
  82994. */
  82995. reIntegrateRotationIntoRotationQuaternion: boolean;
  82996. /** @hidden */
  82997. _poseMatrix: Nullable<Matrix>;
  82998. /** @hidden */
  82999. _localMatrix: Matrix;
  83000. private _usePivotMatrix;
  83001. private _absolutePosition;
  83002. private _absoluteScaling;
  83003. private _absoluteRotationQuaternion;
  83004. private _pivotMatrix;
  83005. private _pivotMatrixInverse;
  83006. protected _postMultiplyPivotMatrix: boolean;
  83007. protected _isWorldMatrixFrozen: boolean;
  83008. /** @hidden */
  83009. _indexInSceneTransformNodesArray: number;
  83010. /**
  83011. * An event triggered after the world matrix is updated
  83012. */
  83013. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  83014. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  83015. /**
  83016. * Gets a string identifying the name of the class
  83017. * @returns "TransformNode" string
  83018. */
  83019. getClassName(): string;
  83020. /**
  83021. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  83022. */
  83023. position: Vector3;
  83024. /**
  83025. * 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)).
  83026. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  83027. */
  83028. rotation: Vector3;
  83029. /**
  83030. * 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)).
  83031. */
  83032. scaling: Vector3;
  83033. /**
  83034. * 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).
  83035. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  83036. */
  83037. rotationQuaternion: Nullable<Quaternion>;
  83038. /**
  83039. * The forward direction of that transform in world space.
  83040. */
  83041. readonly forward: Vector3;
  83042. /**
  83043. * The up direction of that transform in world space.
  83044. */
  83045. readonly up: Vector3;
  83046. /**
  83047. * The right direction of that transform in world space.
  83048. */
  83049. readonly right: Vector3;
  83050. /**
  83051. * Copies the parameter passed Matrix into the mesh Pose matrix.
  83052. * @param matrix the matrix to copy the pose from
  83053. * @returns this TransformNode.
  83054. */
  83055. updatePoseMatrix(matrix: Matrix): TransformNode;
  83056. /**
  83057. * Returns the mesh Pose matrix.
  83058. * @returns the pose matrix
  83059. */
  83060. getPoseMatrix(): Matrix;
  83061. /** @hidden */
  83062. _isSynchronized(): boolean;
  83063. /** @hidden */
  83064. _initCache(): void;
  83065. /**
  83066. * Flag the transform node as dirty (Forcing it to update everything)
  83067. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  83068. * @returns this transform node
  83069. */
  83070. markAsDirty(property: string): TransformNode;
  83071. /**
  83072. * Returns the current mesh absolute position.
  83073. * Returns a Vector3.
  83074. */
  83075. readonly absolutePosition: Vector3;
  83076. /**
  83077. * Returns the current mesh absolute scaling.
  83078. * Returns a Vector3.
  83079. */
  83080. readonly absoluteScaling: Vector3;
  83081. /**
  83082. * Returns the current mesh absolute rotation.
  83083. * Returns a Quaternion.
  83084. */
  83085. readonly absoluteRotationQuaternion: Quaternion;
  83086. /**
  83087. * Sets a new matrix to apply before all other transformation
  83088. * @param matrix defines the transform matrix
  83089. * @returns the current TransformNode
  83090. */
  83091. setPreTransformMatrix(matrix: Matrix): TransformNode;
  83092. /**
  83093. * Sets a new pivot matrix to the current node
  83094. * @param matrix defines the new pivot matrix to use
  83095. * @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
  83096. * @returns the current TransformNode
  83097. */
  83098. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  83099. /**
  83100. * Returns the mesh pivot matrix.
  83101. * Default : Identity.
  83102. * @returns the matrix
  83103. */
  83104. getPivotMatrix(): Matrix;
  83105. /**
  83106. * Instantiate (when possible) or clone that node with its hierarchy
  83107. * @param newParent defines the new parent to use for the instance (or clone)
  83108. * @param options defines options to configure how copy is done
  83109. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  83110. * @returns an instance (or a clone) of the current node with its hiearchy
  83111. */
  83112. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  83113. doNotInstantiate: boolean;
  83114. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  83115. /**
  83116. * Prevents the World matrix to be computed any longer
  83117. * @param newWorldMatrix defines an optional matrix to use as world matrix
  83118. * @returns the TransformNode.
  83119. */
  83120. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  83121. /**
  83122. * Allows back the World matrix computation.
  83123. * @returns the TransformNode.
  83124. */
  83125. unfreezeWorldMatrix(): this;
  83126. /**
  83127. * True if the World matrix has been frozen.
  83128. */
  83129. readonly isWorldMatrixFrozen: boolean;
  83130. /**
  83131. * Retuns the mesh absolute position in the World.
  83132. * @returns a Vector3.
  83133. */
  83134. getAbsolutePosition(): Vector3;
  83135. /**
  83136. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  83137. * @param absolutePosition the absolute position to set
  83138. * @returns the TransformNode.
  83139. */
  83140. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  83141. /**
  83142. * Sets the mesh position in its local space.
  83143. * @param vector3 the position to set in localspace
  83144. * @returns the TransformNode.
  83145. */
  83146. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  83147. /**
  83148. * Returns the mesh position in the local space from the current World matrix values.
  83149. * @returns a new Vector3.
  83150. */
  83151. getPositionExpressedInLocalSpace(): Vector3;
  83152. /**
  83153. * Translates the mesh along the passed Vector3 in its local space.
  83154. * @param vector3 the distance to translate in localspace
  83155. * @returns the TransformNode.
  83156. */
  83157. locallyTranslate(vector3: Vector3): TransformNode;
  83158. private static _lookAtVectorCache;
  83159. /**
  83160. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  83161. * @param targetPoint the position (must be in same space as current mesh) to look at
  83162. * @param yawCor optional yaw (y-axis) correction in radians
  83163. * @param pitchCor optional pitch (x-axis) correction in radians
  83164. * @param rollCor optional roll (z-axis) correction in radians
  83165. * @param space the choosen space of the target
  83166. * @returns the TransformNode.
  83167. */
  83168. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  83169. /**
  83170. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  83171. * This Vector3 is expressed in the World space.
  83172. * @param localAxis axis to rotate
  83173. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  83174. */
  83175. getDirection(localAxis: Vector3): Vector3;
  83176. /**
  83177. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  83178. * localAxis is expressed in the mesh local space.
  83179. * result is computed in the Wordl space from the mesh World matrix.
  83180. * @param localAxis axis to rotate
  83181. * @param result the resulting transformnode
  83182. * @returns this TransformNode.
  83183. */
  83184. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  83185. /**
  83186. * Sets this transform node rotation to the given local axis.
  83187. * @param localAxis the axis in local space
  83188. * @param yawCor optional yaw (y-axis) correction in radians
  83189. * @param pitchCor optional pitch (x-axis) correction in radians
  83190. * @param rollCor optional roll (z-axis) correction in radians
  83191. * @returns this TransformNode
  83192. */
  83193. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  83194. /**
  83195. * Sets a new pivot point to the current node
  83196. * @param point defines the new pivot point to use
  83197. * @param space defines if the point is in world or local space (local by default)
  83198. * @returns the current TransformNode
  83199. */
  83200. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  83201. /**
  83202. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  83203. * @returns the pivot point
  83204. */
  83205. getPivotPoint(): Vector3;
  83206. /**
  83207. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  83208. * @param result the vector3 to store the result
  83209. * @returns this TransformNode.
  83210. */
  83211. getPivotPointToRef(result: Vector3): TransformNode;
  83212. /**
  83213. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  83214. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  83215. */
  83216. getAbsolutePivotPoint(): Vector3;
  83217. /**
  83218. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  83219. * @param result vector3 to store the result
  83220. * @returns this TransformNode.
  83221. */
  83222. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  83223. /**
  83224. * Defines the passed node as the parent of the current node.
  83225. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  83226. * @see https://doc.babylonjs.com/how_to/parenting
  83227. * @param node the node ot set as the parent
  83228. * @returns this TransformNode.
  83229. */
  83230. setParent(node: Nullable<Node>): TransformNode;
  83231. private _nonUniformScaling;
  83232. /**
  83233. * True if the scaling property of this object is non uniform eg. (1,2,1)
  83234. */
  83235. readonly nonUniformScaling: boolean;
  83236. /** @hidden */
  83237. _updateNonUniformScalingState(value: boolean): boolean;
  83238. /**
  83239. * Attach the current TransformNode to another TransformNode associated with a bone
  83240. * @param bone Bone affecting the TransformNode
  83241. * @param affectedTransformNode TransformNode associated with the bone
  83242. * @returns this object
  83243. */
  83244. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  83245. /**
  83246. * Detach the transform node if its associated with a bone
  83247. * @returns this object
  83248. */
  83249. detachFromBone(): TransformNode;
  83250. private static _rotationAxisCache;
  83251. /**
  83252. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  83253. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  83254. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  83255. * The passed axis is also normalized.
  83256. * @param axis the axis to rotate around
  83257. * @param amount the amount to rotate in radians
  83258. * @param space Space to rotate in (Default: local)
  83259. * @returns the TransformNode.
  83260. */
  83261. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  83262. /**
  83263. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  83264. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  83265. * The passed axis is also normalized. .
  83266. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  83267. * @param point the point to rotate around
  83268. * @param axis the axis to rotate around
  83269. * @param amount the amount to rotate in radians
  83270. * @returns the TransformNode
  83271. */
  83272. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  83273. /**
  83274. * Translates the mesh along the axis vector for the passed distance in the given space.
  83275. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  83276. * @param axis the axis to translate in
  83277. * @param distance the distance to translate
  83278. * @param space Space to rotate in (Default: local)
  83279. * @returns the TransformNode.
  83280. */
  83281. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  83282. /**
  83283. * Adds a rotation step to the mesh current rotation.
  83284. * x, y, z are Euler angles expressed in radians.
  83285. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  83286. * This means this rotation is made in the mesh local space only.
  83287. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  83288. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  83289. * ```javascript
  83290. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  83291. * ```
  83292. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  83293. * 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.
  83294. * @param x Rotation to add
  83295. * @param y Rotation to add
  83296. * @param z Rotation to add
  83297. * @returns the TransformNode.
  83298. */
  83299. addRotation(x: number, y: number, z: number): TransformNode;
  83300. /**
  83301. * @hidden
  83302. */
  83303. protected _getEffectiveParent(): Nullable<Node>;
  83304. /**
  83305. * Computes the world matrix of the node
  83306. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  83307. * @returns the world matrix
  83308. */
  83309. computeWorldMatrix(force?: boolean): Matrix;
  83310. protected _afterComputeWorldMatrix(): void;
  83311. /**
  83312. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  83313. * @param func callback function to add
  83314. *
  83315. * @returns the TransformNode.
  83316. */
  83317. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  83318. /**
  83319. * Removes a registered callback function.
  83320. * @param func callback function to remove
  83321. * @returns the TransformNode.
  83322. */
  83323. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  83324. /**
  83325. * Gets the position of the current mesh in camera space
  83326. * @param camera defines the camera to use
  83327. * @returns a position
  83328. */
  83329. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  83330. /**
  83331. * Returns the distance from the mesh to the active camera
  83332. * @param camera defines the camera to use
  83333. * @returns the distance
  83334. */
  83335. getDistanceToCamera(camera?: Nullable<Camera>): number;
  83336. /**
  83337. * Clone the current transform node
  83338. * @param name Name of the new clone
  83339. * @param newParent New parent for the clone
  83340. * @param doNotCloneChildren Do not clone children hierarchy
  83341. * @returns the new transform node
  83342. */
  83343. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  83344. /**
  83345. * Serializes the objects information.
  83346. * @param currentSerializationObject defines the object to serialize in
  83347. * @returns the serialized object
  83348. */
  83349. serialize(currentSerializationObject?: any): any;
  83350. /**
  83351. * Returns a new TransformNode object parsed from the source provided.
  83352. * @param parsedTransformNode is the source.
  83353. * @param scene the scne the object belongs to
  83354. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  83355. * @returns a new TransformNode object parsed from the source provided.
  83356. */
  83357. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  83358. /**
  83359. * Get all child-transformNodes of this node
  83360. * @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
  83361. * @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
  83362. * @returns an array of TransformNode
  83363. */
  83364. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  83365. /**
  83366. * Releases resources associated with this transform node.
  83367. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  83368. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  83369. */
  83370. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  83371. /**
  83372. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  83373. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  83374. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  83375. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  83376. * @returns the current mesh
  83377. */
  83378. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  83379. private _syncAbsoluteScalingAndRotation;
  83380. }
  83381. }
  83382. declare module BABYLON {
  83383. /**
  83384. * Defines the types of pose enabled controllers that are supported
  83385. */
  83386. export enum PoseEnabledControllerType {
  83387. /**
  83388. * HTC Vive
  83389. */
  83390. VIVE = 0,
  83391. /**
  83392. * Oculus Rift
  83393. */
  83394. OCULUS = 1,
  83395. /**
  83396. * Windows mixed reality
  83397. */
  83398. WINDOWS = 2,
  83399. /**
  83400. * Samsung gear VR
  83401. */
  83402. GEAR_VR = 3,
  83403. /**
  83404. * Google Daydream
  83405. */
  83406. DAYDREAM = 4,
  83407. /**
  83408. * Generic
  83409. */
  83410. GENERIC = 5
  83411. }
  83412. /**
  83413. * Defines the MutableGamepadButton interface for the state of a gamepad button
  83414. */
  83415. export interface MutableGamepadButton {
  83416. /**
  83417. * Value of the button/trigger
  83418. */
  83419. value: number;
  83420. /**
  83421. * If the button/trigger is currently touched
  83422. */
  83423. touched: boolean;
  83424. /**
  83425. * If the button/trigger is currently pressed
  83426. */
  83427. pressed: boolean;
  83428. }
  83429. /**
  83430. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  83431. * @hidden
  83432. */
  83433. export interface ExtendedGamepadButton extends GamepadButton {
  83434. /**
  83435. * If the button/trigger is currently pressed
  83436. */
  83437. readonly pressed: boolean;
  83438. /**
  83439. * If the button/trigger is currently touched
  83440. */
  83441. readonly touched: boolean;
  83442. /**
  83443. * Value of the button/trigger
  83444. */
  83445. readonly value: number;
  83446. }
  83447. /** @hidden */
  83448. export interface _GamePadFactory {
  83449. /**
  83450. * Returns wether or not the current gamepad can be created for this type of controller.
  83451. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  83452. * @returns true if it can be created, otherwise false
  83453. */
  83454. canCreate(gamepadInfo: any): boolean;
  83455. /**
  83456. * Creates a new instance of the Gamepad.
  83457. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  83458. * @returns the new gamepad instance
  83459. */
  83460. create(gamepadInfo: any): Gamepad;
  83461. }
  83462. /**
  83463. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  83464. */
  83465. export class PoseEnabledControllerHelper {
  83466. /** @hidden */
  83467. static _ControllerFactories: _GamePadFactory[];
  83468. /** @hidden */
  83469. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  83470. /**
  83471. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  83472. * @param vrGamepad the gamepad to initialized
  83473. * @returns a vr controller of the type the gamepad identified as
  83474. */
  83475. static InitiateController(vrGamepad: any): Gamepad;
  83476. }
  83477. /**
  83478. * Defines the PoseEnabledController object that contains state of a vr capable controller
  83479. */
  83480. export class PoseEnabledController extends Gamepad implements PoseControlled {
  83481. /**
  83482. * If the controller is used in a webXR session
  83483. */
  83484. isXR: boolean;
  83485. private _deviceRoomPosition;
  83486. private _deviceRoomRotationQuaternion;
  83487. /**
  83488. * The device position in babylon space
  83489. */
  83490. devicePosition: Vector3;
  83491. /**
  83492. * The device rotation in babylon space
  83493. */
  83494. deviceRotationQuaternion: Quaternion;
  83495. /**
  83496. * The scale factor of the device in babylon space
  83497. */
  83498. deviceScaleFactor: number;
  83499. /**
  83500. * (Likely devicePosition should be used instead) The device position in its room space
  83501. */
  83502. position: Vector3;
  83503. /**
  83504. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  83505. */
  83506. rotationQuaternion: Quaternion;
  83507. /**
  83508. * The type of controller (Eg. Windows mixed reality)
  83509. */
  83510. controllerType: PoseEnabledControllerType;
  83511. protected _calculatedPosition: Vector3;
  83512. private _calculatedRotation;
  83513. /**
  83514. * The raw pose from the device
  83515. */
  83516. rawPose: DevicePose;
  83517. private _trackPosition;
  83518. private _maxRotationDistFromHeadset;
  83519. private _draggedRoomRotation;
  83520. /**
  83521. * @hidden
  83522. */
  83523. _disableTrackPosition(fixedPosition: Vector3): void;
  83524. /**
  83525. * Internal, the mesh attached to the controller
  83526. * @hidden
  83527. */
  83528. _mesh: Nullable<AbstractMesh>;
  83529. private _poseControlledCamera;
  83530. private _leftHandSystemQuaternion;
  83531. /**
  83532. * Internal, matrix used to convert room space to babylon space
  83533. * @hidden
  83534. */
  83535. _deviceToWorld: Matrix;
  83536. /**
  83537. * Node to be used when casting a ray from the controller
  83538. * @hidden
  83539. */
  83540. _pointingPoseNode: Nullable<TransformNode>;
  83541. /**
  83542. * Name of the child mesh that can be used to cast a ray from the controller
  83543. */
  83544. static readonly POINTING_POSE: string;
  83545. /**
  83546. * Creates a new PoseEnabledController from a gamepad
  83547. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  83548. */
  83549. constructor(browserGamepad: any);
  83550. private _workingMatrix;
  83551. /**
  83552. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  83553. */
  83554. update(): void;
  83555. /**
  83556. * Updates only the pose device and mesh without doing any button event checking
  83557. */
  83558. protected _updatePoseAndMesh(): void;
  83559. /**
  83560. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  83561. * @param poseData raw pose fromthe device
  83562. */
  83563. updateFromDevice(poseData: DevicePose): void;
  83564. /**
  83565. * @hidden
  83566. */
  83567. _meshAttachedObservable: Observable<AbstractMesh>;
  83568. /**
  83569. * Attaches a mesh to the controller
  83570. * @param mesh the mesh to be attached
  83571. */
  83572. attachToMesh(mesh: AbstractMesh): void;
  83573. /**
  83574. * Attaches the controllers mesh to a camera
  83575. * @param camera the camera the mesh should be attached to
  83576. */
  83577. attachToPoseControlledCamera(camera: TargetCamera): void;
  83578. /**
  83579. * Disposes of the controller
  83580. */
  83581. dispose(): void;
  83582. /**
  83583. * The mesh that is attached to the controller
  83584. */
  83585. readonly mesh: Nullable<AbstractMesh>;
  83586. /**
  83587. * Gets the ray of the controller in the direction the controller is pointing
  83588. * @param length the length the resulting ray should be
  83589. * @returns a ray in the direction the controller is pointing
  83590. */
  83591. getForwardRay(length?: number): Ray;
  83592. }
  83593. }
  83594. declare module BABYLON {
  83595. /**
  83596. * Defines the WebVRController object that represents controllers tracked in 3D space
  83597. */
  83598. export abstract class WebVRController extends PoseEnabledController {
  83599. /**
  83600. * Internal, the default controller model for the controller
  83601. */
  83602. protected _defaultModel: Nullable<AbstractMesh>;
  83603. /**
  83604. * Fired when the trigger state has changed
  83605. */
  83606. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  83607. /**
  83608. * Fired when the main button state has changed
  83609. */
  83610. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  83611. /**
  83612. * Fired when the secondary button state has changed
  83613. */
  83614. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  83615. /**
  83616. * Fired when the pad state has changed
  83617. */
  83618. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  83619. /**
  83620. * Fired when controllers stick values have changed
  83621. */
  83622. onPadValuesChangedObservable: Observable<StickValues>;
  83623. /**
  83624. * Array of button availible on the controller
  83625. */
  83626. protected _buttons: Array<MutableGamepadButton>;
  83627. private _onButtonStateChange;
  83628. /**
  83629. * Fired when a controller button's state has changed
  83630. * @param callback the callback containing the button that was modified
  83631. */
  83632. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  83633. /**
  83634. * X and Y axis corresponding to the controllers joystick
  83635. */
  83636. pad: StickValues;
  83637. /**
  83638. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  83639. */
  83640. hand: string;
  83641. /**
  83642. * The default controller model for the controller
  83643. */
  83644. readonly defaultModel: Nullable<AbstractMesh>;
  83645. /**
  83646. * Creates a new WebVRController from a gamepad
  83647. * @param vrGamepad the gamepad that the WebVRController should be created from
  83648. */
  83649. constructor(vrGamepad: any);
  83650. /**
  83651. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  83652. */
  83653. update(): void;
  83654. /**
  83655. * Function to be called when a button is modified
  83656. */
  83657. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  83658. /**
  83659. * Loads a mesh and attaches it to the controller
  83660. * @param scene the scene the mesh should be added to
  83661. * @param meshLoaded callback for when the mesh has been loaded
  83662. */
  83663. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  83664. private _setButtonValue;
  83665. private _changes;
  83666. private _checkChanges;
  83667. /**
  83668. * Disposes of th webVRCOntroller
  83669. */
  83670. dispose(): void;
  83671. }
  83672. }
  83673. declare module BABYLON {
  83674. /**
  83675. * The HemisphericLight simulates the ambient environment light,
  83676. * so the passed direction is the light reflection direction, not the incoming direction.
  83677. */
  83678. export class HemisphericLight extends Light {
  83679. /**
  83680. * The groundColor is the light in the opposite direction to the one specified during creation.
  83681. * 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.
  83682. */
  83683. groundColor: Color3;
  83684. /**
  83685. * The light reflection direction, not the incoming direction.
  83686. */
  83687. direction: Vector3;
  83688. /**
  83689. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  83690. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  83691. * The HemisphericLight can't cast shadows.
  83692. * Documentation : https://doc.babylonjs.com/babylon101/lights
  83693. * @param name The friendly name of the light
  83694. * @param direction The direction of the light reflection
  83695. * @param scene The scene the light belongs to
  83696. */
  83697. constructor(name: string, direction: Vector3, scene: Scene);
  83698. protected _buildUniformLayout(): void;
  83699. /**
  83700. * Returns the string "HemisphericLight".
  83701. * @return The class name
  83702. */
  83703. getClassName(): string;
  83704. /**
  83705. * Sets the HemisphericLight direction towards the passed target (Vector3).
  83706. * Returns the updated direction.
  83707. * @param target The target the direction should point to
  83708. * @return The computed direction
  83709. */
  83710. setDirectionToTarget(target: Vector3): Vector3;
  83711. /**
  83712. * Returns the shadow generator associated to the light.
  83713. * @returns Always null for hemispheric lights because it does not support shadows.
  83714. */
  83715. getShadowGenerator(): Nullable<IShadowGenerator>;
  83716. /**
  83717. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  83718. * @param effect The effect to update
  83719. * @param lightIndex The index of the light in the effect to update
  83720. * @returns The hemispheric light
  83721. */
  83722. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  83723. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  83724. /**
  83725. * Computes the world matrix of the node
  83726. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  83727. * @param useWasUpdatedFlag defines a reserved property
  83728. * @returns the world matrix
  83729. */
  83730. computeWorldMatrix(): Matrix;
  83731. /**
  83732. * Returns the integer 3.
  83733. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  83734. */
  83735. getTypeID(): number;
  83736. /**
  83737. * Prepares the list of defines specific to the light type.
  83738. * @param defines the list of defines
  83739. * @param lightIndex defines the index of the light for the effect
  83740. */
  83741. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  83742. }
  83743. }
  83744. declare module BABYLON {
  83745. /** @hidden */
  83746. export var vrMultiviewToSingleviewPixelShader: {
  83747. name: string;
  83748. shader: string;
  83749. };
  83750. }
  83751. declare module BABYLON {
  83752. /**
  83753. * Renders to multiple views with a single draw call
  83754. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  83755. */
  83756. export class MultiviewRenderTarget extends RenderTargetTexture {
  83757. /**
  83758. * Creates a multiview render target
  83759. * @param scene scene used with the render target
  83760. * @param size the size of the render target (used for each view)
  83761. */
  83762. constructor(scene: Scene, size?: number | {
  83763. width: number;
  83764. height: number;
  83765. } | {
  83766. ratio: number;
  83767. });
  83768. /**
  83769. * @hidden
  83770. * @param faceIndex the face index, if its a cube texture
  83771. */
  83772. _bindFrameBuffer(faceIndex?: number): void;
  83773. /**
  83774. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  83775. * @returns the view count
  83776. */
  83777. getViewCount(): number;
  83778. }
  83779. }
  83780. declare module BABYLON {
  83781. /**
  83782. * Represents a camera frustum
  83783. */
  83784. export class Frustum {
  83785. /**
  83786. * Gets the planes representing the frustum
  83787. * @param transform matrix to be applied to the returned planes
  83788. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  83789. */
  83790. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  83791. /**
  83792. * Gets the near frustum plane transformed by the transform matrix
  83793. * @param transform transformation matrix to be applied to the resulting frustum plane
  83794. * @param frustumPlane the resuling frustum plane
  83795. */
  83796. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83797. /**
  83798. * Gets the far frustum plane transformed by the transform matrix
  83799. * @param transform transformation matrix to be applied to the resulting frustum plane
  83800. * @param frustumPlane the resuling frustum plane
  83801. */
  83802. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83803. /**
  83804. * Gets the left frustum plane transformed by the transform matrix
  83805. * @param transform transformation matrix to be applied to the resulting frustum plane
  83806. * @param frustumPlane the resuling frustum plane
  83807. */
  83808. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83809. /**
  83810. * Gets the right frustum plane transformed by the transform matrix
  83811. * @param transform transformation matrix to be applied to the resulting frustum plane
  83812. * @param frustumPlane the resuling frustum plane
  83813. */
  83814. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83815. /**
  83816. * Gets the top frustum plane transformed by the transform matrix
  83817. * @param transform transformation matrix to be applied to the resulting frustum plane
  83818. * @param frustumPlane the resuling frustum plane
  83819. */
  83820. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83821. /**
  83822. * Gets the bottom frustum plane transformed by the transform matrix
  83823. * @param transform transformation matrix to be applied to the resulting frustum plane
  83824. * @param frustumPlane the resuling frustum plane
  83825. */
  83826. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83827. /**
  83828. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  83829. * @param transform transformation matrix to be applied to the resulting frustum planes
  83830. * @param frustumPlanes the resuling frustum planes
  83831. */
  83832. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  83833. }
  83834. }
  83835. declare module BABYLON {
  83836. interface Engine {
  83837. /**
  83838. * Creates a new multiview render target
  83839. * @param width defines the width of the texture
  83840. * @param height defines the height of the texture
  83841. * @returns the created multiview texture
  83842. */
  83843. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  83844. /**
  83845. * Binds a multiview framebuffer to be drawn to
  83846. * @param multiviewTexture texture to bind
  83847. */
  83848. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  83849. }
  83850. interface Camera {
  83851. /**
  83852. * @hidden
  83853. * 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)
  83854. */
  83855. _useMultiviewToSingleView: boolean;
  83856. /**
  83857. * @hidden
  83858. * 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)
  83859. */
  83860. _multiviewTexture: Nullable<RenderTargetTexture>;
  83861. /**
  83862. * @hidden
  83863. * ensures the multiview texture of the camera exists and has the specified width/height
  83864. * @param width height to set on the multiview texture
  83865. * @param height width to set on the multiview texture
  83866. */
  83867. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  83868. }
  83869. interface Scene {
  83870. /** @hidden */
  83871. _transformMatrixR: Matrix;
  83872. /** @hidden */
  83873. _multiviewSceneUbo: Nullable<UniformBuffer>;
  83874. /** @hidden */
  83875. _createMultiviewUbo(): void;
  83876. /** @hidden */
  83877. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  83878. /** @hidden */
  83879. _renderMultiviewToSingleView(camera: Camera): void;
  83880. }
  83881. }
  83882. declare module BABYLON {
  83883. /**
  83884. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  83885. * This will not be used for webXR as it supports displaying texture arrays directly
  83886. */
  83887. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  83888. /**
  83889. * Initializes a VRMultiviewToSingleview
  83890. * @param name name of the post process
  83891. * @param camera camera to be applied to
  83892. * @param scaleFactor scaling factor to the size of the output texture
  83893. */
  83894. constructor(name: string, camera: Camera, scaleFactor: number);
  83895. }
  83896. }
  83897. declare module BABYLON {
  83898. /**
  83899. * Interface used to define additional presentation attributes
  83900. */
  83901. export interface IVRPresentationAttributes {
  83902. /**
  83903. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  83904. */
  83905. highRefreshRate: boolean;
  83906. /**
  83907. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  83908. */
  83909. foveationLevel: number;
  83910. }
  83911. interface Engine {
  83912. /** @hidden */
  83913. _vrDisplay: any;
  83914. /** @hidden */
  83915. _vrSupported: boolean;
  83916. /** @hidden */
  83917. _oldSize: Size;
  83918. /** @hidden */
  83919. _oldHardwareScaleFactor: number;
  83920. /** @hidden */
  83921. _vrExclusivePointerMode: boolean;
  83922. /** @hidden */
  83923. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  83924. /** @hidden */
  83925. _onVRDisplayPointerRestricted: () => void;
  83926. /** @hidden */
  83927. _onVRDisplayPointerUnrestricted: () => void;
  83928. /** @hidden */
  83929. _onVrDisplayConnect: Nullable<(display: any) => void>;
  83930. /** @hidden */
  83931. _onVrDisplayDisconnect: Nullable<() => void>;
  83932. /** @hidden */
  83933. _onVrDisplayPresentChange: Nullable<() => void>;
  83934. /**
  83935. * Observable signaled when VR display mode changes
  83936. */
  83937. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  83938. /**
  83939. * Observable signaled when VR request present is complete
  83940. */
  83941. onVRRequestPresentComplete: Observable<boolean>;
  83942. /**
  83943. * Observable signaled when VR request present starts
  83944. */
  83945. onVRRequestPresentStart: Observable<Engine>;
  83946. /**
  83947. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  83948. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  83949. */
  83950. isInVRExclusivePointerMode: boolean;
  83951. /**
  83952. * Gets a boolean indicating if a webVR device was detected
  83953. * @returns true if a webVR device was detected
  83954. */
  83955. isVRDevicePresent(): boolean;
  83956. /**
  83957. * Gets the current webVR device
  83958. * @returns the current webVR device (or null)
  83959. */
  83960. getVRDevice(): any;
  83961. /**
  83962. * Initializes a webVR display and starts listening to display change events
  83963. * The onVRDisplayChangedObservable will be notified upon these changes
  83964. * @returns A promise containing a VRDisplay and if vr is supported
  83965. */
  83966. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  83967. /** @hidden */
  83968. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  83969. /**
  83970. * Gets or sets the presentation attributes used to configure VR rendering
  83971. */
  83972. vrPresentationAttributes?: IVRPresentationAttributes;
  83973. /**
  83974. * Call this function to switch to webVR mode
  83975. * Will do nothing if webVR is not supported or if there is no webVR device
  83976. * @param options the webvr options provided to the camera. mainly used for multiview
  83977. * @see http://doc.babylonjs.com/how_to/webvr_camera
  83978. */
  83979. enableVR(options: WebVROptions): void;
  83980. /** @hidden */
  83981. _onVRFullScreenTriggered(): void;
  83982. }
  83983. }
  83984. declare module BABYLON {
  83985. /**
  83986. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  83987. * IMPORTANT!! The data is right-hand data.
  83988. * @export
  83989. * @interface DevicePose
  83990. */
  83991. export interface DevicePose {
  83992. /**
  83993. * The position of the device, values in array are [x,y,z].
  83994. */
  83995. readonly position: Nullable<Float32Array>;
  83996. /**
  83997. * The linearVelocity of the device, values in array are [x,y,z].
  83998. */
  83999. readonly linearVelocity: Nullable<Float32Array>;
  84000. /**
  84001. * The linearAcceleration of the device, values in array are [x,y,z].
  84002. */
  84003. readonly linearAcceleration: Nullable<Float32Array>;
  84004. /**
  84005. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  84006. */
  84007. readonly orientation: Nullable<Float32Array>;
  84008. /**
  84009. * The angularVelocity of the device, values in array are [x,y,z].
  84010. */
  84011. readonly angularVelocity: Nullable<Float32Array>;
  84012. /**
  84013. * The angularAcceleration of the device, values in array are [x,y,z].
  84014. */
  84015. readonly angularAcceleration: Nullable<Float32Array>;
  84016. }
  84017. /**
  84018. * Interface representing a pose controlled object in Babylon.
  84019. * A pose controlled object has both regular pose values as well as pose values
  84020. * from an external device such as a VR head mounted display
  84021. */
  84022. export interface PoseControlled {
  84023. /**
  84024. * The position of the object in babylon space.
  84025. */
  84026. position: Vector3;
  84027. /**
  84028. * The rotation quaternion of the object in babylon space.
  84029. */
  84030. rotationQuaternion: Quaternion;
  84031. /**
  84032. * The position of the device in babylon space.
  84033. */
  84034. devicePosition?: Vector3;
  84035. /**
  84036. * The rotation quaternion of the device in babylon space.
  84037. */
  84038. deviceRotationQuaternion: Quaternion;
  84039. /**
  84040. * The raw pose coming from the device.
  84041. */
  84042. rawPose: Nullable<DevicePose>;
  84043. /**
  84044. * The scale of the device to be used when translating from device space to babylon space.
  84045. */
  84046. deviceScaleFactor: number;
  84047. /**
  84048. * Updates the poseControlled values based on the input device pose.
  84049. * @param poseData the pose data to update the object with
  84050. */
  84051. updateFromDevice(poseData: DevicePose): void;
  84052. }
  84053. /**
  84054. * Set of options to customize the webVRCamera
  84055. */
  84056. export interface WebVROptions {
  84057. /**
  84058. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  84059. */
  84060. trackPosition?: boolean;
  84061. /**
  84062. * Sets the scale of the vrDevice in babylon space. (default: 1)
  84063. */
  84064. positionScale?: number;
  84065. /**
  84066. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  84067. */
  84068. displayName?: string;
  84069. /**
  84070. * Should the native controller meshes be initialized. (default: true)
  84071. */
  84072. controllerMeshes?: boolean;
  84073. /**
  84074. * Creating a default HemiLight only on controllers. (default: true)
  84075. */
  84076. defaultLightingOnControllers?: boolean;
  84077. /**
  84078. * If you don't want to use the default VR button of the helper. (default: false)
  84079. */
  84080. useCustomVRButton?: boolean;
  84081. /**
  84082. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  84083. */
  84084. customVRButton?: HTMLButtonElement;
  84085. /**
  84086. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  84087. */
  84088. rayLength?: number;
  84089. /**
  84090. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  84091. */
  84092. defaultHeight?: number;
  84093. /**
  84094. * If multiview should be used if availible (default: false)
  84095. */
  84096. useMultiview?: boolean;
  84097. }
  84098. /**
  84099. * This represents a WebVR camera.
  84100. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  84101. * @example http://doc.babylonjs.com/how_to/webvr_camera
  84102. */
  84103. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  84104. private webVROptions;
  84105. /**
  84106. * @hidden
  84107. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  84108. */
  84109. _vrDevice: any;
  84110. /**
  84111. * The rawPose of the vrDevice.
  84112. */
  84113. rawPose: Nullable<DevicePose>;
  84114. private _onVREnabled;
  84115. private _specsVersion;
  84116. private _attached;
  84117. private _frameData;
  84118. protected _descendants: Array<Node>;
  84119. private _deviceRoomPosition;
  84120. /** @hidden */
  84121. _deviceRoomRotationQuaternion: Quaternion;
  84122. private _standingMatrix;
  84123. /**
  84124. * Represents device position in babylon space.
  84125. */
  84126. devicePosition: Vector3;
  84127. /**
  84128. * Represents device rotation in babylon space.
  84129. */
  84130. deviceRotationQuaternion: Quaternion;
  84131. /**
  84132. * The scale of the device to be used when translating from device space to babylon space.
  84133. */
  84134. deviceScaleFactor: number;
  84135. private _deviceToWorld;
  84136. private _worldToDevice;
  84137. /**
  84138. * References to the webVR controllers for the vrDevice.
  84139. */
  84140. controllers: Array<WebVRController>;
  84141. /**
  84142. * Emits an event when a controller is attached.
  84143. */
  84144. onControllersAttachedObservable: Observable<WebVRController[]>;
  84145. /**
  84146. * Emits an event when a controller's mesh has been loaded;
  84147. */
  84148. onControllerMeshLoadedObservable: Observable<WebVRController>;
  84149. /**
  84150. * Emits an event when the HMD's pose has been updated.
  84151. */
  84152. onPoseUpdatedFromDeviceObservable: Observable<any>;
  84153. private _poseSet;
  84154. /**
  84155. * If the rig cameras be used as parent instead of this camera.
  84156. */
  84157. rigParenting: boolean;
  84158. private _lightOnControllers;
  84159. private _defaultHeight?;
  84160. /**
  84161. * Instantiates a WebVRFreeCamera.
  84162. * @param name The name of the WebVRFreeCamera
  84163. * @param position The starting anchor position for the camera
  84164. * @param scene The scene the camera belongs to
  84165. * @param webVROptions a set of customizable options for the webVRCamera
  84166. */
  84167. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  84168. /**
  84169. * Gets the device distance from the ground in meters.
  84170. * @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.
  84171. */
  84172. deviceDistanceToRoomGround(): number;
  84173. /**
  84174. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  84175. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  84176. */
  84177. useStandingMatrix(callback?: (bool: boolean) => void): void;
  84178. /**
  84179. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  84180. * @returns A promise with a boolean set to if the standing matrix is supported.
  84181. */
  84182. useStandingMatrixAsync(): Promise<boolean>;
  84183. /**
  84184. * Disposes the camera
  84185. */
  84186. dispose(): void;
  84187. /**
  84188. * Gets a vrController by name.
  84189. * @param name The name of the controller to retreive
  84190. * @returns the controller matching the name specified or null if not found
  84191. */
  84192. getControllerByName(name: string): Nullable<WebVRController>;
  84193. private _leftController;
  84194. /**
  84195. * The controller corresponding to the users left hand.
  84196. */
  84197. readonly leftController: Nullable<WebVRController>;
  84198. private _rightController;
  84199. /**
  84200. * The controller corresponding to the users right hand.
  84201. */
  84202. readonly rightController: Nullable<WebVRController>;
  84203. /**
  84204. * Casts a ray forward from the vrCamera's gaze.
  84205. * @param length Length of the ray (default: 100)
  84206. * @returns the ray corresponding to the gaze
  84207. */
  84208. getForwardRay(length?: number): Ray;
  84209. /**
  84210. * @hidden
  84211. * Updates the camera based on device's frame data
  84212. */
  84213. _checkInputs(): void;
  84214. /**
  84215. * Updates the poseControlled values based on the input device pose.
  84216. * @param poseData Pose coming from the device
  84217. */
  84218. updateFromDevice(poseData: DevicePose): void;
  84219. private _htmlElementAttached;
  84220. private _detachIfAttached;
  84221. /**
  84222. * WebVR's attach control will start broadcasting frames to the device.
  84223. * Note that in certain browsers (chrome for example) this function must be called
  84224. * within a user-interaction callback. Example:
  84225. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  84226. *
  84227. * @param element html element to attach the vrDevice to
  84228. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  84229. */
  84230. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  84231. /**
  84232. * Detaches the camera from the html element and disables VR
  84233. *
  84234. * @param element html element to detach from
  84235. */
  84236. detachControl(element: HTMLElement): void;
  84237. /**
  84238. * @returns the name of this class
  84239. */
  84240. getClassName(): string;
  84241. /**
  84242. * Calls resetPose on the vrDisplay
  84243. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  84244. */
  84245. resetToCurrentRotation(): void;
  84246. /**
  84247. * @hidden
  84248. * Updates the rig cameras (left and right eye)
  84249. */
  84250. _updateRigCameras(): void;
  84251. private _workingVector;
  84252. private _oneVector;
  84253. private _workingMatrix;
  84254. private updateCacheCalled;
  84255. private _correctPositionIfNotTrackPosition;
  84256. /**
  84257. * @hidden
  84258. * Updates the cached values of the camera
  84259. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  84260. */
  84261. _updateCache(ignoreParentClass?: boolean): void;
  84262. /**
  84263. * @hidden
  84264. * Get current device position in babylon world
  84265. */
  84266. _computeDevicePosition(): void;
  84267. /**
  84268. * Updates the current device position and rotation in the babylon world
  84269. */
  84270. update(): void;
  84271. /**
  84272. * @hidden
  84273. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  84274. * @returns an identity matrix
  84275. */
  84276. _getViewMatrix(): Matrix;
  84277. private _tmpMatrix;
  84278. /**
  84279. * This function is called by the two RIG cameras.
  84280. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  84281. * @hidden
  84282. */
  84283. _getWebVRViewMatrix(): Matrix;
  84284. /** @hidden */
  84285. _getWebVRProjectionMatrix(): Matrix;
  84286. private _onGamepadConnectedObserver;
  84287. private _onGamepadDisconnectedObserver;
  84288. private _updateCacheWhenTrackingDisabledObserver;
  84289. /**
  84290. * Initializes the controllers and their meshes
  84291. */
  84292. initControllers(): void;
  84293. }
  84294. }
  84295. declare module BABYLON {
  84296. /**
  84297. * Size options for a post process
  84298. */
  84299. export type PostProcessOptions = {
  84300. width: number;
  84301. height: number;
  84302. };
  84303. /**
  84304. * PostProcess can be used to apply a shader to a texture after it has been rendered
  84305. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  84306. */
  84307. export class PostProcess {
  84308. /** Name of the PostProcess. */
  84309. name: string;
  84310. /**
  84311. * Gets or sets the unique id of the post process
  84312. */
  84313. uniqueId: number;
  84314. /**
  84315. * Width of the texture to apply the post process on
  84316. */
  84317. width: number;
  84318. /**
  84319. * Height of the texture to apply the post process on
  84320. */
  84321. height: number;
  84322. /**
  84323. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  84324. * @hidden
  84325. */
  84326. _outputTexture: Nullable<InternalTexture>;
  84327. /**
  84328. * Sampling mode used by the shader
  84329. * See https://doc.babylonjs.com/classes/3.1/texture
  84330. */
  84331. renderTargetSamplingMode: number;
  84332. /**
  84333. * Clear color to use when screen clearing
  84334. */
  84335. clearColor: Color4;
  84336. /**
  84337. * If the buffer needs to be cleared before applying the post process. (default: true)
  84338. * Should be set to false if shader will overwrite all previous pixels.
  84339. */
  84340. autoClear: boolean;
  84341. /**
  84342. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  84343. */
  84344. alphaMode: number;
  84345. /**
  84346. * Sets the setAlphaBlendConstants of the babylon engine
  84347. */
  84348. alphaConstants: Color4;
  84349. /**
  84350. * Animations to be used for the post processing
  84351. */
  84352. animations: Animation[];
  84353. /**
  84354. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  84355. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  84356. */
  84357. enablePixelPerfectMode: boolean;
  84358. /**
  84359. * Force the postprocess to be applied without taking in account viewport
  84360. */
  84361. forceFullscreenViewport: boolean;
  84362. /**
  84363. * List of inspectable custom properties (used by the Inspector)
  84364. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84365. */
  84366. inspectableCustomProperties: IInspectable[];
  84367. /**
  84368. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  84369. *
  84370. * | Value | Type | Description |
  84371. * | ----- | ----------------------------------- | ----------- |
  84372. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  84373. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  84374. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  84375. *
  84376. */
  84377. scaleMode: number;
  84378. /**
  84379. * Force textures to be a power of two (default: false)
  84380. */
  84381. alwaysForcePOT: boolean;
  84382. private _samples;
  84383. /**
  84384. * Number of sample textures (default: 1)
  84385. */
  84386. samples: number;
  84387. /**
  84388. * Modify the scale of the post process to be the same as the viewport (default: false)
  84389. */
  84390. adaptScaleToCurrentViewport: boolean;
  84391. private _camera;
  84392. private _scene;
  84393. private _engine;
  84394. private _options;
  84395. private _reusable;
  84396. private _textureType;
  84397. /**
  84398. * Smart array of input and output textures for the post process.
  84399. * @hidden
  84400. */
  84401. _textures: SmartArray<InternalTexture>;
  84402. /**
  84403. * The index in _textures that corresponds to the output texture.
  84404. * @hidden
  84405. */
  84406. _currentRenderTextureInd: number;
  84407. private _effect;
  84408. private _samplers;
  84409. private _fragmentUrl;
  84410. private _vertexUrl;
  84411. private _parameters;
  84412. private _scaleRatio;
  84413. protected _indexParameters: any;
  84414. private _shareOutputWithPostProcess;
  84415. private _texelSize;
  84416. private _forcedOutputTexture;
  84417. /**
  84418. * Returns the fragment url or shader name used in the post process.
  84419. * @returns the fragment url or name in the shader store.
  84420. */
  84421. getEffectName(): string;
  84422. /**
  84423. * An event triggered when the postprocess is activated.
  84424. */
  84425. onActivateObservable: Observable<Camera>;
  84426. private _onActivateObserver;
  84427. /**
  84428. * A function that is added to the onActivateObservable
  84429. */
  84430. onActivate: Nullable<(camera: Camera) => void>;
  84431. /**
  84432. * An event triggered when the postprocess changes its size.
  84433. */
  84434. onSizeChangedObservable: Observable<PostProcess>;
  84435. private _onSizeChangedObserver;
  84436. /**
  84437. * A function that is added to the onSizeChangedObservable
  84438. */
  84439. onSizeChanged: (postProcess: PostProcess) => void;
  84440. /**
  84441. * An event triggered when the postprocess applies its effect.
  84442. */
  84443. onApplyObservable: Observable<Effect>;
  84444. private _onApplyObserver;
  84445. /**
  84446. * A function that is added to the onApplyObservable
  84447. */
  84448. onApply: (effect: Effect) => void;
  84449. /**
  84450. * An event triggered before rendering the postprocess
  84451. */
  84452. onBeforeRenderObservable: Observable<Effect>;
  84453. private _onBeforeRenderObserver;
  84454. /**
  84455. * A function that is added to the onBeforeRenderObservable
  84456. */
  84457. onBeforeRender: (effect: Effect) => void;
  84458. /**
  84459. * An event triggered after rendering the postprocess
  84460. */
  84461. onAfterRenderObservable: Observable<Effect>;
  84462. private _onAfterRenderObserver;
  84463. /**
  84464. * A function that is added to the onAfterRenderObservable
  84465. */
  84466. onAfterRender: (efect: Effect) => void;
  84467. /**
  84468. * 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
  84469. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  84470. */
  84471. inputTexture: InternalTexture;
  84472. /**
  84473. * Gets the camera which post process is applied to.
  84474. * @returns The camera the post process is applied to.
  84475. */
  84476. getCamera(): Camera;
  84477. /**
  84478. * Gets the texel size of the postprocess.
  84479. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  84480. */
  84481. readonly texelSize: Vector2;
  84482. /**
  84483. * Creates a new instance PostProcess
  84484. * @param name The name of the PostProcess.
  84485. * @param fragmentUrl The url of the fragment shader to be used.
  84486. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  84487. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  84488. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  84489. * @param camera The camera to apply the render pass to.
  84490. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  84491. * @param engine The engine which the post process will be applied. (default: current engine)
  84492. * @param reusable If the post process can be reused on the same frame. (default: false)
  84493. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  84494. * @param textureType Type of textures used when performing the post process. (default: 0)
  84495. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  84496. * @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
  84497. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  84498. */
  84499. constructor(
  84500. /** Name of the PostProcess. */
  84501. 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);
  84502. /**
  84503. * Gets a string idenfifying the name of the class
  84504. * @returns "PostProcess" string
  84505. */
  84506. getClassName(): string;
  84507. /**
  84508. * Gets the engine which this post process belongs to.
  84509. * @returns The engine the post process was enabled with.
  84510. */
  84511. getEngine(): Engine;
  84512. /**
  84513. * The effect that is created when initializing the post process.
  84514. * @returns The created effect corresponding the the postprocess.
  84515. */
  84516. getEffect(): Effect;
  84517. /**
  84518. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  84519. * @param postProcess The post process to share the output with.
  84520. * @returns This post process.
  84521. */
  84522. shareOutputWith(postProcess: PostProcess): PostProcess;
  84523. /**
  84524. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  84525. * This should be called if the post process that shares output with this post process is disabled/disposed.
  84526. */
  84527. useOwnOutput(): void;
  84528. /**
  84529. * Updates the effect with the current post process compile time values and recompiles the shader.
  84530. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  84531. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  84532. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  84533. * @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
  84534. * @param onCompiled Called when the shader has been compiled.
  84535. * @param onError Called if there is an error when compiling a shader.
  84536. */
  84537. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  84538. /**
  84539. * The post process is reusable if it can be used multiple times within one frame.
  84540. * @returns If the post process is reusable
  84541. */
  84542. isReusable(): boolean;
  84543. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  84544. markTextureDirty(): void;
  84545. /**
  84546. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  84547. * 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.
  84548. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  84549. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  84550. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  84551. * @returns The target texture that was bound to be written to.
  84552. */
  84553. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  84554. /**
  84555. * If the post process is supported.
  84556. */
  84557. readonly isSupported: boolean;
  84558. /**
  84559. * The aspect ratio of the output texture.
  84560. */
  84561. readonly aspectRatio: number;
  84562. /**
  84563. * Get a value indicating if the post-process is ready to be used
  84564. * @returns true if the post-process is ready (shader is compiled)
  84565. */
  84566. isReady(): boolean;
  84567. /**
  84568. * Binds all textures and uniforms to the shader, this will be run on every pass.
  84569. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  84570. */
  84571. apply(): Nullable<Effect>;
  84572. private _disposeTextures;
  84573. /**
  84574. * Disposes the post process.
  84575. * @param camera The camera to dispose the post process on.
  84576. */
  84577. dispose(camera?: Camera): void;
  84578. }
  84579. }
  84580. declare module BABYLON {
  84581. /** @hidden */
  84582. export var kernelBlurVaryingDeclaration: {
  84583. name: string;
  84584. shader: string;
  84585. };
  84586. }
  84587. declare module BABYLON {
  84588. /** @hidden */
  84589. export var kernelBlurFragment: {
  84590. name: string;
  84591. shader: string;
  84592. };
  84593. }
  84594. declare module BABYLON {
  84595. /** @hidden */
  84596. export var kernelBlurFragment2: {
  84597. name: string;
  84598. shader: string;
  84599. };
  84600. }
  84601. declare module BABYLON {
  84602. /** @hidden */
  84603. export var kernelBlurPixelShader: {
  84604. name: string;
  84605. shader: string;
  84606. };
  84607. }
  84608. declare module BABYLON {
  84609. /** @hidden */
  84610. export var kernelBlurVertex: {
  84611. name: string;
  84612. shader: string;
  84613. };
  84614. }
  84615. declare module BABYLON {
  84616. /** @hidden */
  84617. export var kernelBlurVertexShader: {
  84618. name: string;
  84619. shader: string;
  84620. };
  84621. }
  84622. declare module BABYLON {
  84623. /**
  84624. * The Blur Post Process which blurs an image based on a kernel and direction.
  84625. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  84626. */
  84627. export class BlurPostProcess extends PostProcess {
  84628. /** The direction in which to blur the image. */
  84629. direction: Vector2;
  84630. private blockCompilation;
  84631. protected _kernel: number;
  84632. protected _idealKernel: number;
  84633. protected _packedFloat: boolean;
  84634. private _staticDefines;
  84635. /**
  84636. * Sets the length in pixels of the blur sample region
  84637. */
  84638. /**
  84639. * Gets the length in pixels of the blur sample region
  84640. */
  84641. kernel: number;
  84642. /**
  84643. * Sets wether or not the blur needs to unpack/repack floats
  84644. */
  84645. /**
  84646. * Gets wether or not the blur is unpacking/repacking floats
  84647. */
  84648. packedFloat: boolean;
  84649. /**
  84650. * Creates a new instance BlurPostProcess
  84651. * @param name The name of the effect.
  84652. * @param direction The direction in which to blur the image.
  84653. * @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.
  84654. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  84655. * @param camera The camera to apply the render pass to.
  84656. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  84657. * @param engine The engine which the post process will be applied. (default: current engine)
  84658. * @param reusable If the post process can be reused on the same frame. (default: false)
  84659. * @param textureType Type of textures used when performing the post process. (default: 0)
  84660. * @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)
  84661. */
  84662. constructor(name: string,
  84663. /** The direction in which to blur the image. */
  84664. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  84665. /**
  84666. * Updates the effect with the current post process compile time values and recompiles the shader.
  84667. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  84668. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  84669. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  84670. * @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
  84671. * @param onCompiled Called when the shader has been compiled.
  84672. * @param onError Called if there is an error when compiling a shader.
  84673. */
  84674. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  84675. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  84676. /**
  84677. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  84678. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  84679. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  84680. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  84681. * The gaps between physical kernels are compensated for in the weighting of the samples
  84682. * @param idealKernel Ideal blur kernel.
  84683. * @return Nearest best kernel.
  84684. */
  84685. protected _nearestBestKernel(idealKernel: number): number;
  84686. /**
  84687. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  84688. * @param x The point on the Gaussian distribution to sample.
  84689. * @return the value of the Gaussian function at x.
  84690. */
  84691. protected _gaussianWeight(x: number): number;
  84692. /**
  84693. * Generates a string that can be used as a floating point number in GLSL.
  84694. * @param x Value to print.
  84695. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  84696. * @return GLSL float string.
  84697. */
  84698. protected _glslFloat(x: number, decimalFigures?: number): string;
  84699. }
  84700. }
  84701. declare module BABYLON {
  84702. /**
  84703. * Mirror texture can be used to simulate the view from a mirror in a scene.
  84704. * It will dynamically be rendered every frame to adapt to the camera point of view.
  84705. * You can then easily use it as a reflectionTexture on a flat surface.
  84706. * In case the surface is not a plane, please consider relying on reflection probes.
  84707. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  84708. */
  84709. export class MirrorTexture extends RenderTargetTexture {
  84710. private scene;
  84711. /**
  84712. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  84713. * 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.
  84714. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  84715. */
  84716. mirrorPlane: Plane;
  84717. /**
  84718. * Define the blur ratio used to blur the reflection if needed.
  84719. */
  84720. blurRatio: number;
  84721. /**
  84722. * Define the adaptive blur kernel used to blur the reflection if needed.
  84723. * This will autocompute the closest best match for the `blurKernel`
  84724. */
  84725. adaptiveBlurKernel: number;
  84726. /**
  84727. * Define the blur kernel used to blur the reflection if needed.
  84728. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  84729. */
  84730. blurKernel: number;
  84731. /**
  84732. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  84733. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  84734. */
  84735. blurKernelX: number;
  84736. /**
  84737. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  84738. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  84739. */
  84740. blurKernelY: number;
  84741. private _autoComputeBlurKernel;
  84742. protected _onRatioRescale(): void;
  84743. private _updateGammaSpace;
  84744. private _imageProcessingConfigChangeObserver;
  84745. private _transformMatrix;
  84746. private _mirrorMatrix;
  84747. private _savedViewMatrix;
  84748. private _blurX;
  84749. private _blurY;
  84750. private _adaptiveBlurKernel;
  84751. private _blurKernelX;
  84752. private _blurKernelY;
  84753. private _blurRatio;
  84754. /**
  84755. * Instantiates a Mirror Texture.
  84756. * Mirror texture can be used to simulate the view from a mirror in a scene.
  84757. * It will dynamically be rendered every frame to adapt to the camera point of view.
  84758. * You can then easily use it as a reflectionTexture on a flat surface.
  84759. * In case the surface is not a plane, please consider relying on reflection probes.
  84760. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  84761. * @param name
  84762. * @param size
  84763. * @param scene
  84764. * @param generateMipMaps
  84765. * @param type
  84766. * @param samplingMode
  84767. * @param generateDepthBuffer
  84768. */
  84769. constructor(name: string, size: number | {
  84770. width: number;
  84771. height: number;
  84772. } | {
  84773. ratio: number;
  84774. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  84775. private _preparePostProcesses;
  84776. /**
  84777. * Clone the mirror texture.
  84778. * @returns the cloned texture
  84779. */
  84780. clone(): MirrorTexture;
  84781. /**
  84782. * Serialize the texture to a JSON representation you could use in Parse later on
  84783. * @returns the serialized JSON representation
  84784. */
  84785. serialize(): any;
  84786. /**
  84787. * Dispose the texture and release its associated resources.
  84788. */
  84789. dispose(): void;
  84790. }
  84791. }
  84792. declare module BABYLON {
  84793. /**
  84794. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  84795. * @see http://doc.babylonjs.com/babylon101/materials#texture
  84796. */
  84797. export class Texture extends BaseTexture {
  84798. /**
  84799. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  84800. */
  84801. static SerializeBuffers: boolean;
  84802. /** @hidden */
  84803. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  84804. /** @hidden */
  84805. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  84806. /** @hidden */
  84807. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  84808. /** nearest is mag = nearest and min = nearest and mip = linear */
  84809. static readonly NEAREST_SAMPLINGMODE: number;
  84810. /** nearest is mag = nearest and min = nearest and mip = linear */
  84811. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  84812. /** Bilinear is mag = linear and min = linear and mip = nearest */
  84813. static readonly BILINEAR_SAMPLINGMODE: number;
  84814. /** Bilinear is mag = linear and min = linear and mip = nearest */
  84815. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  84816. /** Trilinear is mag = linear and min = linear and mip = linear */
  84817. static readonly TRILINEAR_SAMPLINGMODE: number;
  84818. /** Trilinear is mag = linear and min = linear and mip = linear */
  84819. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  84820. /** mag = nearest and min = nearest and mip = nearest */
  84821. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  84822. /** mag = nearest and min = linear and mip = nearest */
  84823. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  84824. /** mag = nearest and min = linear and mip = linear */
  84825. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  84826. /** mag = nearest and min = linear and mip = none */
  84827. static readonly NEAREST_LINEAR: number;
  84828. /** mag = nearest and min = nearest and mip = none */
  84829. static readonly NEAREST_NEAREST: number;
  84830. /** mag = linear and min = nearest and mip = nearest */
  84831. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  84832. /** mag = linear and min = nearest and mip = linear */
  84833. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  84834. /** mag = linear and min = linear and mip = none */
  84835. static readonly LINEAR_LINEAR: number;
  84836. /** mag = linear and min = nearest and mip = none */
  84837. static readonly LINEAR_NEAREST: number;
  84838. /** Explicit coordinates mode */
  84839. static readonly EXPLICIT_MODE: number;
  84840. /** Spherical coordinates mode */
  84841. static readonly SPHERICAL_MODE: number;
  84842. /** Planar coordinates mode */
  84843. static readonly PLANAR_MODE: number;
  84844. /** Cubic coordinates mode */
  84845. static readonly CUBIC_MODE: number;
  84846. /** Projection coordinates mode */
  84847. static readonly PROJECTION_MODE: number;
  84848. /** Inverse Cubic coordinates mode */
  84849. static readonly SKYBOX_MODE: number;
  84850. /** Inverse Cubic coordinates mode */
  84851. static readonly INVCUBIC_MODE: number;
  84852. /** Equirectangular coordinates mode */
  84853. static readonly EQUIRECTANGULAR_MODE: number;
  84854. /** Equirectangular Fixed coordinates mode */
  84855. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  84856. /** Equirectangular Fixed Mirrored coordinates mode */
  84857. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  84858. /** Texture is not repeating outside of 0..1 UVs */
  84859. static readonly CLAMP_ADDRESSMODE: number;
  84860. /** Texture is repeating outside of 0..1 UVs */
  84861. static readonly WRAP_ADDRESSMODE: number;
  84862. /** Texture is repeating and mirrored */
  84863. static readonly MIRROR_ADDRESSMODE: number;
  84864. /**
  84865. * 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
  84866. */
  84867. static UseSerializedUrlIfAny: boolean;
  84868. /**
  84869. * Define the url of the texture.
  84870. */
  84871. url: Nullable<string>;
  84872. /**
  84873. * Define an offset on the texture to offset the u coordinates of the UVs
  84874. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  84875. */
  84876. uOffset: number;
  84877. /**
  84878. * Define an offset on the texture to offset the v coordinates of the UVs
  84879. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  84880. */
  84881. vOffset: number;
  84882. /**
  84883. * Define an offset on the texture to scale the u coordinates of the UVs
  84884. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  84885. */
  84886. uScale: number;
  84887. /**
  84888. * Define an offset on the texture to scale the v coordinates of the UVs
  84889. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  84890. */
  84891. vScale: number;
  84892. /**
  84893. * Define an offset on the texture to rotate around the u coordinates of the UVs
  84894. * @see http://doc.babylonjs.com/how_to/more_materials
  84895. */
  84896. uAng: number;
  84897. /**
  84898. * Define an offset on the texture to rotate around the v coordinates of the UVs
  84899. * @see http://doc.babylonjs.com/how_to/more_materials
  84900. */
  84901. vAng: number;
  84902. /**
  84903. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  84904. * @see http://doc.babylonjs.com/how_to/more_materials
  84905. */
  84906. wAng: number;
  84907. /**
  84908. * Defines the center of rotation (U)
  84909. */
  84910. uRotationCenter: number;
  84911. /**
  84912. * Defines the center of rotation (V)
  84913. */
  84914. vRotationCenter: number;
  84915. /**
  84916. * Defines the center of rotation (W)
  84917. */
  84918. wRotationCenter: number;
  84919. /**
  84920. * Are mip maps generated for this texture or not.
  84921. */
  84922. readonly noMipmap: boolean;
  84923. /**
  84924. * List of inspectable custom properties (used by the Inspector)
  84925. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84926. */
  84927. inspectableCustomProperties: Nullable<IInspectable[]>;
  84928. private _noMipmap;
  84929. /** @hidden */
  84930. _invertY: boolean;
  84931. private _rowGenerationMatrix;
  84932. private _cachedTextureMatrix;
  84933. private _projectionModeMatrix;
  84934. private _t0;
  84935. private _t1;
  84936. private _t2;
  84937. private _cachedUOffset;
  84938. private _cachedVOffset;
  84939. private _cachedUScale;
  84940. private _cachedVScale;
  84941. private _cachedUAng;
  84942. private _cachedVAng;
  84943. private _cachedWAng;
  84944. private _cachedProjectionMatrixId;
  84945. private _cachedCoordinatesMode;
  84946. /** @hidden */
  84947. protected _initialSamplingMode: number;
  84948. /** @hidden */
  84949. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  84950. private _deleteBuffer;
  84951. protected _format: Nullable<number>;
  84952. private _delayedOnLoad;
  84953. private _delayedOnError;
  84954. private _mimeType?;
  84955. /**
  84956. * Observable triggered once the texture has been loaded.
  84957. */
  84958. onLoadObservable: Observable<Texture>;
  84959. protected _isBlocking: boolean;
  84960. /**
  84961. * Is the texture preventing material to render while loading.
  84962. * If false, a default texture will be used instead of the loading one during the preparation step.
  84963. */
  84964. isBlocking: boolean;
  84965. /**
  84966. * Get the current sampling mode associated with the texture.
  84967. */
  84968. readonly samplingMode: number;
  84969. /**
  84970. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  84971. */
  84972. readonly invertY: boolean;
  84973. /**
  84974. * Instantiates a new texture.
  84975. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  84976. * @see http://doc.babylonjs.com/babylon101/materials#texture
  84977. * @param url defines the url of the picture to load as a texture
  84978. * @param scene defines the scene or engine the texture will belong to
  84979. * @param noMipmap defines if the texture will require mip maps or not
  84980. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  84981. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  84982. * @param onLoad defines a callback triggered when the texture has been loaded
  84983. * @param onError defines a callback triggered when an error occurred during the loading session
  84984. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  84985. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  84986. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  84987. * @param mimeType defines an optional mime type information
  84988. */
  84989. 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);
  84990. /**
  84991. * Update the url (and optional buffer) of this texture if url was null during construction.
  84992. * @param url the url of the texture
  84993. * @param buffer the buffer of the texture (defaults to null)
  84994. * @param onLoad callback called when the texture is loaded (defaults to null)
  84995. */
  84996. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  84997. /**
  84998. * Finish the loading sequence of a texture flagged as delayed load.
  84999. * @hidden
  85000. */
  85001. delayLoad(): void;
  85002. private _prepareRowForTextureGeneration;
  85003. /**
  85004. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  85005. * @returns the transform matrix of the texture.
  85006. */
  85007. getTextureMatrix(uBase?: number): Matrix;
  85008. /**
  85009. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  85010. * @returns The reflection texture transform
  85011. */
  85012. getReflectionTextureMatrix(): Matrix;
  85013. /**
  85014. * Clones the texture.
  85015. * @returns the cloned texture
  85016. */
  85017. clone(): Texture;
  85018. /**
  85019. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  85020. * @returns The JSON representation of the texture
  85021. */
  85022. serialize(): any;
  85023. /**
  85024. * Get the current class name of the texture useful for serialization or dynamic coding.
  85025. * @returns "Texture"
  85026. */
  85027. getClassName(): string;
  85028. /**
  85029. * Dispose the texture and release its associated resources.
  85030. */
  85031. dispose(): void;
  85032. /**
  85033. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  85034. * @param parsedTexture Define the JSON representation of the texture
  85035. * @param scene Define the scene the parsed texture should be instantiated in
  85036. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  85037. * @returns The parsed texture if successful
  85038. */
  85039. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  85040. /**
  85041. * Creates a texture from its base 64 representation.
  85042. * @param data Define the base64 payload without the data: prefix
  85043. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  85044. * @param scene Define the scene the texture should belong to
  85045. * @param noMipmap Forces the texture to not create mip map information if true
  85046. * @param invertY define if the texture needs to be inverted on the y axis during loading
  85047. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  85048. * @param onLoad define a callback triggered when the texture has been loaded
  85049. * @param onError define a callback triggered when an error occurred during the loading session
  85050. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  85051. * @returns the created texture
  85052. */
  85053. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  85054. /**
  85055. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  85056. * @param data Define the base64 payload without the data: prefix
  85057. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  85058. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  85059. * @param scene Define the scene the texture should belong to
  85060. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  85061. * @param noMipmap Forces the texture to not create mip map information if true
  85062. * @param invertY define if the texture needs to be inverted on the y axis during loading
  85063. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  85064. * @param onLoad define a callback triggered when the texture has been loaded
  85065. * @param onError define a callback triggered when an error occurred during the loading session
  85066. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  85067. * @returns the created texture
  85068. */
  85069. 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;
  85070. }
  85071. }
  85072. declare module BABYLON {
  85073. /**
  85074. * PostProcessManager is used to manage one or more post processes or post process pipelines
  85075. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  85076. */
  85077. export class PostProcessManager {
  85078. private _scene;
  85079. private _indexBuffer;
  85080. private _vertexBuffers;
  85081. /**
  85082. * Creates a new instance PostProcess
  85083. * @param scene The scene that the post process is associated with.
  85084. */
  85085. constructor(scene: Scene);
  85086. private _prepareBuffers;
  85087. private _buildIndexBuffer;
  85088. /**
  85089. * Rebuilds the vertex buffers of the manager.
  85090. * @hidden
  85091. */
  85092. _rebuild(): void;
  85093. /**
  85094. * Prepares a frame to be run through a post process.
  85095. * @param sourceTexture The input texture to the post procesess. (default: null)
  85096. * @param postProcesses An array of post processes to be run. (default: null)
  85097. * @returns True if the post processes were able to be run.
  85098. * @hidden
  85099. */
  85100. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  85101. /**
  85102. * Manually render a set of post processes to a texture.
  85103. * @param postProcesses An array of post processes to be run.
  85104. * @param targetTexture The target texture to render to.
  85105. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  85106. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  85107. * @param lodLevel defines which lod of the texture to render to
  85108. */
  85109. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  85110. /**
  85111. * Finalize the result of the output of the postprocesses.
  85112. * @param doNotPresent If true the result will not be displayed to the screen.
  85113. * @param targetTexture The target texture to render to.
  85114. * @param faceIndex The index of the face to bind the target texture to.
  85115. * @param postProcesses The array of post processes to render.
  85116. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  85117. * @hidden
  85118. */
  85119. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  85120. /**
  85121. * Disposes of the post process manager.
  85122. */
  85123. dispose(): void;
  85124. }
  85125. }
  85126. declare module BABYLON {
  85127. /** Interface used by value gradients (color, factor, ...) */
  85128. export interface IValueGradient {
  85129. /**
  85130. * Gets or sets the gradient value (between 0 and 1)
  85131. */
  85132. gradient: number;
  85133. }
  85134. /** Class used to store color4 gradient */
  85135. export class ColorGradient implements IValueGradient {
  85136. /**
  85137. * Gets or sets the gradient value (between 0 and 1)
  85138. */
  85139. gradient: number;
  85140. /**
  85141. * Gets or sets first associated color
  85142. */
  85143. color1: Color4;
  85144. /**
  85145. * Gets or sets second associated color
  85146. */
  85147. color2?: Color4;
  85148. /**
  85149. * Will get a color picked randomly between color1 and color2.
  85150. * If color2 is undefined then color1 will be used
  85151. * @param result defines the target Color4 to store the result in
  85152. */
  85153. getColorToRef(result: Color4): void;
  85154. }
  85155. /** Class used to store color 3 gradient */
  85156. export class Color3Gradient implements IValueGradient {
  85157. /**
  85158. * Gets or sets the gradient value (between 0 and 1)
  85159. */
  85160. gradient: number;
  85161. /**
  85162. * Gets or sets the associated color
  85163. */
  85164. color: Color3;
  85165. }
  85166. /** Class used to store factor gradient */
  85167. export class FactorGradient implements IValueGradient {
  85168. /**
  85169. * Gets or sets the gradient value (between 0 and 1)
  85170. */
  85171. gradient: number;
  85172. /**
  85173. * Gets or sets first associated factor
  85174. */
  85175. factor1: number;
  85176. /**
  85177. * Gets or sets second associated factor
  85178. */
  85179. factor2?: number;
  85180. /**
  85181. * Will get a number picked randomly between factor1 and factor2.
  85182. * If factor2 is undefined then factor1 will be used
  85183. * @returns the picked number
  85184. */
  85185. getFactor(): number;
  85186. }
  85187. /**
  85188. * Helper used to simplify some generic gradient tasks
  85189. */
  85190. export class GradientHelper {
  85191. /**
  85192. * Gets the current gradient from an array of IValueGradient
  85193. * @param ratio defines the current ratio to get
  85194. * @param gradients defines the array of IValueGradient
  85195. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  85196. */
  85197. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  85198. }
  85199. }
  85200. declare module BABYLON {
  85201. interface ThinEngine {
  85202. /**
  85203. * Creates a dynamic texture
  85204. * @param width defines the width of the texture
  85205. * @param height defines the height of the texture
  85206. * @param generateMipMaps defines if the engine should generate the mip levels
  85207. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  85208. * @returns the dynamic texture inside an InternalTexture
  85209. */
  85210. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  85211. /**
  85212. * Update the content of a dynamic texture
  85213. * @param texture defines the texture to update
  85214. * @param canvas defines the canvas containing the source
  85215. * @param invertY defines if data must be stored with Y axis inverted
  85216. * @param premulAlpha defines if alpha is stored as premultiplied
  85217. * @param format defines the format of the data
  85218. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  85219. */
  85220. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  85221. }
  85222. }
  85223. declare module BABYLON {
  85224. /**
  85225. * Helper class used to generate a canvas to manipulate images
  85226. */
  85227. export class CanvasGenerator {
  85228. /**
  85229. * Create a new canvas (or offscreen canvas depending on the context)
  85230. * @param width defines the expected width
  85231. * @param height defines the expected height
  85232. * @return a new canvas or offscreen canvas
  85233. */
  85234. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  85235. }
  85236. }
  85237. declare module BABYLON {
  85238. /**
  85239. * A class extending Texture allowing drawing on a texture
  85240. * @see http://doc.babylonjs.com/how_to/dynamictexture
  85241. */
  85242. export class DynamicTexture extends Texture {
  85243. private _generateMipMaps;
  85244. private _canvas;
  85245. private _context;
  85246. private _engine;
  85247. /**
  85248. * Creates a DynamicTexture
  85249. * @param name defines the name of the texture
  85250. * @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
  85251. * @param scene defines the scene where you want the texture
  85252. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  85253. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  85254. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  85255. */
  85256. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  85257. /**
  85258. * Get the current class name of the texture useful for serialization or dynamic coding.
  85259. * @returns "DynamicTexture"
  85260. */
  85261. getClassName(): string;
  85262. /**
  85263. * Gets the current state of canRescale
  85264. */
  85265. readonly canRescale: boolean;
  85266. private _recreate;
  85267. /**
  85268. * Scales the texture
  85269. * @param ratio the scale factor to apply to both width and height
  85270. */
  85271. scale(ratio: number): void;
  85272. /**
  85273. * Resizes the texture
  85274. * @param width the new width
  85275. * @param height the new height
  85276. */
  85277. scaleTo(width: number, height: number): void;
  85278. /**
  85279. * Gets the context of the canvas used by the texture
  85280. * @returns the canvas context of the dynamic texture
  85281. */
  85282. getContext(): CanvasRenderingContext2D;
  85283. /**
  85284. * Clears the texture
  85285. */
  85286. clear(): void;
  85287. /**
  85288. * Updates the texture
  85289. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  85290. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  85291. */
  85292. update(invertY?: boolean, premulAlpha?: boolean): void;
  85293. /**
  85294. * Draws text onto the texture
  85295. * @param text defines the text to be drawn
  85296. * @param x defines the placement of the text from the left
  85297. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  85298. * @param font defines the font to be used with font-style, font-size, font-name
  85299. * @param color defines the color used for the text
  85300. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  85301. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  85302. * @param update defines whether texture is immediately update (default is true)
  85303. */
  85304. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  85305. /**
  85306. * Clones the texture
  85307. * @returns the clone of the texture.
  85308. */
  85309. clone(): DynamicTexture;
  85310. /**
  85311. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  85312. * @returns a serialized dynamic texture object
  85313. */
  85314. serialize(): any;
  85315. /** @hidden */
  85316. _rebuild(): void;
  85317. }
  85318. }
  85319. declare module BABYLON {
  85320. interface AbstractScene {
  85321. /**
  85322. * The list of procedural textures added to the scene
  85323. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  85324. */
  85325. proceduralTextures: Array<ProceduralTexture>;
  85326. }
  85327. /**
  85328. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  85329. * in a given scene.
  85330. */
  85331. export class ProceduralTextureSceneComponent implements ISceneComponent {
  85332. /**
  85333. * The component name helpfull to identify the component in the list of scene components.
  85334. */
  85335. readonly name: string;
  85336. /**
  85337. * The scene the component belongs to.
  85338. */
  85339. scene: Scene;
  85340. /**
  85341. * Creates a new instance of the component for the given scene
  85342. * @param scene Defines the scene to register the component in
  85343. */
  85344. constructor(scene: Scene);
  85345. /**
  85346. * Registers the component in a given scene
  85347. */
  85348. register(): void;
  85349. /**
  85350. * Rebuilds the elements related to this component in case of
  85351. * context lost for instance.
  85352. */
  85353. rebuild(): void;
  85354. /**
  85355. * Disposes the component and the associated ressources.
  85356. */
  85357. dispose(): void;
  85358. private _beforeClear;
  85359. }
  85360. }
  85361. declare module BABYLON {
  85362. interface ThinEngine {
  85363. /**
  85364. * Creates a new render target cube texture
  85365. * @param size defines the size of the texture
  85366. * @param options defines the options used to create the texture
  85367. * @returns a new render target cube texture stored in an InternalTexture
  85368. */
  85369. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  85370. }
  85371. }
  85372. declare module BABYLON {
  85373. /** @hidden */
  85374. export var proceduralVertexShader: {
  85375. name: string;
  85376. shader: string;
  85377. };
  85378. }
  85379. declare module BABYLON {
  85380. /**
  85381. * 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.
  85382. * This is the base class of any Procedural texture and contains most of the shareable code.
  85383. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  85384. */
  85385. export class ProceduralTexture extends Texture {
  85386. isCube: boolean;
  85387. /**
  85388. * Define if the texture is enabled or not (disabled texture will not render)
  85389. */
  85390. isEnabled: boolean;
  85391. /**
  85392. * Define if the texture must be cleared before rendering (default is true)
  85393. */
  85394. autoClear: boolean;
  85395. /**
  85396. * Callback called when the texture is generated
  85397. */
  85398. onGenerated: () => void;
  85399. /**
  85400. * Event raised when the texture is generated
  85401. */
  85402. onGeneratedObservable: Observable<ProceduralTexture>;
  85403. /** @hidden */
  85404. _generateMipMaps: boolean;
  85405. /** @hidden **/
  85406. _effect: Effect;
  85407. /** @hidden */
  85408. _textures: {
  85409. [key: string]: Texture;
  85410. };
  85411. private _size;
  85412. private _currentRefreshId;
  85413. private _refreshRate;
  85414. private _vertexBuffers;
  85415. private _indexBuffer;
  85416. private _uniforms;
  85417. private _samplers;
  85418. private _fragment;
  85419. private _floats;
  85420. private _ints;
  85421. private _floatsArrays;
  85422. private _colors3;
  85423. private _colors4;
  85424. private _vectors2;
  85425. private _vectors3;
  85426. private _matrices;
  85427. private _fallbackTexture;
  85428. private _fallbackTextureUsed;
  85429. private _engine;
  85430. private _cachedDefines;
  85431. private _contentUpdateId;
  85432. private _contentData;
  85433. /**
  85434. * Instantiates a new procedural texture.
  85435. * 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.
  85436. * This is the base class of any Procedural texture and contains most of the shareable code.
  85437. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  85438. * @param name Define the name of the texture
  85439. * @param size Define the size of the texture to create
  85440. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  85441. * @param scene Define the scene the texture belongs to
  85442. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  85443. * @param generateMipMaps Define if the texture should creates mip maps or not
  85444. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  85445. */
  85446. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  85447. /**
  85448. * The effect that is created when initializing the post process.
  85449. * @returns The created effect corresponding the the postprocess.
  85450. */
  85451. getEffect(): Effect;
  85452. /**
  85453. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  85454. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  85455. */
  85456. getContent(): Nullable<ArrayBufferView>;
  85457. private _createIndexBuffer;
  85458. /** @hidden */
  85459. _rebuild(): void;
  85460. /**
  85461. * Resets the texture in order to recreate its associated resources.
  85462. * This can be called in case of context loss
  85463. */
  85464. reset(): void;
  85465. protected _getDefines(): string;
  85466. /**
  85467. * Is the texture ready to be used ? (rendered at least once)
  85468. * @returns true if ready, otherwise, false.
  85469. */
  85470. isReady(): boolean;
  85471. /**
  85472. * Resets the refresh counter of the texture and start bak from scratch.
  85473. * Could be useful to regenerate the texture if it is setup to render only once.
  85474. */
  85475. resetRefreshCounter(): void;
  85476. /**
  85477. * Set the fragment shader to use in order to render the texture.
  85478. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  85479. */
  85480. setFragment(fragment: any): void;
  85481. /**
  85482. * Define the refresh rate of the texture or the rendering frequency.
  85483. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  85484. */
  85485. refreshRate: number;
  85486. /** @hidden */
  85487. _shouldRender(): boolean;
  85488. /**
  85489. * Get the size the texture is rendering at.
  85490. * @returns the size (texture is always squared)
  85491. */
  85492. getRenderSize(): number;
  85493. /**
  85494. * Resize the texture to new value.
  85495. * @param size Define the new size the texture should have
  85496. * @param generateMipMaps Define whether the new texture should create mip maps
  85497. */
  85498. resize(size: number, generateMipMaps: boolean): void;
  85499. private _checkUniform;
  85500. /**
  85501. * Set a texture in the shader program used to render.
  85502. * @param name Define the name of the uniform samplers as defined in the shader
  85503. * @param texture Define the texture to bind to this sampler
  85504. * @return the texture itself allowing "fluent" like uniform updates
  85505. */
  85506. setTexture(name: string, texture: Texture): ProceduralTexture;
  85507. /**
  85508. * Set a float in the shader.
  85509. * @param name Define the name of the uniform as defined in the shader
  85510. * @param value Define the value to give to the uniform
  85511. * @return the texture itself allowing "fluent" like uniform updates
  85512. */
  85513. setFloat(name: string, value: number): ProceduralTexture;
  85514. /**
  85515. * Set a int in the shader.
  85516. * @param name Define the name of the uniform as defined in the shader
  85517. * @param value Define the value to give to the uniform
  85518. * @return the texture itself allowing "fluent" like uniform updates
  85519. */
  85520. setInt(name: string, value: number): ProceduralTexture;
  85521. /**
  85522. * Set an array of floats in the shader.
  85523. * @param name Define the name of the uniform as defined in the shader
  85524. * @param value Define the value to give to the uniform
  85525. * @return the texture itself allowing "fluent" like uniform updates
  85526. */
  85527. setFloats(name: string, value: number[]): ProceduralTexture;
  85528. /**
  85529. * Set a vec3 in the shader from a Color3.
  85530. * @param name Define the name of the uniform as defined in the shader
  85531. * @param value Define the value to give to the uniform
  85532. * @return the texture itself allowing "fluent" like uniform updates
  85533. */
  85534. setColor3(name: string, value: Color3): ProceduralTexture;
  85535. /**
  85536. * Set a vec4 in the shader from a Color4.
  85537. * @param name Define the name of the uniform as defined in the shader
  85538. * @param value Define the value to give to the uniform
  85539. * @return the texture itself allowing "fluent" like uniform updates
  85540. */
  85541. setColor4(name: string, value: Color4): ProceduralTexture;
  85542. /**
  85543. * Set a vec2 in the shader from a Vector2.
  85544. * @param name Define the name of the uniform as defined in the shader
  85545. * @param value Define the value to give to the uniform
  85546. * @return the texture itself allowing "fluent" like uniform updates
  85547. */
  85548. setVector2(name: string, value: Vector2): ProceduralTexture;
  85549. /**
  85550. * Set a vec3 in the shader from a Vector3.
  85551. * @param name Define the name of the uniform as defined in the shader
  85552. * @param value Define the value to give to the uniform
  85553. * @return the texture itself allowing "fluent" like uniform updates
  85554. */
  85555. setVector3(name: string, value: Vector3): ProceduralTexture;
  85556. /**
  85557. * Set a mat4 in the shader from a MAtrix.
  85558. * @param name Define the name of the uniform as defined in the shader
  85559. * @param value Define the value to give to the uniform
  85560. * @return the texture itself allowing "fluent" like uniform updates
  85561. */
  85562. setMatrix(name: string, value: Matrix): ProceduralTexture;
  85563. /**
  85564. * Render the texture to its associated render target.
  85565. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  85566. */
  85567. render(useCameraPostProcess?: boolean): void;
  85568. /**
  85569. * Clone the texture.
  85570. * @returns the cloned texture
  85571. */
  85572. clone(): ProceduralTexture;
  85573. /**
  85574. * Dispose the texture and release its asoociated resources.
  85575. */
  85576. dispose(): void;
  85577. }
  85578. }
  85579. declare module BABYLON {
  85580. /**
  85581. * This represents the base class for particle system in Babylon.
  85582. * 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.
  85583. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  85584. * @example https://doc.babylonjs.com/babylon101/particles
  85585. */
  85586. export class BaseParticleSystem {
  85587. /**
  85588. * Source color is added to the destination color without alpha affecting the result
  85589. */
  85590. static BLENDMODE_ONEONE: number;
  85591. /**
  85592. * Blend current color and particle color using particle’s alpha
  85593. */
  85594. static BLENDMODE_STANDARD: number;
  85595. /**
  85596. * Add current color and particle color multiplied by particle’s alpha
  85597. */
  85598. static BLENDMODE_ADD: number;
  85599. /**
  85600. * Multiply current color with particle color
  85601. */
  85602. static BLENDMODE_MULTIPLY: number;
  85603. /**
  85604. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  85605. */
  85606. static BLENDMODE_MULTIPLYADD: number;
  85607. /**
  85608. * List of animations used by the particle system.
  85609. */
  85610. animations: Animation[];
  85611. /**
  85612. * The id of the Particle system.
  85613. */
  85614. id: string;
  85615. /**
  85616. * The friendly name of the Particle system.
  85617. */
  85618. name: string;
  85619. /**
  85620. * The rendering group used by the Particle system to chose when to render.
  85621. */
  85622. renderingGroupId: number;
  85623. /**
  85624. * The emitter represents the Mesh or position we are attaching the particle system to.
  85625. */
  85626. emitter: Nullable<AbstractMesh | Vector3>;
  85627. /**
  85628. * The maximum number of particles to emit per frame
  85629. */
  85630. emitRate: number;
  85631. /**
  85632. * If you want to launch only a few particles at once, that can be done, as well.
  85633. */
  85634. manualEmitCount: number;
  85635. /**
  85636. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  85637. */
  85638. updateSpeed: number;
  85639. /**
  85640. * The amount of time the particle system is running (depends of the overall update speed).
  85641. */
  85642. targetStopDuration: number;
  85643. /**
  85644. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  85645. */
  85646. disposeOnStop: boolean;
  85647. /**
  85648. * Minimum power of emitting particles.
  85649. */
  85650. minEmitPower: number;
  85651. /**
  85652. * Maximum power of emitting particles.
  85653. */
  85654. maxEmitPower: number;
  85655. /**
  85656. * Minimum life time of emitting particles.
  85657. */
  85658. minLifeTime: number;
  85659. /**
  85660. * Maximum life time of emitting particles.
  85661. */
  85662. maxLifeTime: number;
  85663. /**
  85664. * Minimum Size of emitting particles.
  85665. */
  85666. minSize: number;
  85667. /**
  85668. * Maximum Size of emitting particles.
  85669. */
  85670. maxSize: number;
  85671. /**
  85672. * Minimum scale of emitting particles on X axis.
  85673. */
  85674. minScaleX: number;
  85675. /**
  85676. * Maximum scale of emitting particles on X axis.
  85677. */
  85678. maxScaleX: number;
  85679. /**
  85680. * Minimum scale of emitting particles on Y axis.
  85681. */
  85682. minScaleY: number;
  85683. /**
  85684. * Maximum scale of emitting particles on Y axis.
  85685. */
  85686. maxScaleY: number;
  85687. /**
  85688. * Gets or sets the minimal initial rotation in radians.
  85689. */
  85690. minInitialRotation: number;
  85691. /**
  85692. * Gets or sets the maximal initial rotation in radians.
  85693. */
  85694. maxInitialRotation: number;
  85695. /**
  85696. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  85697. */
  85698. minAngularSpeed: number;
  85699. /**
  85700. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  85701. */
  85702. maxAngularSpeed: number;
  85703. /**
  85704. * The texture used to render each particle. (this can be a spritesheet)
  85705. */
  85706. particleTexture: Nullable<Texture>;
  85707. /**
  85708. * The layer mask we are rendering the particles through.
  85709. */
  85710. layerMask: number;
  85711. /**
  85712. * This can help using your own shader to render the particle system.
  85713. * The according effect will be created
  85714. */
  85715. customShader: any;
  85716. /**
  85717. * By default particle system starts as soon as they are created. This prevents the
  85718. * automatic start to happen and let you decide when to start emitting particles.
  85719. */
  85720. preventAutoStart: boolean;
  85721. private _noiseTexture;
  85722. /**
  85723. * Gets or sets a texture used to add random noise to particle positions
  85724. */
  85725. noiseTexture: Nullable<ProceduralTexture>;
  85726. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  85727. noiseStrength: Vector3;
  85728. /**
  85729. * Callback triggered when the particle animation is ending.
  85730. */
  85731. onAnimationEnd: Nullable<() => void>;
  85732. /**
  85733. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  85734. */
  85735. blendMode: number;
  85736. /**
  85737. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  85738. * to override the particles.
  85739. */
  85740. forceDepthWrite: boolean;
  85741. /** 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 */
  85742. preWarmCycles: number;
  85743. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  85744. preWarmStepOffset: number;
  85745. /**
  85746. * 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)
  85747. */
  85748. spriteCellChangeSpeed: number;
  85749. /**
  85750. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  85751. */
  85752. startSpriteCellID: number;
  85753. /**
  85754. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  85755. */
  85756. endSpriteCellID: number;
  85757. /**
  85758. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  85759. */
  85760. spriteCellWidth: number;
  85761. /**
  85762. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  85763. */
  85764. spriteCellHeight: number;
  85765. /**
  85766. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  85767. */
  85768. spriteRandomStartCell: boolean;
  85769. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  85770. translationPivot: Vector2;
  85771. /** @hidden */
  85772. protected _isAnimationSheetEnabled: boolean;
  85773. /**
  85774. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  85775. */
  85776. beginAnimationOnStart: boolean;
  85777. /**
  85778. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  85779. */
  85780. beginAnimationFrom: number;
  85781. /**
  85782. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  85783. */
  85784. beginAnimationTo: number;
  85785. /**
  85786. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  85787. */
  85788. beginAnimationLoop: boolean;
  85789. /**
  85790. * Gets or sets a world offset applied to all particles
  85791. */
  85792. worldOffset: Vector3;
  85793. /**
  85794. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  85795. */
  85796. isAnimationSheetEnabled: boolean;
  85797. /**
  85798. * Get hosting scene
  85799. * @returns the scene
  85800. */
  85801. getScene(): Scene;
  85802. /**
  85803. * You can use gravity if you want to give an orientation to your particles.
  85804. */
  85805. gravity: Vector3;
  85806. protected _colorGradients: Nullable<Array<ColorGradient>>;
  85807. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  85808. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  85809. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  85810. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  85811. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  85812. protected _dragGradients: Nullable<Array<FactorGradient>>;
  85813. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  85814. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  85815. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  85816. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  85817. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  85818. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  85819. /**
  85820. * Defines the delay in milliseconds before starting the system (0 by default)
  85821. */
  85822. startDelay: number;
  85823. /**
  85824. * Gets the current list of drag gradients.
  85825. * You must use addDragGradient and removeDragGradient to udpate this list
  85826. * @returns the list of drag gradients
  85827. */
  85828. getDragGradients(): Nullable<Array<FactorGradient>>;
  85829. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  85830. limitVelocityDamping: number;
  85831. /**
  85832. * Gets the current list of limit velocity gradients.
  85833. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  85834. * @returns the list of limit velocity gradients
  85835. */
  85836. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  85837. /**
  85838. * Gets the current list of color gradients.
  85839. * You must use addColorGradient and removeColorGradient to udpate this list
  85840. * @returns the list of color gradients
  85841. */
  85842. getColorGradients(): Nullable<Array<ColorGradient>>;
  85843. /**
  85844. * Gets the current list of size gradients.
  85845. * You must use addSizeGradient and removeSizeGradient to udpate this list
  85846. * @returns the list of size gradients
  85847. */
  85848. getSizeGradients(): Nullable<Array<FactorGradient>>;
  85849. /**
  85850. * Gets the current list of color remap gradients.
  85851. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  85852. * @returns the list of color remap gradients
  85853. */
  85854. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  85855. /**
  85856. * Gets the current list of alpha remap gradients.
  85857. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  85858. * @returns the list of alpha remap gradients
  85859. */
  85860. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  85861. /**
  85862. * Gets the current list of life time gradients.
  85863. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  85864. * @returns the list of life time gradients
  85865. */
  85866. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  85867. /**
  85868. * Gets the current list of angular speed gradients.
  85869. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  85870. * @returns the list of angular speed gradients
  85871. */
  85872. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  85873. /**
  85874. * Gets the current list of velocity gradients.
  85875. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  85876. * @returns the list of velocity gradients
  85877. */
  85878. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  85879. /**
  85880. * Gets the current list of start size gradients.
  85881. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  85882. * @returns the list of start size gradients
  85883. */
  85884. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  85885. /**
  85886. * Gets the current list of emit rate gradients.
  85887. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  85888. * @returns the list of emit rate gradients
  85889. */
  85890. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  85891. /**
  85892. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85893. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85894. */
  85895. direction1: Vector3;
  85896. /**
  85897. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85898. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85899. */
  85900. direction2: Vector3;
  85901. /**
  85902. * 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.
  85903. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85904. */
  85905. minEmitBox: Vector3;
  85906. /**
  85907. * 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.
  85908. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85909. */
  85910. maxEmitBox: Vector3;
  85911. /**
  85912. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  85913. */
  85914. color1: Color4;
  85915. /**
  85916. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  85917. */
  85918. color2: Color4;
  85919. /**
  85920. * Color the particle will have at the end of its lifetime
  85921. */
  85922. colorDead: Color4;
  85923. /**
  85924. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  85925. */
  85926. textureMask: Color4;
  85927. /**
  85928. * The particle emitter type defines the emitter used by the particle system.
  85929. * It can be for example box, sphere, or cone...
  85930. */
  85931. particleEmitterType: IParticleEmitterType;
  85932. /** @hidden */
  85933. _isSubEmitter: boolean;
  85934. /**
  85935. * Gets or sets the billboard mode to use when isBillboardBased = true.
  85936. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  85937. */
  85938. billboardMode: number;
  85939. protected _isBillboardBased: boolean;
  85940. /**
  85941. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  85942. */
  85943. isBillboardBased: boolean;
  85944. /**
  85945. * The scene the particle system belongs to.
  85946. */
  85947. protected _scene: Scene;
  85948. /**
  85949. * Local cache of defines for image processing.
  85950. */
  85951. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  85952. /**
  85953. * Default configuration related to image processing available in the standard Material.
  85954. */
  85955. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  85956. /**
  85957. * Gets the image processing configuration used either in this material.
  85958. */
  85959. /**
  85960. * Sets the Default image processing configuration used either in the this material.
  85961. *
  85962. * If sets to null, the scene one is in use.
  85963. */
  85964. imageProcessingConfiguration: ImageProcessingConfiguration;
  85965. /**
  85966. * Attaches a new image processing configuration to the Standard Material.
  85967. * @param configuration
  85968. */
  85969. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  85970. /** @hidden */
  85971. protected _reset(): void;
  85972. /** @hidden */
  85973. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  85974. /**
  85975. * Instantiates a particle system.
  85976. * 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.
  85977. * @param name The name of the particle system
  85978. */
  85979. constructor(name: string);
  85980. /**
  85981. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  85982. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85983. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85984. * @returns the emitter
  85985. */
  85986. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  85987. /**
  85988. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  85989. * @param radius The radius of the hemisphere to emit from
  85990. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85991. * @returns the emitter
  85992. */
  85993. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  85994. /**
  85995. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  85996. * @param radius The radius of the sphere to emit from
  85997. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85998. * @returns the emitter
  85999. */
  86000. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  86001. /**
  86002. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  86003. * @param radius The radius of the sphere to emit from
  86004. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  86005. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  86006. * @returns the emitter
  86007. */
  86008. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  86009. /**
  86010. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  86011. * @param radius The radius of the emission cylinder
  86012. * @param height The height of the emission cylinder
  86013. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  86014. * @param directionRandomizer How much to randomize the particle direction [0-1]
  86015. * @returns the emitter
  86016. */
  86017. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  86018. /**
  86019. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  86020. * @param radius The radius of the cylinder to emit from
  86021. * @param height The height of the emission cylinder
  86022. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86023. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  86024. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  86025. * @returns the emitter
  86026. */
  86027. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  86028. /**
  86029. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  86030. * @param radius The radius of the cone to emit from
  86031. * @param angle The base angle of the cone
  86032. * @returns the emitter
  86033. */
  86034. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  86035. /**
  86036. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  86037. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86038. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86039. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86040. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86041. * @returns the emitter
  86042. */
  86043. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  86044. }
  86045. }
  86046. declare module BABYLON {
  86047. /**
  86048. * Type of sub emitter
  86049. */
  86050. export enum SubEmitterType {
  86051. /**
  86052. * Attached to the particle over it's lifetime
  86053. */
  86054. ATTACHED = 0,
  86055. /**
  86056. * Created when the particle dies
  86057. */
  86058. END = 1
  86059. }
  86060. /**
  86061. * Sub emitter class used to emit particles from an existing particle
  86062. */
  86063. export class SubEmitter {
  86064. /**
  86065. * the particle system to be used by the sub emitter
  86066. */
  86067. particleSystem: ParticleSystem;
  86068. /**
  86069. * Type of the submitter (Default: END)
  86070. */
  86071. type: SubEmitterType;
  86072. /**
  86073. * 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)
  86074. * Note: This only is supported when using an emitter of type Mesh
  86075. */
  86076. inheritDirection: boolean;
  86077. /**
  86078. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  86079. */
  86080. inheritedVelocityAmount: number;
  86081. /**
  86082. * Creates a sub emitter
  86083. * @param particleSystem the particle system to be used by the sub emitter
  86084. */
  86085. constructor(
  86086. /**
  86087. * the particle system to be used by the sub emitter
  86088. */
  86089. particleSystem: ParticleSystem);
  86090. /**
  86091. * Clones the sub emitter
  86092. * @returns the cloned sub emitter
  86093. */
  86094. clone(): SubEmitter;
  86095. /**
  86096. * Serialize current object to a JSON object
  86097. * @returns the serialized object
  86098. */
  86099. serialize(): any;
  86100. /** @hidden */
  86101. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  86102. /**
  86103. * Creates a new SubEmitter from a serialized JSON version
  86104. * @param serializationObject defines the JSON object to read from
  86105. * @param scene defines the hosting scene
  86106. * @param rootUrl defines the rootUrl for data loading
  86107. * @returns a new SubEmitter
  86108. */
  86109. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  86110. /** Release associated resources */
  86111. dispose(): void;
  86112. }
  86113. }
  86114. declare module BABYLON {
  86115. /** @hidden */
  86116. export var clipPlaneFragmentDeclaration: {
  86117. name: string;
  86118. shader: string;
  86119. };
  86120. }
  86121. declare module BABYLON {
  86122. /** @hidden */
  86123. export var imageProcessingDeclaration: {
  86124. name: string;
  86125. shader: string;
  86126. };
  86127. }
  86128. declare module BABYLON {
  86129. /** @hidden */
  86130. export var imageProcessingFunctions: {
  86131. name: string;
  86132. shader: string;
  86133. };
  86134. }
  86135. declare module BABYLON {
  86136. /** @hidden */
  86137. export var clipPlaneFragment: {
  86138. name: string;
  86139. shader: string;
  86140. };
  86141. }
  86142. declare module BABYLON {
  86143. /** @hidden */
  86144. export var particlesPixelShader: {
  86145. name: string;
  86146. shader: string;
  86147. };
  86148. }
  86149. declare module BABYLON {
  86150. /** @hidden */
  86151. export var clipPlaneVertexDeclaration: {
  86152. name: string;
  86153. shader: string;
  86154. };
  86155. }
  86156. declare module BABYLON {
  86157. /** @hidden */
  86158. export var clipPlaneVertex: {
  86159. name: string;
  86160. shader: string;
  86161. };
  86162. }
  86163. declare module BABYLON {
  86164. /** @hidden */
  86165. export var particlesVertexShader: {
  86166. name: string;
  86167. shader: string;
  86168. };
  86169. }
  86170. declare module BABYLON {
  86171. /**
  86172. * This represents a particle system in Babylon.
  86173. * 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.
  86174. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  86175. * @example https://doc.babylonjs.com/babylon101/particles
  86176. */
  86177. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  86178. /**
  86179. * Billboard mode will only apply to Y axis
  86180. */
  86181. static readonly BILLBOARDMODE_Y: number;
  86182. /**
  86183. * Billboard mode will apply to all axes
  86184. */
  86185. static readonly BILLBOARDMODE_ALL: number;
  86186. /**
  86187. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  86188. */
  86189. static readonly BILLBOARDMODE_STRETCHED: number;
  86190. /**
  86191. * This function can be defined to provide custom update for active particles.
  86192. * This function will be called instead of regular update (age, position, color, etc.).
  86193. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  86194. */
  86195. updateFunction: (particles: Particle[]) => void;
  86196. private _emitterWorldMatrix;
  86197. /**
  86198. * This function can be defined to specify initial direction for every new particle.
  86199. * It by default use the emitterType defined function
  86200. */
  86201. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  86202. /**
  86203. * This function can be defined to specify initial position for every new particle.
  86204. * It by default use the emitterType defined function
  86205. */
  86206. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  86207. /**
  86208. * @hidden
  86209. */
  86210. _inheritedVelocityOffset: Vector3;
  86211. /**
  86212. * An event triggered when the system is disposed
  86213. */
  86214. onDisposeObservable: Observable<ParticleSystem>;
  86215. private _onDisposeObserver;
  86216. /**
  86217. * Sets a callback that will be triggered when the system is disposed
  86218. */
  86219. onDispose: () => void;
  86220. private _particles;
  86221. private _epsilon;
  86222. private _capacity;
  86223. private _stockParticles;
  86224. private _newPartsExcess;
  86225. private _vertexData;
  86226. private _vertexBuffer;
  86227. private _vertexBuffers;
  86228. private _spriteBuffer;
  86229. private _indexBuffer;
  86230. private _effect;
  86231. private _customEffect;
  86232. private _cachedDefines;
  86233. private _scaledColorStep;
  86234. private _colorDiff;
  86235. private _scaledDirection;
  86236. private _scaledGravity;
  86237. private _currentRenderId;
  86238. private _alive;
  86239. private _useInstancing;
  86240. private _started;
  86241. private _stopped;
  86242. private _actualFrame;
  86243. private _scaledUpdateSpeed;
  86244. private _vertexBufferSize;
  86245. /** @hidden */
  86246. _currentEmitRateGradient: Nullable<FactorGradient>;
  86247. /** @hidden */
  86248. _currentEmitRate1: number;
  86249. /** @hidden */
  86250. _currentEmitRate2: number;
  86251. /** @hidden */
  86252. _currentStartSizeGradient: Nullable<FactorGradient>;
  86253. /** @hidden */
  86254. _currentStartSize1: number;
  86255. /** @hidden */
  86256. _currentStartSize2: number;
  86257. private readonly _rawTextureWidth;
  86258. private _rampGradientsTexture;
  86259. private _useRampGradients;
  86260. /** Gets or sets a boolean indicating that ramp gradients must be used
  86261. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  86262. */
  86263. useRampGradients: boolean;
  86264. /**
  86265. * 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.
  86266. * 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: [])
  86267. */
  86268. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  86269. private _subEmitters;
  86270. /**
  86271. * @hidden
  86272. * If the particle systems emitter should be disposed when the particle system is disposed
  86273. */
  86274. _disposeEmitterOnDispose: boolean;
  86275. /**
  86276. * The current active Sub-systems, this property is used by the root particle system only.
  86277. */
  86278. activeSubSystems: Array<ParticleSystem>;
  86279. private _rootParticleSystem;
  86280. /**
  86281. * Gets the current list of active particles
  86282. */
  86283. readonly particles: Particle[];
  86284. /**
  86285. * Returns the string "ParticleSystem"
  86286. * @returns a string containing the class name
  86287. */
  86288. getClassName(): string;
  86289. /**
  86290. * Instantiates a particle system.
  86291. * 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.
  86292. * @param name The name of the particle system
  86293. * @param capacity The max number of particles alive at the same time
  86294. * @param scene The scene the particle system belongs to
  86295. * @param customEffect a custom effect used to change the way particles are rendered by default
  86296. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  86297. * @param epsilon Offset used to render the particles
  86298. */
  86299. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  86300. private _addFactorGradient;
  86301. private _removeFactorGradient;
  86302. /**
  86303. * Adds a new life time gradient
  86304. * @param gradient defines the gradient to use (between 0 and 1)
  86305. * @param factor defines the life time factor to affect to the specified gradient
  86306. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86307. * @returns the current particle system
  86308. */
  86309. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86310. /**
  86311. * Remove a specific life time gradient
  86312. * @param gradient defines the gradient to remove
  86313. * @returns the current particle system
  86314. */
  86315. removeLifeTimeGradient(gradient: number): IParticleSystem;
  86316. /**
  86317. * Adds a new size gradient
  86318. * @param gradient defines the gradient to use (between 0 and 1)
  86319. * @param factor defines the size factor to affect to the specified gradient
  86320. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86321. * @returns the current particle system
  86322. */
  86323. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86324. /**
  86325. * Remove a specific size gradient
  86326. * @param gradient defines the gradient to remove
  86327. * @returns the current particle system
  86328. */
  86329. removeSizeGradient(gradient: number): IParticleSystem;
  86330. /**
  86331. * Adds a new color remap gradient
  86332. * @param gradient defines the gradient to use (between 0 and 1)
  86333. * @param min defines the color remap minimal range
  86334. * @param max defines the color remap maximal range
  86335. * @returns the current particle system
  86336. */
  86337. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86338. /**
  86339. * Remove a specific color remap gradient
  86340. * @param gradient defines the gradient to remove
  86341. * @returns the current particle system
  86342. */
  86343. removeColorRemapGradient(gradient: number): IParticleSystem;
  86344. /**
  86345. * Adds a new alpha remap gradient
  86346. * @param gradient defines the gradient to use (between 0 and 1)
  86347. * @param min defines the alpha remap minimal range
  86348. * @param max defines the alpha remap maximal range
  86349. * @returns the current particle system
  86350. */
  86351. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86352. /**
  86353. * Remove a specific alpha remap gradient
  86354. * @param gradient defines the gradient to remove
  86355. * @returns the current particle system
  86356. */
  86357. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  86358. /**
  86359. * Adds a new angular speed gradient
  86360. * @param gradient defines the gradient to use (between 0 and 1)
  86361. * @param factor defines the angular speed to affect to the specified gradient
  86362. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86363. * @returns the current particle system
  86364. */
  86365. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86366. /**
  86367. * Remove a specific angular speed gradient
  86368. * @param gradient defines the gradient to remove
  86369. * @returns the current particle system
  86370. */
  86371. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  86372. /**
  86373. * Adds a new velocity gradient
  86374. * @param gradient defines the gradient to use (between 0 and 1)
  86375. * @param factor defines the velocity to affect to the specified gradient
  86376. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86377. * @returns the current particle system
  86378. */
  86379. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86380. /**
  86381. * Remove a specific velocity gradient
  86382. * @param gradient defines the gradient to remove
  86383. * @returns the current particle system
  86384. */
  86385. removeVelocityGradient(gradient: number): IParticleSystem;
  86386. /**
  86387. * Adds a new limit velocity gradient
  86388. * @param gradient defines the gradient to use (between 0 and 1)
  86389. * @param factor defines the limit velocity value to affect to the specified gradient
  86390. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86391. * @returns the current particle system
  86392. */
  86393. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86394. /**
  86395. * Remove a specific limit velocity gradient
  86396. * @param gradient defines the gradient to remove
  86397. * @returns the current particle system
  86398. */
  86399. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86400. /**
  86401. * Adds a new drag gradient
  86402. * @param gradient defines the gradient to use (between 0 and 1)
  86403. * @param factor defines the drag value to affect to the specified gradient
  86404. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86405. * @returns the current particle system
  86406. */
  86407. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86408. /**
  86409. * Remove a specific drag gradient
  86410. * @param gradient defines the gradient to remove
  86411. * @returns the current particle system
  86412. */
  86413. removeDragGradient(gradient: number): IParticleSystem;
  86414. /**
  86415. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86416. * @param gradient defines the gradient to use (between 0 and 1)
  86417. * @param factor defines the emit rate value to affect to the specified gradient
  86418. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86419. * @returns the current particle system
  86420. */
  86421. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86422. /**
  86423. * Remove a specific emit rate gradient
  86424. * @param gradient defines the gradient to remove
  86425. * @returns the current particle system
  86426. */
  86427. removeEmitRateGradient(gradient: number): IParticleSystem;
  86428. /**
  86429. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  86430. * @param gradient defines the gradient to use (between 0 and 1)
  86431. * @param factor defines the start size value to affect to the specified gradient
  86432. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86433. * @returns the current particle system
  86434. */
  86435. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86436. /**
  86437. * Remove a specific start size gradient
  86438. * @param gradient defines the gradient to remove
  86439. * @returns the current particle system
  86440. */
  86441. removeStartSizeGradient(gradient: number): IParticleSystem;
  86442. private _createRampGradientTexture;
  86443. /**
  86444. * Gets the current list of ramp gradients.
  86445. * You must use addRampGradient and removeRampGradient to udpate this list
  86446. * @returns the list of ramp gradients
  86447. */
  86448. getRampGradients(): Nullable<Array<Color3Gradient>>;
  86449. /**
  86450. * Adds a new ramp gradient used to remap particle colors
  86451. * @param gradient defines the gradient to use (between 0 and 1)
  86452. * @param color defines the color to affect to the specified gradient
  86453. * @returns the current particle system
  86454. */
  86455. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  86456. /**
  86457. * Remove a specific ramp gradient
  86458. * @param gradient defines the gradient to remove
  86459. * @returns the current particle system
  86460. */
  86461. removeRampGradient(gradient: number): ParticleSystem;
  86462. /**
  86463. * Adds a new color gradient
  86464. * @param gradient defines the gradient to use (between 0 and 1)
  86465. * @param color1 defines the color to affect to the specified gradient
  86466. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  86467. * @returns this particle system
  86468. */
  86469. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  86470. /**
  86471. * Remove a specific color gradient
  86472. * @param gradient defines the gradient to remove
  86473. * @returns this particle system
  86474. */
  86475. removeColorGradient(gradient: number): IParticleSystem;
  86476. private _fetchR;
  86477. protected _reset(): void;
  86478. private _resetEffect;
  86479. private _createVertexBuffers;
  86480. private _createIndexBuffer;
  86481. /**
  86482. * Gets the maximum number of particles active at the same time.
  86483. * @returns The max number of active particles.
  86484. */
  86485. getCapacity(): number;
  86486. /**
  86487. * Gets whether there are still active particles in the system.
  86488. * @returns True if it is alive, otherwise false.
  86489. */
  86490. isAlive(): boolean;
  86491. /**
  86492. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86493. * @returns True if it has been started, otherwise false.
  86494. */
  86495. isStarted(): boolean;
  86496. private _prepareSubEmitterInternalArray;
  86497. /**
  86498. * Starts the particle system and begins to emit
  86499. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  86500. */
  86501. start(delay?: number): void;
  86502. /**
  86503. * Stops the particle system.
  86504. * @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.
  86505. */
  86506. stop(stopSubEmitters?: boolean): void;
  86507. /**
  86508. * Remove all active particles
  86509. */
  86510. reset(): void;
  86511. /**
  86512. * @hidden (for internal use only)
  86513. */
  86514. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  86515. /**
  86516. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  86517. * Its lifetime will start back at 0.
  86518. */
  86519. recycleParticle: (particle: Particle) => void;
  86520. private _stopSubEmitters;
  86521. private _createParticle;
  86522. private _removeFromRoot;
  86523. private _emitFromParticle;
  86524. private _update;
  86525. /** @hidden */
  86526. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  86527. /** @hidden */
  86528. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  86529. /** @hidden */
  86530. private _getEffect;
  86531. /**
  86532. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  86533. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  86534. */
  86535. animate(preWarmOnly?: boolean): void;
  86536. private _appendParticleVertices;
  86537. /**
  86538. * Rebuilds the particle system.
  86539. */
  86540. rebuild(): void;
  86541. /**
  86542. * Is this system ready to be used/rendered
  86543. * @return true if the system is ready
  86544. */
  86545. isReady(): boolean;
  86546. private _render;
  86547. /**
  86548. * Renders the particle system in its current state.
  86549. * @returns the current number of particles
  86550. */
  86551. render(): number;
  86552. /**
  86553. * Disposes the particle system and free the associated resources
  86554. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86555. */
  86556. dispose(disposeTexture?: boolean): void;
  86557. /**
  86558. * Clones the particle system.
  86559. * @param name The name of the cloned object
  86560. * @param newEmitter The new emitter to use
  86561. * @returns the cloned particle system
  86562. */
  86563. clone(name: string, newEmitter: any): ParticleSystem;
  86564. /**
  86565. * Serializes the particle system to a JSON object.
  86566. * @returns the JSON object
  86567. */
  86568. serialize(): any;
  86569. /** @hidden */
  86570. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  86571. /** @hidden */
  86572. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  86573. /**
  86574. * Parses a JSON object to create a particle system.
  86575. * @param parsedParticleSystem The JSON object to parse
  86576. * @param scene The scene to create the particle system in
  86577. * @param rootUrl The root url to use to load external dependencies like texture
  86578. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  86579. * @returns the Parsed particle system
  86580. */
  86581. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  86582. }
  86583. }
  86584. declare module BABYLON {
  86585. /**
  86586. * A particle represents one of the element emitted by a particle system.
  86587. * This is mainly define by its coordinates, direction, velocity and age.
  86588. */
  86589. export class Particle {
  86590. /**
  86591. * The particle system the particle belongs to.
  86592. */
  86593. particleSystem: ParticleSystem;
  86594. private static _Count;
  86595. /**
  86596. * Unique ID of the particle
  86597. */
  86598. id: number;
  86599. /**
  86600. * The world position of the particle in the scene.
  86601. */
  86602. position: Vector3;
  86603. /**
  86604. * The world direction of the particle in the scene.
  86605. */
  86606. direction: Vector3;
  86607. /**
  86608. * The color of the particle.
  86609. */
  86610. color: Color4;
  86611. /**
  86612. * The color change of the particle per step.
  86613. */
  86614. colorStep: Color4;
  86615. /**
  86616. * Defines how long will the life of the particle be.
  86617. */
  86618. lifeTime: number;
  86619. /**
  86620. * The current age of the particle.
  86621. */
  86622. age: number;
  86623. /**
  86624. * The current size of the particle.
  86625. */
  86626. size: number;
  86627. /**
  86628. * The current scale of the particle.
  86629. */
  86630. scale: Vector2;
  86631. /**
  86632. * The current angle of the particle.
  86633. */
  86634. angle: number;
  86635. /**
  86636. * Defines how fast is the angle changing.
  86637. */
  86638. angularSpeed: number;
  86639. /**
  86640. * Defines the cell index used by the particle to be rendered from a sprite.
  86641. */
  86642. cellIndex: number;
  86643. /**
  86644. * The information required to support color remapping
  86645. */
  86646. remapData: Vector4;
  86647. /** @hidden */
  86648. _randomCellOffset?: number;
  86649. /** @hidden */
  86650. _initialDirection: Nullable<Vector3>;
  86651. /** @hidden */
  86652. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  86653. /** @hidden */
  86654. _initialStartSpriteCellID: number;
  86655. /** @hidden */
  86656. _initialEndSpriteCellID: number;
  86657. /** @hidden */
  86658. _currentColorGradient: Nullable<ColorGradient>;
  86659. /** @hidden */
  86660. _currentColor1: Color4;
  86661. /** @hidden */
  86662. _currentColor2: Color4;
  86663. /** @hidden */
  86664. _currentSizeGradient: Nullable<FactorGradient>;
  86665. /** @hidden */
  86666. _currentSize1: number;
  86667. /** @hidden */
  86668. _currentSize2: number;
  86669. /** @hidden */
  86670. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  86671. /** @hidden */
  86672. _currentAngularSpeed1: number;
  86673. /** @hidden */
  86674. _currentAngularSpeed2: number;
  86675. /** @hidden */
  86676. _currentVelocityGradient: Nullable<FactorGradient>;
  86677. /** @hidden */
  86678. _currentVelocity1: number;
  86679. /** @hidden */
  86680. _currentVelocity2: number;
  86681. /** @hidden */
  86682. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  86683. /** @hidden */
  86684. _currentLimitVelocity1: number;
  86685. /** @hidden */
  86686. _currentLimitVelocity2: number;
  86687. /** @hidden */
  86688. _currentDragGradient: Nullable<FactorGradient>;
  86689. /** @hidden */
  86690. _currentDrag1: number;
  86691. /** @hidden */
  86692. _currentDrag2: number;
  86693. /** @hidden */
  86694. _randomNoiseCoordinates1: Vector3;
  86695. /** @hidden */
  86696. _randomNoiseCoordinates2: Vector3;
  86697. /**
  86698. * Creates a new instance Particle
  86699. * @param particleSystem the particle system the particle belongs to
  86700. */
  86701. constructor(
  86702. /**
  86703. * The particle system the particle belongs to.
  86704. */
  86705. particleSystem: ParticleSystem);
  86706. private updateCellInfoFromSystem;
  86707. /**
  86708. * Defines how the sprite cell index is updated for the particle
  86709. */
  86710. updateCellIndex(): void;
  86711. /** @hidden */
  86712. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  86713. /** @hidden */
  86714. _inheritParticleInfoToSubEmitters(): void;
  86715. /** @hidden */
  86716. _reset(): void;
  86717. /**
  86718. * Copy the properties of particle to another one.
  86719. * @param other the particle to copy the information to.
  86720. */
  86721. copyTo(other: Particle): void;
  86722. }
  86723. }
  86724. declare module BABYLON {
  86725. /**
  86726. * Particle emitter represents a volume emitting particles.
  86727. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  86728. */
  86729. export interface IParticleEmitterType {
  86730. /**
  86731. * Called by the particle System when the direction is computed for the created particle.
  86732. * @param worldMatrix is the world matrix of the particle system
  86733. * @param directionToUpdate is the direction vector to update with the result
  86734. * @param particle is the particle we are computed the direction for
  86735. */
  86736. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86737. /**
  86738. * Called by the particle System when the position is computed for the created particle.
  86739. * @param worldMatrix is the world matrix of the particle system
  86740. * @param positionToUpdate is the position vector to update with the result
  86741. * @param particle is the particle we are computed the position for
  86742. */
  86743. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86744. /**
  86745. * Clones the current emitter and returns a copy of it
  86746. * @returns the new emitter
  86747. */
  86748. clone(): IParticleEmitterType;
  86749. /**
  86750. * Called by the GPUParticleSystem to setup the update shader
  86751. * @param effect defines the update shader
  86752. */
  86753. applyToShader(effect: Effect): void;
  86754. /**
  86755. * Returns a string to use to update the GPU particles update shader
  86756. * @returns the effect defines string
  86757. */
  86758. getEffectDefines(): string;
  86759. /**
  86760. * Returns a string representing the class name
  86761. * @returns a string containing the class name
  86762. */
  86763. getClassName(): string;
  86764. /**
  86765. * Serializes the particle system to a JSON object.
  86766. * @returns the JSON object
  86767. */
  86768. serialize(): any;
  86769. /**
  86770. * Parse properties from a JSON object
  86771. * @param serializationObject defines the JSON object
  86772. */
  86773. parse(serializationObject: any): void;
  86774. }
  86775. }
  86776. declare module BABYLON {
  86777. /**
  86778. * Particle emitter emitting particles from the inside of a box.
  86779. * It emits the particles randomly between 2 given directions.
  86780. */
  86781. export class BoxParticleEmitter implements IParticleEmitterType {
  86782. /**
  86783. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86784. */
  86785. direction1: Vector3;
  86786. /**
  86787. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86788. */
  86789. direction2: Vector3;
  86790. /**
  86791. * 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.
  86792. */
  86793. minEmitBox: Vector3;
  86794. /**
  86795. * 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.
  86796. */
  86797. maxEmitBox: Vector3;
  86798. /**
  86799. * Creates a new instance BoxParticleEmitter
  86800. */
  86801. constructor();
  86802. /**
  86803. * Called by the particle System when the direction is computed for the created particle.
  86804. * @param worldMatrix is the world matrix of the particle system
  86805. * @param directionToUpdate is the direction vector to update with the result
  86806. * @param particle is the particle we are computed the direction for
  86807. */
  86808. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86809. /**
  86810. * Called by the particle System when the position is computed for the created particle.
  86811. * @param worldMatrix is the world matrix of the particle system
  86812. * @param positionToUpdate is the position vector to update with the result
  86813. * @param particle is the particle we are computed the position for
  86814. */
  86815. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86816. /**
  86817. * Clones the current emitter and returns a copy of it
  86818. * @returns the new emitter
  86819. */
  86820. clone(): BoxParticleEmitter;
  86821. /**
  86822. * Called by the GPUParticleSystem to setup the update shader
  86823. * @param effect defines the update shader
  86824. */
  86825. applyToShader(effect: Effect): void;
  86826. /**
  86827. * Returns a string to use to update the GPU particles update shader
  86828. * @returns a string containng the defines string
  86829. */
  86830. getEffectDefines(): string;
  86831. /**
  86832. * Returns the string "BoxParticleEmitter"
  86833. * @returns a string containing the class name
  86834. */
  86835. getClassName(): string;
  86836. /**
  86837. * Serializes the particle system to a JSON object.
  86838. * @returns the JSON object
  86839. */
  86840. serialize(): any;
  86841. /**
  86842. * Parse properties from a JSON object
  86843. * @param serializationObject defines the JSON object
  86844. */
  86845. parse(serializationObject: any): void;
  86846. }
  86847. }
  86848. declare module BABYLON {
  86849. /**
  86850. * Particle emitter emitting particles from the inside of a cone.
  86851. * It emits the particles alongside the cone volume from the base to the particle.
  86852. * The emission direction might be randomized.
  86853. */
  86854. export class ConeParticleEmitter implements IParticleEmitterType {
  86855. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  86856. directionRandomizer: number;
  86857. private _radius;
  86858. private _angle;
  86859. private _height;
  86860. /**
  86861. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  86862. */
  86863. radiusRange: number;
  86864. /**
  86865. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  86866. */
  86867. heightRange: number;
  86868. /**
  86869. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  86870. */
  86871. emitFromSpawnPointOnly: boolean;
  86872. /**
  86873. * Gets or sets the radius of the emission cone
  86874. */
  86875. radius: number;
  86876. /**
  86877. * Gets or sets the angle of the emission cone
  86878. */
  86879. angle: number;
  86880. private _buildHeight;
  86881. /**
  86882. * Creates a new instance ConeParticleEmitter
  86883. * @param radius the radius of the emission cone (1 by default)
  86884. * @param angle the cone base angle (PI by default)
  86885. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  86886. */
  86887. constructor(radius?: number, angle?: number,
  86888. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  86889. directionRandomizer?: number);
  86890. /**
  86891. * Called by the particle System when the direction is computed for the created particle.
  86892. * @param worldMatrix is the world matrix of the particle system
  86893. * @param directionToUpdate is the direction vector to update with the result
  86894. * @param particle is the particle we are computed the direction for
  86895. */
  86896. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86897. /**
  86898. * Called by the particle System when the position is computed for the created particle.
  86899. * @param worldMatrix is the world matrix of the particle system
  86900. * @param positionToUpdate is the position vector to update with the result
  86901. * @param particle is the particle we are computed the position for
  86902. */
  86903. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86904. /**
  86905. * Clones the current emitter and returns a copy of it
  86906. * @returns the new emitter
  86907. */
  86908. clone(): ConeParticleEmitter;
  86909. /**
  86910. * Called by the GPUParticleSystem to setup the update shader
  86911. * @param effect defines the update shader
  86912. */
  86913. applyToShader(effect: Effect): void;
  86914. /**
  86915. * Returns a string to use to update the GPU particles update shader
  86916. * @returns a string containng the defines string
  86917. */
  86918. getEffectDefines(): string;
  86919. /**
  86920. * Returns the string "ConeParticleEmitter"
  86921. * @returns a string containing the class name
  86922. */
  86923. getClassName(): string;
  86924. /**
  86925. * Serializes the particle system to a JSON object.
  86926. * @returns the JSON object
  86927. */
  86928. serialize(): any;
  86929. /**
  86930. * Parse properties from a JSON object
  86931. * @param serializationObject defines the JSON object
  86932. */
  86933. parse(serializationObject: any): void;
  86934. }
  86935. }
  86936. declare module BABYLON {
  86937. /**
  86938. * Particle emitter emitting particles from the inside of a cylinder.
  86939. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  86940. */
  86941. export class CylinderParticleEmitter implements IParticleEmitterType {
  86942. /**
  86943. * The radius of the emission cylinder.
  86944. */
  86945. radius: number;
  86946. /**
  86947. * The height of the emission cylinder.
  86948. */
  86949. height: number;
  86950. /**
  86951. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86952. */
  86953. radiusRange: number;
  86954. /**
  86955. * How much to randomize the particle direction [0-1].
  86956. */
  86957. directionRandomizer: number;
  86958. /**
  86959. * Creates a new instance CylinderParticleEmitter
  86960. * @param radius the radius of the emission cylinder (1 by default)
  86961. * @param height the height of the emission cylinder (1 by default)
  86962. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86963. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86964. */
  86965. constructor(
  86966. /**
  86967. * The radius of the emission cylinder.
  86968. */
  86969. radius?: number,
  86970. /**
  86971. * The height of the emission cylinder.
  86972. */
  86973. height?: number,
  86974. /**
  86975. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86976. */
  86977. radiusRange?: number,
  86978. /**
  86979. * How much to randomize the particle direction [0-1].
  86980. */
  86981. directionRandomizer?: number);
  86982. /**
  86983. * Called by the particle System when the direction is computed for the created particle.
  86984. * @param worldMatrix is the world matrix of the particle system
  86985. * @param directionToUpdate is the direction vector to update with the result
  86986. * @param particle is the particle we are computed the direction for
  86987. */
  86988. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86989. /**
  86990. * Called by the particle System when the position is computed for the created particle.
  86991. * @param worldMatrix is the world matrix of the particle system
  86992. * @param positionToUpdate is the position vector to update with the result
  86993. * @param particle is the particle we are computed the position for
  86994. */
  86995. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86996. /**
  86997. * Clones the current emitter and returns a copy of it
  86998. * @returns the new emitter
  86999. */
  87000. clone(): CylinderParticleEmitter;
  87001. /**
  87002. * Called by the GPUParticleSystem to setup the update shader
  87003. * @param effect defines the update shader
  87004. */
  87005. applyToShader(effect: Effect): void;
  87006. /**
  87007. * Returns a string to use to update the GPU particles update shader
  87008. * @returns a string containng the defines string
  87009. */
  87010. getEffectDefines(): string;
  87011. /**
  87012. * Returns the string "CylinderParticleEmitter"
  87013. * @returns a string containing the class name
  87014. */
  87015. getClassName(): string;
  87016. /**
  87017. * Serializes the particle system to a JSON object.
  87018. * @returns the JSON object
  87019. */
  87020. serialize(): any;
  87021. /**
  87022. * Parse properties from a JSON object
  87023. * @param serializationObject defines the JSON object
  87024. */
  87025. parse(serializationObject: any): void;
  87026. }
  87027. /**
  87028. * Particle emitter emitting particles from the inside of a cylinder.
  87029. * It emits the particles randomly between two vectors.
  87030. */
  87031. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  87032. /**
  87033. * The min limit of the emission direction.
  87034. */
  87035. direction1: Vector3;
  87036. /**
  87037. * The max limit of the emission direction.
  87038. */
  87039. direction2: Vector3;
  87040. /**
  87041. * Creates a new instance CylinderDirectedParticleEmitter
  87042. * @param radius the radius of the emission cylinder (1 by default)
  87043. * @param height the height of the emission cylinder (1 by default)
  87044. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87045. * @param direction1 the min limit of the emission direction (up vector by default)
  87046. * @param direction2 the max limit of the emission direction (up vector by default)
  87047. */
  87048. constructor(radius?: number, height?: number, radiusRange?: number,
  87049. /**
  87050. * The min limit of the emission direction.
  87051. */
  87052. direction1?: Vector3,
  87053. /**
  87054. * The max limit of the emission direction.
  87055. */
  87056. direction2?: Vector3);
  87057. /**
  87058. * Called by the particle System when the direction is computed for the created particle.
  87059. * @param worldMatrix is the world matrix of the particle system
  87060. * @param directionToUpdate is the direction vector to update with the result
  87061. * @param particle is the particle we are computed the direction for
  87062. */
  87063. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87064. /**
  87065. * Clones the current emitter and returns a copy of it
  87066. * @returns the new emitter
  87067. */
  87068. clone(): CylinderDirectedParticleEmitter;
  87069. /**
  87070. * Called by the GPUParticleSystem to setup the update shader
  87071. * @param effect defines the update shader
  87072. */
  87073. applyToShader(effect: Effect): void;
  87074. /**
  87075. * Returns a string to use to update the GPU particles update shader
  87076. * @returns a string containng the defines string
  87077. */
  87078. getEffectDefines(): string;
  87079. /**
  87080. * Returns the string "CylinderDirectedParticleEmitter"
  87081. * @returns a string containing the class name
  87082. */
  87083. getClassName(): string;
  87084. /**
  87085. * Serializes the particle system to a JSON object.
  87086. * @returns the JSON object
  87087. */
  87088. serialize(): any;
  87089. /**
  87090. * Parse properties from a JSON object
  87091. * @param serializationObject defines the JSON object
  87092. */
  87093. parse(serializationObject: any): void;
  87094. }
  87095. }
  87096. declare module BABYLON {
  87097. /**
  87098. * Particle emitter emitting particles from the inside of a hemisphere.
  87099. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  87100. */
  87101. export class HemisphericParticleEmitter implements IParticleEmitterType {
  87102. /**
  87103. * The radius of the emission hemisphere.
  87104. */
  87105. radius: number;
  87106. /**
  87107. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87108. */
  87109. radiusRange: number;
  87110. /**
  87111. * How much to randomize the particle direction [0-1].
  87112. */
  87113. directionRandomizer: number;
  87114. /**
  87115. * Creates a new instance HemisphericParticleEmitter
  87116. * @param radius the radius of the emission hemisphere (1 by default)
  87117. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87118. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  87119. */
  87120. constructor(
  87121. /**
  87122. * The radius of the emission hemisphere.
  87123. */
  87124. radius?: number,
  87125. /**
  87126. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87127. */
  87128. radiusRange?: number,
  87129. /**
  87130. * How much to randomize the particle direction [0-1].
  87131. */
  87132. directionRandomizer?: number);
  87133. /**
  87134. * Called by the particle System when the direction is computed for the created particle.
  87135. * @param worldMatrix is the world matrix of the particle system
  87136. * @param directionToUpdate is the direction vector to update with the result
  87137. * @param particle is the particle we are computed the direction for
  87138. */
  87139. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87140. /**
  87141. * Called by the particle System when the position is computed for the created particle.
  87142. * @param worldMatrix is the world matrix of the particle system
  87143. * @param positionToUpdate is the position vector to update with the result
  87144. * @param particle is the particle we are computed the position for
  87145. */
  87146. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  87147. /**
  87148. * Clones the current emitter and returns a copy of it
  87149. * @returns the new emitter
  87150. */
  87151. clone(): HemisphericParticleEmitter;
  87152. /**
  87153. * Called by the GPUParticleSystem to setup the update shader
  87154. * @param effect defines the update shader
  87155. */
  87156. applyToShader(effect: Effect): void;
  87157. /**
  87158. * Returns a string to use to update the GPU particles update shader
  87159. * @returns a string containng the defines string
  87160. */
  87161. getEffectDefines(): string;
  87162. /**
  87163. * Returns the string "HemisphericParticleEmitter"
  87164. * @returns a string containing the class name
  87165. */
  87166. getClassName(): string;
  87167. /**
  87168. * Serializes the particle system to a JSON object.
  87169. * @returns the JSON object
  87170. */
  87171. serialize(): any;
  87172. /**
  87173. * Parse properties from a JSON object
  87174. * @param serializationObject defines the JSON object
  87175. */
  87176. parse(serializationObject: any): void;
  87177. }
  87178. }
  87179. declare module BABYLON {
  87180. /**
  87181. * Particle emitter emitting particles from a point.
  87182. * It emits the particles randomly between 2 given directions.
  87183. */
  87184. export class PointParticleEmitter implements IParticleEmitterType {
  87185. /**
  87186. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87187. */
  87188. direction1: Vector3;
  87189. /**
  87190. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87191. */
  87192. direction2: Vector3;
  87193. /**
  87194. * Creates a new instance PointParticleEmitter
  87195. */
  87196. constructor();
  87197. /**
  87198. * Called by the particle System when the direction is computed for the created particle.
  87199. * @param worldMatrix is the world matrix of the particle system
  87200. * @param directionToUpdate is the direction vector to update with the result
  87201. * @param particle is the particle we are computed the direction for
  87202. */
  87203. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87204. /**
  87205. * Called by the particle System when the position is computed for the created particle.
  87206. * @param worldMatrix is the world matrix of the particle system
  87207. * @param positionToUpdate is the position vector to update with the result
  87208. * @param particle is the particle we are computed the position for
  87209. */
  87210. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  87211. /**
  87212. * Clones the current emitter and returns a copy of it
  87213. * @returns the new emitter
  87214. */
  87215. clone(): PointParticleEmitter;
  87216. /**
  87217. * Called by the GPUParticleSystem to setup the update shader
  87218. * @param effect defines the update shader
  87219. */
  87220. applyToShader(effect: Effect): void;
  87221. /**
  87222. * Returns a string to use to update the GPU particles update shader
  87223. * @returns a string containng the defines string
  87224. */
  87225. getEffectDefines(): string;
  87226. /**
  87227. * Returns the string "PointParticleEmitter"
  87228. * @returns a string containing the class name
  87229. */
  87230. getClassName(): string;
  87231. /**
  87232. * Serializes the particle system to a JSON object.
  87233. * @returns the JSON object
  87234. */
  87235. serialize(): any;
  87236. /**
  87237. * Parse properties from a JSON object
  87238. * @param serializationObject defines the JSON object
  87239. */
  87240. parse(serializationObject: any): void;
  87241. }
  87242. }
  87243. declare module BABYLON {
  87244. /**
  87245. * Particle emitter emitting particles from the inside of a sphere.
  87246. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  87247. */
  87248. export class SphereParticleEmitter implements IParticleEmitterType {
  87249. /**
  87250. * The radius of the emission sphere.
  87251. */
  87252. radius: number;
  87253. /**
  87254. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87255. */
  87256. radiusRange: number;
  87257. /**
  87258. * How much to randomize the particle direction [0-1].
  87259. */
  87260. directionRandomizer: number;
  87261. /**
  87262. * Creates a new instance SphereParticleEmitter
  87263. * @param radius the radius of the emission sphere (1 by default)
  87264. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87265. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  87266. */
  87267. constructor(
  87268. /**
  87269. * The radius of the emission sphere.
  87270. */
  87271. radius?: number,
  87272. /**
  87273. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87274. */
  87275. radiusRange?: number,
  87276. /**
  87277. * How much to randomize the particle direction [0-1].
  87278. */
  87279. directionRandomizer?: number);
  87280. /**
  87281. * Called by the particle System when the direction is computed for the created particle.
  87282. * @param worldMatrix is the world matrix of the particle system
  87283. * @param directionToUpdate is the direction vector to update with the result
  87284. * @param particle is the particle we are computed the direction for
  87285. */
  87286. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87287. /**
  87288. * Called by the particle System when the position is computed for the created particle.
  87289. * @param worldMatrix is the world matrix of the particle system
  87290. * @param positionToUpdate is the position vector to update with the result
  87291. * @param particle is the particle we are computed the position for
  87292. */
  87293. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  87294. /**
  87295. * Clones the current emitter and returns a copy of it
  87296. * @returns the new emitter
  87297. */
  87298. clone(): SphereParticleEmitter;
  87299. /**
  87300. * Called by the GPUParticleSystem to setup the update shader
  87301. * @param effect defines the update shader
  87302. */
  87303. applyToShader(effect: Effect): void;
  87304. /**
  87305. * Returns a string to use to update the GPU particles update shader
  87306. * @returns a string containng the defines string
  87307. */
  87308. getEffectDefines(): string;
  87309. /**
  87310. * Returns the string "SphereParticleEmitter"
  87311. * @returns a string containing the class name
  87312. */
  87313. getClassName(): string;
  87314. /**
  87315. * Serializes the particle system to a JSON object.
  87316. * @returns the JSON object
  87317. */
  87318. serialize(): any;
  87319. /**
  87320. * Parse properties from a JSON object
  87321. * @param serializationObject defines the JSON object
  87322. */
  87323. parse(serializationObject: any): void;
  87324. }
  87325. /**
  87326. * Particle emitter emitting particles from the inside of a sphere.
  87327. * It emits the particles randomly between two vectors.
  87328. */
  87329. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  87330. /**
  87331. * The min limit of the emission direction.
  87332. */
  87333. direction1: Vector3;
  87334. /**
  87335. * The max limit of the emission direction.
  87336. */
  87337. direction2: Vector3;
  87338. /**
  87339. * Creates a new instance SphereDirectedParticleEmitter
  87340. * @param radius the radius of the emission sphere (1 by default)
  87341. * @param direction1 the min limit of the emission direction (up vector by default)
  87342. * @param direction2 the max limit of the emission direction (up vector by default)
  87343. */
  87344. constructor(radius?: number,
  87345. /**
  87346. * The min limit of the emission direction.
  87347. */
  87348. direction1?: Vector3,
  87349. /**
  87350. * The max limit of the emission direction.
  87351. */
  87352. direction2?: Vector3);
  87353. /**
  87354. * Called by the particle System when the direction is computed for the created particle.
  87355. * @param worldMatrix is the world matrix of the particle system
  87356. * @param directionToUpdate is the direction vector to update with the result
  87357. * @param particle is the particle we are computed the direction for
  87358. */
  87359. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87360. /**
  87361. * Clones the current emitter and returns a copy of it
  87362. * @returns the new emitter
  87363. */
  87364. clone(): SphereDirectedParticleEmitter;
  87365. /**
  87366. * Called by the GPUParticleSystem to setup the update shader
  87367. * @param effect defines the update shader
  87368. */
  87369. applyToShader(effect: Effect): void;
  87370. /**
  87371. * Returns a string to use to update the GPU particles update shader
  87372. * @returns a string containng the defines string
  87373. */
  87374. getEffectDefines(): string;
  87375. /**
  87376. * Returns the string "SphereDirectedParticleEmitter"
  87377. * @returns a string containing the class name
  87378. */
  87379. getClassName(): string;
  87380. /**
  87381. * Serializes the particle system to a JSON object.
  87382. * @returns the JSON object
  87383. */
  87384. serialize(): any;
  87385. /**
  87386. * Parse properties from a JSON object
  87387. * @param serializationObject defines the JSON object
  87388. */
  87389. parse(serializationObject: any): void;
  87390. }
  87391. }
  87392. declare module BABYLON {
  87393. /**
  87394. * Interface representing a particle system in Babylon.js.
  87395. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  87396. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  87397. */
  87398. export interface IParticleSystem {
  87399. /**
  87400. * List of animations used by the particle system.
  87401. */
  87402. animations: Animation[];
  87403. /**
  87404. * The id of the Particle system.
  87405. */
  87406. id: string;
  87407. /**
  87408. * The name of the Particle system.
  87409. */
  87410. name: string;
  87411. /**
  87412. * The emitter represents the Mesh or position we are attaching the particle system to.
  87413. */
  87414. emitter: Nullable<AbstractMesh | Vector3>;
  87415. /**
  87416. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  87417. */
  87418. isBillboardBased: boolean;
  87419. /**
  87420. * The rendering group used by the Particle system to chose when to render.
  87421. */
  87422. renderingGroupId: number;
  87423. /**
  87424. * The layer mask we are rendering the particles through.
  87425. */
  87426. layerMask: number;
  87427. /**
  87428. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  87429. */
  87430. updateSpeed: number;
  87431. /**
  87432. * The amount of time the particle system is running (depends of the overall update speed).
  87433. */
  87434. targetStopDuration: number;
  87435. /**
  87436. * The texture used to render each particle. (this can be a spritesheet)
  87437. */
  87438. particleTexture: Nullable<Texture>;
  87439. /**
  87440. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  87441. */
  87442. blendMode: number;
  87443. /**
  87444. * Minimum life time of emitting particles.
  87445. */
  87446. minLifeTime: number;
  87447. /**
  87448. * Maximum life time of emitting particles.
  87449. */
  87450. maxLifeTime: number;
  87451. /**
  87452. * Minimum Size of emitting particles.
  87453. */
  87454. minSize: number;
  87455. /**
  87456. * Maximum Size of emitting particles.
  87457. */
  87458. maxSize: number;
  87459. /**
  87460. * Minimum scale of emitting particles on X axis.
  87461. */
  87462. minScaleX: number;
  87463. /**
  87464. * Maximum scale of emitting particles on X axis.
  87465. */
  87466. maxScaleX: number;
  87467. /**
  87468. * Minimum scale of emitting particles on Y axis.
  87469. */
  87470. minScaleY: number;
  87471. /**
  87472. * Maximum scale of emitting particles on Y axis.
  87473. */
  87474. maxScaleY: number;
  87475. /**
  87476. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  87477. */
  87478. color1: Color4;
  87479. /**
  87480. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  87481. */
  87482. color2: Color4;
  87483. /**
  87484. * Color the particle will have at the end of its lifetime.
  87485. */
  87486. colorDead: Color4;
  87487. /**
  87488. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  87489. */
  87490. emitRate: number;
  87491. /**
  87492. * You can use gravity if you want to give an orientation to your particles.
  87493. */
  87494. gravity: Vector3;
  87495. /**
  87496. * Minimum power of emitting particles.
  87497. */
  87498. minEmitPower: number;
  87499. /**
  87500. * Maximum power of emitting particles.
  87501. */
  87502. maxEmitPower: number;
  87503. /**
  87504. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  87505. */
  87506. minAngularSpeed: number;
  87507. /**
  87508. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  87509. */
  87510. maxAngularSpeed: number;
  87511. /**
  87512. * Gets or sets the minimal initial rotation in radians.
  87513. */
  87514. minInitialRotation: number;
  87515. /**
  87516. * Gets or sets the maximal initial rotation in radians.
  87517. */
  87518. maxInitialRotation: number;
  87519. /**
  87520. * The particle emitter type defines the emitter used by the particle system.
  87521. * It can be for example box, sphere, or cone...
  87522. */
  87523. particleEmitterType: Nullable<IParticleEmitterType>;
  87524. /**
  87525. * Defines the delay in milliseconds before starting the system (0 by default)
  87526. */
  87527. startDelay: number;
  87528. /**
  87529. * 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
  87530. */
  87531. preWarmCycles: number;
  87532. /**
  87533. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  87534. */
  87535. preWarmStepOffset: number;
  87536. /**
  87537. * 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)
  87538. */
  87539. spriteCellChangeSpeed: number;
  87540. /**
  87541. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  87542. */
  87543. startSpriteCellID: number;
  87544. /**
  87545. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  87546. */
  87547. endSpriteCellID: number;
  87548. /**
  87549. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  87550. */
  87551. spriteCellWidth: number;
  87552. /**
  87553. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  87554. */
  87555. spriteCellHeight: number;
  87556. /**
  87557. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  87558. */
  87559. spriteRandomStartCell: boolean;
  87560. /**
  87561. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  87562. */
  87563. isAnimationSheetEnabled: boolean;
  87564. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  87565. translationPivot: Vector2;
  87566. /**
  87567. * Gets or sets a texture used to add random noise to particle positions
  87568. */
  87569. noiseTexture: Nullable<BaseTexture>;
  87570. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  87571. noiseStrength: Vector3;
  87572. /**
  87573. * Gets or sets the billboard mode to use when isBillboardBased = true.
  87574. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  87575. */
  87576. billboardMode: number;
  87577. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  87578. limitVelocityDamping: number;
  87579. /**
  87580. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  87581. */
  87582. beginAnimationOnStart: boolean;
  87583. /**
  87584. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  87585. */
  87586. beginAnimationFrom: number;
  87587. /**
  87588. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  87589. */
  87590. beginAnimationTo: number;
  87591. /**
  87592. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  87593. */
  87594. beginAnimationLoop: boolean;
  87595. /**
  87596. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  87597. */
  87598. disposeOnStop: boolean;
  87599. /**
  87600. * Gets the maximum number of particles active at the same time.
  87601. * @returns The max number of active particles.
  87602. */
  87603. getCapacity(): number;
  87604. /**
  87605. * Gets if the system has been started. (Note: this will still be true after stop is called)
  87606. * @returns True if it has been started, otherwise false.
  87607. */
  87608. isStarted(): boolean;
  87609. /**
  87610. * Animates the particle system for this frame.
  87611. */
  87612. animate(): void;
  87613. /**
  87614. * Renders the particle system in its current state.
  87615. * @returns the current number of particles
  87616. */
  87617. render(): number;
  87618. /**
  87619. * Dispose the particle system and frees its associated resources.
  87620. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  87621. */
  87622. dispose(disposeTexture?: boolean): void;
  87623. /**
  87624. * Clones the particle system.
  87625. * @param name The name of the cloned object
  87626. * @param newEmitter The new emitter to use
  87627. * @returns the cloned particle system
  87628. */
  87629. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  87630. /**
  87631. * Serializes the particle system to a JSON object.
  87632. * @returns the JSON object
  87633. */
  87634. serialize(): any;
  87635. /**
  87636. * Rebuild the particle system
  87637. */
  87638. rebuild(): void;
  87639. /**
  87640. * Starts the particle system and begins to emit
  87641. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  87642. */
  87643. start(delay?: number): void;
  87644. /**
  87645. * Stops the particle system.
  87646. */
  87647. stop(): void;
  87648. /**
  87649. * Remove all active particles
  87650. */
  87651. reset(): void;
  87652. /**
  87653. * Is this system ready to be used/rendered
  87654. * @return true if the system is ready
  87655. */
  87656. isReady(): boolean;
  87657. /**
  87658. * Adds a new color gradient
  87659. * @param gradient defines the gradient to use (between 0 and 1)
  87660. * @param color1 defines the color to affect to the specified gradient
  87661. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  87662. * @returns the current particle system
  87663. */
  87664. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  87665. /**
  87666. * Remove a specific color gradient
  87667. * @param gradient defines the gradient to remove
  87668. * @returns the current particle system
  87669. */
  87670. removeColorGradient(gradient: number): IParticleSystem;
  87671. /**
  87672. * Adds a new size gradient
  87673. * @param gradient defines the gradient to use (between 0 and 1)
  87674. * @param factor defines the size factor to affect to the specified gradient
  87675. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87676. * @returns the current particle system
  87677. */
  87678. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87679. /**
  87680. * Remove a specific size gradient
  87681. * @param gradient defines the gradient to remove
  87682. * @returns the current particle system
  87683. */
  87684. removeSizeGradient(gradient: number): IParticleSystem;
  87685. /**
  87686. * Gets the current list of color gradients.
  87687. * You must use addColorGradient and removeColorGradient to udpate this list
  87688. * @returns the list of color gradients
  87689. */
  87690. getColorGradients(): Nullable<Array<ColorGradient>>;
  87691. /**
  87692. * Gets the current list of size gradients.
  87693. * You must use addSizeGradient and removeSizeGradient to udpate this list
  87694. * @returns the list of size gradients
  87695. */
  87696. getSizeGradients(): Nullable<Array<FactorGradient>>;
  87697. /**
  87698. * Gets the current list of angular speed gradients.
  87699. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  87700. * @returns the list of angular speed gradients
  87701. */
  87702. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  87703. /**
  87704. * Adds a new angular speed gradient
  87705. * @param gradient defines the gradient to use (between 0 and 1)
  87706. * @param factor defines the angular speed to affect to the specified gradient
  87707. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87708. * @returns the current particle system
  87709. */
  87710. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87711. /**
  87712. * Remove a specific angular speed gradient
  87713. * @param gradient defines the gradient to remove
  87714. * @returns the current particle system
  87715. */
  87716. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  87717. /**
  87718. * Gets the current list of velocity gradients.
  87719. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  87720. * @returns the list of velocity gradients
  87721. */
  87722. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  87723. /**
  87724. * Adds a new velocity gradient
  87725. * @param gradient defines the gradient to use (between 0 and 1)
  87726. * @param factor defines the velocity to affect to the specified gradient
  87727. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87728. * @returns the current particle system
  87729. */
  87730. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87731. /**
  87732. * Remove a specific velocity gradient
  87733. * @param gradient defines the gradient to remove
  87734. * @returns the current particle system
  87735. */
  87736. removeVelocityGradient(gradient: number): IParticleSystem;
  87737. /**
  87738. * Gets the current list of limit velocity gradients.
  87739. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  87740. * @returns the list of limit velocity gradients
  87741. */
  87742. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  87743. /**
  87744. * Adds a new limit velocity gradient
  87745. * @param gradient defines the gradient to use (between 0 and 1)
  87746. * @param factor defines the limit velocity to affect to the specified gradient
  87747. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87748. * @returns the current particle system
  87749. */
  87750. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87751. /**
  87752. * Remove a specific limit velocity gradient
  87753. * @param gradient defines the gradient to remove
  87754. * @returns the current particle system
  87755. */
  87756. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  87757. /**
  87758. * Adds a new drag gradient
  87759. * @param gradient defines the gradient to use (between 0 and 1)
  87760. * @param factor defines the drag to affect to the specified gradient
  87761. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87762. * @returns the current particle system
  87763. */
  87764. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87765. /**
  87766. * Remove a specific drag gradient
  87767. * @param gradient defines the gradient to remove
  87768. * @returns the current particle system
  87769. */
  87770. removeDragGradient(gradient: number): IParticleSystem;
  87771. /**
  87772. * Gets the current list of drag gradients.
  87773. * You must use addDragGradient and removeDragGradient to udpate this list
  87774. * @returns the list of drag gradients
  87775. */
  87776. getDragGradients(): Nullable<Array<FactorGradient>>;
  87777. /**
  87778. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  87779. * @param gradient defines the gradient to use (between 0 and 1)
  87780. * @param factor defines the emit rate to affect to the specified gradient
  87781. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87782. * @returns the current particle system
  87783. */
  87784. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87785. /**
  87786. * Remove a specific emit rate gradient
  87787. * @param gradient defines the gradient to remove
  87788. * @returns the current particle system
  87789. */
  87790. removeEmitRateGradient(gradient: number): IParticleSystem;
  87791. /**
  87792. * Gets the current list of emit rate gradients.
  87793. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  87794. * @returns the list of emit rate gradients
  87795. */
  87796. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  87797. /**
  87798. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  87799. * @param gradient defines the gradient to use (between 0 and 1)
  87800. * @param factor defines the start size to affect to the specified gradient
  87801. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87802. * @returns the current particle system
  87803. */
  87804. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87805. /**
  87806. * Remove a specific start size gradient
  87807. * @param gradient defines the gradient to remove
  87808. * @returns the current particle system
  87809. */
  87810. removeStartSizeGradient(gradient: number): IParticleSystem;
  87811. /**
  87812. * Gets the current list of start size gradients.
  87813. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  87814. * @returns the list of start size gradients
  87815. */
  87816. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  87817. /**
  87818. * Adds a new life time gradient
  87819. * @param gradient defines the gradient to use (between 0 and 1)
  87820. * @param factor defines the life time factor to affect to the specified gradient
  87821. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87822. * @returns the current particle system
  87823. */
  87824. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87825. /**
  87826. * Remove a specific life time gradient
  87827. * @param gradient defines the gradient to remove
  87828. * @returns the current particle system
  87829. */
  87830. removeLifeTimeGradient(gradient: number): IParticleSystem;
  87831. /**
  87832. * Gets the current list of life time gradients.
  87833. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  87834. * @returns the list of life time gradients
  87835. */
  87836. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  87837. /**
  87838. * Gets the current list of color gradients.
  87839. * You must use addColorGradient and removeColorGradient to udpate this list
  87840. * @returns the list of color gradients
  87841. */
  87842. getColorGradients(): Nullable<Array<ColorGradient>>;
  87843. /**
  87844. * Adds a new ramp gradient used to remap particle colors
  87845. * @param gradient defines the gradient to use (between 0 and 1)
  87846. * @param color defines the color to affect to the specified gradient
  87847. * @returns the current particle system
  87848. */
  87849. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  87850. /**
  87851. * Gets the current list of ramp gradients.
  87852. * You must use addRampGradient and removeRampGradient to udpate this list
  87853. * @returns the list of ramp gradients
  87854. */
  87855. getRampGradients(): Nullable<Array<Color3Gradient>>;
  87856. /** Gets or sets a boolean indicating that ramp gradients must be used
  87857. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  87858. */
  87859. useRampGradients: boolean;
  87860. /**
  87861. * Adds a new color remap gradient
  87862. * @param gradient defines the gradient to use (between 0 and 1)
  87863. * @param min defines the color remap minimal range
  87864. * @param max defines the color remap maximal range
  87865. * @returns the current particle system
  87866. */
  87867. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87868. /**
  87869. * Gets the current list of color remap gradients.
  87870. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  87871. * @returns the list of color remap gradients
  87872. */
  87873. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  87874. /**
  87875. * Adds a new alpha remap gradient
  87876. * @param gradient defines the gradient to use (between 0 and 1)
  87877. * @param min defines the alpha remap minimal range
  87878. * @param max defines the alpha remap maximal range
  87879. * @returns the current particle system
  87880. */
  87881. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87882. /**
  87883. * Gets the current list of alpha remap gradients.
  87884. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  87885. * @returns the list of alpha remap gradients
  87886. */
  87887. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  87888. /**
  87889. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  87890. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87891. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87892. * @returns the emitter
  87893. */
  87894. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  87895. /**
  87896. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  87897. * @param radius The radius of the hemisphere to emit from
  87898. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87899. * @returns the emitter
  87900. */
  87901. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  87902. /**
  87903. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  87904. * @param radius The radius of the sphere to emit from
  87905. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87906. * @returns the emitter
  87907. */
  87908. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  87909. /**
  87910. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  87911. * @param radius The radius of the sphere to emit from
  87912. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  87913. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  87914. * @returns the emitter
  87915. */
  87916. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  87917. /**
  87918. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  87919. * @param radius The radius of the emission cylinder
  87920. * @param height The height of the emission cylinder
  87921. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  87922. * @param directionRandomizer How much to randomize the particle direction [0-1]
  87923. * @returns the emitter
  87924. */
  87925. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  87926. /**
  87927. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  87928. * @param radius The radius of the cylinder to emit from
  87929. * @param height The height of the emission cylinder
  87930. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87931. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  87932. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  87933. * @returns the emitter
  87934. */
  87935. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  87936. /**
  87937. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  87938. * @param radius The radius of the cone to emit from
  87939. * @param angle The base angle of the cone
  87940. * @returns the emitter
  87941. */
  87942. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  87943. /**
  87944. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  87945. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87946. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87947. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87948. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87949. * @returns the emitter
  87950. */
  87951. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  87952. /**
  87953. * Get hosting scene
  87954. * @returns the scene
  87955. */
  87956. getScene(): Scene;
  87957. }
  87958. }
  87959. declare module BABYLON {
  87960. /**
  87961. * Creates an instance based on a source mesh.
  87962. */
  87963. export class InstancedMesh extends AbstractMesh {
  87964. private _sourceMesh;
  87965. private _currentLOD;
  87966. /** @hidden */
  87967. _indexInSourceMeshInstanceArray: number;
  87968. constructor(name: string, source: Mesh);
  87969. /**
  87970. * Returns the string "InstancedMesh".
  87971. */
  87972. getClassName(): string;
  87973. /** Gets the list of lights affecting that mesh */
  87974. readonly lightSources: Light[];
  87975. _resyncLightSources(): void;
  87976. _resyncLightSource(light: Light): void;
  87977. _removeLightSource(light: Light, dispose: boolean): void;
  87978. /**
  87979. * If the source mesh receives shadows
  87980. */
  87981. readonly receiveShadows: boolean;
  87982. /**
  87983. * The material of the source mesh
  87984. */
  87985. readonly material: Nullable<Material>;
  87986. /**
  87987. * Visibility of the source mesh
  87988. */
  87989. readonly visibility: number;
  87990. /**
  87991. * Skeleton of the source mesh
  87992. */
  87993. readonly skeleton: Nullable<Skeleton>;
  87994. /**
  87995. * Rendering ground id of the source mesh
  87996. */
  87997. renderingGroupId: number;
  87998. /**
  87999. * Returns the total number of vertices (integer).
  88000. */
  88001. getTotalVertices(): number;
  88002. /**
  88003. * Returns a positive integer : the total number of indices in this mesh geometry.
  88004. * @returns the numner of indices or zero if the mesh has no geometry.
  88005. */
  88006. getTotalIndices(): number;
  88007. /**
  88008. * The source mesh of the instance
  88009. */
  88010. readonly sourceMesh: Mesh;
  88011. /**
  88012. * Is this node ready to be used/rendered
  88013. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  88014. * @return {boolean} is it ready
  88015. */
  88016. isReady(completeCheck?: boolean): boolean;
  88017. /**
  88018. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88019. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  88020. * @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.
  88021. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  88022. */
  88023. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  88024. /**
  88025. * Sets the vertex data of the mesh geometry for the requested `kind`.
  88026. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  88027. * The `data` are either a numeric array either a Float32Array.
  88028. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  88029. * 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).
  88030. * Note that a new underlying VertexBuffer object is created each call.
  88031. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  88032. *
  88033. * Possible `kind` values :
  88034. * - VertexBuffer.PositionKind
  88035. * - VertexBuffer.UVKind
  88036. * - VertexBuffer.UV2Kind
  88037. * - VertexBuffer.UV3Kind
  88038. * - VertexBuffer.UV4Kind
  88039. * - VertexBuffer.UV5Kind
  88040. * - VertexBuffer.UV6Kind
  88041. * - VertexBuffer.ColorKind
  88042. * - VertexBuffer.MatricesIndicesKind
  88043. * - VertexBuffer.MatricesIndicesExtraKind
  88044. * - VertexBuffer.MatricesWeightsKind
  88045. * - VertexBuffer.MatricesWeightsExtraKind
  88046. *
  88047. * Returns the Mesh.
  88048. */
  88049. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  88050. /**
  88051. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  88052. * If the mesh has no geometry, it is simply returned as it is.
  88053. * The `data` are either a numeric array either a Float32Array.
  88054. * No new underlying VertexBuffer object is created.
  88055. * 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.
  88056. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  88057. *
  88058. * Possible `kind` values :
  88059. * - VertexBuffer.PositionKind
  88060. * - VertexBuffer.UVKind
  88061. * - VertexBuffer.UV2Kind
  88062. * - VertexBuffer.UV3Kind
  88063. * - VertexBuffer.UV4Kind
  88064. * - VertexBuffer.UV5Kind
  88065. * - VertexBuffer.UV6Kind
  88066. * - VertexBuffer.ColorKind
  88067. * - VertexBuffer.MatricesIndicesKind
  88068. * - VertexBuffer.MatricesIndicesExtraKind
  88069. * - VertexBuffer.MatricesWeightsKind
  88070. * - VertexBuffer.MatricesWeightsExtraKind
  88071. *
  88072. * Returns the Mesh.
  88073. */
  88074. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  88075. /**
  88076. * Sets the mesh indices.
  88077. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  88078. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  88079. * This method creates a new index buffer each call.
  88080. * Returns the Mesh.
  88081. */
  88082. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  88083. /**
  88084. * Boolean : True if the mesh owns the requested kind of data.
  88085. */
  88086. isVerticesDataPresent(kind: string): boolean;
  88087. /**
  88088. * Returns an array of indices (IndicesArray).
  88089. */
  88090. getIndices(): Nullable<IndicesArray>;
  88091. readonly _positions: Nullable<Vector3[]>;
  88092. /**
  88093. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  88094. * This means the mesh underlying bounding box and sphere are recomputed.
  88095. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  88096. * @returns the current mesh
  88097. */
  88098. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  88099. /** @hidden */
  88100. _preActivate(): InstancedMesh;
  88101. /** @hidden */
  88102. _activate(renderId: number, intermediateRendering: boolean): boolean;
  88103. /** @hidden */
  88104. _postActivate(): void;
  88105. getWorldMatrix(): Matrix;
  88106. readonly isAnInstance: boolean;
  88107. /**
  88108. * Returns the current associated LOD AbstractMesh.
  88109. */
  88110. getLOD(camera: Camera): AbstractMesh;
  88111. /** @hidden */
  88112. _syncSubMeshes(): InstancedMesh;
  88113. /** @hidden */
  88114. _generatePointsArray(): boolean;
  88115. /**
  88116. * Creates a new InstancedMesh from the current mesh.
  88117. * - name (string) : the cloned mesh name
  88118. * - newParent (optional Node) : the optional Node to parent the clone to.
  88119. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  88120. *
  88121. * Returns the clone.
  88122. */
  88123. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  88124. /**
  88125. * Disposes the InstancedMesh.
  88126. * Returns nothing.
  88127. */
  88128. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88129. }
  88130. interface Mesh {
  88131. /**
  88132. * Register a custom buffer that will be instanced
  88133. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88134. * @param kind defines the buffer kind
  88135. * @param stride defines the stride in floats
  88136. */
  88137. registerInstancedBuffer(kind: string, stride: number): void;
  88138. /** @hidden */
  88139. _userInstancedBuffersStorage: {
  88140. data: {
  88141. [key: string]: Float32Array;
  88142. };
  88143. sizes: {
  88144. [key: string]: number;
  88145. };
  88146. vertexBuffers: {
  88147. [key: string]: Nullable<VertexBuffer>;
  88148. };
  88149. strides: {
  88150. [key: string]: number;
  88151. };
  88152. };
  88153. }
  88154. interface AbstractMesh {
  88155. /**
  88156. * Object used to store instanced buffers defined by user
  88157. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88158. */
  88159. instancedBuffers: {
  88160. [key: string]: any;
  88161. };
  88162. }
  88163. }
  88164. declare module BABYLON {
  88165. /**
  88166. * Defines the options associated with the creation of a shader material.
  88167. */
  88168. export interface IShaderMaterialOptions {
  88169. /**
  88170. * Does the material work in alpha blend mode
  88171. */
  88172. needAlphaBlending: boolean;
  88173. /**
  88174. * Does the material work in alpha test mode
  88175. */
  88176. needAlphaTesting: boolean;
  88177. /**
  88178. * The list of attribute names used in the shader
  88179. */
  88180. attributes: string[];
  88181. /**
  88182. * The list of unifrom names used in the shader
  88183. */
  88184. uniforms: string[];
  88185. /**
  88186. * The list of UBO names used in the shader
  88187. */
  88188. uniformBuffers: string[];
  88189. /**
  88190. * The list of sampler names used in the shader
  88191. */
  88192. samplers: string[];
  88193. /**
  88194. * The list of defines used in the shader
  88195. */
  88196. defines: string[];
  88197. }
  88198. /**
  88199. * 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.
  88200. *
  88201. * This returned material effects how the mesh will look based on the code in the shaders.
  88202. *
  88203. * @see http://doc.babylonjs.com/how_to/shader_material
  88204. */
  88205. export class ShaderMaterial extends Material {
  88206. private _shaderPath;
  88207. private _options;
  88208. private _textures;
  88209. private _textureArrays;
  88210. private _floats;
  88211. private _ints;
  88212. private _floatsArrays;
  88213. private _colors3;
  88214. private _colors3Arrays;
  88215. private _colors4;
  88216. private _colors4Arrays;
  88217. private _vectors2;
  88218. private _vectors3;
  88219. private _vectors4;
  88220. private _matrices;
  88221. private _matrixArrays;
  88222. private _matrices3x3;
  88223. private _matrices2x2;
  88224. private _vectors2Arrays;
  88225. private _vectors3Arrays;
  88226. private _vectors4Arrays;
  88227. private _cachedWorldViewMatrix;
  88228. private _cachedWorldViewProjectionMatrix;
  88229. private _renderId;
  88230. private _multiview;
  88231. /**
  88232. * Instantiate a new shader material.
  88233. * 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.
  88234. * This returned material effects how the mesh will look based on the code in the shaders.
  88235. * @see http://doc.babylonjs.com/how_to/shader_material
  88236. * @param name Define the name of the material in the scene
  88237. * @param scene Define the scene the material belongs to
  88238. * @param shaderPath Defines the route to the shader code in one of three ways:
  88239. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  88240. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  88241. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  88242. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  88243. * @param options Define the options used to create the shader
  88244. */
  88245. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  88246. /**
  88247. * Gets the shader path used to define the shader code
  88248. * It can be modified to trigger a new compilation
  88249. */
  88250. /**
  88251. * Sets the shader path used to define the shader code
  88252. * It can be modified to trigger a new compilation
  88253. */
  88254. shaderPath: any;
  88255. /**
  88256. * Gets the options used to compile the shader.
  88257. * They can be modified to trigger a new compilation
  88258. */
  88259. readonly options: IShaderMaterialOptions;
  88260. /**
  88261. * Gets the current class name of the material e.g. "ShaderMaterial"
  88262. * Mainly use in serialization.
  88263. * @returns the class name
  88264. */
  88265. getClassName(): string;
  88266. /**
  88267. * Specifies if the material will require alpha blending
  88268. * @returns a boolean specifying if alpha blending is needed
  88269. */
  88270. needAlphaBlending(): boolean;
  88271. /**
  88272. * Specifies if this material should be rendered in alpha test mode
  88273. * @returns a boolean specifying if an alpha test is needed.
  88274. */
  88275. needAlphaTesting(): boolean;
  88276. private _checkUniform;
  88277. /**
  88278. * Set a texture in the shader.
  88279. * @param name Define the name of the uniform samplers as defined in the shader
  88280. * @param texture Define the texture to bind to this sampler
  88281. * @return the material itself allowing "fluent" like uniform updates
  88282. */
  88283. setTexture(name: string, texture: Texture): ShaderMaterial;
  88284. /**
  88285. * Set a texture array in the shader.
  88286. * @param name Define the name of the uniform sampler array as defined in the shader
  88287. * @param textures Define the list of textures to bind to this sampler
  88288. * @return the material itself allowing "fluent" like uniform updates
  88289. */
  88290. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  88291. /**
  88292. * Set a float in the shader.
  88293. * @param name Define the name of the uniform as defined in the shader
  88294. * @param value Define the value to give to the uniform
  88295. * @return the material itself allowing "fluent" like uniform updates
  88296. */
  88297. setFloat(name: string, value: number): ShaderMaterial;
  88298. /**
  88299. * Set a int in the shader.
  88300. * @param name Define the name of the uniform as defined in the shader
  88301. * @param value Define the value to give to the uniform
  88302. * @return the material itself allowing "fluent" like uniform updates
  88303. */
  88304. setInt(name: string, value: number): ShaderMaterial;
  88305. /**
  88306. * Set an array of floats in the shader.
  88307. * @param name Define the name of the uniform as defined in the shader
  88308. * @param value Define the value to give to the uniform
  88309. * @return the material itself allowing "fluent" like uniform updates
  88310. */
  88311. setFloats(name: string, value: number[]): ShaderMaterial;
  88312. /**
  88313. * Set a vec3 in the shader from a Color3.
  88314. * @param name Define the name of the uniform as defined in the shader
  88315. * @param value Define the value to give to the uniform
  88316. * @return the material itself allowing "fluent" like uniform updates
  88317. */
  88318. setColor3(name: string, value: Color3): ShaderMaterial;
  88319. /**
  88320. * Set a vec3 array in the shader from a Color3 array.
  88321. * @param name Define the name of the uniform as defined in the shader
  88322. * @param value Define the value to give to the uniform
  88323. * @return the material itself allowing "fluent" like uniform updates
  88324. */
  88325. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  88326. /**
  88327. * Set a vec4 in the shader from a Color4.
  88328. * @param name Define the name of the uniform as defined in the shader
  88329. * @param value Define the value to give to the uniform
  88330. * @return the material itself allowing "fluent" like uniform updates
  88331. */
  88332. setColor4(name: string, value: Color4): ShaderMaterial;
  88333. /**
  88334. * Set a vec4 array in the shader from a Color4 array.
  88335. * @param name Define the name of the uniform as defined in the shader
  88336. * @param value Define the value to give to the uniform
  88337. * @return the material itself allowing "fluent" like uniform updates
  88338. */
  88339. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  88340. /**
  88341. * Set a vec2 in the shader from a Vector2.
  88342. * @param name Define the name of the uniform as defined in the shader
  88343. * @param value Define the value to give to the uniform
  88344. * @return the material itself allowing "fluent" like uniform updates
  88345. */
  88346. setVector2(name: string, value: Vector2): ShaderMaterial;
  88347. /**
  88348. * Set a vec3 in the shader from a Vector3.
  88349. * @param name Define the name of the uniform as defined in the shader
  88350. * @param value Define the value to give to the uniform
  88351. * @return the material itself allowing "fluent" like uniform updates
  88352. */
  88353. setVector3(name: string, value: Vector3): ShaderMaterial;
  88354. /**
  88355. * Set a vec4 in the shader from a Vector4.
  88356. * @param name Define the name of the uniform as defined in the shader
  88357. * @param value Define the value to give to the uniform
  88358. * @return the material itself allowing "fluent" like uniform updates
  88359. */
  88360. setVector4(name: string, value: Vector4): ShaderMaterial;
  88361. /**
  88362. * Set a mat4 in the shader from a Matrix.
  88363. * @param name Define the name of the uniform as defined in the shader
  88364. * @param value Define the value to give to the uniform
  88365. * @return the material itself allowing "fluent" like uniform updates
  88366. */
  88367. setMatrix(name: string, value: Matrix): ShaderMaterial;
  88368. /**
  88369. * Set a float32Array in the shader from a matrix array.
  88370. * @param name Define the name of the uniform as defined in the shader
  88371. * @param value Define the value to give to the uniform
  88372. * @return the material itself allowing "fluent" like uniform updates
  88373. */
  88374. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  88375. /**
  88376. * Set a mat3 in the shader from a Float32Array.
  88377. * @param name Define the name of the uniform as defined in the shader
  88378. * @param value Define the value to give to the uniform
  88379. * @return the material itself allowing "fluent" like uniform updates
  88380. */
  88381. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  88382. /**
  88383. * Set a mat2 in the shader from a Float32Array.
  88384. * @param name Define the name of the uniform as defined in the shader
  88385. * @param value Define the value to give to the uniform
  88386. * @return the material itself allowing "fluent" like uniform updates
  88387. */
  88388. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  88389. /**
  88390. * Set a vec2 array in the shader from a number array.
  88391. * @param name Define the name of the uniform as defined in the shader
  88392. * @param value Define the value to give to the uniform
  88393. * @return the material itself allowing "fluent" like uniform updates
  88394. */
  88395. setArray2(name: string, value: number[]): ShaderMaterial;
  88396. /**
  88397. * Set a vec3 array in the shader from a number array.
  88398. * @param name Define the name of the uniform as defined in the shader
  88399. * @param value Define the value to give to the uniform
  88400. * @return the material itself allowing "fluent" like uniform updates
  88401. */
  88402. setArray3(name: string, value: number[]): ShaderMaterial;
  88403. /**
  88404. * Set a vec4 array in the shader from a number array.
  88405. * @param name Define the name of the uniform as defined in the shader
  88406. * @param value Define the value to give to the uniform
  88407. * @return the material itself allowing "fluent" like uniform updates
  88408. */
  88409. setArray4(name: string, value: number[]): ShaderMaterial;
  88410. private _checkCache;
  88411. /**
  88412. * Specifies that the submesh is ready to be used
  88413. * @param mesh defines the mesh to check
  88414. * @param subMesh defines which submesh to check
  88415. * @param useInstances specifies that instances should be used
  88416. * @returns a boolean indicating that the submesh is ready or not
  88417. */
  88418. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88419. /**
  88420. * Checks if the material is ready to render the requested mesh
  88421. * @param mesh Define the mesh to render
  88422. * @param useInstances Define whether or not the material is used with instances
  88423. * @returns true if ready, otherwise false
  88424. */
  88425. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  88426. /**
  88427. * Binds the world matrix to the material
  88428. * @param world defines the world transformation matrix
  88429. */
  88430. bindOnlyWorldMatrix(world: Matrix): void;
  88431. /**
  88432. * Binds the material to the mesh
  88433. * @param world defines the world transformation matrix
  88434. * @param mesh defines the mesh to bind the material to
  88435. */
  88436. bind(world: Matrix, mesh?: Mesh): void;
  88437. /**
  88438. * Gets the active textures from the material
  88439. * @returns an array of textures
  88440. */
  88441. getActiveTextures(): BaseTexture[];
  88442. /**
  88443. * Specifies if the material uses a texture
  88444. * @param texture defines the texture to check against the material
  88445. * @returns a boolean specifying if the material uses the texture
  88446. */
  88447. hasTexture(texture: BaseTexture): boolean;
  88448. /**
  88449. * Makes a duplicate of the material, and gives it a new name
  88450. * @param name defines the new name for the duplicated material
  88451. * @returns the cloned material
  88452. */
  88453. clone(name: string): ShaderMaterial;
  88454. /**
  88455. * Disposes the material
  88456. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  88457. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  88458. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  88459. */
  88460. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  88461. /**
  88462. * Serializes this material in a JSON representation
  88463. * @returns the serialized material object
  88464. */
  88465. serialize(): any;
  88466. /**
  88467. * Creates a shader material from parsed shader material data
  88468. * @param source defines the JSON represnetation of the material
  88469. * @param scene defines the hosting scene
  88470. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  88471. * @returns a new material
  88472. */
  88473. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  88474. }
  88475. }
  88476. declare module BABYLON {
  88477. /** @hidden */
  88478. export var colorPixelShader: {
  88479. name: string;
  88480. shader: string;
  88481. };
  88482. }
  88483. declare module BABYLON {
  88484. /** @hidden */
  88485. export var colorVertexShader: {
  88486. name: string;
  88487. shader: string;
  88488. };
  88489. }
  88490. declare module BABYLON {
  88491. /**
  88492. * Line mesh
  88493. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  88494. */
  88495. export class LinesMesh extends Mesh {
  88496. /**
  88497. * If vertex color should be applied to the mesh
  88498. */
  88499. readonly useVertexColor?: boolean | undefined;
  88500. /**
  88501. * If vertex alpha should be applied to the mesh
  88502. */
  88503. readonly useVertexAlpha?: boolean | undefined;
  88504. /**
  88505. * Color of the line (Default: White)
  88506. */
  88507. color: Color3;
  88508. /**
  88509. * Alpha of the line (Default: 1)
  88510. */
  88511. alpha: number;
  88512. /**
  88513. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  88514. * This margin is expressed in world space coordinates, so its value may vary.
  88515. * Default value is 0.1
  88516. */
  88517. intersectionThreshold: number;
  88518. private _colorShader;
  88519. private color4;
  88520. /**
  88521. * Creates a new LinesMesh
  88522. * @param name defines the name
  88523. * @param scene defines the hosting scene
  88524. * @param parent defines the parent mesh if any
  88525. * @param source defines the optional source LinesMesh used to clone data from
  88526. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  88527. * When false, achieved by calling a clone(), also passing False.
  88528. * This will make creation of children, recursive.
  88529. * @param useVertexColor defines if this LinesMesh supports vertex color
  88530. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  88531. */
  88532. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  88533. /**
  88534. * If vertex color should be applied to the mesh
  88535. */
  88536. useVertexColor?: boolean | undefined,
  88537. /**
  88538. * If vertex alpha should be applied to the mesh
  88539. */
  88540. useVertexAlpha?: boolean | undefined);
  88541. private _addClipPlaneDefine;
  88542. private _removeClipPlaneDefine;
  88543. isReady(): boolean;
  88544. /**
  88545. * Returns the string "LineMesh"
  88546. */
  88547. getClassName(): string;
  88548. /**
  88549. * @hidden
  88550. */
  88551. /**
  88552. * @hidden
  88553. */
  88554. material: Material;
  88555. /**
  88556. * @hidden
  88557. */
  88558. readonly checkCollisions: boolean;
  88559. /** @hidden */
  88560. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  88561. /** @hidden */
  88562. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  88563. /**
  88564. * Disposes of the line mesh
  88565. * @param doNotRecurse If children should be disposed
  88566. */
  88567. dispose(doNotRecurse?: boolean): void;
  88568. /**
  88569. * Returns a new LineMesh object cloned from the current one.
  88570. */
  88571. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  88572. /**
  88573. * Creates a new InstancedLinesMesh object from the mesh model.
  88574. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  88575. * @param name defines the name of the new instance
  88576. * @returns a new InstancedLinesMesh
  88577. */
  88578. createInstance(name: string): InstancedLinesMesh;
  88579. }
  88580. /**
  88581. * Creates an instance based on a source LinesMesh
  88582. */
  88583. export class InstancedLinesMesh extends InstancedMesh {
  88584. /**
  88585. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  88586. * This margin is expressed in world space coordinates, so its value may vary.
  88587. * Initilized with the intersectionThreshold value of the source LinesMesh
  88588. */
  88589. intersectionThreshold: number;
  88590. constructor(name: string, source: LinesMesh);
  88591. /**
  88592. * Returns the string "InstancedLinesMesh".
  88593. */
  88594. getClassName(): string;
  88595. }
  88596. }
  88597. declare module BABYLON {
  88598. /** @hidden */
  88599. export var linePixelShader: {
  88600. name: string;
  88601. shader: string;
  88602. };
  88603. }
  88604. declare module BABYLON {
  88605. /** @hidden */
  88606. export var lineVertexShader: {
  88607. name: string;
  88608. shader: string;
  88609. };
  88610. }
  88611. declare module BABYLON {
  88612. interface AbstractMesh {
  88613. /**
  88614. * Gets the edgesRenderer associated with the mesh
  88615. */
  88616. edgesRenderer: Nullable<EdgesRenderer>;
  88617. }
  88618. interface LinesMesh {
  88619. /**
  88620. * Enables the edge rendering mode on the mesh.
  88621. * This mode makes the mesh edges visible
  88622. * @param epsilon defines the maximal distance between two angles to detect a face
  88623. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  88624. * @returns the currentAbstractMesh
  88625. * @see https://www.babylonjs-playground.com/#19O9TU#0
  88626. */
  88627. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  88628. }
  88629. interface InstancedLinesMesh {
  88630. /**
  88631. * Enables the edge rendering mode on the mesh.
  88632. * This mode makes the mesh edges visible
  88633. * @param epsilon defines the maximal distance between two angles to detect a face
  88634. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  88635. * @returns the current InstancedLinesMesh
  88636. * @see https://www.babylonjs-playground.com/#19O9TU#0
  88637. */
  88638. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  88639. }
  88640. /**
  88641. * Defines the minimum contract an Edges renderer should follow.
  88642. */
  88643. export interface IEdgesRenderer extends IDisposable {
  88644. /**
  88645. * Gets or sets a boolean indicating if the edgesRenderer is active
  88646. */
  88647. isEnabled: boolean;
  88648. /**
  88649. * Renders the edges of the attached mesh,
  88650. */
  88651. render(): void;
  88652. /**
  88653. * Checks wether or not the edges renderer is ready to render.
  88654. * @return true if ready, otherwise false.
  88655. */
  88656. isReady(): boolean;
  88657. }
  88658. /**
  88659. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  88660. */
  88661. export class EdgesRenderer implements IEdgesRenderer {
  88662. /**
  88663. * Define the size of the edges with an orthographic camera
  88664. */
  88665. edgesWidthScalerForOrthographic: number;
  88666. /**
  88667. * Define the size of the edges with a perspective camera
  88668. */
  88669. edgesWidthScalerForPerspective: number;
  88670. protected _source: AbstractMesh;
  88671. protected _linesPositions: number[];
  88672. protected _linesNormals: number[];
  88673. protected _linesIndices: number[];
  88674. protected _epsilon: number;
  88675. protected _indicesCount: number;
  88676. protected _lineShader: ShaderMaterial;
  88677. protected _ib: DataBuffer;
  88678. protected _buffers: {
  88679. [key: string]: Nullable<VertexBuffer>;
  88680. };
  88681. protected _checkVerticesInsteadOfIndices: boolean;
  88682. private _meshRebuildObserver;
  88683. private _meshDisposeObserver;
  88684. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  88685. isEnabled: boolean;
  88686. /**
  88687. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  88688. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  88689. * @param source Mesh used to create edges
  88690. * @param epsilon sum of angles in adjacency to check for edge
  88691. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  88692. * @param generateEdgesLines - should generate Lines or only prepare resources.
  88693. */
  88694. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  88695. protected _prepareRessources(): void;
  88696. /** @hidden */
  88697. _rebuild(): void;
  88698. /**
  88699. * Releases the required resources for the edges renderer
  88700. */
  88701. dispose(): void;
  88702. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  88703. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  88704. /**
  88705. * Checks if the pair of p0 and p1 is en edge
  88706. * @param faceIndex
  88707. * @param edge
  88708. * @param faceNormals
  88709. * @param p0
  88710. * @param p1
  88711. * @private
  88712. */
  88713. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  88714. /**
  88715. * push line into the position, normal and index buffer
  88716. * @protected
  88717. */
  88718. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  88719. /**
  88720. * Generates lines edges from adjacencjes
  88721. * @private
  88722. */
  88723. _generateEdgesLines(): void;
  88724. /**
  88725. * Checks wether or not the edges renderer is ready to render.
  88726. * @return true if ready, otherwise false.
  88727. */
  88728. isReady(): boolean;
  88729. /**
  88730. * Renders the edges of the attached mesh,
  88731. */
  88732. render(): void;
  88733. }
  88734. /**
  88735. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  88736. */
  88737. export class LineEdgesRenderer extends EdgesRenderer {
  88738. /**
  88739. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  88740. * @param source LineMesh used to generate edges
  88741. * @param epsilon not important (specified angle for edge detection)
  88742. * @param checkVerticesInsteadOfIndices not important for LineMesh
  88743. */
  88744. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  88745. /**
  88746. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  88747. */
  88748. _generateEdgesLines(): void;
  88749. }
  88750. }
  88751. declare module BABYLON {
  88752. /**
  88753. * This represents the object necessary to create a rendering group.
  88754. * This is exclusively used and created by the rendering manager.
  88755. * To modify the behavior, you use the available helpers in your scene or meshes.
  88756. * @hidden
  88757. */
  88758. export class RenderingGroup {
  88759. index: number;
  88760. private static _zeroVector;
  88761. private _scene;
  88762. private _opaqueSubMeshes;
  88763. private _transparentSubMeshes;
  88764. private _alphaTestSubMeshes;
  88765. private _depthOnlySubMeshes;
  88766. private _particleSystems;
  88767. private _spriteManagers;
  88768. private _opaqueSortCompareFn;
  88769. private _alphaTestSortCompareFn;
  88770. private _transparentSortCompareFn;
  88771. private _renderOpaque;
  88772. private _renderAlphaTest;
  88773. private _renderTransparent;
  88774. /** @hidden */
  88775. _edgesRenderers: SmartArray<IEdgesRenderer>;
  88776. onBeforeTransparentRendering: () => void;
  88777. /**
  88778. * Set the opaque sort comparison function.
  88779. * If null the sub meshes will be render in the order they were created
  88780. */
  88781. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  88782. /**
  88783. * Set the alpha test sort comparison function.
  88784. * If null the sub meshes will be render in the order they were created
  88785. */
  88786. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  88787. /**
  88788. * Set the transparent sort comparison function.
  88789. * If null the sub meshes will be render in the order they were created
  88790. */
  88791. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  88792. /**
  88793. * Creates a new rendering group.
  88794. * @param index The rendering group index
  88795. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  88796. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  88797. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  88798. */
  88799. 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>);
  88800. /**
  88801. * Render all the sub meshes contained in the group.
  88802. * @param customRenderFunction Used to override the default render behaviour of the group.
  88803. * @returns true if rendered some submeshes.
  88804. */
  88805. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  88806. /**
  88807. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  88808. * @param subMeshes The submeshes to render
  88809. */
  88810. private renderOpaqueSorted;
  88811. /**
  88812. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  88813. * @param subMeshes The submeshes to render
  88814. */
  88815. private renderAlphaTestSorted;
  88816. /**
  88817. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  88818. * @param subMeshes The submeshes to render
  88819. */
  88820. private renderTransparentSorted;
  88821. /**
  88822. * Renders the submeshes in a specified order.
  88823. * @param subMeshes The submeshes to sort before render
  88824. * @param sortCompareFn The comparison function use to sort
  88825. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  88826. * @param transparent Specifies to activate blending if true
  88827. */
  88828. private static renderSorted;
  88829. /**
  88830. * Renders the submeshes in the order they were dispatched (no sort applied).
  88831. * @param subMeshes The submeshes to render
  88832. */
  88833. private static renderUnsorted;
  88834. /**
  88835. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  88836. * are rendered back to front if in the same alpha index.
  88837. *
  88838. * @param a The first submesh
  88839. * @param b The second submesh
  88840. * @returns The result of the comparison
  88841. */
  88842. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  88843. /**
  88844. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  88845. * are rendered back to front.
  88846. *
  88847. * @param a The first submesh
  88848. * @param b The second submesh
  88849. * @returns The result of the comparison
  88850. */
  88851. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  88852. /**
  88853. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  88854. * are rendered front to back (prevent overdraw).
  88855. *
  88856. * @param a The first submesh
  88857. * @param b The second submesh
  88858. * @returns The result of the comparison
  88859. */
  88860. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  88861. /**
  88862. * Resets the different lists of submeshes to prepare a new frame.
  88863. */
  88864. prepare(): void;
  88865. dispose(): void;
  88866. /**
  88867. * Inserts the submesh in its correct queue depending on its material.
  88868. * @param subMesh The submesh to dispatch
  88869. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  88870. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  88871. */
  88872. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  88873. dispatchSprites(spriteManager: ISpriteManager): void;
  88874. dispatchParticles(particleSystem: IParticleSystem): void;
  88875. private _renderParticles;
  88876. private _renderSprites;
  88877. }
  88878. }
  88879. declare module BABYLON {
  88880. /**
  88881. * Interface describing the different options available in the rendering manager
  88882. * regarding Auto Clear between groups.
  88883. */
  88884. export interface IRenderingManagerAutoClearSetup {
  88885. /**
  88886. * Defines whether or not autoclear is enable.
  88887. */
  88888. autoClear: boolean;
  88889. /**
  88890. * Defines whether or not to autoclear the depth buffer.
  88891. */
  88892. depth: boolean;
  88893. /**
  88894. * Defines whether or not to autoclear the stencil buffer.
  88895. */
  88896. stencil: boolean;
  88897. }
  88898. /**
  88899. * This class is used by the onRenderingGroupObservable
  88900. */
  88901. export class RenderingGroupInfo {
  88902. /**
  88903. * The Scene that being rendered
  88904. */
  88905. scene: Scene;
  88906. /**
  88907. * The camera currently used for the rendering pass
  88908. */
  88909. camera: Nullable<Camera>;
  88910. /**
  88911. * The ID of the renderingGroup being processed
  88912. */
  88913. renderingGroupId: number;
  88914. }
  88915. /**
  88916. * This is the manager responsible of all the rendering for meshes sprites and particles.
  88917. * It is enable to manage the different groups as well as the different necessary sort functions.
  88918. * This should not be used directly aside of the few static configurations
  88919. */
  88920. export class RenderingManager {
  88921. /**
  88922. * The max id used for rendering groups (not included)
  88923. */
  88924. static MAX_RENDERINGGROUPS: number;
  88925. /**
  88926. * The min id used for rendering groups (included)
  88927. */
  88928. static MIN_RENDERINGGROUPS: number;
  88929. /**
  88930. * Used to globally prevent autoclearing scenes.
  88931. */
  88932. static AUTOCLEAR: boolean;
  88933. /**
  88934. * @hidden
  88935. */
  88936. _useSceneAutoClearSetup: boolean;
  88937. private _scene;
  88938. private _renderingGroups;
  88939. private _depthStencilBufferAlreadyCleaned;
  88940. private _autoClearDepthStencil;
  88941. private _customOpaqueSortCompareFn;
  88942. private _customAlphaTestSortCompareFn;
  88943. private _customTransparentSortCompareFn;
  88944. private _renderingGroupInfo;
  88945. /**
  88946. * Instantiates a new rendering group for a particular scene
  88947. * @param scene Defines the scene the groups belongs to
  88948. */
  88949. constructor(scene: Scene);
  88950. private _clearDepthStencilBuffer;
  88951. /**
  88952. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  88953. * @hidden
  88954. */
  88955. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  88956. /**
  88957. * Resets the different information of the group to prepare a new frame
  88958. * @hidden
  88959. */
  88960. reset(): void;
  88961. /**
  88962. * Dispose and release the group and its associated resources.
  88963. * @hidden
  88964. */
  88965. dispose(): void;
  88966. /**
  88967. * Clear the info related to rendering groups preventing retention points during dispose.
  88968. */
  88969. freeRenderingGroups(): void;
  88970. private _prepareRenderingGroup;
  88971. /**
  88972. * Add a sprite manager to the rendering manager in order to render it this frame.
  88973. * @param spriteManager Define the sprite manager to render
  88974. */
  88975. dispatchSprites(spriteManager: ISpriteManager): void;
  88976. /**
  88977. * Add a particle system to the rendering manager in order to render it this frame.
  88978. * @param particleSystem Define the particle system to render
  88979. */
  88980. dispatchParticles(particleSystem: IParticleSystem): void;
  88981. /**
  88982. * Add a submesh to the manager in order to render it this frame
  88983. * @param subMesh The submesh to dispatch
  88984. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  88985. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  88986. */
  88987. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  88988. /**
  88989. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  88990. * This allowed control for front to back rendering or reversly depending of the special needs.
  88991. *
  88992. * @param renderingGroupId The rendering group id corresponding to its index
  88993. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  88994. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  88995. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  88996. */
  88997. 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;
  88998. /**
  88999. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  89000. *
  89001. * @param renderingGroupId The rendering group id corresponding to its index
  89002. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  89003. * @param depth Automatically clears depth between groups if true and autoClear is true.
  89004. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  89005. */
  89006. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  89007. /**
  89008. * Gets the current auto clear configuration for one rendering group of the rendering
  89009. * manager.
  89010. * @param index the rendering group index to get the information for
  89011. * @returns The auto clear setup for the requested rendering group
  89012. */
  89013. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  89014. }
  89015. }
  89016. declare module BABYLON {
  89017. /**
  89018. * This Helps creating a texture that will be created from a camera in your scene.
  89019. * It is basically a dynamic texture that could be used to create special effects for instance.
  89020. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  89021. */
  89022. export class RenderTargetTexture extends Texture {
  89023. isCube: boolean;
  89024. /**
  89025. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  89026. */
  89027. static readonly REFRESHRATE_RENDER_ONCE: number;
  89028. /**
  89029. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  89030. */
  89031. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  89032. /**
  89033. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  89034. * the central point of your effect and can save a lot of performances.
  89035. */
  89036. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  89037. /**
  89038. * Use this predicate to dynamically define the list of mesh you want to render.
  89039. * If set, the renderList property will be overwritten.
  89040. */
  89041. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  89042. private _renderList;
  89043. /**
  89044. * Use this list to define the list of mesh you want to render.
  89045. */
  89046. renderList: Nullable<Array<AbstractMesh>>;
  89047. private _hookArray;
  89048. /**
  89049. * Define if particles should be rendered in your texture.
  89050. */
  89051. renderParticles: boolean;
  89052. /**
  89053. * Define if sprites should be rendered in your texture.
  89054. */
  89055. renderSprites: boolean;
  89056. /**
  89057. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  89058. */
  89059. coordinatesMode: number;
  89060. /**
  89061. * Define the camera used to render the texture.
  89062. */
  89063. activeCamera: Nullable<Camera>;
  89064. /**
  89065. * Override the render function of the texture with your own one.
  89066. */
  89067. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  89068. /**
  89069. * Define if camera post processes should be use while rendering the texture.
  89070. */
  89071. useCameraPostProcesses: boolean;
  89072. /**
  89073. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  89074. */
  89075. ignoreCameraViewport: boolean;
  89076. private _postProcessManager;
  89077. private _postProcesses;
  89078. private _resizeObserver;
  89079. /**
  89080. * An event triggered when the texture is unbind.
  89081. */
  89082. onBeforeBindObservable: Observable<RenderTargetTexture>;
  89083. /**
  89084. * An event triggered when the texture is unbind.
  89085. */
  89086. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  89087. private _onAfterUnbindObserver;
  89088. /**
  89089. * Set a after unbind callback in the texture.
  89090. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  89091. */
  89092. onAfterUnbind: () => void;
  89093. /**
  89094. * An event triggered before rendering the texture
  89095. */
  89096. onBeforeRenderObservable: Observable<number>;
  89097. private _onBeforeRenderObserver;
  89098. /**
  89099. * Set a before render callback in the texture.
  89100. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  89101. */
  89102. onBeforeRender: (faceIndex: number) => void;
  89103. /**
  89104. * An event triggered after rendering the texture
  89105. */
  89106. onAfterRenderObservable: Observable<number>;
  89107. private _onAfterRenderObserver;
  89108. /**
  89109. * Set a after render callback in the texture.
  89110. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  89111. */
  89112. onAfterRender: (faceIndex: number) => void;
  89113. /**
  89114. * An event triggered after the texture clear
  89115. */
  89116. onClearObservable: Observable<Engine>;
  89117. private _onClearObserver;
  89118. /**
  89119. * Set a clear callback in the texture.
  89120. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  89121. */
  89122. onClear: (Engine: Engine) => void;
  89123. /**
  89124. * An event triggered when the texture is resized.
  89125. */
  89126. onResizeObservable: Observable<RenderTargetTexture>;
  89127. /**
  89128. * Define the clear color of the Render Target if it should be different from the scene.
  89129. */
  89130. clearColor: Color4;
  89131. protected _size: number | {
  89132. width: number;
  89133. height: number;
  89134. };
  89135. protected _initialSizeParameter: number | {
  89136. width: number;
  89137. height: number;
  89138. } | {
  89139. ratio: number;
  89140. };
  89141. protected _sizeRatio: Nullable<number>;
  89142. /** @hidden */
  89143. _generateMipMaps: boolean;
  89144. protected _renderingManager: RenderingManager;
  89145. /** @hidden */
  89146. _waitingRenderList: string[];
  89147. protected _doNotChangeAspectRatio: boolean;
  89148. protected _currentRefreshId: number;
  89149. protected _refreshRate: number;
  89150. protected _textureMatrix: Matrix;
  89151. protected _samples: number;
  89152. protected _renderTargetOptions: RenderTargetCreationOptions;
  89153. /**
  89154. * Gets render target creation options that were used.
  89155. */
  89156. readonly renderTargetOptions: RenderTargetCreationOptions;
  89157. protected _engine: Engine;
  89158. protected _onRatioRescale(): void;
  89159. /**
  89160. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  89161. * It must define where the camera used to render the texture is set
  89162. */
  89163. boundingBoxPosition: Vector3;
  89164. private _boundingBoxSize;
  89165. /**
  89166. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  89167. * When defined, the cubemap will switch to local mode
  89168. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  89169. * @example https://www.babylonjs-playground.com/#RNASML
  89170. */
  89171. boundingBoxSize: Vector3;
  89172. /**
  89173. * In case the RTT has been created with a depth texture, get the associated
  89174. * depth texture.
  89175. * Otherwise, return null.
  89176. */
  89177. depthStencilTexture: Nullable<InternalTexture>;
  89178. /**
  89179. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  89180. * or used a shadow, depth texture...
  89181. * @param name The friendly name of the texture
  89182. * @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)
  89183. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  89184. * @param generateMipMaps True if mip maps need to be generated after render.
  89185. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  89186. * @param type The type of the buffer in the RTT (int, half float, float...)
  89187. * @param isCube True if a cube texture needs to be created
  89188. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  89189. * @param generateDepthBuffer True to generate a depth buffer
  89190. * @param generateStencilBuffer True to generate a stencil buffer
  89191. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  89192. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  89193. * @param delayAllocation if the texture allocation should be delayed (default: false)
  89194. */
  89195. constructor(name: string, size: number | {
  89196. width: number;
  89197. height: number;
  89198. } | {
  89199. ratio: number;
  89200. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  89201. /**
  89202. * Creates a depth stencil texture.
  89203. * This is only available in WebGL 2 or with the depth texture extension available.
  89204. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  89205. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  89206. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  89207. */
  89208. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  89209. private _processSizeParameter;
  89210. /**
  89211. * Define the number of samples to use in case of MSAA.
  89212. * It defaults to one meaning no MSAA has been enabled.
  89213. */
  89214. samples: number;
  89215. /**
  89216. * Resets the refresh counter of the texture and start bak from scratch.
  89217. * Could be useful to regenerate the texture if it is setup to render only once.
  89218. */
  89219. resetRefreshCounter(): void;
  89220. /**
  89221. * Define the refresh rate of the texture or the rendering frequency.
  89222. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  89223. */
  89224. refreshRate: number;
  89225. /**
  89226. * Adds a post process to the render target rendering passes.
  89227. * @param postProcess define the post process to add
  89228. */
  89229. addPostProcess(postProcess: PostProcess): void;
  89230. /**
  89231. * Clear all the post processes attached to the render target
  89232. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  89233. */
  89234. clearPostProcesses(dispose?: boolean): void;
  89235. /**
  89236. * Remove one of the post process from the list of attached post processes to the texture
  89237. * @param postProcess define the post process to remove from the list
  89238. */
  89239. removePostProcess(postProcess: PostProcess): void;
  89240. /** @hidden */
  89241. _shouldRender(): boolean;
  89242. /**
  89243. * Gets the actual render size of the texture.
  89244. * @returns the width of the render size
  89245. */
  89246. getRenderSize(): number;
  89247. /**
  89248. * Gets the actual render width of the texture.
  89249. * @returns the width of the render size
  89250. */
  89251. getRenderWidth(): number;
  89252. /**
  89253. * Gets the actual render height of the texture.
  89254. * @returns the height of the render size
  89255. */
  89256. getRenderHeight(): number;
  89257. /**
  89258. * Get if the texture can be rescaled or not.
  89259. */
  89260. readonly canRescale: boolean;
  89261. /**
  89262. * Resize the texture using a ratio.
  89263. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  89264. */
  89265. scale(ratio: number): void;
  89266. /**
  89267. * Get the texture reflection matrix used to rotate/transform the reflection.
  89268. * @returns the reflection matrix
  89269. */
  89270. getReflectionTextureMatrix(): Matrix;
  89271. /**
  89272. * Resize the texture to a new desired size.
  89273. * Be carrefull as it will recreate all the data in the new texture.
  89274. * @param size Define the new size. It can be:
  89275. * - a number for squared texture,
  89276. * - an object containing { width: number, height: number }
  89277. * - or an object containing a ratio { ratio: number }
  89278. */
  89279. resize(size: number | {
  89280. width: number;
  89281. height: number;
  89282. } | {
  89283. ratio: number;
  89284. }): void;
  89285. /**
  89286. * Renders all the objects from the render list into the texture.
  89287. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  89288. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  89289. */
  89290. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  89291. private _bestReflectionRenderTargetDimension;
  89292. /**
  89293. * @hidden
  89294. * @param faceIndex face index to bind to if this is a cubetexture
  89295. */
  89296. _bindFrameBuffer(faceIndex?: number): void;
  89297. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  89298. private renderToTarget;
  89299. /**
  89300. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  89301. * This allowed control for front to back rendering or reversly depending of the special needs.
  89302. *
  89303. * @param renderingGroupId The rendering group id corresponding to its index
  89304. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  89305. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  89306. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  89307. */
  89308. 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;
  89309. /**
  89310. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  89311. *
  89312. * @param renderingGroupId The rendering group id corresponding to its index
  89313. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  89314. */
  89315. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  89316. /**
  89317. * Clones the texture.
  89318. * @returns the cloned texture
  89319. */
  89320. clone(): RenderTargetTexture;
  89321. /**
  89322. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  89323. * @returns The JSON representation of the texture
  89324. */
  89325. serialize(): any;
  89326. /**
  89327. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  89328. */
  89329. disposeFramebufferObjects(): void;
  89330. /**
  89331. * Dispose the texture and release its associated resources.
  89332. */
  89333. dispose(): void;
  89334. /** @hidden */
  89335. _rebuild(): void;
  89336. /**
  89337. * Clear the info related to rendering groups preventing retention point in material dispose.
  89338. */
  89339. freeRenderingGroups(): void;
  89340. /**
  89341. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  89342. * @returns the view count
  89343. */
  89344. getViewCount(): number;
  89345. }
  89346. }
  89347. declare module BABYLON {
  89348. /**
  89349. * Options for compiling materials.
  89350. */
  89351. export interface IMaterialCompilationOptions {
  89352. /**
  89353. * Defines whether clip planes are enabled.
  89354. */
  89355. clipPlane: boolean;
  89356. /**
  89357. * Defines whether instances are enabled.
  89358. */
  89359. useInstances: boolean;
  89360. }
  89361. /**
  89362. * Base class for the main features of a material in Babylon.js
  89363. */
  89364. export class Material implements IAnimatable {
  89365. /**
  89366. * Returns the triangle fill mode
  89367. */
  89368. static readonly TriangleFillMode: number;
  89369. /**
  89370. * Returns the wireframe mode
  89371. */
  89372. static readonly WireFrameFillMode: number;
  89373. /**
  89374. * Returns the point fill mode
  89375. */
  89376. static readonly PointFillMode: number;
  89377. /**
  89378. * Returns the point list draw mode
  89379. */
  89380. static readonly PointListDrawMode: number;
  89381. /**
  89382. * Returns the line list draw mode
  89383. */
  89384. static readonly LineListDrawMode: number;
  89385. /**
  89386. * Returns the line loop draw mode
  89387. */
  89388. static readonly LineLoopDrawMode: number;
  89389. /**
  89390. * Returns the line strip draw mode
  89391. */
  89392. static readonly LineStripDrawMode: number;
  89393. /**
  89394. * Returns the triangle strip draw mode
  89395. */
  89396. static readonly TriangleStripDrawMode: number;
  89397. /**
  89398. * Returns the triangle fan draw mode
  89399. */
  89400. static readonly TriangleFanDrawMode: number;
  89401. /**
  89402. * Stores the clock-wise side orientation
  89403. */
  89404. static readonly ClockWiseSideOrientation: number;
  89405. /**
  89406. * Stores the counter clock-wise side orientation
  89407. */
  89408. static readonly CounterClockWiseSideOrientation: number;
  89409. /**
  89410. * The dirty texture flag value
  89411. */
  89412. static readonly TextureDirtyFlag: number;
  89413. /**
  89414. * The dirty light flag value
  89415. */
  89416. static readonly LightDirtyFlag: number;
  89417. /**
  89418. * The dirty fresnel flag value
  89419. */
  89420. static readonly FresnelDirtyFlag: number;
  89421. /**
  89422. * The dirty attribute flag value
  89423. */
  89424. static readonly AttributesDirtyFlag: number;
  89425. /**
  89426. * The dirty misc flag value
  89427. */
  89428. static readonly MiscDirtyFlag: number;
  89429. /**
  89430. * The all dirty flag value
  89431. */
  89432. static readonly AllDirtyFlag: number;
  89433. /**
  89434. * The ID of the material
  89435. */
  89436. id: string;
  89437. /**
  89438. * Gets or sets the unique id of the material
  89439. */
  89440. uniqueId: number;
  89441. /**
  89442. * The name of the material
  89443. */
  89444. name: string;
  89445. /**
  89446. * Gets or sets user defined metadata
  89447. */
  89448. metadata: any;
  89449. /**
  89450. * For internal use only. Please do not use.
  89451. */
  89452. reservedDataStore: any;
  89453. /**
  89454. * Specifies if the ready state should be checked on each call
  89455. */
  89456. checkReadyOnEveryCall: boolean;
  89457. /**
  89458. * Specifies if the ready state should be checked once
  89459. */
  89460. checkReadyOnlyOnce: boolean;
  89461. /**
  89462. * The state of the material
  89463. */
  89464. state: string;
  89465. /**
  89466. * The alpha value of the material
  89467. */
  89468. protected _alpha: number;
  89469. /**
  89470. * List of inspectable custom properties (used by the Inspector)
  89471. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  89472. */
  89473. inspectableCustomProperties: IInspectable[];
  89474. /**
  89475. * Sets the alpha value of the material
  89476. */
  89477. /**
  89478. * Gets the alpha value of the material
  89479. */
  89480. alpha: number;
  89481. /**
  89482. * Specifies if back face culling is enabled
  89483. */
  89484. protected _backFaceCulling: boolean;
  89485. /**
  89486. * Sets the back-face culling state
  89487. */
  89488. /**
  89489. * Gets the back-face culling state
  89490. */
  89491. backFaceCulling: boolean;
  89492. /**
  89493. * Stores the value for side orientation
  89494. */
  89495. sideOrientation: number;
  89496. /**
  89497. * Callback triggered when the material is compiled
  89498. */
  89499. onCompiled: Nullable<(effect: Effect) => void>;
  89500. /**
  89501. * Callback triggered when an error occurs
  89502. */
  89503. onError: Nullable<(effect: Effect, errors: string) => void>;
  89504. /**
  89505. * Callback triggered to get the render target textures
  89506. */
  89507. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  89508. /**
  89509. * Gets a boolean indicating that current material needs to register RTT
  89510. */
  89511. readonly hasRenderTargetTextures: boolean;
  89512. /**
  89513. * Specifies if the material should be serialized
  89514. */
  89515. doNotSerialize: boolean;
  89516. /**
  89517. * @hidden
  89518. */
  89519. _storeEffectOnSubMeshes: boolean;
  89520. /**
  89521. * Stores the animations for the material
  89522. */
  89523. animations: Nullable<Array<Animation>>;
  89524. /**
  89525. * An event triggered when the material is disposed
  89526. */
  89527. onDisposeObservable: Observable<Material>;
  89528. /**
  89529. * An observer which watches for dispose events
  89530. */
  89531. private _onDisposeObserver;
  89532. private _onUnBindObservable;
  89533. /**
  89534. * Called during a dispose event
  89535. */
  89536. onDispose: () => void;
  89537. private _onBindObservable;
  89538. /**
  89539. * An event triggered when the material is bound
  89540. */
  89541. readonly onBindObservable: Observable<AbstractMesh>;
  89542. /**
  89543. * An observer which watches for bind events
  89544. */
  89545. private _onBindObserver;
  89546. /**
  89547. * Called during a bind event
  89548. */
  89549. onBind: (Mesh: AbstractMesh) => void;
  89550. /**
  89551. * An event triggered when the material is unbound
  89552. */
  89553. readonly onUnBindObservable: Observable<Material>;
  89554. /**
  89555. * Stores the value of the alpha mode
  89556. */
  89557. private _alphaMode;
  89558. /**
  89559. * Sets the value of the alpha mode.
  89560. *
  89561. * | Value | Type | Description |
  89562. * | --- | --- | --- |
  89563. * | 0 | ALPHA_DISABLE | |
  89564. * | 1 | ALPHA_ADD | |
  89565. * | 2 | ALPHA_COMBINE | |
  89566. * | 3 | ALPHA_SUBTRACT | |
  89567. * | 4 | ALPHA_MULTIPLY | |
  89568. * | 5 | ALPHA_MAXIMIZED | |
  89569. * | 6 | ALPHA_ONEONE | |
  89570. * | 7 | ALPHA_PREMULTIPLIED | |
  89571. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  89572. * | 9 | ALPHA_INTERPOLATE | |
  89573. * | 10 | ALPHA_SCREENMODE | |
  89574. *
  89575. */
  89576. /**
  89577. * Gets the value of the alpha mode
  89578. */
  89579. alphaMode: number;
  89580. /**
  89581. * Stores the state of the need depth pre-pass value
  89582. */
  89583. private _needDepthPrePass;
  89584. /**
  89585. * Sets the need depth pre-pass value
  89586. */
  89587. /**
  89588. * Gets the depth pre-pass value
  89589. */
  89590. needDepthPrePass: boolean;
  89591. /**
  89592. * Specifies if depth writing should be disabled
  89593. */
  89594. disableDepthWrite: boolean;
  89595. /**
  89596. * Specifies if depth writing should be forced
  89597. */
  89598. forceDepthWrite: boolean;
  89599. /**
  89600. * Specifies the depth function that should be used. 0 means the default engine function
  89601. */
  89602. depthFunction: number;
  89603. /**
  89604. * Specifies if there should be a separate pass for culling
  89605. */
  89606. separateCullingPass: boolean;
  89607. /**
  89608. * Stores the state specifing if fog should be enabled
  89609. */
  89610. private _fogEnabled;
  89611. /**
  89612. * Sets the state for enabling fog
  89613. */
  89614. /**
  89615. * Gets the value of the fog enabled state
  89616. */
  89617. fogEnabled: boolean;
  89618. /**
  89619. * Stores the size of points
  89620. */
  89621. pointSize: number;
  89622. /**
  89623. * Stores the z offset value
  89624. */
  89625. zOffset: number;
  89626. /**
  89627. * Gets a value specifying if wireframe mode is enabled
  89628. */
  89629. /**
  89630. * Sets the state of wireframe mode
  89631. */
  89632. wireframe: boolean;
  89633. /**
  89634. * Gets the value specifying if point clouds are enabled
  89635. */
  89636. /**
  89637. * Sets the state of point cloud mode
  89638. */
  89639. pointsCloud: boolean;
  89640. /**
  89641. * Gets the material fill mode
  89642. */
  89643. /**
  89644. * Sets the material fill mode
  89645. */
  89646. fillMode: number;
  89647. /**
  89648. * @hidden
  89649. * Stores the effects for the material
  89650. */
  89651. _effect: Nullable<Effect>;
  89652. /**
  89653. * @hidden
  89654. * Specifies if the material was previously ready
  89655. */
  89656. _wasPreviouslyReady: boolean;
  89657. /**
  89658. * Specifies if uniform buffers should be used
  89659. */
  89660. private _useUBO;
  89661. /**
  89662. * Stores a reference to the scene
  89663. */
  89664. private _scene;
  89665. /**
  89666. * Stores the fill mode state
  89667. */
  89668. private _fillMode;
  89669. /**
  89670. * Specifies if the depth write state should be cached
  89671. */
  89672. private _cachedDepthWriteState;
  89673. /**
  89674. * Specifies if the depth function state should be cached
  89675. */
  89676. private _cachedDepthFunctionState;
  89677. /**
  89678. * Stores the uniform buffer
  89679. */
  89680. protected _uniformBuffer: UniformBuffer;
  89681. /** @hidden */
  89682. _indexInSceneMaterialArray: number;
  89683. /** @hidden */
  89684. meshMap: Nullable<{
  89685. [id: string]: AbstractMesh | undefined;
  89686. }>;
  89687. /**
  89688. * Creates a material instance
  89689. * @param name defines the name of the material
  89690. * @param scene defines the scene to reference
  89691. * @param doNotAdd specifies if the material should be added to the scene
  89692. */
  89693. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  89694. /**
  89695. * Returns a string representation of the current material
  89696. * @param fullDetails defines a boolean indicating which levels of logging is desired
  89697. * @returns a string with material information
  89698. */
  89699. toString(fullDetails?: boolean): string;
  89700. /**
  89701. * Gets the class name of the material
  89702. * @returns a string with the class name of the material
  89703. */
  89704. getClassName(): string;
  89705. /**
  89706. * Specifies if updates for the material been locked
  89707. */
  89708. readonly isFrozen: boolean;
  89709. /**
  89710. * Locks updates for the material
  89711. */
  89712. freeze(): void;
  89713. /**
  89714. * Unlocks updates for the material
  89715. */
  89716. unfreeze(): void;
  89717. /**
  89718. * Specifies if the material is ready to be used
  89719. * @param mesh defines the mesh to check
  89720. * @param useInstances specifies if instances should be used
  89721. * @returns a boolean indicating if the material is ready to be used
  89722. */
  89723. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  89724. /**
  89725. * Specifies that the submesh is ready to be used
  89726. * @param mesh defines the mesh to check
  89727. * @param subMesh defines which submesh to check
  89728. * @param useInstances specifies that instances should be used
  89729. * @returns a boolean indicating that the submesh is ready or not
  89730. */
  89731. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  89732. /**
  89733. * Returns the material effect
  89734. * @returns the effect associated with the material
  89735. */
  89736. getEffect(): Nullable<Effect>;
  89737. /**
  89738. * Returns the current scene
  89739. * @returns a Scene
  89740. */
  89741. getScene(): Scene;
  89742. /**
  89743. * Specifies if the material will require alpha blending
  89744. * @returns a boolean specifying if alpha blending is needed
  89745. */
  89746. needAlphaBlending(): boolean;
  89747. /**
  89748. * Specifies if the mesh will require alpha blending
  89749. * @param mesh defines the mesh to check
  89750. * @returns a boolean specifying if alpha blending is needed for the mesh
  89751. */
  89752. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  89753. /**
  89754. * Specifies if this material should be rendered in alpha test mode
  89755. * @returns a boolean specifying if an alpha test is needed.
  89756. */
  89757. needAlphaTesting(): boolean;
  89758. /**
  89759. * Gets the texture used for the alpha test
  89760. * @returns the texture to use for alpha testing
  89761. */
  89762. getAlphaTestTexture(): Nullable<BaseTexture>;
  89763. /**
  89764. * Marks the material to indicate that it needs to be re-calculated
  89765. */
  89766. markDirty(): void;
  89767. /** @hidden */
  89768. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  89769. /**
  89770. * Binds the material to the mesh
  89771. * @param world defines the world transformation matrix
  89772. * @param mesh defines the mesh to bind the material to
  89773. */
  89774. bind(world: Matrix, mesh?: Mesh): void;
  89775. /**
  89776. * Binds the submesh to the material
  89777. * @param world defines the world transformation matrix
  89778. * @param mesh defines the mesh containing the submesh
  89779. * @param subMesh defines the submesh to bind the material to
  89780. */
  89781. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  89782. /**
  89783. * Binds the world matrix to the material
  89784. * @param world defines the world transformation matrix
  89785. */
  89786. bindOnlyWorldMatrix(world: Matrix): void;
  89787. /**
  89788. * Binds the scene's uniform buffer to the effect.
  89789. * @param effect defines the effect to bind to the scene uniform buffer
  89790. * @param sceneUbo defines the uniform buffer storing scene data
  89791. */
  89792. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  89793. /**
  89794. * Binds the view matrix to the effect
  89795. * @param effect defines the effect to bind the view matrix to
  89796. */
  89797. bindView(effect: Effect): void;
  89798. /**
  89799. * Binds the view projection matrix to the effect
  89800. * @param effect defines the effect to bind the view projection matrix to
  89801. */
  89802. bindViewProjection(effect: Effect): void;
  89803. /**
  89804. * Specifies if material alpha testing should be turned on for the mesh
  89805. * @param mesh defines the mesh to check
  89806. */
  89807. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  89808. /**
  89809. * Processes to execute after binding the material to a mesh
  89810. * @param mesh defines the rendered mesh
  89811. */
  89812. protected _afterBind(mesh?: Mesh): void;
  89813. /**
  89814. * Unbinds the material from the mesh
  89815. */
  89816. unbind(): void;
  89817. /**
  89818. * Gets the active textures from the material
  89819. * @returns an array of textures
  89820. */
  89821. getActiveTextures(): BaseTexture[];
  89822. /**
  89823. * Specifies if the material uses a texture
  89824. * @param texture defines the texture to check against the material
  89825. * @returns a boolean specifying if the material uses the texture
  89826. */
  89827. hasTexture(texture: BaseTexture): boolean;
  89828. /**
  89829. * Makes a duplicate of the material, and gives it a new name
  89830. * @param name defines the new name for the duplicated material
  89831. * @returns the cloned material
  89832. */
  89833. clone(name: string): Nullable<Material>;
  89834. /**
  89835. * Gets the meshes bound to the material
  89836. * @returns an array of meshes bound to the material
  89837. */
  89838. getBindedMeshes(): AbstractMesh[];
  89839. /**
  89840. * Force shader compilation
  89841. * @param mesh defines the mesh associated with this material
  89842. * @param onCompiled defines a function to execute once the material is compiled
  89843. * @param options defines the options to configure the compilation
  89844. * @param onError defines a function to execute if the material fails compiling
  89845. */
  89846. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  89847. /**
  89848. * Force shader compilation
  89849. * @param mesh defines the mesh that will use this material
  89850. * @param options defines additional options for compiling the shaders
  89851. * @returns a promise that resolves when the compilation completes
  89852. */
  89853. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  89854. private static readonly _AllDirtyCallBack;
  89855. private static readonly _ImageProcessingDirtyCallBack;
  89856. private static readonly _TextureDirtyCallBack;
  89857. private static readonly _FresnelDirtyCallBack;
  89858. private static readonly _MiscDirtyCallBack;
  89859. private static readonly _LightsDirtyCallBack;
  89860. private static readonly _AttributeDirtyCallBack;
  89861. private static _FresnelAndMiscDirtyCallBack;
  89862. private static _TextureAndMiscDirtyCallBack;
  89863. private static readonly _DirtyCallbackArray;
  89864. private static readonly _RunDirtyCallBacks;
  89865. /**
  89866. * Marks a define in the material to indicate that it needs to be re-computed
  89867. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  89868. */
  89869. markAsDirty(flag: number): void;
  89870. /**
  89871. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  89872. * @param func defines a function which checks material defines against the submeshes
  89873. */
  89874. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  89875. /**
  89876. * Indicates that we need to re-calculated for all submeshes
  89877. */
  89878. protected _markAllSubMeshesAsAllDirty(): void;
  89879. /**
  89880. * Indicates that image processing needs to be re-calculated for all submeshes
  89881. */
  89882. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  89883. /**
  89884. * Indicates that textures need to be re-calculated for all submeshes
  89885. */
  89886. protected _markAllSubMeshesAsTexturesDirty(): void;
  89887. /**
  89888. * Indicates that fresnel needs to be re-calculated for all submeshes
  89889. */
  89890. protected _markAllSubMeshesAsFresnelDirty(): void;
  89891. /**
  89892. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  89893. */
  89894. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  89895. /**
  89896. * Indicates that lights need to be re-calculated for all submeshes
  89897. */
  89898. protected _markAllSubMeshesAsLightsDirty(): void;
  89899. /**
  89900. * Indicates that attributes need to be re-calculated for all submeshes
  89901. */
  89902. protected _markAllSubMeshesAsAttributesDirty(): void;
  89903. /**
  89904. * Indicates that misc needs to be re-calculated for all submeshes
  89905. */
  89906. protected _markAllSubMeshesAsMiscDirty(): void;
  89907. /**
  89908. * Indicates that textures and misc need to be re-calculated for all submeshes
  89909. */
  89910. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  89911. /**
  89912. * Disposes the material
  89913. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  89914. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  89915. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  89916. */
  89917. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  89918. /** @hidden */
  89919. private releaseVertexArrayObject;
  89920. /**
  89921. * Serializes this material
  89922. * @returns the serialized material object
  89923. */
  89924. serialize(): any;
  89925. /**
  89926. * Creates a material from parsed material data
  89927. * @param parsedMaterial defines parsed material data
  89928. * @param scene defines the hosting scene
  89929. * @param rootUrl defines the root URL to use to load textures
  89930. * @returns a new material
  89931. */
  89932. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  89933. }
  89934. }
  89935. declare module BABYLON {
  89936. /**
  89937. * A multi-material is used to apply different materials to different parts of the same object without the need of
  89938. * separate meshes. This can be use to improve performances.
  89939. * @see http://doc.babylonjs.com/how_to/multi_materials
  89940. */
  89941. export class MultiMaterial extends Material {
  89942. private _subMaterials;
  89943. /**
  89944. * Gets or Sets the list of Materials used within the multi material.
  89945. * They need to be ordered according to the submeshes order in the associated mesh
  89946. */
  89947. subMaterials: Nullable<Material>[];
  89948. /**
  89949. * Function used to align with Node.getChildren()
  89950. * @returns the list of Materials used within the multi material
  89951. */
  89952. getChildren(): Nullable<Material>[];
  89953. /**
  89954. * Instantiates a new Multi Material
  89955. * A multi-material is used to apply different materials to different parts of the same object without the need of
  89956. * separate meshes. This can be use to improve performances.
  89957. * @see http://doc.babylonjs.com/how_to/multi_materials
  89958. * @param name Define the name in the scene
  89959. * @param scene Define the scene the material belongs to
  89960. */
  89961. constructor(name: string, scene: Scene);
  89962. private _hookArray;
  89963. /**
  89964. * Get one of the submaterial by its index in the submaterials array
  89965. * @param index The index to look the sub material at
  89966. * @returns The Material if the index has been defined
  89967. */
  89968. getSubMaterial(index: number): Nullable<Material>;
  89969. /**
  89970. * Get the list of active textures for the whole sub materials list.
  89971. * @returns All the textures that will be used during the rendering
  89972. */
  89973. getActiveTextures(): BaseTexture[];
  89974. /**
  89975. * Gets the current class name of the material e.g. "MultiMaterial"
  89976. * Mainly use in serialization.
  89977. * @returns the class name
  89978. */
  89979. getClassName(): string;
  89980. /**
  89981. * Checks if the material is ready to render the requested sub mesh
  89982. * @param mesh Define the mesh the submesh belongs to
  89983. * @param subMesh Define the sub mesh to look readyness for
  89984. * @param useInstances Define whether or not the material is used with instances
  89985. * @returns true if ready, otherwise false
  89986. */
  89987. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  89988. /**
  89989. * Clones the current material and its related sub materials
  89990. * @param name Define the name of the newly cloned material
  89991. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  89992. * @returns the cloned material
  89993. */
  89994. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  89995. /**
  89996. * Serializes the materials into a JSON representation.
  89997. * @returns the JSON representation
  89998. */
  89999. serialize(): any;
  90000. /**
  90001. * Dispose the material and release its associated resources
  90002. * @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)
  90003. * @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)
  90004. * @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)
  90005. */
  90006. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  90007. /**
  90008. * Creates a MultiMaterial from parsed MultiMaterial data.
  90009. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  90010. * @param scene defines the hosting scene
  90011. * @returns a new MultiMaterial
  90012. */
  90013. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  90014. }
  90015. }
  90016. declare module BABYLON {
  90017. /**
  90018. * Base class for submeshes
  90019. */
  90020. export class BaseSubMesh {
  90021. /** @hidden */
  90022. _materialDefines: Nullable<MaterialDefines>;
  90023. /** @hidden */
  90024. _materialEffect: Nullable<Effect>;
  90025. /**
  90026. * Gets material defines used by the effect associated to the sub mesh
  90027. */
  90028. /**
  90029. * Sets material defines used by the effect associated to the sub mesh
  90030. */
  90031. materialDefines: Nullable<MaterialDefines>;
  90032. /**
  90033. * Gets associated effect
  90034. */
  90035. readonly effect: Nullable<Effect>;
  90036. /**
  90037. * Sets associated effect (effect used to render this submesh)
  90038. * @param effect defines the effect to associate with
  90039. * @param defines defines the set of defines used to compile this effect
  90040. */
  90041. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  90042. }
  90043. /**
  90044. * Defines a subdivision inside a mesh
  90045. */
  90046. export class SubMesh extends BaseSubMesh implements ICullable {
  90047. /** the material index to use */
  90048. materialIndex: number;
  90049. /** vertex index start */
  90050. verticesStart: number;
  90051. /** vertices count */
  90052. verticesCount: number;
  90053. /** index start */
  90054. indexStart: number;
  90055. /** indices count */
  90056. indexCount: number;
  90057. /** @hidden */
  90058. _linesIndexCount: number;
  90059. private _mesh;
  90060. private _renderingMesh;
  90061. private _boundingInfo;
  90062. private _linesIndexBuffer;
  90063. /** @hidden */
  90064. _lastColliderWorldVertices: Nullable<Vector3[]>;
  90065. /** @hidden */
  90066. _trianglePlanes: Plane[];
  90067. /** @hidden */
  90068. _lastColliderTransformMatrix: Nullable<Matrix>;
  90069. /** @hidden */
  90070. _renderId: number;
  90071. /** @hidden */
  90072. _alphaIndex: number;
  90073. /** @hidden */
  90074. _distanceToCamera: number;
  90075. /** @hidden */
  90076. _id: number;
  90077. private _currentMaterial;
  90078. /**
  90079. * Add a new submesh to a mesh
  90080. * @param materialIndex defines the material index to use
  90081. * @param verticesStart defines vertex index start
  90082. * @param verticesCount defines vertices count
  90083. * @param indexStart defines index start
  90084. * @param indexCount defines indices count
  90085. * @param mesh defines the parent mesh
  90086. * @param renderingMesh defines an optional rendering mesh
  90087. * @param createBoundingBox defines if bounding box should be created for this submesh
  90088. * @returns the new submesh
  90089. */
  90090. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  90091. /**
  90092. * Creates a new submesh
  90093. * @param materialIndex defines the material index to use
  90094. * @param verticesStart defines vertex index start
  90095. * @param verticesCount defines vertices count
  90096. * @param indexStart defines index start
  90097. * @param indexCount defines indices count
  90098. * @param mesh defines the parent mesh
  90099. * @param renderingMesh defines an optional rendering mesh
  90100. * @param createBoundingBox defines if bounding box should be created for this submesh
  90101. */
  90102. constructor(
  90103. /** the material index to use */
  90104. materialIndex: number,
  90105. /** vertex index start */
  90106. verticesStart: number,
  90107. /** vertices count */
  90108. verticesCount: number,
  90109. /** index start */
  90110. indexStart: number,
  90111. /** indices count */
  90112. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  90113. /**
  90114. * Returns true if this submesh covers the entire parent mesh
  90115. * @ignorenaming
  90116. */
  90117. readonly IsGlobal: boolean;
  90118. /**
  90119. * Returns the submesh BoudingInfo object
  90120. * @returns current bounding info (or mesh's one if the submesh is global)
  90121. */
  90122. getBoundingInfo(): BoundingInfo;
  90123. /**
  90124. * Sets the submesh BoundingInfo
  90125. * @param boundingInfo defines the new bounding info to use
  90126. * @returns the SubMesh
  90127. */
  90128. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  90129. /**
  90130. * Returns the mesh of the current submesh
  90131. * @return the parent mesh
  90132. */
  90133. getMesh(): AbstractMesh;
  90134. /**
  90135. * Returns the rendering mesh of the submesh
  90136. * @returns the rendering mesh (could be different from parent mesh)
  90137. */
  90138. getRenderingMesh(): Mesh;
  90139. /**
  90140. * Returns the submesh material
  90141. * @returns null or the current material
  90142. */
  90143. getMaterial(): Nullable<Material>;
  90144. /**
  90145. * Sets a new updated BoundingInfo object to the submesh
  90146. * @param data defines an optional position array to use to determine the bounding info
  90147. * @returns the SubMesh
  90148. */
  90149. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  90150. /** @hidden */
  90151. _checkCollision(collider: Collider): boolean;
  90152. /**
  90153. * Updates the submesh BoundingInfo
  90154. * @param world defines the world matrix to use to update the bounding info
  90155. * @returns the submesh
  90156. */
  90157. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  90158. /**
  90159. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  90160. * @param frustumPlanes defines the frustum planes
  90161. * @returns true if the submesh is intersecting with the frustum
  90162. */
  90163. isInFrustum(frustumPlanes: Plane[]): boolean;
  90164. /**
  90165. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  90166. * @param frustumPlanes defines the frustum planes
  90167. * @returns true if the submesh is inside the frustum
  90168. */
  90169. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  90170. /**
  90171. * Renders the submesh
  90172. * @param enableAlphaMode defines if alpha needs to be used
  90173. * @returns the submesh
  90174. */
  90175. render(enableAlphaMode: boolean): SubMesh;
  90176. /**
  90177. * @hidden
  90178. */
  90179. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  90180. /**
  90181. * Checks if the submesh intersects with a ray
  90182. * @param ray defines the ray to test
  90183. * @returns true is the passed ray intersects the submesh bounding box
  90184. */
  90185. canIntersects(ray: Ray): boolean;
  90186. /**
  90187. * Intersects current submesh with a ray
  90188. * @param ray defines the ray to test
  90189. * @param positions defines mesh's positions array
  90190. * @param indices defines mesh's indices array
  90191. * @param fastCheck defines if only bounding info should be used
  90192. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90193. * @returns intersection info or null if no intersection
  90194. */
  90195. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  90196. /** @hidden */
  90197. private _intersectLines;
  90198. /** @hidden */
  90199. private _intersectUnIndexedLines;
  90200. /** @hidden */
  90201. private _intersectTriangles;
  90202. /** @hidden */
  90203. private _intersectUnIndexedTriangles;
  90204. /** @hidden */
  90205. _rebuild(): void;
  90206. /**
  90207. * Creates a new submesh from the passed mesh
  90208. * @param newMesh defines the new hosting mesh
  90209. * @param newRenderingMesh defines an optional rendering mesh
  90210. * @returns the new submesh
  90211. */
  90212. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  90213. /**
  90214. * Release associated resources
  90215. */
  90216. dispose(): void;
  90217. /**
  90218. * Gets the class name
  90219. * @returns the string "SubMesh".
  90220. */
  90221. getClassName(): string;
  90222. /**
  90223. * Creates a new submesh from indices data
  90224. * @param materialIndex the index of the main mesh material
  90225. * @param startIndex the index where to start the copy in the mesh indices array
  90226. * @param indexCount the number of indices to copy then from the startIndex
  90227. * @param mesh the main mesh to create the submesh from
  90228. * @param renderingMesh the optional rendering mesh
  90229. * @returns a new submesh
  90230. */
  90231. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  90232. }
  90233. }
  90234. declare module BABYLON {
  90235. /**
  90236. * Class used to represent data loading progression
  90237. */
  90238. export class SceneLoaderFlags {
  90239. private static _ForceFullSceneLoadingForIncremental;
  90240. private static _ShowLoadingScreen;
  90241. private static _CleanBoneMatrixWeights;
  90242. private static _loggingLevel;
  90243. /**
  90244. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  90245. */
  90246. static ForceFullSceneLoadingForIncremental: boolean;
  90247. /**
  90248. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  90249. */
  90250. static ShowLoadingScreen: boolean;
  90251. /**
  90252. * Defines the current logging level (while loading the scene)
  90253. * @ignorenaming
  90254. */
  90255. static loggingLevel: number;
  90256. /**
  90257. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  90258. */
  90259. static CleanBoneMatrixWeights: boolean;
  90260. }
  90261. }
  90262. declare module BABYLON {
  90263. /**
  90264. * Class used to store geometry data (vertex buffers + index buffer)
  90265. */
  90266. export class Geometry implements IGetSetVerticesData {
  90267. /**
  90268. * Gets or sets the ID of the geometry
  90269. */
  90270. id: string;
  90271. /**
  90272. * Gets or sets the unique ID of the geometry
  90273. */
  90274. uniqueId: number;
  90275. /**
  90276. * Gets the delay loading state of the geometry (none by default which means not delayed)
  90277. */
  90278. delayLoadState: number;
  90279. /**
  90280. * Gets the file containing the data to load when running in delay load state
  90281. */
  90282. delayLoadingFile: Nullable<string>;
  90283. /**
  90284. * Callback called when the geometry is updated
  90285. */
  90286. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  90287. private _scene;
  90288. private _engine;
  90289. private _meshes;
  90290. private _totalVertices;
  90291. /** @hidden */
  90292. _indices: IndicesArray;
  90293. /** @hidden */
  90294. _vertexBuffers: {
  90295. [key: string]: VertexBuffer;
  90296. };
  90297. private _isDisposed;
  90298. private _extend;
  90299. private _boundingBias;
  90300. /** @hidden */
  90301. _delayInfo: Array<string>;
  90302. private _indexBuffer;
  90303. private _indexBufferIsUpdatable;
  90304. /** @hidden */
  90305. _boundingInfo: Nullable<BoundingInfo>;
  90306. /** @hidden */
  90307. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  90308. /** @hidden */
  90309. _softwareSkinningFrameId: number;
  90310. private _vertexArrayObjects;
  90311. private _updatable;
  90312. /** @hidden */
  90313. _positions: Nullable<Vector3[]>;
  90314. /**
  90315. * 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
  90316. */
  90317. /**
  90318. * 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
  90319. */
  90320. boundingBias: Vector2;
  90321. /**
  90322. * Static function used to attach a new empty geometry to a mesh
  90323. * @param mesh defines the mesh to attach the geometry to
  90324. * @returns the new Geometry
  90325. */
  90326. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  90327. /**
  90328. * Creates a new geometry
  90329. * @param id defines the unique ID
  90330. * @param scene defines the hosting scene
  90331. * @param vertexData defines the VertexData used to get geometry data
  90332. * @param updatable defines if geometry must be updatable (false by default)
  90333. * @param mesh defines the mesh that will be associated with the geometry
  90334. */
  90335. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  90336. /**
  90337. * Gets the current extend of the geometry
  90338. */
  90339. readonly extend: {
  90340. minimum: Vector3;
  90341. maximum: Vector3;
  90342. };
  90343. /**
  90344. * Gets the hosting scene
  90345. * @returns the hosting Scene
  90346. */
  90347. getScene(): Scene;
  90348. /**
  90349. * Gets the hosting engine
  90350. * @returns the hosting Engine
  90351. */
  90352. getEngine(): Engine;
  90353. /**
  90354. * Defines if the geometry is ready to use
  90355. * @returns true if the geometry is ready to be used
  90356. */
  90357. isReady(): boolean;
  90358. /**
  90359. * Gets a value indicating that the geometry should not be serialized
  90360. */
  90361. readonly doNotSerialize: boolean;
  90362. /** @hidden */
  90363. _rebuild(): void;
  90364. /**
  90365. * Affects all geometry data in one call
  90366. * @param vertexData defines the geometry data
  90367. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  90368. */
  90369. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  90370. /**
  90371. * Set specific vertex data
  90372. * @param kind defines the data kind (Position, normal, etc...)
  90373. * @param data defines the vertex data to use
  90374. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  90375. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  90376. */
  90377. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  90378. /**
  90379. * Removes a specific vertex data
  90380. * @param kind defines the data kind (Position, normal, etc...)
  90381. */
  90382. removeVerticesData(kind: string): void;
  90383. /**
  90384. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  90385. * @param buffer defines the vertex buffer to use
  90386. * @param totalVertices defines the total number of vertices for position kind (could be null)
  90387. */
  90388. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  90389. /**
  90390. * Update a specific vertex buffer
  90391. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  90392. * It will do nothing if the buffer is not updatable
  90393. * @param kind defines the data kind (Position, normal, etc...)
  90394. * @param data defines the data to use
  90395. * @param offset defines the offset in the target buffer where to store the data
  90396. * @param useBytes set to true if the offset is in bytes
  90397. */
  90398. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  90399. /**
  90400. * Update a specific vertex buffer
  90401. * This function will create a new buffer if the current one is not updatable
  90402. * @param kind defines the data kind (Position, normal, etc...)
  90403. * @param data defines the data to use
  90404. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  90405. */
  90406. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  90407. private _updateBoundingInfo;
  90408. /** @hidden */
  90409. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  90410. /**
  90411. * Gets total number of vertices
  90412. * @returns the total number of vertices
  90413. */
  90414. getTotalVertices(): number;
  90415. /**
  90416. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  90417. * @param kind defines the data kind (Position, normal, etc...)
  90418. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  90419. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90420. * @returns a float array containing vertex data
  90421. */
  90422. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  90423. /**
  90424. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  90425. * @param kind defines the data kind (Position, normal, etc...)
  90426. * @returns true if the vertex buffer with the specified kind is updatable
  90427. */
  90428. isVertexBufferUpdatable(kind: string): boolean;
  90429. /**
  90430. * Gets a specific vertex buffer
  90431. * @param kind defines the data kind (Position, normal, etc...)
  90432. * @returns a VertexBuffer
  90433. */
  90434. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  90435. /**
  90436. * Returns all vertex buffers
  90437. * @return an object holding all vertex buffers indexed by kind
  90438. */
  90439. getVertexBuffers(): Nullable<{
  90440. [key: string]: VertexBuffer;
  90441. }>;
  90442. /**
  90443. * Gets a boolean indicating if specific vertex buffer is present
  90444. * @param kind defines the data kind (Position, normal, etc...)
  90445. * @returns true if data is present
  90446. */
  90447. isVerticesDataPresent(kind: string): boolean;
  90448. /**
  90449. * Gets a list of all attached data kinds (Position, normal, etc...)
  90450. * @returns a list of string containing all kinds
  90451. */
  90452. getVerticesDataKinds(): string[];
  90453. /**
  90454. * Update index buffer
  90455. * @param indices defines the indices to store in the index buffer
  90456. * @param offset defines the offset in the target buffer where to store the data
  90457. * @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)
  90458. */
  90459. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  90460. /**
  90461. * Creates a new index buffer
  90462. * @param indices defines the indices to store in the index buffer
  90463. * @param totalVertices defines the total number of vertices (could be null)
  90464. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  90465. */
  90466. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  90467. /**
  90468. * Return the total number of indices
  90469. * @returns the total number of indices
  90470. */
  90471. getTotalIndices(): number;
  90472. /**
  90473. * Gets the index buffer array
  90474. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  90475. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90476. * @returns the index buffer array
  90477. */
  90478. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  90479. /**
  90480. * Gets the index buffer
  90481. * @return the index buffer
  90482. */
  90483. getIndexBuffer(): Nullable<DataBuffer>;
  90484. /** @hidden */
  90485. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  90486. /**
  90487. * Release the associated resources for a specific mesh
  90488. * @param mesh defines the source mesh
  90489. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  90490. */
  90491. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  90492. /**
  90493. * Apply current geometry to a given mesh
  90494. * @param mesh defines the mesh to apply geometry to
  90495. */
  90496. applyToMesh(mesh: Mesh): void;
  90497. private _updateExtend;
  90498. private _applyToMesh;
  90499. private notifyUpdate;
  90500. /**
  90501. * Load the geometry if it was flagged as delay loaded
  90502. * @param scene defines the hosting scene
  90503. * @param onLoaded defines a callback called when the geometry is loaded
  90504. */
  90505. load(scene: Scene, onLoaded?: () => void): void;
  90506. private _queueLoad;
  90507. /**
  90508. * Invert the geometry to move from a right handed system to a left handed one.
  90509. */
  90510. toLeftHanded(): void;
  90511. /** @hidden */
  90512. _resetPointsArrayCache(): void;
  90513. /** @hidden */
  90514. _generatePointsArray(): boolean;
  90515. /**
  90516. * Gets a value indicating if the geometry is disposed
  90517. * @returns true if the geometry was disposed
  90518. */
  90519. isDisposed(): boolean;
  90520. private _disposeVertexArrayObjects;
  90521. /**
  90522. * Free all associated resources
  90523. */
  90524. dispose(): void;
  90525. /**
  90526. * Clone the current geometry into a new geometry
  90527. * @param id defines the unique ID of the new geometry
  90528. * @returns a new geometry object
  90529. */
  90530. copy(id: string): Geometry;
  90531. /**
  90532. * Serialize the current geometry info (and not the vertices data) into a JSON object
  90533. * @return a JSON representation of the current geometry data (without the vertices data)
  90534. */
  90535. serialize(): any;
  90536. private toNumberArray;
  90537. /**
  90538. * Serialize all vertices data into a JSON oject
  90539. * @returns a JSON representation of the current geometry data
  90540. */
  90541. serializeVerticeData(): any;
  90542. /**
  90543. * Extracts a clone of a mesh geometry
  90544. * @param mesh defines the source mesh
  90545. * @param id defines the unique ID of the new geometry object
  90546. * @returns the new geometry object
  90547. */
  90548. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  90549. /**
  90550. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  90551. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  90552. * Be aware Math.random() could cause collisions, but:
  90553. * "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"
  90554. * @returns a string containing a new GUID
  90555. */
  90556. static RandomId(): string;
  90557. /** @hidden */
  90558. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  90559. private static _CleanMatricesWeights;
  90560. /**
  90561. * Create a new geometry from persisted data (Using .babylon file format)
  90562. * @param parsedVertexData defines the persisted data
  90563. * @param scene defines the hosting scene
  90564. * @param rootUrl defines the root url to use to load assets (like delayed data)
  90565. * @returns the new geometry object
  90566. */
  90567. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  90568. }
  90569. }
  90570. declare module BABYLON {
  90571. /**
  90572. * Define an interface for all classes that will get and set the data on vertices
  90573. */
  90574. export interface IGetSetVerticesData {
  90575. /**
  90576. * Gets a boolean indicating if specific vertex data is present
  90577. * @param kind defines the vertex data kind to use
  90578. * @returns true is data kind is present
  90579. */
  90580. isVerticesDataPresent(kind: string): boolean;
  90581. /**
  90582. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  90583. * @param kind defines the data kind (Position, normal, etc...)
  90584. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  90585. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90586. * @returns a float array containing vertex data
  90587. */
  90588. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  90589. /**
  90590. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  90591. * @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.
  90592. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90593. * @returns the indices array or an empty array if the mesh has no geometry
  90594. */
  90595. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  90596. /**
  90597. * Set specific vertex data
  90598. * @param kind defines the data kind (Position, normal, etc...)
  90599. * @param data defines the vertex data to use
  90600. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  90601. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  90602. */
  90603. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  90604. /**
  90605. * Update a specific associated vertex buffer
  90606. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  90607. * - VertexBuffer.PositionKind
  90608. * - VertexBuffer.UVKind
  90609. * - VertexBuffer.UV2Kind
  90610. * - VertexBuffer.UV3Kind
  90611. * - VertexBuffer.UV4Kind
  90612. * - VertexBuffer.UV5Kind
  90613. * - VertexBuffer.UV6Kind
  90614. * - VertexBuffer.ColorKind
  90615. * - VertexBuffer.MatricesIndicesKind
  90616. * - VertexBuffer.MatricesIndicesExtraKind
  90617. * - VertexBuffer.MatricesWeightsKind
  90618. * - VertexBuffer.MatricesWeightsExtraKind
  90619. * @param data defines the data source
  90620. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  90621. * @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)
  90622. */
  90623. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  90624. /**
  90625. * Creates a new index buffer
  90626. * @param indices defines the indices to store in the index buffer
  90627. * @param totalVertices defines the total number of vertices (could be null)
  90628. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  90629. */
  90630. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  90631. }
  90632. /**
  90633. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  90634. */
  90635. export class VertexData {
  90636. /**
  90637. * Mesh side orientation : usually the external or front surface
  90638. */
  90639. static readonly FRONTSIDE: number;
  90640. /**
  90641. * Mesh side orientation : usually the internal or back surface
  90642. */
  90643. static readonly BACKSIDE: number;
  90644. /**
  90645. * Mesh side orientation : both internal and external or front and back surfaces
  90646. */
  90647. static readonly DOUBLESIDE: number;
  90648. /**
  90649. * Mesh side orientation : by default, `FRONTSIDE`
  90650. */
  90651. static readonly DEFAULTSIDE: number;
  90652. /**
  90653. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  90654. */
  90655. positions: Nullable<FloatArray>;
  90656. /**
  90657. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  90658. */
  90659. normals: Nullable<FloatArray>;
  90660. /**
  90661. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  90662. */
  90663. tangents: Nullable<FloatArray>;
  90664. /**
  90665. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90666. */
  90667. uvs: Nullable<FloatArray>;
  90668. /**
  90669. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90670. */
  90671. uvs2: Nullable<FloatArray>;
  90672. /**
  90673. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90674. */
  90675. uvs3: Nullable<FloatArray>;
  90676. /**
  90677. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90678. */
  90679. uvs4: Nullable<FloatArray>;
  90680. /**
  90681. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90682. */
  90683. uvs5: Nullable<FloatArray>;
  90684. /**
  90685. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90686. */
  90687. uvs6: Nullable<FloatArray>;
  90688. /**
  90689. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  90690. */
  90691. colors: Nullable<FloatArray>;
  90692. /**
  90693. * 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).
  90694. */
  90695. matricesIndices: Nullable<FloatArray>;
  90696. /**
  90697. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  90698. */
  90699. matricesWeights: Nullable<FloatArray>;
  90700. /**
  90701. * An array extending the number of possible indices
  90702. */
  90703. matricesIndicesExtra: Nullable<FloatArray>;
  90704. /**
  90705. * An array extending the number of possible weights when the number of indices is extended
  90706. */
  90707. matricesWeightsExtra: Nullable<FloatArray>;
  90708. /**
  90709. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  90710. */
  90711. indices: Nullable<IndicesArray>;
  90712. /**
  90713. * Uses the passed data array to set the set the values for the specified kind of data
  90714. * @param data a linear array of floating numbers
  90715. * @param kind the type of data that is being set, eg positions, colors etc
  90716. */
  90717. set(data: FloatArray, kind: string): void;
  90718. /**
  90719. * Associates the vertexData to the passed Mesh.
  90720. * Sets it as updatable or not (default `false`)
  90721. * @param mesh the mesh the vertexData is applied to
  90722. * @param updatable when used and having the value true allows new data to update the vertexData
  90723. * @returns the VertexData
  90724. */
  90725. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  90726. /**
  90727. * Associates the vertexData to the passed Geometry.
  90728. * Sets it as updatable or not (default `false`)
  90729. * @param geometry the geometry the vertexData is applied to
  90730. * @param updatable when used and having the value true allows new data to update the vertexData
  90731. * @returns VertexData
  90732. */
  90733. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  90734. /**
  90735. * Updates the associated mesh
  90736. * @param mesh the mesh to be updated
  90737. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  90738. * @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
  90739. * @returns VertexData
  90740. */
  90741. updateMesh(mesh: Mesh): VertexData;
  90742. /**
  90743. * Updates the associated geometry
  90744. * @param geometry the geometry to be updated
  90745. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  90746. * @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
  90747. * @returns VertexData.
  90748. */
  90749. updateGeometry(geometry: Geometry): VertexData;
  90750. private _applyTo;
  90751. private _update;
  90752. /**
  90753. * Transforms each position and each normal of the vertexData according to the passed Matrix
  90754. * @param matrix the transforming matrix
  90755. * @returns the VertexData
  90756. */
  90757. transform(matrix: Matrix): VertexData;
  90758. /**
  90759. * Merges the passed VertexData into the current one
  90760. * @param other the VertexData to be merged into the current one
  90761. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  90762. * @returns the modified VertexData
  90763. */
  90764. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  90765. private _mergeElement;
  90766. private _validate;
  90767. /**
  90768. * Serializes the VertexData
  90769. * @returns a serialized object
  90770. */
  90771. serialize(): any;
  90772. /**
  90773. * Extracts the vertexData from a mesh
  90774. * @param mesh the mesh from which to extract the VertexData
  90775. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  90776. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  90777. * @returns the object VertexData associated to the passed mesh
  90778. */
  90779. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  90780. /**
  90781. * Extracts the vertexData from the geometry
  90782. * @param geometry the geometry from which to extract the VertexData
  90783. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  90784. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  90785. * @returns the object VertexData associated to the passed mesh
  90786. */
  90787. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  90788. private static _ExtractFrom;
  90789. /**
  90790. * Creates the VertexData for a Ribbon
  90791. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  90792. * * pathArray array of paths, each of which an array of successive Vector3
  90793. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  90794. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  90795. * * 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
  90796. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90797. * * 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)
  90798. * * 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)
  90799. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  90800. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  90801. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  90802. * @returns the VertexData of the ribbon
  90803. */
  90804. static CreateRibbon(options: {
  90805. pathArray: Vector3[][];
  90806. closeArray?: boolean;
  90807. closePath?: boolean;
  90808. offset?: number;
  90809. sideOrientation?: number;
  90810. frontUVs?: Vector4;
  90811. backUVs?: Vector4;
  90812. invertUV?: boolean;
  90813. uvs?: Vector2[];
  90814. colors?: Color4[];
  90815. }): VertexData;
  90816. /**
  90817. * Creates the VertexData for a box
  90818. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90819. * * size sets the width, height and depth of the box to the value of size, optional default 1
  90820. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  90821. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  90822. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  90823. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  90824. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  90825. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90826. * * 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)
  90827. * * 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)
  90828. * @returns the VertexData of the box
  90829. */
  90830. static CreateBox(options: {
  90831. size?: number;
  90832. width?: number;
  90833. height?: number;
  90834. depth?: number;
  90835. faceUV?: Vector4[];
  90836. faceColors?: Color4[];
  90837. sideOrientation?: number;
  90838. frontUVs?: Vector4;
  90839. backUVs?: Vector4;
  90840. }): VertexData;
  90841. /**
  90842. * Creates the VertexData for a tiled box
  90843. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90844. * * faceTiles sets the pattern, tile size and number of tiles for a face
  90845. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  90846. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  90847. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90848. * @returns the VertexData of the box
  90849. */
  90850. static CreateTiledBox(options: {
  90851. pattern?: number;
  90852. width?: number;
  90853. height?: number;
  90854. depth?: number;
  90855. tileSize?: number;
  90856. tileWidth?: number;
  90857. tileHeight?: number;
  90858. alignHorizontal?: number;
  90859. alignVertical?: number;
  90860. faceUV?: Vector4[];
  90861. faceColors?: Color4[];
  90862. sideOrientation?: number;
  90863. }): VertexData;
  90864. /**
  90865. * Creates the VertexData for a tiled plane
  90866. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90867. * * pattern a limited pattern arrangement depending on the number
  90868. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  90869. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  90870. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  90871. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90872. * * 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)
  90873. * * 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)
  90874. * @returns the VertexData of the tiled plane
  90875. */
  90876. static CreateTiledPlane(options: {
  90877. pattern?: number;
  90878. tileSize?: number;
  90879. tileWidth?: number;
  90880. tileHeight?: number;
  90881. size?: number;
  90882. width?: number;
  90883. height?: number;
  90884. alignHorizontal?: number;
  90885. alignVertical?: number;
  90886. sideOrientation?: number;
  90887. frontUVs?: Vector4;
  90888. backUVs?: Vector4;
  90889. }): VertexData;
  90890. /**
  90891. * Creates the VertexData for an ellipsoid, defaults to a sphere
  90892. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90893. * * segments sets the number of horizontal strips optional, default 32
  90894. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  90895. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  90896. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  90897. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  90898. * * 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
  90899. * * 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
  90900. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90901. * * 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)
  90902. * * 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)
  90903. * @returns the VertexData of the ellipsoid
  90904. */
  90905. static CreateSphere(options: {
  90906. segments?: number;
  90907. diameter?: number;
  90908. diameterX?: number;
  90909. diameterY?: number;
  90910. diameterZ?: number;
  90911. arc?: number;
  90912. slice?: number;
  90913. sideOrientation?: number;
  90914. frontUVs?: Vector4;
  90915. backUVs?: Vector4;
  90916. }): VertexData;
  90917. /**
  90918. * Creates the VertexData for a cylinder, cone or prism
  90919. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90920. * * height sets the height (y direction) of the cylinder, optional, default 2
  90921. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  90922. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  90923. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  90924. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  90925. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  90926. * * 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
  90927. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  90928. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  90929. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  90930. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  90931. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90932. * * 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)
  90933. * * 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)
  90934. * @returns the VertexData of the cylinder, cone or prism
  90935. */
  90936. static CreateCylinder(options: {
  90937. height?: number;
  90938. diameterTop?: number;
  90939. diameterBottom?: number;
  90940. diameter?: number;
  90941. tessellation?: number;
  90942. subdivisions?: number;
  90943. arc?: number;
  90944. faceColors?: Color4[];
  90945. faceUV?: Vector4[];
  90946. hasRings?: boolean;
  90947. enclose?: boolean;
  90948. sideOrientation?: number;
  90949. frontUVs?: Vector4;
  90950. backUVs?: Vector4;
  90951. }): VertexData;
  90952. /**
  90953. * Creates the VertexData for a torus
  90954. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90955. * * diameter the diameter of the torus, optional default 1
  90956. * * thickness the diameter of the tube forming the torus, optional default 0.5
  90957. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  90958. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90959. * * 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)
  90960. * * 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)
  90961. * @returns the VertexData of the torus
  90962. */
  90963. static CreateTorus(options: {
  90964. diameter?: number;
  90965. thickness?: number;
  90966. tessellation?: number;
  90967. sideOrientation?: number;
  90968. frontUVs?: Vector4;
  90969. backUVs?: Vector4;
  90970. }): VertexData;
  90971. /**
  90972. * Creates the VertexData of the LineSystem
  90973. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  90974. * - lines an array of lines, each line being an array of successive Vector3
  90975. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  90976. * @returns the VertexData of the LineSystem
  90977. */
  90978. static CreateLineSystem(options: {
  90979. lines: Vector3[][];
  90980. colors?: Nullable<Color4[][]>;
  90981. }): VertexData;
  90982. /**
  90983. * Create the VertexData for a DashedLines
  90984. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  90985. * - points an array successive Vector3
  90986. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  90987. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  90988. * - dashNb the intended total number of dashes, optional, default 200
  90989. * @returns the VertexData for the DashedLines
  90990. */
  90991. static CreateDashedLines(options: {
  90992. points: Vector3[];
  90993. dashSize?: number;
  90994. gapSize?: number;
  90995. dashNb?: number;
  90996. }): VertexData;
  90997. /**
  90998. * Creates the VertexData for a Ground
  90999. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  91000. * - width the width (x direction) of the ground, optional, default 1
  91001. * - height the height (z direction) of the ground, optional, default 1
  91002. * - subdivisions the number of subdivisions per side, optional, default 1
  91003. * @returns the VertexData of the Ground
  91004. */
  91005. static CreateGround(options: {
  91006. width?: number;
  91007. height?: number;
  91008. subdivisions?: number;
  91009. subdivisionsX?: number;
  91010. subdivisionsY?: number;
  91011. }): VertexData;
  91012. /**
  91013. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  91014. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  91015. * * xmin the ground minimum X coordinate, optional, default -1
  91016. * * zmin the ground minimum Z coordinate, optional, default -1
  91017. * * xmax the ground maximum X coordinate, optional, default 1
  91018. * * zmax the ground maximum Z coordinate, optional, default 1
  91019. * * 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}
  91020. * * 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}
  91021. * @returns the VertexData of the TiledGround
  91022. */
  91023. static CreateTiledGround(options: {
  91024. xmin: number;
  91025. zmin: number;
  91026. xmax: number;
  91027. zmax: number;
  91028. subdivisions?: {
  91029. w: number;
  91030. h: number;
  91031. };
  91032. precision?: {
  91033. w: number;
  91034. h: number;
  91035. };
  91036. }): VertexData;
  91037. /**
  91038. * Creates the VertexData of the Ground designed from a heightmap
  91039. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  91040. * * width the width (x direction) of the ground
  91041. * * height the height (z direction) of the ground
  91042. * * subdivisions the number of subdivisions per side
  91043. * * minHeight the minimum altitude on the ground, optional, default 0
  91044. * * maxHeight the maximum altitude on the ground, optional default 1
  91045. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  91046. * * buffer the array holding the image color data
  91047. * * bufferWidth the width of image
  91048. * * bufferHeight the height of image
  91049. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  91050. * @returns the VertexData of the Ground designed from a heightmap
  91051. */
  91052. static CreateGroundFromHeightMap(options: {
  91053. width: number;
  91054. height: number;
  91055. subdivisions: number;
  91056. minHeight: number;
  91057. maxHeight: number;
  91058. colorFilter: Color3;
  91059. buffer: Uint8Array;
  91060. bufferWidth: number;
  91061. bufferHeight: number;
  91062. alphaFilter: number;
  91063. }): VertexData;
  91064. /**
  91065. * Creates the VertexData for a Plane
  91066. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  91067. * * size sets the width and height of the plane to the value of size, optional default 1
  91068. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  91069. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  91070. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91071. * * 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)
  91072. * * 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)
  91073. * @returns the VertexData of the box
  91074. */
  91075. static CreatePlane(options: {
  91076. size?: number;
  91077. width?: number;
  91078. height?: number;
  91079. sideOrientation?: number;
  91080. frontUVs?: Vector4;
  91081. backUVs?: Vector4;
  91082. }): VertexData;
  91083. /**
  91084. * Creates the VertexData of the Disc or regular Polygon
  91085. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  91086. * * radius the radius of the disc, optional default 0.5
  91087. * * tessellation the number of polygon sides, optional, default 64
  91088. * * 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
  91089. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91090. * * 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)
  91091. * * 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)
  91092. * @returns the VertexData of the box
  91093. */
  91094. static CreateDisc(options: {
  91095. radius?: number;
  91096. tessellation?: number;
  91097. arc?: number;
  91098. sideOrientation?: number;
  91099. frontUVs?: Vector4;
  91100. backUVs?: Vector4;
  91101. }): VertexData;
  91102. /**
  91103. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  91104. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  91105. * @param polygon a mesh built from polygonTriangulation.build()
  91106. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91107. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  91108. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  91109. * @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)
  91110. * @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)
  91111. * @returns the VertexData of the Polygon
  91112. */
  91113. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  91114. /**
  91115. * Creates the VertexData of the IcoSphere
  91116. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  91117. * * radius the radius of the IcoSphere, optional default 1
  91118. * * radiusX allows stretching in the x direction, optional, default radius
  91119. * * radiusY allows stretching in the y direction, optional, default radius
  91120. * * radiusZ allows stretching in the z direction, optional, default radius
  91121. * * flat when true creates a flat shaded mesh, optional, default true
  91122. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  91123. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91124. * * 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)
  91125. * * 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)
  91126. * @returns the VertexData of the IcoSphere
  91127. */
  91128. static CreateIcoSphere(options: {
  91129. radius?: number;
  91130. radiusX?: number;
  91131. radiusY?: number;
  91132. radiusZ?: number;
  91133. flat?: boolean;
  91134. subdivisions?: number;
  91135. sideOrientation?: number;
  91136. frontUVs?: Vector4;
  91137. backUVs?: Vector4;
  91138. }): VertexData;
  91139. /**
  91140. * Creates the VertexData for a Polyhedron
  91141. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  91142. * * type provided types are:
  91143. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  91144. * * 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)
  91145. * * size the size of the IcoSphere, optional default 1
  91146. * * sizeX allows stretching in the x direction, optional, default size
  91147. * * sizeY allows stretching in the y direction, optional, default size
  91148. * * sizeZ allows stretching in the z direction, optional, default size
  91149. * * 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
  91150. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  91151. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  91152. * * flat when true creates a flat shaded mesh, optional, default true
  91153. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  91154. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91155. * * 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)
  91156. * * 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)
  91157. * @returns the VertexData of the Polyhedron
  91158. */
  91159. static CreatePolyhedron(options: {
  91160. type?: number;
  91161. size?: number;
  91162. sizeX?: number;
  91163. sizeY?: number;
  91164. sizeZ?: number;
  91165. custom?: any;
  91166. faceUV?: Vector4[];
  91167. faceColors?: Color4[];
  91168. flat?: boolean;
  91169. sideOrientation?: number;
  91170. frontUVs?: Vector4;
  91171. backUVs?: Vector4;
  91172. }): VertexData;
  91173. /**
  91174. * Creates the VertexData for a TorusKnot
  91175. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  91176. * * radius the radius of the torus knot, optional, default 2
  91177. * * tube the thickness of the tube, optional, default 0.5
  91178. * * radialSegments the number of sides on each tube segments, optional, default 32
  91179. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  91180. * * p the number of windings around the z axis, optional, default 2
  91181. * * q the number of windings around the x axis, optional, default 3
  91182. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91183. * * 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)
  91184. * * 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)
  91185. * @returns the VertexData of the Torus Knot
  91186. */
  91187. static CreateTorusKnot(options: {
  91188. radius?: number;
  91189. tube?: number;
  91190. radialSegments?: number;
  91191. tubularSegments?: number;
  91192. p?: number;
  91193. q?: number;
  91194. sideOrientation?: number;
  91195. frontUVs?: Vector4;
  91196. backUVs?: Vector4;
  91197. }): VertexData;
  91198. /**
  91199. * Compute normals for given positions and indices
  91200. * @param positions an array of vertex positions, [...., x, y, z, ......]
  91201. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  91202. * @param normals an array of vertex normals, [...., x, y, z, ......]
  91203. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  91204. * * facetNormals : optional array of facet normals (vector3)
  91205. * * facetPositions : optional array of facet positions (vector3)
  91206. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  91207. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  91208. * * bInfo : optional bounding info, required for facetPartitioning computation
  91209. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  91210. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  91211. * * useRightHandedSystem: optional boolean to for right handed system computation
  91212. * * depthSort : optional boolean to enable the facet depth sort computation
  91213. * * distanceTo : optional Vector3 to compute the facet depth from this location
  91214. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  91215. */
  91216. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  91217. facetNormals?: any;
  91218. facetPositions?: any;
  91219. facetPartitioning?: any;
  91220. ratio?: number;
  91221. bInfo?: any;
  91222. bbSize?: Vector3;
  91223. subDiv?: any;
  91224. useRightHandedSystem?: boolean;
  91225. depthSort?: boolean;
  91226. distanceTo?: Vector3;
  91227. depthSortedFacets?: any;
  91228. }): void;
  91229. /** @hidden */
  91230. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  91231. /**
  91232. * Applies VertexData created from the imported parameters to the geometry
  91233. * @param parsedVertexData the parsed data from an imported file
  91234. * @param geometry the geometry to apply the VertexData to
  91235. */
  91236. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  91237. }
  91238. }
  91239. declare module BABYLON {
  91240. /**
  91241. * Defines a target to use with MorphTargetManager
  91242. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  91243. */
  91244. export class MorphTarget implements IAnimatable {
  91245. /** defines the name of the target */
  91246. name: string;
  91247. /**
  91248. * Gets or sets the list of animations
  91249. */
  91250. animations: Animation[];
  91251. private _scene;
  91252. private _positions;
  91253. private _normals;
  91254. private _tangents;
  91255. private _uvs;
  91256. private _influence;
  91257. private _uniqueId;
  91258. /**
  91259. * Observable raised when the influence changes
  91260. */
  91261. onInfluenceChanged: Observable<boolean>;
  91262. /** @hidden */
  91263. _onDataLayoutChanged: Observable<void>;
  91264. /**
  91265. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  91266. */
  91267. influence: number;
  91268. /**
  91269. * Gets or sets the id of the morph Target
  91270. */
  91271. id: string;
  91272. private _animationPropertiesOverride;
  91273. /**
  91274. * Gets or sets the animation properties override
  91275. */
  91276. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  91277. /**
  91278. * Creates a new MorphTarget
  91279. * @param name defines the name of the target
  91280. * @param influence defines the influence to use
  91281. * @param scene defines the scene the morphtarget belongs to
  91282. */
  91283. constructor(
  91284. /** defines the name of the target */
  91285. name: string, influence?: number, scene?: Nullable<Scene>);
  91286. /**
  91287. * Gets the unique ID of this manager
  91288. */
  91289. readonly uniqueId: number;
  91290. /**
  91291. * Gets a boolean defining if the target contains position data
  91292. */
  91293. readonly hasPositions: boolean;
  91294. /**
  91295. * Gets a boolean defining if the target contains normal data
  91296. */
  91297. readonly hasNormals: boolean;
  91298. /**
  91299. * Gets a boolean defining if the target contains tangent data
  91300. */
  91301. readonly hasTangents: boolean;
  91302. /**
  91303. * Gets a boolean defining if the target contains texture coordinates data
  91304. */
  91305. readonly hasUVs: boolean;
  91306. /**
  91307. * Affects position data to this target
  91308. * @param data defines the position data to use
  91309. */
  91310. setPositions(data: Nullable<FloatArray>): void;
  91311. /**
  91312. * Gets the position data stored in this target
  91313. * @returns a FloatArray containing the position data (or null if not present)
  91314. */
  91315. getPositions(): Nullable<FloatArray>;
  91316. /**
  91317. * Affects normal data to this target
  91318. * @param data defines the normal data to use
  91319. */
  91320. setNormals(data: Nullable<FloatArray>): void;
  91321. /**
  91322. * Gets the normal data stored in this target
  91323. * @returns a FloatArray containing the normal data (or null if not present)
  91324. */
  91325. getNormals(): Nullable<FloatArray>;
  91326. /**
  91327. * Affects tangent data to this target
  91328. * @param data defines the tangent data to use
  91329. */
  91330. setTangents(data: Nullable<FloatArray>): void;
  91331. /**
  91332. * Gets the tangent data stored in this target
  91333. * @returns a FloatArray containing the tangent data (or null if not present)
  91334. */
  91335. getTangents(): Nullable<FloatArray>;
  91336. /**
  91337. * Affects texture coordinates data to this target
  91338. * @param data defines the texture coordinates data to use
  91339. */
  91340. setUVs(data: Nullable<FloatArray>): void;
  91341. /**
  91342. * Gets the texture coordinates data stored in this target
  91343. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  91344. */
  91345. getUVs(): Nullable<FloatArray>;
  91346. /**
  91347. * Clone the current target
  91348. * @returns a new MorphTarget
  91349. */
  91350. clone(): MorphTarget;
  91351. /**
  91352. * Serializes the current target into a Serialization object
  91353. * @returns the serialized object
  91354. */
  91355. serialize(): any;
  91356. /**
  91357. * Returns the string "MorphTarget"
  91358. * @returns "MorphTarget"
  91359. */
  91360. getClassName(): string;
  91361. /**
  91362. * Creates a new target from serialized data
  91363. * @param serializationObject defines the serialized data to use
  91364. * @returns a new MorphTarget
  91365. */
  91366. static Parse(serializationObject: any): MorphTarget;
  91367. /**
  91368. * Creates a MorphTarget from mesh data
  91369. * @param mesh defines the source mesh
  91370. * @param name defines the name to use for the new target
  91371. * @param influence defines the influence to attach to the target
  91372. * @returns a new MorphTarget
  91373. */
  91374. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  91375. }
  91376. }
  91377. declare module BABYLON {
  91378. /**
  91379. * This class is used to deform meshes using morphing between different targets
  91380. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  91381. */
  91382. export class MorphTargetManager {
  91383. private _targets;
  91384. private _targetInfluenceChangedObservers;
  91385. private _targetDataLayoutChangedObservers;
  91386. private _activeTargets;
  91387. private _scene;
  91388. private _influences;
  91389. private _supportsNormals;
  91390. private _supportsTangents;
  91391. private _supportsUVs;
  91392. private _vertexCount;
  91393. private _uniqueId;
  91394. private _tempInfluences;
  91395. /**
  91396. * Gets or sets a boolean indicating if normals must be morphed
  91397. */
  91398. enableNormalMorphing: boolean;
  91399. /**
  91400. * Gets or sets a boolean indicating if tangents must be morphed
  91401. */
  91402. enableTangentMorphing: boolean;
  91403. /**
  91404. * Gets or sets a boolean indicating if UV must be morphed
  91405. */
  91406. enableUVMorphing: boolean;
  91407. /**
  91408. * Creates a new MorphTargetManager
  91409. * @param scene defines the current scene
  91410. */
  91411. constructor(scene?: Nullable<Scene>);
  91412. /**
  91413. * Gets the unique ID of this manager
  91414. */
  91415. readonly uniqueId: number;
  91416. /**
  91417. * Gets the number of vertices handled by this manager
  91418. */
  91419. readonly vertexCount: number;
  91420. /**
  91421. * Gets a boolean indicating if this manager supports morphing of normals
  91422. */
  91423. readonly supportsNormals: boolean;
  91424. /**
  91425. * Gets a boolean indicating if this manager supports morphing of tangents
  91426. */
  91427. readonly supportsTangents: boolean;
  91428. /**
  91429. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  91430. */
  91431. readonly supportsUVs: boolean;
  91432. /**
  91433. * Gets the number of targets stored in this manager
  91434. */
  91435. readonly numTargets: number;
  91436. /**
  91437. * Gets the number of influencers (ie. the number of targets with influences > 0)
  91438. */
  91439. readonly numInfluencers: number;
  91440. /**
  91441. * Gets the list of influences (one per target)
  91442. */
  91443. readonly influences: Float32Array;
  91444. /**
  91445. * Gets the active target at specified index. An active target is a target with an influence > 0
  91446. * @param index defines the index to check
  91447. * @returns the requested target
  91448. */
  91449. getActiveTarget(index: number): MorphTarget;
  91450. /**
  91451. * Gets the target at specified index
  91452. * @param index defines the index to check
  91453. * @returns the requested target
  91454. */
  91455. getTarget(index: number): MorphTarget;
  91456. /**
  91457. * Add a new target to this manager
  91458. * @param target defines the target to add
  91459. */
  91460. addTarget(target: MorphTarget): void;
  91461. /**
  91462. * Removes a target from the manager
  91463. * @param target defines the target to remove
  91464. */
  91465. removeTarget(target: MorphTarget): void;
  91466. /**
  91467. * Clone the current manager
  91468. * @returns a new MorphTargetManager
  91469. */
  91470. clone(): MorphTargetManager;
  91471. /**
  91472. * Serializes the current manager into a Serialization object
  91473. * @returns the serialized object
  91474. */
  91475. serialize(): any;
  91476. private _syncActiveTargets;
  91477. /**
  91478. * Syncrhonize the targets with all the meshes using this morph target manager
  91479. */
  91480. synchronize(): void;
  91481. /**
  91482. * Creates a new MorphTargetManager from serialized data
  91483. * @param serializationObject defines the serialized data
  91484. * @param scene defines the hosting scene
  91485. * @returns the new MorphTargetManager
  91486. */
  91487. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  91488. }
  91489. }
  91490. declare module BABYLON {
  91491. /**
  91492. * Class used to represent a specific level of detail of a mesh
  91493. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  91494. */
  91495. export class MeshLODLevel {
  91496. /** Defines the distance where this level should start being displayed */
  91497. distance: number;
  91498. /** Defines the mesh to use to render this level */
  91499. mesh: Nullable<Mesh>;
  91500. /**
  91501. * Creates a new LOD level
  91502. * @param distance defines the distance where this level should star being displayed
  91503. * @param mesh defines the mesh to use to render this level
  91504. */
  91505. constructor(
  91506. /** Defines the distance where this level should start being displayed */
  91507. distance: number,
  91508. /** Defines the mesh to use to render this level */
  91509. mesh: Nullable<Mesh>);
  91510. }
  91511. }
  91512. declare module BABYLON {
  91513. /**
  91514. * Mesh representing the gorund
  91515. */
  91516. export class GroundMesh extends Mesh {
  91517. /** If octree should be generated */
  91518. generateOctree: boolean;
  91519. private _heightQuads;
  91520. /** @hidden */
  91521. _subdivisionsX: number;
  91522. /** @hidden */
  91523. _subdivisionsY: number;
  91524. /** @hidden */
  91525. _width: number;
  91526. /** @hidden */
  91527. _height: number;
  91528. /** @hidden */
  91529. _minX: number;
  91530. /** @hidden */
  91531. _maxX: number;
  91532. /** @hidden */
  91533. _minZ: number;
  91534. /** @hidden */
  91535. _maxZ: number;
  91536. constructor(name: string, scene: Scene);
  91537. /**
  91538. * "GroundMesh"
  91539. * @returns "GroundMesh"
  91540. */
  91541. getClassName(): string;
  91542. /**
  91543. * The minimum of x and y subdivisions
  91544. */
  91545. readonly subdivisions: number;
  91546. /**
  91547. * X subdivisions
  91548. */
  91549. readonly subdivisionsX: number;
  91550. /**
  91551. * Y subdivisions
  91552. */
  91553. readonly subdivisionsY: number;
  91554. /**
  91555. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  91556. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  91557. * @param chunksCount the number of subdivisions for x and y
  91558. * @param octreeBlocksSize (Default: 32)
  91559. */
  91560. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  91561. /**
  91562. * Returns a height (y) value in the Worl system :
  91563. * the ground altitude at the coordinates (x, z) expressed in the World system.
  91564. * @param x x coordinate
  91565. * @param z z coordinate
  91566. * @returns the ground y position if (x, z) are outside the ground surface.
  91567. */
  91568. getHeightAtCoordinates(x: number, z: number): number;
  91569. /**
  91570. * Returns a normalized vector (Vector3) orthogonal to the ground
  91571. * at the ground coordinates (x, z) expressed in the World system.
  91572. * @param x x coordinate
  91573. * @param z z coordinate
  91574. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  91575. */
  91576. getNormalAtCoordinates(x: number, z: number): Vector3;
  91577. /**
  91578. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  91579. * at the ground coordinates (x, z) expressed in the World system.
  91580. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  91581. * @param x x coordinate
  91582. * @param z z coordinate
  91583. * @param ref vector to store the result
  91584. * @returns the GroundMesh.
  91585. */
  91586. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  91587. /**
  91588. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  91589. * if the ground has been updated.
  91590. * This can be used in the render loop.
  91591. * @returns the GroundMesh.
  91592. */
  91593. updateCoordinateHeights(): GroundMesh;
  91594. private _getFacetAt;
  91595. private _initHeightQuads;
  91596. private _computeHeightQuads;
  91597. /**
  91598. * Serializes this ground mesh
  91599. * @param serializationObject object to write serialization to
  91600. */
  91601. serialize(serializationObject: any): void;
  91602. /**
  91603. * Parses a serialized ground mesh
  91604. * @param parsedMesh the serialized mesh
  91605. * @param scene the scene to create the ground mesh in
  91606. * @returns the created ground mesh
  91607. */
  91608. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  91609. }
  91610. }
  91611. declare module BABYLON {
  91612. /**
  91613. * Interface for Physics-Joint data
  91614. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91615. */
  91616. export interface PhysicsJointData {
  91617. /**
  91618. * The main pivot of the joint
  91619. */
  91620. mainPivot?: Vector3;
  91621. /**
  91622. * The connected pivot of the joint
  91623. */
  91624. connectedPivot?: Vector3;
  91625. /**
  91626. * The main axis of the joint
  91627. */
  91628. mainAxis?: Vector3;
  91629. /**
  91630. * The connected axis of the joint
  91631. */
  91632. connectedAxis?: Vector3;
  91633. /**
  91634. * The collision of the joint
  91635. */
  91636. collision?: boolean;
  91637. /**
  91638. * Native Oimo/Cannon/Energy data
  91639. */
  91640. nativeParams?: any;
  91641. }
  91642. /**
  91643. * This is a holder class for the physics joint created by the physics plugin
  91644. * It holds a set of functions to control the underlying joint
  91645. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91646. */
  91647. export class PhysicsJoint {
  91648. /**
  91649. * The type of the physics joint
  91650. */
  91651. type: number;
  91652. /**
  91653. * The data for the physics joint
  91654. */
  91655. jointData: PhysicsJointData;
  91656. private _physicsJoint;
  91657. protected _physicsPlugin: IPhysicsEnginePlugin;
  91658. /**
  91659. * Initializes the physics joint
  91660. * @param type The type of the physics joint
  91661. * @param jointData The data for the physics joint
  91662. */
  91663. constructor(
  91664. /**
  91665. * The type of the physics joint
  91666. */
  91667. type: number,
  91668. /**
  91669. * The data for the physics joint
  91670. */
  91671. jointData: PhysicsJointData);
  91672. /**
  91673. * Gets the physics joint
  91674. */
  91675. /**
  91676. * Sets the physics joint
  91677. */
  91678. physicsJoint: any;
  91679. /**
  91680. * Sets the physics plugin
  91681. */
  91682. physicsPlugin: IPhysicsEnginePlugin;
  91683. /**
  91684. * Execute a function that is physics-plugin specific.
  91685. * @param {Function} func the function that will be executed.
  91686. * It accepts two parameters: the physics world and the physics joint
  91687. */
  91688. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  91689. /**
  91690. * Distance-Joint type
  91691. */
  91692. static DistanceJoint: number;
  91693. /**
  91694. * Hinge-Joint type
  91695. */
  91696. static HingeJoint: number;
  91697. /**
  91698. * Ball-and-Socket joint type
  91699. */
  91700. static BallAndSocketJoint: number;
  91701. /**
  91702. * Wheel-Joint type
  91703. */
  91704. static WheelJoint: number;
  91705. /**
  91706. * Slider-Joint type
  91707. */
  91708. static SliderJoint: number;
  91709. /**
  91710. * Prismatic-Joint type
  91711. */
  91712. static PrismaticJoint: number;
  91713. /**
  91714. * Universal-Joint type
  91715. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  91716. */
  91717. static UniversalJoint: number;
  91718. /**
  91719. * Hinge-Joint 2 type
  91720. */
  91721. static Hinge2Joint: number;
  91722. /**
  91723. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  91724. */
  91725. static PointToPointJoint: number;
  91726. /**
  91727. * Spring-Joint type
  91728. */
  91729. static SpringJoint: number;
  91730. /**
  91731. * Lock-Joint type
  91732. */
  91733. static LockJoint: number;
  91734. }
  91735. /**
  91736. * A class representing a physics distance joint
  91737. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91738. */
  91739. export class DistanceJoint extends PhysicsJoint {
  91740. /**
  91741. *
  91742. * @param jointData The data for the Distance-Joint
  91743. */
  91744. constructor(jointData: DistanceJointData);
  91745. /**
  91746. * Update the predefined distance.
  91747. * @param maxDistance The maximum preferred distance
  91748. * @param minDistance The minimum preferred distance
  91749. */
  91750. updateDistance(maxDistance: number, minDistance?: number): void;
  91751. }
  91752. /**
  91753. * Represents a Motor-Enabled Joint
  91754. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91755. */
  91756. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  91757. /**
  91758. * Initializes the Motor-Enabled Joint
  91759. * @param type The type of the joint
  91760. * @param jointData The physica joint data for the joint
  91761. */
  91762. constructor(type: number, jointData: PhysicsJointData);
  91763. /**
  91764. * Set the motor values.
  91765. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91766. * @param force the force to apply
  91767. * @param maxForce max force for this motor.
  91768. */
  91769. setMotor(force?: number, maxForce?: number): void;
  91770. /**
  91771. * Set the motor's limits.
  91772. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91773. * @param upperLimit The upper limit of the motor
  91774. * @param lowerLimit The lower limit of the motor
  91775. */
  91776. setLimit(upperLimit: number, lowerLimit?: number): void;
  91777. }
  91778. /**
  91779. * This class represents a single physics Hinge-Joint
  91780. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91781. */
  91782. export class HingeJoint extends MotorEnabledJoint {
  91783. /**
  91784. * Initializes the Hinge-Joint
  91785. * @param jointData The joint data for the Hinge-Joint
  91786. */
  91787. constructor(jointData: PhysicsJointData);
  91788. /**
  91789. * Set the motor values.
  91790. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91791. * @param {number} force the force to apply
  91792. * @param {number} maxForce max force for this motor.
  91793. */
  91794. setMotor(force?: number, maxForce?: number): void;
  91795. /**
  91796. * Set the motor's limits.
  91797. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91798. * @param upperLimit The upper limit of the motor
  91799. * @param lowerLimit The lower limit of the motor
  91800. */
  91801. setLimit(upperLimit: number, lowerLimit?: number): void;
  91802. }
  91803. /**
  91804. * This class represents a dual hinge physics joint (same as wheel joint)
  91805. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91806. */
  91807. export class Hinge2Joint extends MotorEnabledJoint {
  91808. /**
  91809. * Initializes the Hinge2-Joint
  91810. * @param jointData The joint data for the Hinge2-Joint
  91811. */
  91812. constructor(jointData: PhysicsJointData);
  91813. /**
  91814. * Set the motor values.
  91815. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91816. * @param {number} targetSpeed the speed the motor is to reach
  91817. * @param {number} maxForce max force for this motor.
  91818. * @param {motorIndex} the motor's index, 0 or 1.
  91819. */
  91820. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  91821. /**
  91822. * Set the motor limits.
  91823. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91824. * @param {number} upperLimit the upper limit
  91825. * @param {number} lowerLimit lower limit
  91826. * @param {motorIndex} the motor's index, 0 or 1.
  91827. */
  91828. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  91829. }
  91830. /**
  91831. * Interface for a motor enabled joint
  91832. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91833. */
  91834. export interface IMotorEnabledJoint {
  91835. /**
  91836. * Physics joint
  91837. */
  91838. physicsJoint: any;
  91839. /**
  91840. * Sets the motor of the motor-enabled joint
  91841. * @param force The force of the motor
  91842. * @param maxForce The maximum force of the motor
  91843. * @param motorIndex The index of the motor
  91844. */
  91845. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  91846. /**
  91847. * Sets the limit of the motor
  91848. * @param upperLimit The upper limit of the motor
  91849. * @param lowerLimit The lower limit of the motor
  91850. * @param motorIndex The index of the motor
  91851. */
  91852. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  91853. }
  91854. /**
  91855. * Joint data for a Distance-Joint
  91856. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91857. */
  91858. export interface DistanceJointData extends PhysicsJointData {
  91859. /**
  91860. * Max distance the 2 joint objects can be apart
  91861. */
  91862. maxDistance: number;
  91863. }
  91864. /**
  91865. * Joint data from a spring joint
  91866. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91867. */
  91868. export interface SpringJointData extends PhysicsJointData {
  91869. /**
  91870. * Length of the spring
  91871. */
  91872. length: number;
  91873. /**
  91874. * Stiffness of the spring
  91875. */
  91876. stiffness: number;
  91877. /**
  91878. * Damping of the spring
  91879. */
  91880. damping: number;
  91881. /** this callback will be called when applying the force to the impostors. */
  91882. forceApplicationCallback: () => void;
  91883. }
  91884. }
  91885. declare module BABYLON {
  91886. /**
  91887. * Holds the data for the raycast result
  91888. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91889. */
  91890. export class PhysicsRaycastResult {
  91891. private _hasHit;
  91892. private _hitDistance;
  91893. private _hitNormalWorld;
  91894. private _hitPointWorld;
  91895. private _rayFromWorld;
  91896. private _rayToWorld;
  91897. /**
  91898. * Gets if there was a hit
  91899. */
  91900. readonly hasHit: boolean;
  91901. /**
  91902. * Gets the distance from the hit
  91903. */
  91904. readonly hitDistance: number;
  91905. /**
  91906. * Gets the hit normal/direction in the world
  91907. */
  91908. readonly hitNormalWorld: Vector3;
  91909. /**
  91910. * Gets the hit point in the world
  91911. */
  91912. readonly hitPointWorld: Vector3;
  91913. /**
  91914. * Gets the ray "start point" of the ray in the world
  91915. */
  91916. readonly rayFromWorld: Vector3;
  91917. /**
  91918. * Gets the ray "end point" of the ray in the world
  91919. */
  91920. readonly rayToWorld: Vector3;
  91921. /**
  91922. * Sets the hit data (normal & point in world space)
  91923. * @param hitNormalWorld defines the normal in world space
  91924. * @param hitPointWorld defines the point in world space
  91925. */
  91926. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  91927. /**
  91928. * Sets the distance from the start point to the hit point
  91929. * @param distance
  91930. */
  91931. setHitDistance(distance: number): void;
  91932. /**
  91933. * Calculates the distance manually
  91934. */
  91935. calculateHitDistance(): void;
  91936. /**
  91937. * Resets all the values to default
  91938. * @param from The from point on world space
  91939. * @param to The to point on world space
  91940. */
  91941. reset(from?: Vector3, to?: Vector3): void;
  91942. }
  91943. /**
  91944. * Interface for the size containing width and height
  91945. */
  91946. interface IXYZ {
  91947. /**
  91948. * X
  91949. */
  91950. x: number;
  91951. /**
  91952. * Y
  91953. */
  91954. y: number;
  91955. /**
  91956. * Z
  91957. */
  91958. z: number;
  91959. }
  91960. }
  91961. declare module BABYLON {
  91962. /**
  91963. * Interface used to describe a physics joint
  91964. */
  91965. export interface PhysicsImpostorJoint {
  91966. /** Defines the main impostor to which the joint is linked */
  91967. mainImpostor: PhysicsImpostor;
  91968. /** Defines the impostor that is connected to the main impostor using this joint */
  91969. connectedImpostor: PhysicsImpostor;
  91970. /** Defines the joint itself */
  91971. joint: PhysicsJoint;
  91972. }
  91973. /** @hidden */
  91974. export interface IPhysicsEnginePlugin {
  91975. world: any;
  91976. name: string;
  91977. setGravity(gravity: Vector3): void;
  91978. setTimeStep(timeStep: number): void;
  91979. getTimeStep(): number;
  91980. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  91981. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  91982. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  91983. generatePhysicsBody(impostor: PhysicsImpostor): void;
  91984. removePhysicsBody(impostor: PhysicsImpostor): void;
  91985. generateJoint(joint: PhysicsImpostorJoint): void;
  91986. removeJoint(joint: PhysicsImpostorJoint): void;
  91987. isSupported(): boolean;
  91988. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  91989. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  91990. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  91991. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  91992. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  91993. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  91994. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  91995. getBodyMass(impostor: PhysicsImpostor): number;
  91996. getBodyFriction(impostor: PhysicsImpostor): number;
  91997. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  91998. getBodyRestitution(impostor: PhysicsImpostor): number;
  91999. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  92000. getBodyPressure?(impostor: PhysicsImpostor): number;
  92001. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  92002. getBodyStiffness?(impostor: PhysicsImpostor): number;
  92003. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  92004. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  92005. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  92006. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  92007. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  92008. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  92009. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  92010. sleepBody(impostor: PhysicsImpostor): void;
  92011. wakeUpBody(impostor: PhysicsImpostor): void;
  92012. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  92013. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  92014. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  92015. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  92016. getRadius(impostor: PhysicsImpostor): number;
  92017. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  92018. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  92019. dispose(): void;
  92020. }
  92021. /**
  92022. * Interface used to define a physics engine
  92023. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  92024. */
  92025. export interface IPhysicsEngine {
  92026. /**
  92027. * Gets the gravity vector used by the simulation
  92028. */
  92029. gravity: Vector3;
  92030. /**
  92031. * Sets the gravity vector used by the simulation
  92032. * @param gravity defines the gravity vector to use
  92033. */
  92034. setGravity(gravity: Vector3): void;
  92035. /**
  92036. * Set the time step of the physics engine.
  92037. * Default is 1/60.
  92038. * To slow it down, enter 1/600 for example.
  92039. * To speed it up, 1/30
  92040. * @param newTimeStep the new timestep to apply to this world.
  92041. */
  92042. setTimeStep(newTimeStep: number): void;
  92043. /**
  92044. * Get the time step of the physics engine.
  92045. * @returns the current time step
  92046. */
  92047. getTimeStep(): number;
  92048. /**
  92049. * Set the sub time step of the physics engine.
  92050. * Default is 0 meaning there is no sub steps
  92051. * To increase physics resolution precision, set a small value (like 1 ms)
  92052. * @param subTimeStep defines the new sub timestep used for physics resolution.
  92053. */
  92054. setSubTimeStep(subTimeStep: number): void;
  92055. /**
  92056. * Get the sub time step of the physics engine.
  92057. * @returns the current sub time step
  92058. */
  92059. getSubTimeStep(): number;
  92060. /**
  92061. * Release all resources
  92062. */
  92063. dispose(): void;
  92064. /**
  92065. * Gets the name of the current physics plugin
  92066. * @returns the name of the plugin
  92067. */
  92068. getPhysicsPluginName(): string;
  92069. /**
  92070. * Adding a new impostor for the impostor tracking.
  92071. * This will be done by the impostor itself.
  92072. * @param impostor the impostor to add
  92073. */
  92074. addImpostor(impostor: PhysicsImpostor): void;
  92075. /**
  92076. * Remove an impostor from the engine.
  92077. * This impostor and its mesh will not longer be updated by the physics engine.
  92078. * @param impostor the impostor to remove
  92079. */
  92080. removeImpostor(impostor: PhysicsImpostor): void;
  92081. /**
  92082. * Add a joint to the physics engine
  92083. * @param mainImpostor defines the main impostor to which the joint is added.
  92084. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  92085. * @param joint defines the joint that will connect both impostors.
  92086. */
  92087. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  92088. /**
  92089. * Removes a joint from the simulation
  92090. * @param mainImpostor defines the impostor used with the joint
  92091. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  92092. * @param joint defines the joint to remove
  92093. */
  92094. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  92095. /**
  92096. * Gets the current plugin used to run the simulation
  92097. * @returns current plugin
  92098. */
  92099. getPhysicsPlugin(): IPhysicsEnginePlugin;
  92100. /**
  92101. * Gets the list of physic impostors
  92102. * @returns an array of PhysicsImpostor
  92103. */
  92104. getImpostors(): Array<PhysicsImpostor>;
  92105. /**
  92106. * Gets the impostor for a physics enabled object
  92107. * @param object defines the object impersonated by the impostor
  92108. * @returns the PhysicsImpostor or null if not found
  92109. */
  92110. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  92111. /**
  92112. * Gets the impostor for a physics body object
  92113. * @param body defines physics body used by the impostor
  92114. * @returns the PhysicsImpostor or null if not found
  92115. */
  92116. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  92117. /**
  92118. * Does a raycast in the physics world
  92119. * @param from when should the ray start?
  92120. * @param to when should the ray end?
  92121. * @returns PhysicsRaycastResult
  92122. */
  92123. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  92124. /**
  92125. * Called by the scene. No need to call it.
  92126. * @param delta defines the timespam between frames
  92127. */
  92128. _step(delta: number): void;
  92129. }
  92130. }
  92131. declare module BABYLON {
  92132. /**
  92133. * The interface for the physics imposter parameters
  92134. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92135. */
  92136. export interface PhysicsImpostorParameters {
  92137. /**
  92138. * The mass of the physics imposter
  92139. */
  92140. mass: number;
  92141. /**
  92142. * The friction of the physics imposter
  92143. */
  92144. friction?: number;
  92145. /**
  92146. * The coefficient of restitution of the physics imposter
  92147. */
  92148. restitution?: number;
  92149. /**
  92150. * The native options of the physics imposter
  92151. */
  92152. nativeOptions?: any;
  92153. /**
  92154. * Specifies if the parent should be ignored
  92155. */
  92156. ignoreParent?: boolean;
  92157. /**
  92158. * Specifies if bi-directional transformations should be disabled
  92159. */
  92160. disableBidirectionalTransformation?: boolean;
  92161. /**
  92162. * The pressure inside the physics imposter, soft object only
  92163. */
  92164. pressure?: number;
  92165. /**
  92166. * The stiffness the physics imposter, soft object only
  92167. */
  92168. stiffness?: number;
  92169. /**
  92170. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  92171. */
  92172. velocityIterations?: number;
  92173. /**
  92174. * The number of iterations used in maintaining consistent vertex positions, soft object only
  92175. */
  92176. positionIterations?: number;
  92177. /**
  92178. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  92179. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  92180. * Add to fix multiple points
  92181. */
  92182. fixedPoints?: number;
  92183. /**
  92184. * The collision margin around a soft object
  92185. */
  92186. margin?: number;
  92187. /**
  92188. * The collision margin around a soft object
  92189. */
  92190. damping?: number;
  92191. /**
  92192. * The path for a rope based on an extrusion
  92193. */
  92194. path?: any;
  92195. /**
  92196. * The shape of an extrusion used for a rope based on an extrusion
  92197. */
  92198. shape?: any;
  92199. }
  92200. /**
  92201. * Interface for a physics-enabled object
  92202. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92203. */
  92204. export interface IPhysicsEnabledObject {
  92205. /**
  92206. * The position of the physics-enabled object
  92207. */
  92208. position: Vector3;
  92209. /**
  92210. * The rotation of the physics-enabled object
  92211. */
  92212. rotationQuaternion: Nullable<Quaternion>;
  92213. /**
  92214. * The scale of the physics-enabled object
  92215. */
  92216. scaling: Vector3;
  92217. /**
  92218. * The rotation of the physics-enabled object
  92219. */
  92220. rotation?: Vector3;
  92221. /**
  92222. * The parent of the physics-enabled object
  92223. */
  92224. parent?: any;
  92225. /**
  92226. * The bounding info of the physics-enabled object
  92227. * @returns The bounding info of the physics-enabled object
  92228. */
  92229. getBoundingInfo(): BoundingInfo;
  92230. /**
  92231. * Computes the world matrix
  92232. * @param force Specifies if the world matrix should be computed by force
  92233. * @returns A world matrix
  92234. */
  92235. computeWorldMatrix(force: boolean): Matrix;
  92236. /**
  92237. * Gets the world matrix
  92238. * @returns A world matrix
  92239. */
  92240. getWorldMatrix?(): Matrix;
  92241. /**
  92242. * Gets the child meshes
  92243. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  92244. * @returns An array of abstract meshes
  92245. */
  92246. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  92247. /**
  92248. * Gets the vertex data
  92249. * @param kind The type of vertex data
  92250. * @returns A nullable array of numbers, or a float32 array
  92251. */
  92252. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  92253. /**
  92254. * Gets the indices from the mesh
  92255. * @returns A nullable array of index arrays
  92256. */
  92257. getIndices?(): Nullable<IndicesArray>;
  92258. /**
  92259. * Gets the scene from the mesh
  92260. * @returns the indices array or null
  92261. */
  92262. getScene?(): Scene;
  92263. /**
  92264. * Gets the absolute position from the mesh
  92265. * @returns the absolute position
  92266. */
  92267. getAbsolutePosition(): Vector3;
  92268. /**
  92269. * Gets the absolute pivot point from the mesh
  92270. * @returns the absolute pivot point
  92271. */
  92272. getAbsolutePivotPoint(): Vector3;
  92273. /**
  92274. * Rotates the mesh
  92275. * @param axis The axis of rotation
  92276. * @param amount The amount of rotation
  92277. * @param space The space of the rotation
  92278. * @returns The rotation transform node
  92279. */
  92280. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  92281. /**
  92282. * Translates the mesh
  92283. * @param axis The axis of translation
  92284. * @param distance The distance of translation
  92285. * @param space The space of the translation
  92286. * @returns The transform node
  92287. */
  92288. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  92289. /**
  92290. * Sets the absolute position of the mesh
  92291. * @param absolutePosition The absolute position of the mesh
  92292. * @returns The transform node
  92293. */
  92294. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  92295. /**
  92296. * Gets the class name of the mesh
  92297. * @returns The class name
  92298. */
  92299. getClassName(): string;
  92300. }
  92301. /**
  92302. * Represents a physics imposter
  92303. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92304. */
  92305. export class PhysicsImpostor {
  92306. /**
  92307. * The physics-enabled object used as the physics imposter
  92308. */
  92309. object: IPhysicsEnabledObject;
  92310. /**
  92311. * The type of the physics imposter
  92312. */
  92313. type: number;
  92314. private _options;
  92315. private _scene?;
  92316. /**
  92317. * The default object size of the imposter
  92318. */
  92319. static DEFAULT_OBJECT_SIZE: Vector3;
  92320. /**
  92321. * The identity quaternion of the imposter
  92322. */
  92323. static IDENTITY_QUATERNION: Quaternion;
  92324. /** @hidden */
  92325. _pluginData: any;
  92326. private _physicsEngine;
  92327. private _physicsBody;
  92328. private _bodyUpdateRequired;
  92329. private _onBeforePhysicsStepCallbacks;
  92330. private _onAfterPhysicsStepCallbacks;
  92331. /** @hidden */
  92332. _onPhysicsCollideCallbacks: Array<{
  92333. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  92334. otherImpostors: Array<PhysicsImpostor>;
  92335. }>;
  92336. private _deltaPosition;
  92337. private _deltaRotation;
  92338. private _deltaRotationConjugated;
  92339. /** @hidden */
  92340. _isFromLine: boolean;
  92341. private _parent;
  92342. private _isDisposed;
  92343. private static _tmpVecs;
  92344. private static _tmpQuat;
  92345. /**
  92346. * Specifies if the physics imposter is disposed
  92347. */
  92348. readonly isDisposed: boolean;
  92349. /**
  92350. * Gets the mass of the physics imposter
  92351. */
  92352. mass: number;
  92353. /**
  92354. * Gets the coefficient of friction
  92355. */
  92356. /**
  92357. * Sets the coefficient of friction
  92358. */
  92359. friction: number;
  92360. /**
  92361. * Gets the coefficient of restitution
  92362. */
  92363. /**
  92364. * Sets the coefficient of restitution
  92365. */
  92366. restitution: number;
  92367. /**
  92368. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  92369. */
  92370. /**
  92371. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  92372. */
  92373. pressure: number;
  92374. /**
  92375. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  92376. */
  92377. /**
  92378. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  92379. */
  92380. stiffness: number;
  92381. /**
  92382. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  92383. */
  92384. /**
  92385. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  92386. */
  92387. velocityIterations: number;
  92388. /**
  92389. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  92390. */
  92391. /**
  92392. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  92393. */
  92394. positionIterations: number;
  92395. /**
  92396. * The unique id of the physics imposter
  92397. * set by the physics engine when adding this impostor to the array
  92398. */
  92399. uniqueId: number;
  92400. /**
  92401. * @hidden
  92402. */
  92403. soft: boolean;
  92404. /**
  92405. * @hidden
  92406. */
  92407. segments: number;
  92408. private _joints;
  92409. /**
  92410. * Initializes the physics imposter
  92411. * @param object The physics-enabled object used as the physics imposter
  92412. * @param type The type of the physics imposter
  92413. * @param _options The options for the physics imposter
  92414. * @param _scene The Babylon scene
  92415. */
  92416. constructor(
  92417. /**
  92418. * The physics-enabled object used as the physics imposter
  92419. */
  92420. object: IPhysicsEnabledObject,
  92421. /**
  92422. * The type of the physics imposter
  92423. */
  92424. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  92425. /**
  92426. * This function will completly initialize this impostor.
  92427. * It will create a new body - but only if this mesh has no parent.
  92428. * If it has, this impostor will not be used other than to define the impostor
  92429. * of the child mesh.
  92430. * @hidden
  92431. */
  92432. _init(): void;
  92433. private _getPhysicsParent;
  92434. /**
  92435. * Should a new body be generated.
  92436. * @returns boolean specifying if body initialization is required
  92437. */
  92438. isBodyInitRequired(): boolean;
  92439. /**
  92440. * Sets the updated scaling
  92441. * @param updated Specifies if the scaling is updated
  92442. */
  92443. setScalingUpdated(): void;
  92444. /**
  92445. * Force a regeneration of this or the parent's impostor's body.
  92446. * Use under cautious - This will remove all joints already implemented.
  92447. */
  92448. forceUpdate(): void;
  92449. /**
  92450. * Gets the body that holds this impostor. Either its own, or its parent.
  92451. */
  92452. /**
  92453. * Set the physics body. Used mainly by the physics engine/plugin
  92454. */
  92455. physicsBody: any;
  92456. /**
  92457. * Get the parent of the physics imposter
  92458. * @returns Physics imposter or null
  92459. */
  92460. /**
  92461. * Sets the parent of the physics imposter
  92462. */
  92463. parent: Nullable<PhysicsImpostor>;
  92464. /**
  92465. * Resets the update flags
  92466. */
  92467. resetUpdateFlags(): void;
  92468. /**
  92469. * Gets the object extend size
  92470. * @returns the object extend size
  92471. */
  92472. getObjectExtendSize(): Vector3;
  92473. /**
  92474. * Gets the object center
  92475. * @returns The object center
  92476. */
  92477. getObjectCenter(): Vector3;
  92478. /**
  92479. * Get a specific parametes from the options parameter
  92480. * @param paramName The object parameter name
  92481. * @returns The object parameter
  92482. */
  92483. getParam(paramName: string): any;
  92484. /**
  92485. * Sets a specific parameter in the options given to the physics plugin
  92486. * @param paramName The parameter name
  92487. * @param value The value of the parameter
  92488. */
  92489. setParam(paramName: string, value: number): void;
  92490. /**
  92491. * Specifically change the body's mass option. Won't recreate the physics body object
  92492. * @param mass The mass of the physics imposter
  92493. */
  92494. setMass(mass: number): void;
  92495. /**
  92496. * Gets the linear velocity
  92497. * @returns linear velocity or null
  92498. */
  92499. getLinearVelocity(): Nullable<Vector3>;
  92500. /**
  92501. * Sets the linear velocity
  92502. * @param velocity linear velocity or null
  92503. */
  92504. setLinearVelocity(velocity: Nullable<Vector3>): void;
  92505. /**
  92506. * Gets the angular velocity
  92507. * @returns angular velocity or null
  92508. */
  92509. getAngularVelocity(): Nullable<Vector3>;
  92510. /**
  92511. * Sets the angular velocity
  92512. * @param velocity The velocity or null
  92513. */
  92514. setAngularVelocity(velocity: Nullable<Vector3>): void;
  92515. /**
  92516. * Execute a function with the physics plugin native code
  92517. * Provide a function the will have two variables - the world object and the physics body object
  92518. * @param func The function to execute with the physics plugin native code
  92519. */
  92520. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  92521. /**
  92522. * Register a function that will be executed before the physics world is stepping forward
  92523. * @param func The function to execute before the physics world is stepped forward
  92524. */
  92525. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  92526. /**
  92527. * Unregister a function that will be executed before the physics world is stepping forward
  92528. * @param func The function to execute before the physics world is stepped forward
  92529. */
  92530. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  92531. /**
  92532. * Register a function that will be executed after the physics step
  92533. * @param func The function to execute after physics step
  92534. */
  92535. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  92536. /**
  92537. * Unregisters a function that will be executed after the physics step
  92538. * @param func The function to execute after physics step
  92539. */
  92540. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  92541. /**
  92542. * register a function that will be executed when this impostor collides against a different body
  92543. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  92544. * @param func Callback that is executed on collision
  92545. */
  92546. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  92547. /**
  92548. * Unregisters the physics imposter on contact
  92549. * @param collideAgainst The physics object to collide against
  92550. * @param func Callback to execute on collision
  92551. */
  92552. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  92553. private _tmpQuat;
  92554. private _tmpQuat2;
  92555. /**
  92556. * Get the parent rotation
  92557. * @returns The parent rotation
  92558. */
  92559. getParentsRotation(): Quaternion;
  92560. /**
  92561. * this function is executed by the physics engine.
  92562. */
  92563. beforeStep: () => void;
  92564. /**
  92565. * this function is executed by the physics engine
  92566. */
  92567. afterStep: () => void;
  92568. /**
  92569. * Legacy collision detection event support
  92570. */
  92571. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  92572. /**
  92573. * event and body object due to cannon's event-based architecture.
  92574. */
  92575. onCollide: (e: {
  92576. body: any;
  92577. }) => void;
  92578. /**
  92579. * Apply a force
  92580. * @param force The force to apply
  92581. * @param contactPoint The contact point for the force
  92582. * @returns The physics imposter
  92583. */
  92584. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  92585. /**
  92586. * Apply an impulse
  92587. * @param force The impulse force
  92588. * @param contactPoint The contact point for the impulse force
  92589. * @returns The physics imposter
  92590. */
  92591. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  92592. /**
  92593. * A help function to create a joint
  92594. * @param otherImpostor A physics imposter used to create a joint
  92595. * @param jointType The type of joint
  92596. * @param jointData The data for the joint
  92597. * @returns The physics imposter
  92598. */
  92599. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  92600. /**
  92601. * Add a joint to this impostor with a different impostor
  92602. * @param otherImpostor A physics imposter used to add a joint
  92603. * @param joint The joint to add
  92604. * @returns The physics imposter
  92605. */
  92606. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  92607. /**
  92608. * Add an anchor to a cloth impostor
  92609. * @param otherImpostor rigid impostor to anchor to
  92610. * @param width ratio across width from 0 to 1
  92611. * @param height ratio up height from 0 to 1
  92612. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  92613. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  92614. * @returns impostor the soft imposter
  92615. */
  92616. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  92617. /**
  92618. * Add a hook to a rope impostor
  92619. * @param otherImpostor rigid impostor to anchor to
  92620. * @param length ratio across rope from 0 to 1
  92621. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  92622. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  92623. * @returns impostor the rope imposter
  92624. */
  92625. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  92626. /**
  92627. * Will keep this body still, in a sleep mode.
  92628. * @returns the physics imposter
  92629. */
  92630. sleep(): PhysicsImpostor;
  92631. /**
  92632. * Wake the body up.
  92633. * @returns The physics imposter
  92634. */
  92635. wakeUp(): PhysicsImpostor;
  92636. /**
  92637. * Clones the physics imposter
  92638. * @param newObject The physics imposter clones to this physics-enabled object
  92639. * @returns A nullable physics imposter
  92640. */
  92641. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  92642. /**
  92643. * Disposes the physics imposter
  92644. */
  92645. dispose(): void;
  92646. /**
  92647. * Sets the delta position
  92648. * @param position The delta position amount
  92649. */
  92650. setDeltaPosition(position: Vector3): void;
  92651. /**
  92652. * Sets the delta rotation
  92653. * @param rotation The delta rotation amount
  92654. */
  92655. setDeltaRotation(rotation: Quaternion): void;
  92656. /**
  92657. * Gets the box size of the physics imposter and stores the result in the input parameter
  92658. * @param result Stores the box size
  92659. * @returns The physics imposter
  92660. */
  92661. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  92662. /**
  92663. * Gets the radius of the physics imposter
  92664. * @returns Radius of the physics imposter
  92665. */
  92666. getRadius(): number;
  92667. /**
  92668. * Sync a bone with this impostor
  92669. * @param bone The bone to sync to the impostor.
  92670. * @param boneMesh The mesh that the bone is influencing.
  92671. * @param jointPivot The pivot of the joint / bone in local space.
  92672. * @param distToJoint Optional distance from the impostor to the joint.
  92673. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  92674. */
  92675. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  92676. /**
  92677. * Sync impostor to a bone
  92678. * @param bone The bone that the impostor will be synced to.
  92679. * @param boneMesh The mesh that the bone is influencing.
  92680. * @param jointPivot The pivot of the joint / bone in local space.
  92681. * @param distToJoint Optional distance from the impostor to the joint.
  92682. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  92683. * @param boneAxis Optional vector3 axis the bone is aligned with
  92684. */
  92685. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  92686. /**
  92687. * No-Imposter type
  92688. */
  92689. static NoImpostor: number;
  92690. /**
  92691. * Sphere-Imposter type
  92692. */
  92693. static SphereImpostor: number;
  92694. /**
  92695. * Box-Imposter type
  92696. */
  92697. static BoxImpostor: number;
  92698. /**
  92699. * Plane-Imposter type
  92700. */
  92701. static PlaneImpostor: number;
  92702. /**
  92703. * Mesh-imposter type
  92704. */
  92705. static MeshImpostor: number;
  92706. /**
  92707. * Capsule-Impostor type (Ammo.js plugin only)
  92708. */
  92709. static CapsuleImpostor: number;
  92710. /**
  92711. * Cylinder-Imposter type
  92712. */
  92713. static CylinderImpostor: number;
  92714. /**
  92715. * Particle-Imposter type
  92716. */
  92717. static ParticleImpostor: number;
  92718. /**
  92719. * Heightmap-Imposter type
  92720. */
  92721. static HeightmapImpostor: number;
  92722. /**
  92723. * ConvexHull-Impostor type (Ammo.js plugin only)
  92724. */
  92725. static ConvexHullImpostor: number;
  92726. /**
  92727. * Custom-Imposter type (Ammo.js plugin only)
  92728. */
  92729. static CustomImpostor: number;
  92730. /**
  92731. * Rope-Imposter type
  92732. */
  92733. static RopeImpostor: number;
  92734. /**
  92735. * Cloth-Imposter type
  92736. */
  92737. static ClothImpostor: number;
  92738. /**
  92739. * Softbody-Imposter type
  92740. */
  92741. static SoftbodyImpostor: number;
  92742. }
  92743. }
  92744. declare module BABYLON {
  92745. /**
  92746. * @hidden
  92747. **/
  92748. export class _CreationDataStorage {
  92749. closePath?: boolean;
  92750. closeArray?: boolean;
  92751. idx: number[];
  92752. dashSize: number;
  92753. gapSize: number;
  92754. path3D: Path3D;
  92755. pathArray: Vector3[][];
  92756. arc: number;
  92757. radius: number;
  92758. cap: number;
  92759. tessellation: number;
  92760. }
  92761. /**
  92762. * @hidden
  92763. **/
  92764. class _InstanceDataStorage {
  92765. visibleInstances: any;
  92766. batchCache: _InstancesBatch;
  92767. instancesBufferSize: number;
  92768. instancesBuffer: Nullable<Buffer>;
  92769. instancesData: Float32Array;
  92770. overridenInstanceCount: number;
  92771. isFrozen: boolean;
  92772. previousBatch: Nullable<_InstancesBatch>;
  92773. hardwareInstancedRendering: boolean;
  92774. sideOrientation: number;
  92775. manualUpdate: boolean;
  92776. }
  92777. /**
  92778. * @hidden
  92779. **/
  92780. export class _InstancesBatch {
  92781. mustReturn: boolean;
  92782. visibleInstances: Nullable<InstancedMesh[]>[];
  92783. renderSelf: boolean[];
  92784. hardwareInstancedRendering: boolean[];
  92785. }
  92786. /**
  92787. * Class used to represent renderable models
  92788. */
  92789. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  92790. /**
  92791. * Mesh side orientation : usually the external or front surface
  92792. */
  92793. static readonly FRONTSIDE: number;
  92794. /**
  92795. * Mesh side orientation : usually the internal or back surface
  92796. */
  92797. static readonly BACKSIDE: number;
  92798. /**
  92799. * Mesh side orientation : both internal and external or front and back surfaces
  92800. */
  92801. static readonly DOUBLESIDE: number;
  92802. /**
  92803. * Mesh side orientation : by default, `FRONTSIDE`
  92804. */
  92805. static readonly DEFAULTSIDE: number;
  92806. /**
  92807. * Mesh cap setting : no cap
  92808. */
  92809. static readonly NO_CAP: number;
  92810. /**
  92811. * Mesh cap setting : one cap at the beginning of the mesh
  92812. */
  92813. static readonly CAP_START: number;
  92814. /**
  92815. * Mesh cap setting : one cap at the end of the mesh
  92816. */
  92817. static readonly CAP_END: number;
  92818. /**
  92819. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  92820. */
  92821. static readonly CAP_ALL: number;
  92822. /**
  92823. * Mesh pattern setting : no flip or rotate
  92824. */
  92825. static readonly NO_FLIP: number;
  92826. /**
  92827. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  92828. */
  92829. static readonly FLIP_TILE: number;
  92830. /**
  92831. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  92832. */
  92833. static readonly ROTATE_TILE: number;
  92834. /**
  92835. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  92836. */
  92837. static readonly FLIP_ROW: number;
  92838. /**
  92839. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  92840. */
  92841. static readonly ROTATE_ROW: number;
  92842. /**
  92843. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  92844. */
  92845. static readonly FLIP_N_ROTATE_TILE: number;
  92846. /**
  92847. * Mesh pattern setting : rotate pattern and rotate
  92848. */
  92849. static readonly FLIP_N_ROTATE_ROW: number;
  92850. /**
  92851. * Mesh tile positioning : part tiles same on left/right or top/bottom
  92852. */
  92853. static readonly CENTER: number;
  92854. /**
  92855. * Mesh tile positioning : part tiles on left
  92856. */
  92857. static readonly LEFT: number;
  92858. /**
  92859. * Mesh tile positioning : part tiles on right
  92860. */
  92861. static readonly RIGHT: number;
  92862. /**
  92863. * Mesh tile positioning : part tiles on top
  92864. */
  92865. static readonly TOP: number;
  92866. /**
  92867. * Mesh tile positioning : part tiles on bottom
  92868. */
  92869. static readonly BOTTOM: number;
  92870. /**
  92871. * Gets the default side orientation.
  92872. * @param orientation the orientation to value to attempt to get
  92873. * @returns the default orientation
  92874. * @hidden
  92875. */
  92876. static _GetDefaultSideOrientation(orientation?: number): number;
  92877. private _internalMeshDataInfo;
  92878. /**
  92879. * An event triggered before rendering the mesh
  92880. */
  92881. readonly onBeforeRenderObservable: Observable<Mesh>;
  92882. /**
  92883. * An event triggered before binding the mesh
  92884. */
  92885. readonly onBeforeBindObservable: Observable<Mesh>;
  92886. /**
  92887. * An event triggered after rendering the mesh
  92888. */
  92889. readonly onAfterRenderObservable: Observable<Mesh>;
  92890. /**
  92891. * An event triggered before drawing the mesh
  92892. */
  92893. readonly onBeforeDrawObservable: Observable<Mesh>;
  92894. private _onBeforeDrawObserver;
  92895. /**
  92896. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  92897. */
  92898. onBeforeDraw: () => void;
  92899. readonly hasInstances: boolean;
  92900. /**
  92901. * Gets the delay loading state of the mesh (when delay loading is turned on)
  92902. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  92903. */
  92904. delayLoadState: number;
  92905. /**
  92906. * Gets the list of instances created from this mesh
  92907. * it is not supposed to be modified manually.
  92908. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  92909. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  92910. */
  92911. instances: InstancedMesh[];
  92912. /**
  92913. * Gets the file containing delay loading data for this mesh
  92914. */
  92915. delayLoadingFile: string;
  92916. /** @hidden */
  92917. _binaryInfo: any;
  92918. /**
  92919. * User defined function used to change how LOD level selection is done
  92920. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  92921. */
  92922. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  92923. /**
  92924. * Gets or sets the morph target manager
  92925. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  92926. */
  92927. morphTargetManager: Nullable<MorphTargetManager>;
  92928. /** @hidden */
  92929. _creationDataStorage: Nullable<_CreationDataStorage>;
  92930. /** @hidden */
  92931. _geometry: Nullable<Geometry>;
  92932. /** @hidden */
  92933. _delayInfo: Array<string>;
  92934. /** @hidden */
  92935. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  92936. /** @hidden */
  92937. _instanceDataStorage: _InstanceDataStorage;
  92938. private _effectiveMaterial;
  92939. /** @hidden */
  92940. _shouldGenerateFlatShading: boolean;
  92941. /** @hidden */
  92942. _originalBuilderSideOrientation: number;
  92943. /**
  92944. * Use this property to change the original side orientation defined at construction time
  92945. */
  92946. overrideMaterialSideOrientation: Nullable<number>;
  92947. /**
  92948. * Gets the source mesh (the one used to clone this one from)
  92949. */
  92950. readonly source: Nullable<Mesh>;
  92951. /**
  92952. * Gets or sets a boolean indicating that this mesh does not use index buffer
  92953. */
  92954. isUnIndexed: boolean;
  92955. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  92956. readonly worldMatrixInstancedBuffer: Float32Array;
  92957. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  92958. manualUpdateOfWorldMatrixInstancedBuffer: boolean;
  92959. /**
  92960. * @constructor
  92961. * @param name The value used by scene.getMeshByName() to do a lookup.
  92962. * @param scene The scene to add this mesh to.
  92963. * @param parent The parent of this mesh, if it has one
  92964. * @param source An optional Mesh from which geometry is shared, cloned.
  92965. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  92966. * When false, achieved by calling a clone(), also passing False.
  92967. * This will make creation of children, recursive.
  92968. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  92969. */
  92970. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  92971. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  92972. doNotInstantiate: boolean;
  92973. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  92974. /**
  92975. * Gets the class name
  92976. * @returns the string "Mesh".
  92977. */
  92978. getClassName(): string;
  92979. /** @hidden */
  92980. readonly _isMesh: boolean;
  92981. /**
  92982. * Returns a description of this mesh
  92983. * @param fullDetails define if full details about this mesh must be used
  92984. * @returns a descriptive string representing this mesh
  92985. */
  92986. toString(fullDetails?: boolean): string;
  92987. /** @hidden */
  92988. _unBindEffect(): void;
  92989. /**
  92990. * Gets a boolean indicating if this mesh has LOD
  92991. */
  92992. readonly hasLODLevels: boolean;
  92993. /**
  92994. * Gets the list of MeshLODLevel associated with the current mesh
  92995. * @returns an array of MeshLODLevel
  92996. */
  92997. getLODLevels(): MeshLODLevel[];
  92998. private _sortLODLevels;
  92999. /**
  93000. * Add a mesh as LOD level triggered at the given distance.
  93001. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  93002. * @param distance The distance from the center of the object to show this level
  93003. * @param mesh The mesh to be added as LOD level (can be null)
  93004. * @return This mesh (for chaining)
  93005. */
  93006. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  93007. /**
  93008. * Returns the LOD level mesh at the passed distance or null if not found.
  93009. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  93010. * @param distance The distance from the center of the object to show this level
  93011. * @returns a Mesh or `null`
  93012. */
  93013. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  93014. /**
  93015. * Remove a mesh from the LOD array
  93016. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  93017. * @param mesh defines the mesh to be removed
  93018. * @return This mesh (for chaining)
  93019. */
  93020. removeLODLevel(mesh: Mesh): Mesh;
  93021. /**
  93022. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  93023. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  93024. * @param camera defines the camera to use to compute distance
  93025. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  93026. * @return This mesh (for chaining)
  93027. */
  93028. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  93029. /**
  93030. * Gets the mesh internal Geometry object
  93031. */
  93032. readonly geometry: Nullable<Geometry>;
  93033. /**
  93034. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  93035. * @returns the total number of vertices
  93036. */
  93037. getTotalVertices(): number;
  93038. /**
  93039. * Returns the content of an associated vertex buffer
  93040. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  93041. * - VertexBuffer.PositionKind
  93042. * - VertexBuffer.UVKind
  93043. * - VertexBuffer.UV2Kind
  93044. * - VertexBuffer.UV3Kind
  93045. * - VertexBuffer.UV4Kind
  93046. * - VertexBuffer.UV5Kind
  93047. * - VertexBuffer.UV6Kind
  93048. * - VertexBuffer.ColorKind
  93049. * - VertexBuffer.MatricesIndicesKind
  93050. * - VertexBuffer.MatricesIndicesExtraKind
  93051. * - VertexBuffer.MatricesWeightsKind
  93052. * - VertexBuffer.MatricesWeightsExtraKind
  93053. * @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
  93054. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  93055. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  93056. */
  93057. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  93058. /**
  93059. * Returns the mesh VertexBuffer object from the requested `kind`
  93060. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  93061. * - VertexBuffer.PositionKind
  93062. * - VertexBuffer.NormalKind
  93063. * - VertexBuffer.UVKind
  93064. * - VertexBuffer.UV2Kind
  93065. * - VertexBuffer.UV3Kind
  93066. * - VertexBuffer.UV4Kind
  93067. * - VertexBuffer.UV5Kind
  93068. * - VertexBuffer.UV6Kind
  93069. * - VertexBuffer.ColorKind
  93070. * - VertexBuffer.MatricesIndicesKind
  93071. * - VertexBuffer.MatricesIndicesExtraKind
  93072. * - VertexBuffer.MatricesWeightsKind
  93073. * - VertexBuffer.MatricesWeightsExtraKind
  93074. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  93075. */
  93076. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  93077. /**
  93078. * Tests if a specific vertex buffer is associated with this mesh
  93079. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  93080. * - VertexBuffer.PositionKind
  93081. * - VertexBuffer.NormalKind
  93082. * - VertexBuffer.UVKind
  93083. * - VertexBuffer.UV2Kind
  93084. * - VertexBuffer.UV3Kind
  93085. * - VertexBuffer.UV4Kind
  93086. * - VertexBuffer.UV5Kind
  93087. * - VertexBuffer.UV6Kind
  93088. * - VertexBuffer.ColorKind
  93089. * - VertexBuffer.MatricesIndicesKind
  93090. * - VertexBuffer.MatricesIndicesExtraKind
  93091. * - VertexBuffer.MatricesWeightsKind
  93092. * - VertexBuffer.MatricesWeightsExtraKind
  93093. * @returns a boolean
  93094. */
  93095. isVerticesDataPresent(kind: string): boolean;
  93096. /**
  93097. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  93098. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  93099. * - VertexBuffer.PositionKind
  93100. * - VertexBuffer.UVKind
  93101. * - VertexBuffer.UV2Kind
  93102. * - VertexBuffer.UV3Kind
  93103. * - VertexBuffer.UV4Kind
  93104. * - VertexBuffer.UV5Kind
  93105. * - VertexBuffer.UV6Kind
  93106. * - VertexBuffer.ColorKind
  93107. * - VertexBuffer.MatricesIndicesKind
  93108. * - VertexBuffer.MatricesIndicesExtraKind
  93109. * - VertexBuffer.MatricesWeightsKind
  93110. * - VertexBuffer.MatricesWeightsExtraKind
  93111. * @returns a boolean
  93112. */
  93113. isVertexBufferUpdatable(kind: string): boolean;
  93114. /**
  93115. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  93116. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  93117. * - VertexBuffer.PositionKind
  93118. * - VertexBuffer.NormalKind
  93119. * - VertexBuffer.UVKind
  93120. * - VertexBuffer.UV2Kind
  93121. * - VertexBuffer.UV3Kind
  93122. * - VertexBuffer.UV4Kind
  93123. * - VertexBuffer.UV5Kind
  93124. * - VertexBuffer.UV6Kind
  93125. * - VertexBuffer.ColorKind
  93126. * - VertexBuffer.MatricesIndicesKind
  93127. * - VertexBuffer.MatricesIndicesExtraKind
  93128. * - VertexBuffer.MatricesWeightsKind
  93129. * - VertexBuffer.MatricesWeightsExtraKind
  93130. * @returns an array of strings
  93131. */
  93132. getVerticesDataKinds(): string[];
  93133. /**
  93134. * Returns a positive integer : the total number of indices in this mesh geometry.
  93135. * @returns the numner of indices or zero if the mesh has no geometry.
  93136. */
  93137. getTotalIndices(): number;
  93138. /**
  93139. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  93140. * @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.
  93141. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  93142. * @returns the indices array or an empty array if the mesh has no geometry
  93143. */
  93144. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  93145. readonly isBlocked: boolean;
  93146. /**
  93147. * Determine if the current mesh is ready to be rendered
  93148. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  93149. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  93150. * @returns true if all associated assets are ready (material, textures, shaders)
  93151. */
  93152. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  93153. /**
  93154. * 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.
  93155. */
  93156. readonly areNormalsFrozen: boolean;
  93157. /**
  93158. * 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.
  93159. * @returns the current mesh
  93160. */
  93161. freezeNormals(): Mesh;
  93162. /**
  93163. * 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
  93164. * @returns the current mesh
  93165. */
  93166. unfreezeNormals(): Mesh;
  93167. /**
  93168. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  93169. */
  93170. overridenInstanceCount: number;
  93171. /** @hidden */
  93172. _preActivate(): Mesh;
  93173. /** @hidden */
  93174. _preActivateForIntermediateRendering(renderId: number): Mesh;
  93175. /** @hidden */
  93176. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  93177. /**
  93178. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  93179. * This means the mesh underlying bounding box and sphere are recomputed.
  93180. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  93181. * @returns the current mesh
  93182. */
  93183. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  93184. /** @hidden */
  93185. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  93186. /**
  93187. * This function will subdivide the mesh into multiple submeshes
  93188. * @param count defines the expected number of submeshes
  93189. */
  93190. subdivide(count: number): void;
  93191. /**
  93192. * Copy a FloatArray into a specific associated vertex buffer
  93193. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  93194. * - VertexBuffer.PositionKind
  93195. * - VertexBuffer.UVKind
  93196. * - VertexBuffer.UV2Kind
  93197. * - VertexBuffer.UV3Kind
  93198. * - VertexBuffer.UV4Kind
  93199. * - VertexBuffer.UV5Kind
  93200. * - VertexBuffer.UV6Kind
  93201. * - VertexBuffer.ColorKind
  93202. * - VertexBuffer.MatricesIndicesKind
  93203. * - VertexBuffer.MatricesIndicesExtraKind
  93204. * - VertexBuffer.MatricesWeightsKind
  93205. * - VertexBuffer.MatricesWeightsExtraKind
  93206. * @param data defines the data source
  93207. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  93208. * @param stride defines the data stride size (can be null)
  93209. * @returns the current mesh
  93210. */
  93211. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  93212. /**
  93213. * Delete a vertex buffer associated with this mesh
  93214. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  93215. * - VertexBuffer.PositionKind
  93216. * - VertexBuffer.UVKind
  93217. * - VertexBuffer.UV2Kind
  93218. * - VertexBuffer.UV3Kind
  93219. * - VertexBuffer.UV4Kind
  93220. * - VertexBuffer.UV5Kind
  93221. * - VertexBuffer.UV6Kind
  93222. * - VertexBuffer.ColorKind
  93223. * - VertexBuffer.MatricesIndicesKind
  93224. * - VertexBuffer.MatricesIndicesExtraKind
  93225. * - VertexBuffer.MatricesWeightsKind
  93226. * - VertexBuffer.MatricesWeightsExtraKind
  93227. */
  93228. removeVerticesData(kind: string): void;
  93229. /**
  93230. * Flags an associated vertex buffer as updatable
  93231. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  93232. * - VertexBuffer.PositionKind
  93233. * - VertexBuffer.UVKind
  93234. * - VertexBuffer.UV2Kind
  93235. * - VertexBuffer.UV3Kind
  93236. * - VertexBuffer.UV4Kind
  93237. * - VertexBuffer.UV5Kind
  93238. * - VertexBuffer.UV6Kind
  93239. * - VertexBuffer.ColorKind
  93240. * - VertexBuffer.MatricesIndicesKind
  93241. * - VertexBuffer.MatricesIndicesExtraKind
  93242. * - VertexBuffer.MatricesWeightsKind
  93243. * - VertexBuffer.MatricesWeightsExtraKind
  93244. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  93245. */
  93246. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  93247. /**
  93248. * Sets the mesh global Vertex Buffer
  93249. * @param buffer defines the buffer to use
  93250. * @returns the current mesh
  93251. */
  93252. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  93253. /**
  93254. * Update a specific associated vertex buffer
  93255. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  93256. * - VertexBuffer.PositionKind
  93257. * - VertexBuffer.UVKind
  93258. * - VertexBuffer.UV2Kind
  93259. * - VertexBuffer.UV3Kind
  93260. * - VertexBuffer.UV4Kind
  93261. * - VertexBuffer.UV5Kind
  93262. * - VertexBuffer.UV6Kind
  93263. * - VertexBuffer.ColorKind
  93264. * - VertexBuffer.MatricesIndicesKind
  93265. * - VertexBuffer.MatricesIndicesExtraKind
  93266. * - VertexBuffer.MatricesWeightsKind
  93267. * - VertexBuffer.MatricesWeightsExtraKind
  93268. * @param data defines the data source
  93269. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  93270. * @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)
  93271. * @returns the current mesh
  93272. */
  93273. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  93274. /**
  93275. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  93276. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  93277. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  93278. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  93279. * @returns the current mesh
  93280. */
  93281. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  93282. /**
  93283. * Creates a un-shared specific occurence of the geometry for the mesh.
  93284. * @returns the current mesh
  93285. */
  93286. makeGeometryUnique(): Mesh;
  93287. /**
  93288. * Set the index buffer of this mesh
  93289. * @param indices defines the source data
  93290. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  93291. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  93292. * @returns the current mesh
  93293. */
  93294. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  93295. /**
  93296. * Update the current index buffer
  93297. * @param indices defines the source data
  93298. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  93299. * @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)
  93300. * @returns the current mesh
  93301. */
  93302. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  93303. /**
  93304. * Invert the geometry to move from a right handed system to a left handed one.
  93305. * @returns the current mesh
  93306. */
  93307. toLeftHanded(): Mesh;
  93308. /** @hidden */
  93309. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  93310. /** @hidden */
  93311. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  93312. /**
  93313. * Registers for this mesh a javascript function called just before the rendering process
  93314. * @param func defines the function to call before rendering this mesh
  93315. * @returns the current mesh
  93316. */
  93317. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  93318. /**
  93319. * Disposes a previously registered javascript function called before the rendering
  93320. * @param func defines the function to remove
  93321. * @returns the current mesh
  93322. */
  93323. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  93324. /**
  93325. * Registers for this mesh a javascript function called just after the rendering is complete
  93326. * @param func defines the function to call after rendering this mesh
  93327. * @returns the current mesh
  93328. */
  93329. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  93330. /**
  93331. * Disposes a previously registered javascript function called after the rendering.
  93332. * @param func defines the function to remove
  93333. * @returns the current mesh
  93334. */
  93335. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  93336. /** @hidden */
  93337. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  93338. /** @hidden */
  93339. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  93340. /** @hidden */
  93341. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  93342. /** @hidden */
  93343. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  93344. /** @hidden */
  93345. _rebuild(): void;
  93346. /** @hidden */
  93347. _freeze(): void;
  93348. /** @hidden */
  93349. _unFreeze(): void;
  93350. /**
  93351. * 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
  93352. * @param subMesh defines the subMesh to render
  93353. * @param enableAlphaMode defines if alpha mode can be changed
  93354. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  93355. * @returns the current mesh
  93356. */
  93357. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  93358. private _onBeforeDraw;
  93359. /**
  93360. * Renormalize the mesh and patch it up if there are no weights
  93361. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  93362. * However in the case of zero weights then we set just a single influence to 1.
  93363. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  93364. */
  93365. cleanMatrixWeights(): void;
  93366. private normalizeSkinFourWeights;
  93367. private normalizeSkinWeightsAndExtra;
  93368. /**
  93369. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  93370. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  93371. * the user know there was an issue with importing the mesh
  93372. * @returns a validation object with skinned, valid and report string
  93373. */
  93374. validateSkinning(): {
  93375. skinned: boolean;
  93376. valid: boolean;
  93377. report: string;
  93378. };
  93379. /** @hidden */
  93380. _checkDelayState(): Mesh;
  93381. private _queueLoad;
  93382. /**
  93383. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  93384. * A mesh is in the frustum if its bounding box intersects the frustum
  93385. * @param frustumPlanes defines the frustum to test
  93386. * @returns true if the mesh is in the frustum planes
  93387. */
  93388. isInFrustum(frustumPlanes: Plane[]): boolean;
  93389. /**
  93390. * Sets the mesh material by the material or multiMaterial `id` property
  93391. * @param id is a string identifying the material or the multiMaterial
  93392. * @returns the current mesh
  93393. */
  93394. setMaterialByID(id: string): Mesh;
  93395. /**
  93396. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  93397. * @returns an array of IAnimatable
  93398. */
  93399. getAnimatables(): IAnimatable[];
  93400. /**
  93401. * Modifies the mesh geometry according to the passed transformation matrix.
  93402. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  93403. * The mesh normals are modified using the same transformation.
  93404. * Note that, under the hood, this method sets a new VertexBuffer each call.
  93405. * @param transform defines the transform matrix to use
  93406. * @see http://doc.babylonjs.com/resources/baking_transformations
  93407. * @returns the current mesh
  93408. */
  93409. bakeTransformIntoVertices(transform: Matrix): Mesh;
  93410. /**
  93411. * Modifies the mesh geometry according to its own current World Matrix.
  93412. * The mesh World Matrix is then reset.
  93413. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  93414. * Note that, under the hood, this method sets a new VertexBuffer each call.
  93415. * @see http://doc.babylonjs.com/resources/baking_transformations
  93416. * @returns the current mesh
  93417. */
  93418. bakeCurrentTransformIntoVertices(): Mesh;
  93419. /** @hidden */
  93420. readonly _positions: Nullable<Vector3[]>;
  93421. /** @hidden */
  93422. _resetPointsArrayCache(): Mesh;
  93423. /** @hidden */
  93424. _generatePointsArray(): boolean;
  93425. /**
  93426. * Returns a new Mesh object generated from the current mesh properties.
  93427. * This method must not get confused with createInstance()
  93428. * @param name is a string, the name given to the new mesh
  93429. * @param newParent can be any Node object (default `null`)
  93430. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  93431. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  93432. * @returns a new mesh
  93433. */
  93434. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  93435. /**
  93436. * Releases resources associated with this mesh.
  93437. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93438. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93439. */
  93440. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93441. /** @hidden */
  93442. _disposeInstanceSpecificData(): void;
  93443. /**
  93444. * Modifies the mesh geometry according to a displacement map.
  93445. * 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.
  93446. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  93447. * @param url is a string, the URL from the image file is to be downloaded.
  93448. * @param minHeight is the lower limit of the displacement.
  93449. * @param maxHeight is the upper limit of the displacement.
  93450. * @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.
  93451. * @param uvOffset is an optional vector2 used to offset UV.
  93452. * @param uvScale is an optional vector2 used to scale UV.
  93453. * @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.
  93454. * @returns the Mesh.
  93455. */
  93456. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  93457. /**
  93458. * Modifies the mesh geometry according to a displacementMap buffer.
  93459. * 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.
  93460. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  93461. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  93462. * @param heightMapWidth is the width of the buffer image.
  93463. * @param heightMapHeight is the height of the buffer image.
  93464. * @param minHeight is the lower limit of the displacement.
  93465. * @param maxHeight is the upper limit of the displacement.
  93466. * @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.
  93467. * @param uvOffset is an optional vector2 used to offset UV.
  93468. * @param uvScale is an optional vector2 used to scale UV.
  93469. * @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.
  93470. * @returns the Mesh.
  93471. */
  93472. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  93473. /**
  93474. * Modify the mesh to get a flat shading rendering.
  93475. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  93476. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  93477. * @returns current mesh
  93478. */
  93479. convertToFlatShadedMesh(): Mesh;
  93480. /**
  93481. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  93482. * In other words, more vertices, no more indices and a single bigger VBO.
  93483. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  93484. * @returns current mesh
  93485. */
  93486. convertToUnIndexedMesh(): Mesh;
  93487. /**
  93488. * Inverses facet orientations.
  93489. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  93490. * @param flipNormals will also inverts the normals
  93491. * @returns current mesh
  93492. */
  93493. flipFaces(flipNormals?: boolean): Mesh;
  93494. /**
  93495. * Increase the number of facets and hence vertices in a mesh
  93496. * Vertex normals are interpolated from existing vertex normals
  93497. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  93498. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  93499. */
  93500. increaseVertices(numberPerEdge: number): void;
  93501. /**
  93502. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  93503. * This will undo any application of covertToFlatShadedMesh
  93504. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  93505. */
  93506. forceSharedVertices(): void;
  93507. /** @hidden */
  93508. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  93509. /** @hidden */
  93510. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  93511. /**
  93512. * Creates a new InstancedMesh object from the mesh model.
  93513. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  93514. * @param name defines the name of the new instance
  93515. * @returns a new InstancedMesh
  93516. */
  93517. createInstance(name: string): InstancedMesh;
  93518. /**
  93519. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  93520. * After this call, all the mesh instances have the same submeshes than the current mesh.
  93521. * @returns the current mesh
  93522. */
  93523. synchronizeInstances(): Mesh;
  93524. /**
  93525. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  93526. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  93527. * This should be used together with the simplification to avoid disappearing triangles.
  93528. * @param successCallback an optional success callback to be called after the optimization finished.
  93529. * @returns the current mesh
  93530. */
  93531. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  93532. /**
  93533. * Serialize current mesh
  93534. * @param serializationObject defines the object which will receive the serialization data
  93535. */
  93536. serialize(serializationObject: any): void;
  93537. /** @hidden */
  93538. _syncGeometryWithMorphTargetManager(): void;
  93539. /** @hidden */
  93540. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  93541. /**
  93542. * Returns a new Mesh object parsed from the source provided.
  93543. * @param parsedMesh is the source
  93544. * @param scene defines the hosting scene
  93545. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  93546. * @returns a new Mesh
  93547. */
  93548. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  93549. /**
  93550. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  93551. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  93552. * @param name defines the name of the mesh to create
  93553. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  93554. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  93555. * @param closePath creates a seam between the first and the last points of each path of the path array
  93556. * @param offset is taken in account only if the `pathArray` is containing a single path
  93557. * @param scene defines the hosting scene
  93558. * @param updatable defines if the mesh must be flagged as updatable
  93559. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93560. * @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)
  93561. * @returns a new Mesh
  93562. */
  93563. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  93564. /**
  93565. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  93566. * @param name defines the name of the mesh to create
  93567. * @param radius sets the radius size (float) of the polygon (default 0.5)
  93568. * @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
  93569. * @param scene defines the hosting scene
  93570. * @param updatable defines if the mesh must be flagged as updatable
  93571. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93572. * @returns a new Mesh
  93573. */
  93574. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  93575. /**
  93576. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  93577. * @param name defines the name of the mesh to create
  93578. * @param size sets the size (float) of each box side (default 1)
  93579. * @param scene defines the hosting scene
  93580. * @param updatable defines if the mesh must be flagged as updatable
  93581. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93582. * @returns a new Mesh
  93583. */
  93584. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  93585. /**
  93586. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  93587. * @param name defines the name of the mesh to create
  93588. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  93589. * @param diameter sets the diameter size (float) of the sphere (default 1)
  93590. * @param scene defines the hosting scene
  93591. * @param updatable defines if the mesh must be flagged as updatable
  93592. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93593. * @returns a new Mesh
  93594. */
  93595. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  93596. /**
  93597. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  93598. * @param name defines the name of the mesh to create
  93599. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  93600. * @param diameter sets the diameter size (float) of the sphere (default 1)
  93601. * @param scene defines the hosting scene
  93602. * @returns a new Mesh
  93603. */
  93604. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  93605. /**
  93606. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  93607. * @param name defines the name of the mesh to create
  93608. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  93609. * @param diameterTop set the top cap diameter (floats, default 1)
  93610. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  93611. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  93612. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  93613. * @param scene defines the hosting scene
  93614. * @param updatable defines if the mesh must be flagged as updatable
  93615. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93616. * @returns a new Mesh
  93617. */
  93618. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  93619. /**
  93620. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  93621. * @param name defines the name of the mesh to create
  93622. * @param diameter sets the diameter size (float) of the torus (default 1)
  93623. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  93624. * @param tessellation sets the number of torus sides (postive integer, default 16)
  93625. * @param scene defines the hosting scene
  93626. * @param updatable defines if the mesh must be flagged as updatable
  93627. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93628. * @returns a new Mesh
  93629. */
  93630. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  93631. /**
  93632. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  93633. * @param name defines the name of the mesh to create
  93634. * @param radius sets the global radius size (float) of the torus knot (default 2)
  93635. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  93636. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  93637. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  93638. * @param p the number of windings on X axis (positive integers, default 2)
  93639. * @param q the number of windings on Y axis (positive integers, default 3)
  93640. * @param scene defines the hosting scene
  93641. * @param updatable defines if the mesh must be flagged as updatable
  93642. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93643. * @returns a new Mesh
  93644. */
  93645. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  93646. /**
  93647. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  93648. * @param name defines the name of the mesh to create
  93649. * @param points is an array successive Vector3
  93650. * @param scene defines the hosting scene
  93651. * @param updatable defines if the mesh must be flagged as updatable
  93652. * @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).
  93653. * @returns a new Mesh
  93654. */
  93655. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  93656. /**
  93657. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  93658. * @param name defines the name of the mesh to create
  93659. * @param points is an array successive Vector3
  93660. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  93661. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  93662. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  93663. * @param scene defines the hosting scene
  93664. * @param updatable defines if the mesh must be flagged as updatable
  93665. * @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)
  93666. * @returns a new Mesh
  93667. */
  93668. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  93669. /**
  93670. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  93671. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  93672. * 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.
  93673. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93674. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  93675. * Remember you can only change the shape positions, not their number when updating a polygon.
  93676. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  93677. * @param name defines the name of the mesh to create
  93678. * @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
  93679. * @param scene defines the hosting scene
  93680. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  93681. * @param updatable defines if the mesh must be flagged as updatable
  93682. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93683. * @param earcutInjection can be used to inject your own earcut reference
  93684. * @returns a new Mesh
  93685. */
  93686. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  93687. /**
  93688. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  93689. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  93690. * @param name defines the name of the mesh to create
  93691. * @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
  93692. * @param depth defines the height of extrusion
  93693. * @param scene defines the hosting scene
  93694. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  93695. * @param updatable defines if the mesh must be flagged as updatable
  93696. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93697. * @param earcutInjection can be used to inject your own earcut reference
  93698. * @returns a new Mesh
  93699. */
  93700. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  93701. /**
  93702. * Creates an extruded shape mesh.
  93703. * 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
  93704. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  93705. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  93706. * @param name defines the name of the mesh to create
  93707. * @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
  93708. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  93709. * @param scale is the value to scale the shape
  93710. * @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
  93711. * @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
  93712. * @param scene defines the hosting scene
  93713. * @param updatable defines if the mesh must be flagged as updatable
  93714. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93715. * @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)
  93716. * @returns a new Mesh
  93717. */
  93718. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  93719. /**
  93720. * Creates an custom extruded shape mesh.
  93721. * The custom extrusion is a parametric shape.
  93722. * It has no predefined shape. Its final shape will depend on the input parameters.
  93723. * Please consider using the same method from the MeshBuilder class instead
  93724. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  93725. * @param name defines the name of the mesh to create
  93726. * @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
  93727. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  93728. * @param scaleFunction is a custom Javascript function called on each path point
  93729. * @param rotationFunction is a custom Javascript function called on each path point
  93730. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  93731. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  93732. * @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
  93733. * @param scene defines the hosting scene
  93734. * @param updatable defines if the mesh must be flagged as updatable
  93735. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93736. * @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)
  93737. * @returns a new Mesh
  93738. */
  93739. 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;
  93740. /**
  93741. * Creates lathe mesh.
  93742. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  93743. * Please consider using the same method from the MeshBuilder class instead
  93744. * @param name defines the name of the mesh to create
  93745. * @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
  93746. * @param radius is the radius value of the lathe
  93747. * @param tessellation is the side number of the lathe.
  93748. * @param scene defines the hosting scene
  93749. * @param updatable defines if the mesh must be flagged as updatable
  93750. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93751. * @returns a new Mesh
  93752. */
  93753. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  93754. /**
  93755. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  93756. * @param name defines the name of the mesh to create
  93757. * @param size sets the size (float) of both sides of the plane at once (default 1)
  93758. * @param scene defines the hosting scene
  93759. * @param updatable defines if the mesh must be flagged as updatable
  93760. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93761. * @returns a new Mesh
  93762. */
  93763. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  93764. /**
  93765. * Creates a ground mesh.
  93766. * Please consider using the same method from the MeshBuilder class instead
  93767. * @param name defines the name of the mesh to create
  93768. * @param width set the width of the ground
  93769. * @param height set the height of the ground
  93770. * @param subdivisions sets the number of subdivisions per side
  93771. * @param scene defines the hosting scene
  93772. * @param updatable defines if the mesh must be flagged as updatable
  93773. * @returns a new Mesh
  93774. */
  93775. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  93776. /**
  93777. * Creates a tiled ground mesh.
  93778. * Please consider using the same method from the MeshBuilder class instead
  93779. * @param name defines the name of the mesh to create
  93780. * @param xmin set the ground minimum X coordinate
  93781. * @param zmin set the ground minimum Y coordinate
  93782. * @param xmax set the ground maximum X coordinate
  93783. * @param zmax set the ground maximum Z coordinate
  93784. * @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
  93785. * @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
  93786. * @param scene defines the hosting scene
  93787. * @param updatable defines if the mesh must be flagged as updatable
  93788. * @returns a new Mesh
  93789. */
  93790. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  93791. w: number;
  93792. h: number;
  93793. }, precision: {
  93794. w: number;
  93795. h: number;
  93796. }, scene: Scene, updatable?: boolean): Mesh;
  93797. /**
  93798. * Creates a ground mesh from a height map.
  93799. * Please consider using the same method from the MeshBuilder class instead
  93800. * @see http://doc.babylonjs.com/babylon101/height_map
  93801. * @param name defines the name of the mesh to create
  93802. * @param url sets the URL of the height map image resource
  93803. * @param width set the ground width size
  93804. * @param height set the ground height size
  93805. * @param subdivisions sets the number of subdivision per side
  93806. * @param minHeight is the minimum altitude on the ground
  93807. * @param maxHeight is the maximum altitude on the ground
  93808. * @param scene defines the hosting scene
  93809. * @param updatable defines if the mesh must be flagged as updatable
  93810. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  93811. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  93812. * @returns a new Mesh
  93813. */
  93814. 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;
  93815. /**
  93816. * Creates a tube mesh.
  93817. * The tube is a parametric shape.
  93818. * It has no predefined shape. Its final shape will depend on the input parameters.
  93819. * Please consider using the same method from the MeshBuilder class instead
  93820. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  93821. * @param name defines the name of the mesh to create
  93822. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  93823. * @param radius sets the tube radius size
  93824. * @param tessellation is the number of sides on the tubular surface
  93825. * @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
  93826. * @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
  93827. * @param scene defines the hosting scene
  93828. * @param updatable defines if the mesh must be flagged as updatable
  93829. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93830. * @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)
  93831. * @returns a new Mesh
  93832. */
  93833. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  93834. (i: number, distance: number): number;
  93835. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  93836. /**
  93837. * Creates a polyhedron mesh.
  93838. * Please consider using the same method from the MeshBuilder class instead.
  93839. * * 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
  93840. * * The parameter `size` (positive float, default 1) sets the polygon size
  93841. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  93842. * * 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`
  93843. * * 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
  93844. * * 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)`)
  93845. * * 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
  93846. * * 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
  93847. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93848. * * If you create a double-sided mesh, you can choose what parts of 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
  93849. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  93850. * @param name defines the name of the mesh to create
  93851. * @param options defines the options used to create the mesh
  93852. * @param scene defines the hosting scene
  93853. * @returns a new Mesh
  93854. */
  93855. static CreatePolyhedron(name: string, options: {
  93856. type?: number;
  93857. size?: number;
  93858. sizeX?: number;
  93859. sizeY?: number;
  93860. sizeZ?: number;
  93861. custom?: any;
  93862. faceUV?: Vector4[];
  93863. faceColors?: Color4[];
  93864. updatable?: boolean;
  93865. sideOrientation?: number;
  93866. }, scene: Scene): Mesh;
  93867. /**
  93868. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  93869. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  93870. * * 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`)
  93871. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  93872. * * 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
  93873. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93874. * * If you create a double-sided mesh, you can choose what parts of 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
  93875. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  93876. * @param name defines the name of the mesh
  93877. * @param options defines the options used to create the mesh
  93878. * @param scene defines the hosting scene
  93879. * @returns a new Mesh
  93880. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  93881. */
  93882. static CreateIcoSphere(name: string, options: {
  93883. radius?: number;
  93884. flat?: boolean;
  93885. subdivisions?: number;
  93886. sideOrientation?: number;
  93887. updatable?: boolean;
  93888. }, scene: Scene): Mesh;
  93889. /**
  93890. * Creates a decal mesh.
  93891. * Please consider using the same method from the MeshBuilder class instead.
  93892. * A decal is a mesh usually applied as a model onto the surface of another mesh
  93893. * @param name defines the name of the mesh
  93894. * @param sourceMesh defines the mesh receiving the decal
  93895. * @param position sets the position of the decal in world coordinates
  93896. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  93897. * @param size sets the decal scaling
  93898. * @param angle sets the angle to rotate the decal
  93899. * @returns a new Mesh
  93900. */
  93901. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  93902. /**
  93903. * Prepare internal position array for software CPU skinning
  93904. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  93905. */
  93906. setPositionsForCPUSkinning(): Float32Array;
  93907. /**
  93908. * Prepare internal normal array for software CPU skinning
  93909. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  93910. */
  93911. setNormalsForCPUSkinning(): Float32Array;
  93912. /**
  93913. * Updates the vertex buffer by applying transformation from the bones
  93914. * @param skeleton defines the skeleton to apply to current mesh
  93915. * @returns the current mesh
  93916. */
  93917. applySkeleton(skeleton: Skeleton): Mesh;
  93918. /**
  93919. * 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
  93920. * @param meshes defines the list of meshes to scan
  93921. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  93922. */
  93923. static MinMax(meshes: AbstractMesh[]): {
  93924. min: Vector3;
  93925. max: Vector3;
  93926. };
  93927. /**
  93928. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  93929. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  93930. * @returns a vector3
  93931. */
  93932. static Center(meshesOrMinMaxVector: {
  93933. min: Vector3;
  93934. max: Vector3;
  93935. } | AbstractMesh[]): Vector3;
  93936. /**
  93937. * Merge the array of meshes into a single mesh for performance reasons.
  93938. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  93939. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  93940. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  93941. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  93942. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  93943. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  93944. * @returns a new mesh
  93945. */
  93946. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  93947. /** @hidden */
  93948. addInstance(instance: InstancedMesh): void;
  93949. /** @hidden */
  93950. removeInstance(instance: InstancedMesh): void;
  93951. }
  93952. }
  93953. declare module BABYLON {
  93954. /**
  93955. * This is the base class of all the camera used in the application.
  93956. * @see http://doc.babylonjs.com/features/cameras
  93957. */
  93958. export class Camera extends Node {
  93959. /** @hidden */
  93960. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  93961. /**
  93962. * This is the default projection mode used by the cameras.
  93963. * It helps recreating a feeling of perspective and better appreciate depth.
  93964. * This is the best way to simulate real life cameras.
  93965. */
  93966. static readonly PERSPECTIVE_CAMERA: number;
  93967. /**
  93968. * This helps creating camera with an orthographic mode.
  93969. * 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.
  93970. */
  93971. static readonly ORTHOGRAPHIC_CAMERA: number;
  93972. /**
  93973. * This is the default FOV mode for perspective cameras.
  93974. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  93975. */
  93976. static readonly FOVMODE_VERTICAL_FIXED: number;
  93977. /**
  93978. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  93979. */
  93980. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  93981. /**
  93982. * This specifies ther is no need for a camera rig.
  93983. * Basically only one eye is rendered corresponding to the camera.
  93984. */
  93985. static readonly RIG_MODE_NONE: number;
  93986. /**
  93987. * Simulates a camera Rig with one blue eye and one red eye.
  93988. * This can be use with 3d blue and red glasses.
  93989. */
  93990. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  93991. /**
  93992. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  93993. */
  93994. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  93995. /**
  93996. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  93997. */
  93998. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  93999. /**
  94000. * Defines that both eyes of the camera will be rendered over under each other.
  94001. */
  94002. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  94003. /**
  94004. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  94005. */
  94006. static readonly RIG_MODE_VR: number;
  94007. /**
  94008. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  94009. */
  94010. static readonly RIG_MODE_WEBVR: number;
  94011. /**
  94012. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  94013. */
  94014. static readonly RIG_MODE_CUSTOM: number;
  94015. /**
  94016. * Defines if by default attaching controls should prevent the default javascript event to continue.
  94017. */
  94018. static ForceAttachControlToAlwaysPreventDefault: boolean;
  94019. /**
  94020. * Define the input manager associated with the camera.
  94021. */
  94022. inputs: CameraInputsManager<Camera>;
  94023. /** @hidden */
  94024. _position: Vector3;
  94025. /**
  94026. * Define the current local position of the camera in the scene
  94027. */
  94028. position: Vector3;
  94029. /**
  94030. * The vector the camera should consider as up.
  94031. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  94032. */
  94033. upVector: Vector3;
  94034. /**
  94035. * Define the current limit on the left side for an orthographic camera
  94036. * In scene unit
  94037. */
  94038. orthoLeft: Nullable<number>;
  94039. /**
  94040. * Define the current limit on the right side for an orthographic camera
  94041. * In scene unit
  94042. */
  94043. orthoRight: Nullable<number>;
  94044. /**
  94045. * Define the current limit on the bottom side for an orthographic camera
  94046. * In scene unit
  94047. */
  94048. orthoBottom: Nullable<number>;
  94049. /**
  94050. * Define the current limit on the top side for an orthographic camera
  94051. * In scene unit
  94052. */
  94053. orthoTop: Nullable<number>;
  94054. /**
  94055. * Field Of View is set in Radians. (default is 0.8)
  94056. */
  94057. fov: number;
  94058. /**
  94059. * Define the minimum distance the camera can see from.
  94060. * This is important to note that the depth buffer are not infinite and the closer it starts
  94061. * the more your scene might encounter depth fighting issue.
  94062. */
  94063. minZ: number;
  94064. /**
  94065. * Define the maximum distance the camera can see to.
  94066. * This is important to note that the depth buffer are not infinite and the further it end
  94067. * the more your scene might encounter depth fighting issue.
  94068. */
  94069. maxZ: number;
  94070. /**
  94071. * Define the default inertia of the camera.
  94072. * This helps giving a smooth feeling to the camera movement.
  94073. */
  94074. inertia: number;
  94075. /**
  94076. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  94077. */
  94078. mode: number;
  94079. /**
  94080. * Define wether the camera is intermediate.
  94081. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  94082. */
  94083. isIntermediate: boolean;
  94084. /**
  94085. * Define the viewport of the camera.
  94086. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  94087. */
  94088. viewport: Viewport;
  94089. /**
  94090. * Restricts the camera to viewing objects with the same layerMask.
  94091. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  94092. */
  94093. layerMask: number;
  94094. /**
  94095. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  94096. */
  94097. fovMode: number;
  94098. /**
  94099. * Rig mode of the camera.
  94100. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  94101. * This is normally controlled byt the camera themselves as internal use.
  94102. */
  94103. cameraRigMode: number;
  94104. /**
  94105. * Defines the distance between both "eyes" in case of a RIG
  94106. */
  94107. interaxialDistance: number;
  94108. /**
  94109. * Defines if stereoscopic rendering is done side by side or over under.
  94110. */
  94111. isStereoscopicSideBySide: boolean;
  94112. /**
  94113. * 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
  94114. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  94115. * else in the scene. (Eg. security camera)
  94116. *
  94117. * 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)
  94118. */
  94119. customRenderTargets: RenderTargetTexture[];
  94120. /**
  94121. * When set, the camera will render to this render target instead of the default canvas
  94122. *
  94123. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  94124. */
  94125. outputRenderTarget: Nullable<RenderTargetTexture>;
  94126. /**
  94127. * Observable triggered when the camera view matrix has changed.
  94128. */
  94129. onViewMatrixChangedObservable: Observable<Camera>;
  94130. /**
  94131. * Observable triggered when the camera Projection matrix has changed.
  94132. */
  94133. onProjectionMatrixChangedObservable: Observable<Camera>;
  94134. /**
  94135. * Observable triggered when the inputs have been processed.
  94136. */
  94137. onAfterCheckInputsObservable: Observable<Camera>;
  94138. /**
  94139. * Observable triggered when reset has been called and applied to the camera.
  94140. */
  94141. onRestoreStateObservable: Observable<Camera>;
  94142. /** @hidden */
  94143. _cameraRigParams: any;
  94144. /** @hidden */
  94145. _rigCameras: Camera[];
  94146. /** @hidden */
  94147. _rigPostProcess: Nullable<PostProcess>;
  94148. protected _webvrViewMatrix: Matrix;
  94149. /** @hidden */
  94150. _skipRendering: boolean;
  94151. /** @hidden */
  94152. _projectionMatrix: Matrix;
  94153. /** @hidden */
  94154. _postProcesses: Nullable<PostProcess>[];
  94155. /** @hidden */
  94156. _activeMeshes: SmartArray<AbstractMesh>;
  94157. protected _globalPosition: Vector3;
  94158. /** @hidden */
  94159. _computedViewMatrix: Matrix;
  94160. private _doNotComputeProjectionMatrix;
  94161. private _transformMatrix;
  94162. private _frustumPlanes;
  94163. private _refreshFrustumPlanes;
  94164. private _storedFov;
  94165. private _stateStored;
  94166. /**
  94167. * Instantiates a new camera object.
  94168. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  94169. * @see http://doc.babylonjs.com/features/cameras
  94170. * @param name Defines the name of the camera in the scene
  94171. * @param position Defines the position of the camera
  94172. * @param scene Defines the scene the camera belongs too
  94173. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  94174. */
  94175. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  94176. /**
  94177. * Store current camera state (fov, position, etc..)
  94178. * @returns the camera
  94179. */
  94180. storeState(): Camera;
  94181. /**
  94182. * Restores the camera state values if it has been stored. You must call storeState() first
  94183. */
  94184. protected _restoreStateValues(): boolean;
  94185. /**
  94186. * Restored camera state. You must call storeState() first.
  94187. * @returns true if restored and false otherwise
  94188. */
  94189. restoreState(): boolean;
  94190. /**
  94191. * Gets the class name of the camera.
  94192. * @returns the class name
  94193. */
  94194. getClassName(): string;
  94195. /** @hidden */
  94196. readonly _isCamera: boolean;
  94197. /**
  94198. * Gets a string representation of the camera useful for debug purpose.
  94199. * @param fullDetails Defines that a more verboe level of logging is required
  94200. * @returns the string representation
  94201. */
  94202. toString(fullDetails?: boolean): string;
  94203. /**
  94204. * Gets the current world space position of the camera.
  94205. */
  94206. readonly globalPosition: Vector3;
  94207. /**
  94208. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  94209. * @returns the active meshe list
  94210. */
  94211. getActiveMeshes(): SmartArray<AbstractMesh>;
  94212. /**
  94213. * Check wether a mesh is part of the current active mesh list of the camera
  94214. * @param mesh Defines the mesh to check
  94215. * @returns true if active, false otherwise
  94216. */
  94217. isActiveMesh(mesh: Mesh): boolean;
  94218. /**
  94219. * Is this camera ready to be used/rendered
  94220. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  94221. * @return true if the camera is ready
  94222. */
  94223. isReady(completeCheck?: boolean): boolean;
  94224. /** @hidden */
  94225. _initCache(): void;
  94226. /** @hidden */
  94227. _updateCache(ignoreParentClass?: boolean): void;
  94228. /** @hidden */
  94229. _isSynchronized(): boolean;
  94230. /** @hidden */
  94231. _isSynchronizedViewMatrix(): boolean;
  94232. /** @hidden */
  94233. _isSynchronizedProjectionMatrix(): boolean;
  94234. /**
  94235. * Attach the input controls to a specific dom element to get the input from.
  94236. * @param element Defines the element the controls should be listened from
  94237. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94238. */
  94239. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94240. /**
  94241. * Detach the current controls from the specified dom element.
  94242. * @param element Defines the element to stop listening the inputs from
  94243. */
  94244. detachControl(element: HTMLElement): void;
  94245. /**
  94246. * Update the camera state according to the different inputs gathered during the frame.
  94247. */
  94248. update(): void;
  94249. /** @hidden */
  94250. _checkInputs(): void;
  94251. /** @hidden */
  94252. readonly rigCameras: Camera[];
  94253. /**
  94254. * Gets the post process used by the rig cameras
  94255. */
  94256. readonly rigPostProcess: Nullable<PostProcess>;
  94257. /**
  94258. * Internal, gets the first post proces.
  94259. * @returns the first post process to be run on this camera.
  94260. */
  94261. _getFirstPostProcess(): Nullable<PostProcess>;
  94262. private _cascadePostProcessesToRigCams;
  94263. /**
  94264. * Attach a post process to the camera.
  94265. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  94266. * @param postProcess The post process to attach to the camera
  94267. * @param insertAt The position of the post process in case several of them are in use in the scene
  94268. * @returns the position the post process has been inserted at
  94269. */
  94270. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  94271. /**
  94272. * Detach a post process to the camera.
  94273. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  94274. * @param postProcess The post process to detach from the camera
  94275. */
  94276. detachPostProcess(postProcess: PostProcess): void;
  94277. /**
  94278. * Gets the current world matrix of the camera
  94279. */
  94280. getWorldMatrix(): Matrix;
  94281. /** @hidden */
  94282. _getViewMatrix(): Matrix;
  94283. /**
  94284. * Gets the current view matrix of the camera.
  94285. * @param force forces the camera to recompute the matrix without looking at the cached state
  94286. * @returns the view matrix
  94287. */
  94288. getViewMatrix(force?: boolean): Matrix;
  94289. /**
  94290. * Freeze the projection matrix.
  94291. * It will prevent the cache check of the camera projection compute and can speed up perf
  94292. * if no parameter of the camera are meant to change
  94293. * @param projection Defines manually a projection if necessary
  94294. */
  94295. freezeProjectionMatrix(projection?: Matrix): void;
  94296. /**
  94297. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  94298. */
  94299. unfreezeProjectionMatrix(): void;
  94300. /**
  94301. * Gets the current projection matrix of the camera.
  94302. * @param force forces the camera to recompute the matrix without looking at the cached state
  94303. * @returns the projection matrix
  94304. */
  94305. getProjectionMatrix(force?: boolean): Matrix;
  94306. /**
  94307. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  94308. * @returns a Matrix
  94309. */
  94310. getTransformationMatrix(): Matrix;
  94311. private _updateFrustumPlanes;
  94312. /**
  94313. * Checks if a cullable object (mesh...) is in the camera frustum
  94314. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  94315. * @param target The object to check
  94316. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  94317. * @returns true if the object is in frustum otherwise false
  94318. */
  94319. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  94320. /**
  94321. * Checks if a cullable object (mesh...) is in the camera frustum
  94322. * Unlike isInFrustum this cheks the full bounding box
  94323. * @param target The object to check
  94324. * @returns true if the object is in frustum otherwise false
  94325. */
  94326. isCompletelyInFrustum(target: ICullable): boolean;
  94327. /**
  94328. * Gets a ray in the forward direction from the camera.
  94329. * @param length Defines the length of the ray to create
  94330. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  94331. * @param origin Defines the start point of the ray which defaults to the camera position
  94332. * @returns the forward ray
  94333. */
  94334. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  94335. /**
  94336. * Releases resources associated with this node.
  94337. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  94338. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  94339. */
  94340. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94341. /** @hidden */
  94342. _isLeftCamera: boolean;
  94343. /**
  94344. * Gets the left camera of a rig setup in case of Rigged Camera
  94345. */
  94346. readonly isLeftCamera: boolean;
  94347. /** @hidden */
  94348. _isRightCamera: boolean;
  94349. /**
  94350. * Gets the right camera of a rig setup in case of Rigged Camera
  94351. */
  94352. readonly isRightCamera: boolean;
  94353. /**
  94354. * Gets the left camera of a rig setup in case of Rigged Camera
  94355. */
  94356. readonly leftCamera: Nullable<FreeCamera>;
  94357. /**
  94358. * Gets the right camera of a rig setup in case of Rigged Camera
  94359. */
  94360. readonly rightCamera: Nullable<FreeCamera>;
  94361. /**
  94362. * Gets the left camera target of a rig setup in case of Rigged Camera
  94363. * @returns the target position
  94364. */
  94365. getLeftTarget(): Nullable<Vector3>;
  94366. /**
  94367. * Gets the right camera target of a rig setup in case of Rigged Camera
  94368. * @returns the target position
  94369. */
  94370. getRightTarget(): Nullable<Vector3>;
  94371. /**
  94372. * @hidden
  94373. */
  94374. setCameraRigMode(mode: number, rigParams: any): void;
  94375. /** @hidden */
  94376. static _setStereoscopicRigMode(camera: Camera): void;
  94377. /** @hidden */
  94378. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  94379. /** @hidden */
  94380. static _setVRRigMode(camera: Camera, rigParams: any): void;
  94381. /** @hidden */
  94382. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  94383. /** @hidden */
  94384. _getVRProjectionMatrix(): Matrix;
  94385. protected _updateCameraRotationMatrix(): void;
  94386. protected _updateWebVRCameraRotationMatrix(): void;
  94387. /**
  94388. * This function MUST be overwritten by the different WebVR cameras available.
  94389. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  94390. * @hidden
  94391. */
  94392. _getWebVRProjectionMatrix(): Matrix;
  94393. /**
  94394. * This function MUST be overwritten by the different WebVR cameras available.
  94395. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  94396. * @hidden
  94397. */
  94398. _getWebVRViewMatrix(): Matrix;
  94399. /** @hidden */
  94400. setCameraRigParameter(name: string, value: any): void;
  94401. /**
  94402. * needs to be overridden by children so sub has required properties to be copied
  94403. * @hidden
  94404. */
  94405. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  94406. /**
  94407. * May need to be overridden by children
  94408. * @hidden
  94409. */
  94410. _updateRigCameras(): void;
  94411. /** @hidden */
  94412. _setupInputs(): void;
  94413. /**
  94414. * Serialiaze the camera setup to a json represention
  94415. * @returns the JSON representation
  94416. */
  94417. serialize(): any;
  94418. /**
  94419. * Clones the current camera.
  94420. * @param name The cloned camera name
  94421. * @returns the cloned camera
  94422. */
  94423. clone(name: string): Camera;
  94424. /**
  94425. * Gets the direction of the camera relative to a given local axis.
  94426. * @param localAxis Defines the reference axis to provide a relative direction.
  94427. * @return the direction
  94428. */
  94429. getDirection(localAxis: Vector3): Vector3;
  94430. /**
  94431. * Returns the current camera absolute rotation
  94432. */
  94433. readonly absoluteRotation: Quaternion;
  94434. /**
  94435. * Gets the direction of the camera relative to a given local axis into a passed vector.
  94436. * @param localAxis Defines the reference axis to provide a relative direction.
  94437. * @param result Defines the vector to store the result in
  94438. */
  94439. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  94440. /**
  94441. * Gets a camera constructor for a given camera type
  94442. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  94443. * @param name The name of the camera the result will be able to instantiate
  94444. * @param scene The scene the result will construct the camera in
  94445. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  94446. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  94447. * @returns a factory method to construc the camera
  94448. */
  94449. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  94450. /**
  94451. * Compute the world matrix of the camera.
  94452. * @returns the camera world matrix
  94453. */
  94454. computeWorldMatrix(): Matrix;
  94455. /**
  94456. * Parse a JSON and creates the camera from the parsed information
  94457. * @param parsedCamera The JSON to parse
  94458. * @param scene The scene to instantiate the camera in
  94459. * @returns the newly constructed camera
  94460. */
  94461. static Parse(parsedCamera: any, scene: Scene): Camera;
  94462. }
  94463. }
  94464. declare module BABYLON {
  94465. /**
  94466. * Class containing static functions to help procedurally build meshes
  94467. */
  94468. export class DiscBuilder {
  94469. /**
  94470. * Creates a plane polygonal mesh. By default, this is a disc
  94471. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  94472. * * 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
  94473. * * 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
  94474. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  94475. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  94476. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94477. * @param name defines the name of the mesh
  94478. * @param options defines the options used to create the mesh
  94479. * @param scene defines the hosting scene
  94480. * @returns the plane polygonal mesh
  94481. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  94482. */
  94483. static CreateDisc(name: string, options: {
  94484. radius?: number;
  94485. tessellation?: number;
  94486. arc?: number;
  94487. updatable?: boolean;
  94488. sideOrientation?: number;
  94489. frontUVs?: Vector4;
  94490. backUVs?: Vector4;
  94491. }, scene?: Nullable<Scene>): Mesh;
  94492. }
  94493. }
  94494. declare module BABYLON {
  94495. /**
  94496. * This represents all the required information to add a fresnel effect on a material:
  94497. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94498. */
  94499. export class FresnelParameters {
  94500. private _isEnabled;
  94501. /**
  94502. * Define if the fresnel effect is enable or not.
  94503. */
  94504. isEnabled: boolean;
  94505. /**
  94506. * Define the color used on edges (grazing angle)
  94507. */
  94508. leftColor: Color3;
  94509. /**
  94510. * Define the color used on center
  94511. */
  94512. rightColor: Color3;
  94513. /**
  94514. * Define bias applied to computed fresnel term
  94515. */
  94516. bias: number;
  94517. /**
  94518. * Defined the power exponent applied to fresnel term
  94519. */
  94520. power: number;
  94521. /**
  94522. * Clones the current fresnel and its valuues
  94523. * @returns a clone fresnel configuration
  94524. */
  94525. clone(): FresnelParameters;
  94526. /**
  94527. * Serializes the current fresnel parameters to a JSON representation.
  94528. * @return the JSON serialization
  94529. */
  94530. serialize(): any;
  94531. /**
  94532. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  94533. * @param parsedFresnelParameters Define the JSON representation
  94534. * @returns the parsed parameters
  94535. */
  94536. static Parse(parsedFresnelParameters: any): FresnelParameters;
  94537. }
  94538. }
  94539. declare module BABYLON {
  94540. /**
  94541. * Base class of materials working in push mode in babylon JS
  94542. * @hidden
  94543. */
  94544. export class PushMaterial extends Material {
  94545. protected _activeEffect: Effect;
  94546. protected _normalMatrix: Matrix;
  94547. /**
  94548. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  94549. * This means that the material can keep using a previous shader while a new one is being compiled.
  94550. * This is mostly used when shader parallel compilation is supported (true by default)
  94551. */
  94552. allowShaderHotSwapping: boolean;
  94553. constructor(name: string, scene: Scene);
  94554. getEffect(): Effect;
  94555. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94556. /**
  94557. * Binds the given world matrix to the active effect
  94558. *
  94559. * @param world the matrix to bind
  94560. */
  94561. bindOnlyWorldMatrix(world: Matrix): void;
  94562. /**
  94563. * Binds the given normal matrix to the active effect
  94564. *
  94565. * @param normalMatrix the matrix to bind
  94566. */
  94567. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  94568. bind(world: Matrix, mesh?: Mesh): void;
  94569. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  94570. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  94571. }
  94572. }
  94573. declare module BABYLON {
  94574. /**
  94575. * This groups all the flags used to control the materials channel.
  94576. */
  94577. export class MaterialFlags {
  94578. private static _DiffuseTextureEnabled;
  94579. /**
  94580. * Are diffuse textures enabled in the application.
  94581. */
  94582. static DiffuseTextureEnabled: boolean;
  94583. private static _AmbientTextureEnabled;
  94584. /**
  94585. * Are ambient textures enabled in the application.
  94586. */
  94587. static AmbientTextureEnabled: boolean;
  94588. private static _OpacityTextureEnabled;
  94589. /**
  94590. * Are opacity textures enabled in the application.
  94591. */
  94592. static OpacityTextureEnabled: boolean;
  94593. private static _ReflectionTextureEnabled;
  94594. /**
  94595. * Are reflection textures enabled in the application.
  94596. */
  94597. static ReflectionTextureEnabled: boolean;
  94598. private static _EmissiveTextureEnabled;
  94599. /**
  94600. * Are emissive textures enabled in the application.
  94601. */
  94602. static EmissiveTextureEnabled: boolean;
  94603. private static _SpecularTextureEnabled;
  94604. /**
  94605. * Are specular textures enabled in the application.
  94606. */
  94607. static SpecularTextureEnabled: boolean;
  94608. private static _BumpTextureEnabled;
  94609. /**
  94610. * Are bump textures enabled in the application.
  94611. */
  94612. static BumpTextureEnabled: boolean;
  94613. private static _LightmapTextureEnabled;
  94614. /**
  94615. * Are lightmap textures enabled in the application.
  94616. */
  94617. static LightmapTextureEnabled: boolean;
  94618. private static _RefractionTextureEnabled;
  94619. /**
  94620. * Are refraction textures enabled in the application.
  94621. */
  94622. static RefractionTextureEnabled: boolean;
  94623. private static _ColorGradingTextureEnabled;
  94624. /**
  94625. * Are color grading textures enabled in the application.
  94626. */
  94627. static ColorGradingTextureEnabled: boolean;
  94628. private static _FresnelEnabled;
  94629. /**
  94630. * Are fresnels enabled in the application.
  94631. */
  94632. static FresnelEnabled: boolean;
  94633. private static _ClearCoatTextureEnabled;
  94634. /**
  94635. * Are clear coat textures enabled in the application.
  94636. */
  94637. static ClearCoatTextureEnabled: boolean;
  94638. private static _ClearCoatBumpTextureEnabled;
  94639. /**
  94640. * Are clear coat bump textures enabled in the application.
  94641. */
  94642. static ClearCoatBumpTextureEnabled: boolean;
  94643. private static _ClearCoatTintTextureEnabled;
  94644. /**
  94645. * Are clear coat tint textures enabled in the application.
  94646. */
  94647. static ClearCoatTintTextureEnabled: boolean;
  94648. private static _SheenTextureEnabled;
  94649. /**
  94650. * Are sheen textures enabled in the application.
  94651. */
  94652. static SheenTextureEnabled: boolean;
  94653. private static _AnisotropicTextureEnabled;
  94654. /**
  94655. * Are anisotropic textures enabled in the application.
  94656. */
  94657. static AnisotropicTextureEnabled: boolean;
  94658. private static _ThicknessTextureEnabled;
  94659. /**
  94660. * Are thickness textures enabled in the application.
  94661. */
  94662. static ThicknessTextureEnabled: boolean;
  94663. }
  94664. }
  94665. declare module BABYLON {
  94666. /** @hidden */
  94667. export var defaultFragmentDeclaration: {
  94668. name: string;
  94669. shader: string;
  94670. };
  94671. }
  94672. declare module BABYLON {
  94673. /** @hidden */
  94674. export var defaultUboDeclaration: {
  94675. name: string;
  94676. shader: string;
  94677. };
  94678. }
  94679. declare module BABYLON {
  94680. /** @hidden */
  94681. export var lightFragmentDeclaration: {
  94682. name: string;
  94683. shader: string;
  94684. };
  94685. }
  94686. declare module BABYLON {
  94687. /** @hidden */
  94688. export var lightUboDeclaration: {
  94689. name: string;
  94690. shader: string;
  94691. };
  94692. }
  94693. declare module BABYLON {
  94694. /** @hidden */
  94695. export var lightsFragmentFunctions: {
  94696. name: string;
  94697. shader: string;
  94698. };
  94699. }
  94700. declare module BABYLON {
  94701. /** @hidden */
  94702. export var shadowsFragmentFunctions: {
  94703. name: string;
  94704. shader: string;
  94705. };
  94706. }
  94707. declare module BABYLON {
  94708. /** @hidden */
  94709. export var fresnelFunction: {
  94710. name: string;
  94711. shader: string;
  94712. };
  94713. }
  94714. declare module BABYLON {
  94715. /** @hidden */
  94716. export var reflectionFunction: {
  94717. name: string;
  94718. shader: string;
  94719. };
  94720. }
  94721. declare module BABYLON {
  94722. /** @hidden */
  94723. export var bumpFragmentFunctions: {
  94724. name: string;
  94725. shader: string;
  94726. };
  94727. }
  94728. declare module BABYLON {
  94729. /** @hidden */
  94730. export var logDepthDeclaration: {
  94731. name: string;
  94732. shader: string;
  94733. };
  94734. }
  94735. declare module BABYLON {
  94736. /** @hidden */
  94737. export var bumpFragment: {
  94738. name: string;
  94739. shader: string;
  94740. };
  94741. }
  94742. declare module BABYLON {
  94743. /** @hidden */
  94744. export var depthPrePass: {
  94745. name: string;
  94746. shader: string;
  94747. };
  94748. }
  94749. declare module BABYLON {
  94750. /** @hidden */
  94751. export var lightFragment: {
  94752. name: string;
  94753. shader: string;
  94754. };
  94755. }
  94756. declare module BABYLON {
  94757. /** @hidden */
  94758. export var logDepthFragment: {
  94759. name: string;
  94760. shader: string;
  94761. };
  94762. }
  94763. declare module BABYLON {
  94764. /** @hidden */
  94765. export var defaultPixelShader: {
  94766. name: string;
  94767. shader: string;
  94768. };
  94769. }
  94770. declare module BABYLON {
  94771. /** @hidden */
  94772. export var defaultVertexDeclaration: {
  94773. name: string;
  94774. shader: string;
  94775. };
  94776. }
  94777. declare module BABYLON {
  94778. /** @hidden */
  94779. export var bumpVertexDeclaration: {
  94780. name: string;
  94781. shader: string;
  94782. };
  94783. }
  94784. declare module BABYLON {
  94785. /** @hidden */
  94786. export var bumpVertex: {
  94787. name: string;
  94788. shader: string;
  94789. };
  94790. }
  94791. declare module BABYLON {
  94792. /** @hidden */
  94793. export var fogVertex: {
  94794. name: string;
  94795. shader: string;
  94796. };
  94797. }
  94798. declare module BABYLON {
  94799. /** @hidden */
  94800. export var shadowsVertex: {
  94801. name: string;
  94802. shader: string;
  94803. };
  94804. }
  94805. declare module BABYLON {
  94806. /** @hidden */
  94807. export var pointCloudVertex: {
  94808. name: string;
  94809. shader: string;
  94810. };
  94811. }
  94812. declare module BABYLON {
  94813. /** @hidden */
  94814. export var logDepthVertex: {
  94815. name: string;
  94816. shader: string;
  94817. };
  94818. }
  94819. declare module BABYLON {
  94820. /** @hidden */
  94821. export var defaultVertexShader: {
  94822. name: string;
  94823. shader: string;
  94824. };
  94825. }
  94826. declare module BABYLON {
  94827. /** @hidden */
  94828. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  94829. MAINUV1: boolean;
  94830. MAINUV2: boolean;
  94831. DIFFUSE: boolean;
  94832. DIFFUSEDIRECTUV: number;
  94833. AMBIENT: boolean;
  94834. AMBIENTDIRECTUV: number;
  94835. OPACITY: boolean;
  94836. OPACITYDIRECTUV: number;
  94837. OPACITYRGB: boolean;
  94838. REFLECTION: boolean;
  94839. EMISSIVE: boolean;
  94840. EMISSIVEDIRECTUV: number;
  94841. SPECULAR: boolean;
  94842. SPECULARDIRECTUV: number;
  94843. BUMP: boolean;
  94844. BUMPDIRECTUV: number;
  94845. PARALLAX: boolean;
  94846. PARALLAXOCCLUSION: boolean;
  94847. SPECULAROVERALPHA: boolean;
  94848. CLIPPLANE: boolean;
  94849. CLIPPLANE2: boolean;
  94850. CLIPPLANE3: boolean;
  94851. CLIPPLANE4: boolean;
  94852. ALPHATEST: boolean;
  94853. DEPTHPREPASS: boolean;
  94854. ALPHAFROMDIFFUSE: boolean;
  94855. POINTSIZE: boolean;
  94856. FOG: boolean;
  94857. SPECULARTERM: boolean;
  94858. DIFFUSEFRESNEL: boolean;
  94859. OPACITYFRESNEL: boolean;
  94860. REFLECTIONFRESNEL: boolean;
  94861. REFRACTIONFRESNEL: boolean;
  94862. EMISSIVEFRESNEL: boolean;
  94863. FRESNEL: boolean;
  94864. NORMAL: boolean;
  94865. UV1: boolean;
  94866. UV2: boolean;
  94867. VERTEXCOLOR: boolean;
  94868. VERTEXALPHA: boolean;
  94869. NUM_BONE_INFLUENCERS: number;
  94870. BonesPerMesh: number;
  94871. BONETEXTURE: boolean;
  94872. INSTANCES: boolean;
  94873. GLOSSINESS: boolean;
  94874. ROUGHNESS: boolean;
  94875. EMISSIVEASILLUMINATION: boolean;
  94876. LINKEMISSIVEWITHDIFFUSE: boolean;
  94877. REFLECTIONFRESNELFROMSPECULAR: boolean;
  94878. LIGHTMAP: boolean;
  94879. LIGHTMAPDIRECTUV: number;
  94880. OBJECTSPACE_NORMALMAP: boolean;
  94881. USELIGHTMAPASSHADOWMAP: boolean;
  94882. REFLECTIONMAP_3D: boolean;
  94883. REFLECTIONMAP_SPHERICAL: boolean;
  94884. REFLECTIONMAP_PLANAR: boolean;
  94885. REFLECTIONMAP_CUBIC: boolean;
  94886. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  94887. REFLECTIONMAP_PROJECTION: boolean;
  94888. REFLECTIONMAP_SKYBOX: boolean;
  94889. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  94890. REFLECTIONMAP_EXPLICIT: boolean;
  94891. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  94892. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  94893. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  94894. INVERTCUBICMAP: boolean;
  94895. LOGARITHMICDEPTH: boolean;
  94896. REFRACTION: boolean;
  94897. REFRACTIONMAP_3D: boolean;
  94898. REFLECTIONOVERALPHA: boolean;
  94899. TWOSIDEDLIGHTING: boolean;
  94900. SHADOWFLOAT: boolean;
  94901. MORPHTARGETS: boolean;
  94902. MORPHTARGETS_NORMAL: boolean;
  94903. MORPHTARGETS_TANGENT: boolean;
  94904. MORPHTARGETS_UV: boolean;
  94905. NUM_MORPH_INFLUENCERS: number;
  94906. NONUNIFORMSCALING: boolean;
  94907. PREMULTIPLYALPHA: boolean;
  94908. IMAGEPROCESSING: boolean;
  94909. VIGNETTE: boolean;
  94910. VIGNETTEBLENDMODEMULTIPLY: boolean;
  94911. VIGNETTEBLENDMODEOPAQUE: boolean;
  94912. TONEMAPPING: boolean;
  94913. TONEMAPPING_ACES: boolean;
  94914. CONTRAST: boolean;
  94915. COLORCURVES: boolean;
  94916. COLORGRADING: boolean;
  94917. COLORGRADING3D: boolean;
  94918. SAMPLER3DGREENDEPTH: boolean;
  94919. SAMPLER3DBGRMAP: boolean;
  94920. IMAGEPROCESSINGPOSTPROCESS: boolean;
  94921. MULTIVIEW: boolean;
  94922. /**
  94923. * If the reflection texture on this material is in linear color space
  94924. * @hidden
  94925. */
  94926. IS_REFLECTION_LINEAR: boolean;
  94927. /**
  94928. * If the refraction texture on this material is in linear color space
  94929. * @hidden
  94930. */
  94931. IS_REFRACTION_LINEAR: boolean;
  94932. EXPOSURE: boolean;
  94933. constructor();
  94934. setReflectionMode(modeToEnable: string): void;
  94935. }
  94936. /**
  94937. * This is the default material used in Babylon. It is the best trade off between quality
  94938. * and performances.
  94939. * @see http://doc.babylonjs.com/babylon101/materials
  94940. */
  94941. export class StandardMaterial extends PushMaterial {
  94942. private _diffuseTexture;
  94943. /**
  94944. * The basic texture of the material as viewed under a light.
  94945. */
  94946. diffuseTexture: Nullable<BaseTexture>;
  94947. private _ambientTexture;
  94948. /**
  94949. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  94950. */
  94951. ambientTexture: Nullable<BaseTexture>;
  94952. private _opacityTexture;
  94953. /**
  94954. * Define the transparency of the material from a texture.
  94955. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  94956. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  94957. */
  94958. opacityTexture: Nullable<BaseTexture>;
  94959. private _reflectionTexture;
  94960. /**
  94961. * Define the texture used to display the reflection.
  94962. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  94963. */
  94964. reflectionTexture: Nullable<BaseTexture>;
  94965. private _emissiveTexture;
  94966. /**
  94967. * Define texture of the material as if self lit.
  94968. * This will be mixed in the final result even in the absence of light.
  94969. */
  94970. emissiveTexture: Nullable<BaseTexture>;
  94971. private _specularTexture;
  94972. /**
  94973. * Define how the color and intensity of the highlight given by the light in the material.
  94974. */
  94975. specularTexture: Nullable<BaseTexture>;
  94976. private _bumpTexture;
  94977. /**
  94978. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  94979. * 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.
  94980. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  94981. */
  94982. bumpTexture: Nullable<BaseTexture>;
  94983. private _lightmapTexture;
  94984. /**
  94985. * Complex lighting can be computationally expensive to compute at runtime.
  94986. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  94987. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  94988. */
  94989. lightmapTexture: Nullable<BaseTexture>;
  94990. private _refractionTexture;
  94991. /**
  94992. * Define the texture used to display the refraction.
  94993. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  94994. */
  94995. refractionTexture: Nullable<BaseTexture>;
  94996. /**
  94997. * The color of the material lit by the environmental background lighting.
  94998. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  94999. */
  95000. ambientColor: Color3;
  95001. /**
  95002. * The basic color of the material as viewed under a light.
  95003. */
  95004. diffuseColor: Color3;
  95005. /**
  95006. * Define how the color and intensity of the highlight given by the light in the material.
  95007. */
  95008. specularColor: Color3;
  95009. /**
  95010. * Define the color of the material as if self lit.
  95011. * This will be mixed in the final result even in the absence of light.
  95012. */
  95013. emissiveColor: Color3;
  95014. /**
  95015. * Defines how sharp are the highlights in the material.
  95016. * The bigger the value the sharper giving a more glossy feeling to the result.
  95017. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  95018. */
  95019. specularPower: number;
  95020. private _useAlphaFromDiffuseTexture;
  95021. /**
  95022. * Does the transparency come from the diffuse texture alpha channel.
  95023. */
  95024. useAlphaFromDiffuseTexture: boolean;
  95025. private _useEmissiveAsIllumination;
  95026. /**
  95027. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  95028. */
  95029. useEmissiveAsIllumination: boolean;
  95030. private _linkEmissiveWithDiffuse;
  95031. /**
  95032. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  95033. * the emissive level when the final color is close to one.
  95034. */
  95035. linkEmissiveWithDiffuse: boolean;
  95036. private _useSpecularOverAlpha;
  95037. /**
  95038. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  95039. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  95040. */
  95041. useSpecularOverAlpha: boolean;
  95042. private _useReflectionOverAlpha;
  95043. /**
  95044. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  95045. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  95046. */
  95047. useReflectionOverAlpha: boolean;
  95048. private _disableLighting;
  95049. /**
  95050. * Does lights from the scene impacts this material.
  95051. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  95052. */
  95053. disableLighting: boolean;
  95054. private _useObjectSpaceNormalMap;
  95055. /**
  95056. * Allows using an object space normal map (instead of tangent space).
  95057. */
  95058. useObjectSpaceNormalMap: boolean;
  95059. private _useParallax;
  95060. /**
  95061. * Is parallax enabled or not.
  95062. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  95063. */
  95064. useParallax: boolean;
  95065. private _useParallaxOcclusion;
  95066. /**
  95067. * Is parallax occlusion enabled or not.
  95068. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  95069. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  95070. */
  95071. useParallaxOcclusion: boolean;
  95072. /**
  95073. * 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.
  95074. */
  95075. parallaxScaleBias: number;
  95076. private _roughness;
  95077. /**
  95078. * Helps to define how blurry the reflections should appears in the material.
  95079. */
  95080. roughness: number;
  95081. /**
  95082. * In case of refraction, define the value of the index of refraction.
  95083. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95084. */
  95085. indexOfRefraction: number;
  95086. /**
  95087. * Invert the refraction texture alongside the y axis.
  95088. * It can be useful with procedural textures or probe for instance.
  95089. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95090. */
  95091. invertRefractionY: boolean;
  95092. /**
  95093. * Defines the alpha limits in alpha test mode.
  95094. */
  95095. alphaCutOff: number;
  95096. private _useLightmapAsShadowmap;
  95097. /**
  95098. * In case of light mapping, define whether the map contains light or shadow informations.
  95099. */
  95100. useLightmapAsShadowmap: boolean;
  95101. private _diffuseFresnelParameters;
  95102. /**
  95103. * Define the diffuse fresnel parameters of the material.
  95104. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95105. */
  95106. diffuseFresnelParameters: FresnelParameters;
  95107. private _opacityFresnelParameters;
  95108. /**
  95109. * Define the opacity fresnel parameters of the material.
  95110. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95111. */
  95112. opacityFresnelParameters: FresnelParameters;
  95113. private _reflectionFresnelParameters;
  95114. /**
  95115. * Define the reflection fresnel parameters of the material.
  95116. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95117. */
  95118. reflectionFresnelParameters: FresnelParameters;
  95119. private _refractionFresnelParameters;
  95120. /**
  95121. * Define the refraction fresnel parameters of the material.
  95122. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95123. */
  95124. refractionFresnelParameters: FresnelParameters;
  95125. private _emissiveFresnelParameters;
  95126. /**
  95127. * Define the emissive fresnel parameters of the material.
  95128. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95129. */
  95130. emissiveFresnelParameters: FresnelParameters;
  95131. private _useReflectionFresnelFromSpecular;
  95132. /**
  95133. * If true automatically deducts the fresnels values from the material specularity.
  95134. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95135. */
  95136. useReflectionFresnelFromSpecular: boolean;
  95137. private _useGlossinessFromSpecularMapAlpha;
  95138. /**
  95139. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  95140. */
  95141. useGlossinessFromSpecularMapAlpha: boolean;
  95142. private _maxSimultaneousLights;
  95143. /**
  95144. * Defines the maximum number of lights that can be used in the material
  95145. */
  95146. maxSimultaneousLights: number;
  95147. private _invertNormalMapX;
  95148. /**
  95149. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  95150. */
  95151. invertNormalMapX: boolean;
  95152. private _invertNormalMapY;
  95153. /**
  95154. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  95155. */
  95156. invertNormalMapY: boolean;
  95157. private _twoSidedLighting;
  95158. /**
  95159. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  95160. */
  95161. twoSidedLighting: boolean;
  95162. /**
  95163. * Default configuration related to image processing available in the standard Material.
  95164. */
  95165. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  95166. /**
  95167. * Gets the image processing configuration used either in this material.
  95168. */
  95169. /**
  95170. * Sets the Default image processing configuration used either in the this material.
  95171. *
  95172. * If sets to null, the scene one is in use.
  95173. */
  95174. imageProcessingConfiguration: ImageProcessingConfiguration;
  95175. /**
  95176. * Keep track of the image processing observer to allow dispose and replace.
  95177. */
  95178. private _imageProcessingObserver;
  95179. /**
  95180. * Attaches a new image processing configuration to the Standard Material.
  95181. * @param configuration
  95182. */
  95183. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  95184. /**
  95185. * Gets wether the color curves effect is enabled.
  95186. */
  95187. /**
  95188. * Sets wether the color curves effect is enabled.
  95189. */
  95190. cameraColorCurvesEnabled: boolean;
  95191. /**
  95192. * Gets wether the color grading effect is enabled.
  95193. */
  95194. /**
  95195. * Gets wether the color grading effect is enabled.
  95196. */
  95197. cameraColorGradingEnabled: boolean;
  95198. /**
  95199. * Gets wether tonemapping is enabled or not.
  95200. */
  95201. /**
  95202. * Sets wether tonemapping is enabled or not
  95203. */
  95204. cameraToneMappingEnabled: boolean;
  95205. /**
  95206. * The camera exposure used on this material.
  95207. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  95208. * This corresponds to a photographic exposure.
  95209. */
  95210. /**
  95211. * The camera exposure used on this material.
  95212. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  95213. * This corresponds to a photographic exposure.
  95214. */
  95215. cameraExposure: number;
  95216. /**
  95217. * Gets The camera contrast used on this material.
  95218. */
  95219. /**
  95220. * Sets The camera contrast used on this material.
  95221. */
  95222. cameraContrast: number;
  95223. /**
  95224. * Gets the Color Grading 2D Lookup Texture.
  95225. */
  95226. /**
  95227. * Sets the Color Grading 2D Lookup Texture.
  95228. */
  95229. cameraColorGradingTexture: Nullable<BaseTexture>;
  95230. /**
  95231. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  95232. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  95233. * 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;
  95234. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  95235. */
  95236. /**
  95237. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  95238. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  95239. * 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;
  95240. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  95241. */
  95242. cameraColorCurves: Nullable<ColorCurves>;
  95243. /**
  95244. * Custom callback helping to override the default shader used in the material.
  95245. */
  95246. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  95247. protected _renderTargets: SmartArray<RenderTargetTexture>;
  95248. protected _worldViewProjectionMatrix: Matrix;
  95249. protected _globalAmbientColor: Color3;
  95250. protected _useLogarithmicDepth: boolean;
  95251. protected _rebuildInParallel: boolean;
  95252. /**
  95253. * Instantiates a new standard material.
  95254. * This is the default material used in Babylon. It is the best trade off between quality
  95255. * and performances.
  95256. * @see http://doc.babylonjs.com/babylon101/materials
  95257. * @param name Define the name of the material in the scene
  95258. * @param scene Define the scene the material belong to
  95259. */
  95260. constructor(name: string, scene: Scene);
  95261. /**
  95262. * Gets a boolean indicating that current material needs to register RTT
  95263. */
  95264. readonly hasRenderTargetTextures: boolean;
  95265. /**
  95266. * Gets the current class name of the material e.g. "StandardMaterial"
  95267. * Mainly use in serialization.
  95268. * @returns the class name
  95269. */
  95270. getClassName(): string;
  95271. /**
  95272. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  95273. * You can try switching to logarithmic depth.
  95274. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  95275. */
  95276. useLogarithmicDepth: boolean;
  95277. /**
  95278. * Specifies if the material will require alpha blending
  95279. * @returns a boolean specifying if alpha blending is needed
  95280. */
  95281. needAlphaBlending(): boolean;
  95282. /**
  95283. * Specifies if this material should be rendered in alpha test mode
  95284. * @returns a boolean specifying if an alpha test is needed.
  95285. */
  95286. needAlphaTesting(): boolean;
  95287. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  95288. /**
  95289. * Get the texture used for alpha test purpose.
  95290. * @returns the diffuse texture in case of the standard material.
  95291. */
  95292. getAlphaTestTexture(): Nullable<BaseTexture>;
  95293. /**
  95294. * Get if the submesh is ready to be used and all its information available.
  95295. * Child classes can use it to update shaders
  95296. * @param mesh defines the mesh to check
  95297. * @param subMesh defines which submesh to check
  95298. * @param useInstances specifies that instances should be used
  95299. * @returns a boolean indicating that the submesh is ready or not
  95300. */
  95301. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  95302. /**
  95303. * Builds the material UBO layouts.
  95304. * Used internally during the effect preparation.
  95305. */
  95306. buildUniformLayout(): void;
  95307. /**
  95308. * Unbinds the material from the mesh
  95309. */
  95310. unbind(): void;
  95311. /**
  95312. * Binds the submesh to this material by preparing the effect and shader to draw
  95313. * @param world defines the world transformation matrix
  95314. * @param mesh defines the mesh containing the submesh
  95315. * @param subMesh defines the submesh to bind the material to
  95316. */
  95317. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  95318. /**
  95319. * Get the list of animatables in the material.
  95320. * @returns the list of animatables object used in the material
  95321. */
  95322. getAnimatables(): IAnimatable[];
  95323. /**
  95324. * Gets the active textures from the material
  95325. * @returns an array of textures
  95326. */
  95327. getActiveTextures(): BaseTexture[];
  95328. /**
  95329. * Specifies if the material uses a texture
  95330. * @param texture defines the texture to check against the material
  95331. * @returns a boolean specifying if the material uses the texture
  95332. */
  95333. hasTexture(texture: BaseTexture): boolean;
  95334. /**
  95335. * Disposes the material
  95336. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  95337. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  95338. */
  95339. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  95340. /**
  95341. * Makes a duplicate of the material, and gives it a new name
  95342. * @param name defines the new name for the duplicated material
  95343. * @returns the cloned material
  95344. */
  95345. clone(name: string): StandardMaterial;
  95346. /**
  95347. * Serializes this material in a JSON representation
  95348. * @returns the serialized material object
  95349. */
  95350. serialize(): any;
  95351. /**
  95352. * Creates a standard material from parsed material data
  95353. * @param source defines the JSON representation of the material
  95354. * @param scene defines the hosting scene
  95355. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  95356. * @returns a new standard material
  95357. */
  95358. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  95359. /**
  95360. * Are diffuse textures enabled in the application.
  95361. */
  95362. static DiffuseTextureEnabled: boolean;
  95363. /**
  95364. * Are ambient textures enabled in the application.
  95365. */
  95366. static AmbientTextureEnabled: boolean;
  95367. /**
  95368. * Are opacity textures enabled in the application.
  95369. */
  95370. static OpacityTextureEnabled: boolean;
  95371. /**
  95372. * Are reflection textures enabled in the application.
  95373. */
  95374. static ReflectionTextureEnabled: boolean;
  95375. /**
  95376. * Are emissive textures enabled in the application.
  95377. */
  95378. static EmissiveTextureEnabled: boolean;
  95379. /**
  95380. * Are specular textures enabled in the application.
  95381. */
  95382. static SpecularTextureEnabled: boolean;
  95383. /**
  95384. * Are bump textures enabled in the application.
  95385. */
  95386. static BumpTextureEnabled: boolean;
  95387. /**
  95388. * Are lightmap textures enabled in the application.
  95389. */
  95390. static LightmapTextureEnabled: boolean;
  95391. /**
  95392. * Are refraction textures enabled in the application.
  95393. */
  95394. static RefractionTextureEnabled: boolean;
  95395. /**
  95396. * Are color grading textures enabled in the application.
  95397. */
  95398. static ColorGradingTextureEnabled: boolean;
  95399. /**
  95400. * Are fresnels enabled in the application.
  95401. */
  95402. static FresnelEnabled: boolean;
  95403. }
  95404. }
  95405. declare module BABYLON {
  95406. /**
  95407. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  95408. *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.
  95409. * The SPS is also a particle system. It provides some methods to manage the particles.
  95410. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  95411. *
  95412. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  95413. */
  95414. export class SolidParticleSystem implements IDisposable {
  95415. /**
  95416. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  95417. * Example : var p = SPS.particles[i];
  95418. */
  95419. particles: SolidParticle[];
  95420. /**
  95421. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  95422. */
  95423. nbParticles: number;
  95424. /**
  95425. * If the particles must ever face the camera (default false). Useful for planar particles.
  95426. */
  95427. billboard: boolean;
  95428. /**
  95429. * Recompute normals when adding a shape
  95430. */
  95431. recomputeNormals: boolean;
  95432. /**
  95433. * This a counter ofr your own usage. It's not set by any SPS functions.
  95434. */
  95435. counter: number;
  95436. /**
  95437. * The SPS name. This name is also given to the underlying mesh.
  95438. */
  95439. name: string;
  95440. /**
  95441. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  95442. */
  95443. mesh: Mesh;
  95444. /**
  95445. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  95446. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  95447. */
  95448. vars: any;
  95449. /**
  95450. * This array is populated when the SPS is set as 'pickable'.
  95451. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  95452. * Each element of this array is an object `{idx: int, faceId: int}`.
  95453. * `idx` is the picked particle index in the `SPS.particles` array
  95454. * `faceId` is the picked face index counted within this particle.
  95455. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  95456. */
  95457. pickedParticles: {
  95458. idx: number;
  95459. faceId: number;
  95460. }[];
  95461. /**
  95462. * This array is populated when `enableDepthSort` is set to true.
  95463. * Each element of this array is an instance of the class DepthSortedParticle.
  95464. */
  95465. depthSortedParticles: DepthSortedParticle[];
  95466. /**
  95467. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  95468. * @hidden
  95469. */
  95470. _bSphereOnly: boolean;
  95471. /**
  95472. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  95473. * @hidden
  95474. */
  95475. _bSphereRadiusFactor: number;
  95476. private _scene;
  95477. private _positions;
  95478. private _indices;
  95479. private _normals;
  95480. private _colors;
  95481. private _uvs;
  95482. private _indices32;
  95483. private _positions32;
  95484. private _normals32;
  95485. private _fixedNormal32;
  95486. private _colors32;
  95487. private _uvs32;
  95488. private _index;
  95489. private _updatable;
  95490. private _pickable;
  95491. private _isVisibilityBoxLocked;
  95492. private _alwaysVisible;
  95493. private _depthSort;
  95494. private _expandable;
  95495. private _shapeCounter;
  95496. private _copy;
  95497. private _color;
  95498. private _computeParticleColor;
  95499. private _computeParticleTexture;
  95500. private _computeParticleRotation;
  95501. private _computeParticleVertex;
  95502. private _computeBoundingBox;
  95503. private _depthSortParticles;
  95504. private _camera;
  95505. private _mustUnrotateFixedNormals;
  95506. private _particlesIntersect;
  95507. private _needs32Bits;
  95508. private _isNotBuilt;
  95509. private _lastParticleId;
  95510. private _idxOfId;
  95511. private _multimaterialEnabled;
  95512. private _useModelMaterial;
  95513. private _indicesByMaterial;
  95514. private _materialIndexes;
  95515. private _depthSortFunction;
  95516. private _materialSortFunction;
  95517. private _materials;
  95518. private _multimaterial;
  95519. private _materialIndexesById;
  95520. private _defaultMaterial;
  95521. private _autoUpdateSubMeshes;
  95522. /**
  95523. * Creates a SPS (Solid Particle System) object.
  95524. * @param name (String) is the SPS name, this will be the underlying mesh name.
  95525. * @param scene (Scene) is the scene in which the SPS is added.
  95526. * @param options defines the options of the sps e.g.
  95527. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  95528. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  95529. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  95530. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  95531. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  95532. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  95533. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  95534. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  95535. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  95536. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  95537. */
  95538. constructor(name: string, scene: Scene, options?: {
  95539. updatable?: boolean;
  95540. isPickable?: boolean;
  95541. enableDepthSort?: boolean;
  95542. particleIntersection?: boolean;
  95543. boundingSphereOnly?: boolean;
  95544. bSphereRadiusFactor?: number;
  95545. expandable?: boolean;
  95546. useModelMaterial?: boolean;
  95547. enableMultiMaterial?: boolean;
  95548. });
  95549. /**
  95550. * Builds the SPS underlying mesh. Returns a standard Mesh.
  95551. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  95552. * @returns the created mesh
  95553. */
  95554. buildMesh(): Mesh;
  95555. /**
  95556. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  95557. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  95558. * Thus the particles generated from `digest()` have their property `position` set yet.
  95559. * @param mesh ( Mesh ) is the mesh to be digested
  95560. * @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
  95561. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  95562. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  95563. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  95564. * @returns the current SPS
  95565. */
  95566. digest(mesh: Mesh, options?: {
  95567. facetNb?: number;
  95568. number?: number;
  95569. delta?: number;
  95570. storage?: [];
  95571. }): SolidParticleSystem;
  95572. /**
  95573. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  95574. * @hidden
  95575. */
  95576. private _unrotateFixedNormals;
  95577. /**
  95578. * Resets the temporary working copy particle
  95579. * @hidden
  95580. */
  95581. private _resetCopy;
  95582. /**
  95583. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  95584. * @param p the current index in the positions array to be updated
  95585. * @param ind the current index in the indices array
  95586. * @param shape a Vector3 array, the shape geometry
  95587. * @param positions the positions array to be updated
  95588. * @param meshInd the shape indices array
  95589. * @param indices the indices array to be updated
  95590. * @param meshUV the shape uv array
  95591. * @param uvs the uv array to be updated
  95592. * @param meshCol the shape color array
  95593. * @param colors the color array to be updated
  95594. * @param meshNor the shape normals array
  95595. * @param normals the normals array to be updated
  95596. * @param idx the particle index
  95597. * @param idxInShape the particle index in its shape
  95598. * @param options the addShape() method passed options
  95599. * @model the particle model
  95600. * @hidden
  95601. */
  95602. private _meshBuilder;
  95603. /**
  95604. * Returns a shape Vector3 array from positions float array
  95605. * @param positions float array
  95606. * @returns a vector3 array
  95607. * @hidden
  95608. */
  95609. private _posToShape;
  95610. /**
  95611. * Returns a shapeUV array from a float uvs (array deep copy)
  95612. * @param uvs as a float array
  95613. * @returns a shapeUV array
  95614. * @hidden
  95615. */
  95616. private _uvsToShapeUV;
  95617. /**
  95618. * Adds a new particle object in the particles array
  95619. * @param idx particle index in particles array
  95620. * @param id particle id
  95621. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  95622. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  95623. * @param model particle ModelShape object
  95624. * @param shapeId model shape identifier
  95625. * @param idxInShape index of the particle in the current model
  95626. * @param bInfo model bounding info object
  95627. * @param storage target storage array, if any
  95628. * @hidden
  95629. */
  95630. private _addParticle;
  95631. /**
  95632. * Adds some particles to the SPS from the model shape. Returns the shape id.
  95633. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  95634. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  95635. * @param nb (positive integer) the number of particles to be created from this model
  95636. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  95637. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  95638. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  95639. * @returns the number of shapes in the system
  95640. */
  95641. addShape(mesh: Mesh, nb: number, options?: {
  95642. positionFunction?: any;
  95643. vertexFunction?: any;
  95644. storage?: [];
  95645. }): number;
  95646. /**
  95647. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  95648. * @hidden
  95649. */
  95650. private _rebuildParticle;
  95651. /**
  95652. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  95653. * @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.
  95654. * @returns the SPS.
  95655. */
  95656. rebuildMesh(reset?: boolean): SolidParticleSystem;
  95657. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  95658. * Returns an array with the removed particles.
  95659. * 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.
  95660. * The SPS can't be empty so at least one particle needs to remain in place.
  95661. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  95662. * @param start index of the first particle to remove
  95663. * @param end index of the last particle to remove (included)
  95664. * @returns an array populated with the removed particles
  95665. */
  95666. removeParticles(start: number, end: number): SolidParticle[];
  95667. /**
  95668. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  95669. * @param solidParticleArray an array populated with Solid Particles objects
  95670. * @returns the SPS
  95671. */
  95672. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  95673. /**
  95674. * Creates a new particle and modifies the SPS mesh geometry :
  95675. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  95676. * - calls _addParticle() to populate the particle array
  95677. * factorized code from addShape() and insertParticlesFromArray()
  95678. * @param idx particle index in the particles array
  95679. * @param i particle index in its shape
  95680. * @param modelShape particle ModelShape object
  95681. * @param shape shape vertex array
  95682. * @param meshInd shape indices array
  95683. * @param meshUV shape uv array
  95684. * @param meshCol shape color array
  95685. * @param meshNor shape normals array
  95686. * @param bbInfo shape bounding info
  95687. * @param storage target particle storage
  95688. * @options addShape() passed options
  95689. * @hidden
  95690. */
  95691. private _insertNewParticle;
  95692. /**
  95693. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  95694. * This method calls `updateParticle()` for each particle of the SPS.
  95695. * For an animated SPS, it is usually called within the render loop.
  95696. * 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.
  95697. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  95698. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  95699. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  95700. * @returns the SPS.
  95701. */
  95702. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  95703. /**
  95704. * Disposes the SPS.
  95705. */
  95706. dispose(): void;
  95707. /**
  95708. * Returns a SolidParticle object from its identifier : particle.id
  95709. * @param id (integer) the particle Id
  95710. * @returns the searched particle or null if not found in the SPS.
  95711. */
  95712. getParticleById(id: number): Nullable<SolidParticle>;
  95713. /**
  95714. * Returns a new array populated with the particles having the passed shapeId.
  95715. * @param shapeId (integer) the shape identifier
  95716. * @returns a new solid particle array
  95717. */
  95718. getParticlesByShapeId(shapeId: number): SolidParticle[];
  95719. /**
  95720. * Populates the passed array "ref" with the particles having the passed shapeId.
  95721. * @param shapeId the shape identifier
  95722. * @returns the SPS
  95723. * @param ref
  95724. */
  95725. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  95726. /**
  95727. * Computes the required SubMeshes according the materials assigned to the particles.
  95728. * @returns the solid particle system.
  95729. * Does nothing if called before the SPS mesh is built.
  95730. */
  95731. computeSubMeshes(): SolidParticleSystem;
  95732. /**
  95733. * Sorts the solid particles by material when MultiMaterial is enabled.
  95734. * Updates the indices32 array.
  95735. * Updates the indicesByMaterial array.
  95736. * Updates the mesh indices array.
  95737. * @returns the SPS
  95738. * @hidden
  95739. */
  95740. private _sortParticlesByMaterial;
  95741. /**
  95742. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  95743. * @hidden
  95744. */
  95745. private _setMaterialIndexesById;
  95746. /**
  95747. * Returns an array with unique values of Materials from the passed array
  95748. * @param array the material array to be checked and filtered
  95749. * @hidden
  95750. */
  95751. private _filterUniqueMaterialId;
  95752. /**
  95753. * Sets a new Standard Material as _defaultMaterial if not already set.
  95754. * @hidden
  95755. */
  95756. private _setDefaultMaterial;
  95757. /**
  95758. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  95759. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  95760. * @returns the SPS.
  95761. */
  95762. refreshVisibleSize(): SolidParticleSystem;
  95763. /**
  95764. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  95765. * @param size the size (float) of the visibility box
  95766. * note : this doesn't lock the SPS mesh bounding box.
  95767. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  95768. */
  95769. setVisibilityBox(size: number): void;
  95770. /**
  95771. * Gets whether the SPS as always visible or not
  95772. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  95773. */
  95774. /**
  95775. * Sets the SPS as always visible or not
  95776. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  95777. */
  95778. isAlwaysVisible: boolean;
  95779. /**
  95780. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  95781. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  95782. */
  95783. /**
  95784. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  95785. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  95786. */
  95787. isVisibilityBoxLocked: boolean;
  95788. /**
  95789. * Tells to `setParticles()` to compute the particle rotations or not.
  95790. * Default value : true. The SPS is faster when it's set to false.
  95791. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  95792. */
  95793. /**
  95794. * Gets if `setParticles()` computes the particle rotations or not.
  95795. * Default value : true. The SPS is faster when it's set to false.
  95796. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  95797. */
  95798. computeParticleRotation: boolean;
  95799. /**
  95800. * Tells to `setParticles()` to compute the particle colors or not.
  95801. * Default value : true. The SPS is faster when it's set to false.
  95802. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  95803. */
  95804. /**
  95805. * Gets if `setParticles()` computes the particle colors or not.
  95806. * Default value : true. The SPS is faster when it's set to false.
  95807. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  95808. */
  95809. computeParticleColor: boolean;
  95810. /**
  95811. * Gets if `setParticles()` computes the particle textures or not.
  95812. * Default value : true. The SPS is faster when it's set to false.
  95813. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  95814. */
  95815. computeParticleTexture: boolean;
  95816. /**
  95817. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  95818. * Default value : false. The SPS is faster when it's set to false.
  95819. * Note : the particle custom vertex positions aren't stored values.
  95820. */
  95821. /**
  95822. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  95823. * Default value : false. The SPS is faster when it's set to false.
  95824. * Note : the particle custom vertex positions aren't stored values.
  95825. */
  95826. computeParticleVertex: boolean;
  95827. /**
  95828. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  95829. */
  95830. /**
  95831. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  95832. */
  95833. computeBoundingBox: boolean;
  95834. /**
  95835. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  95836. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  95837. * Default : `true`
  95838. */
  95839. /**
  95840. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  95841. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  95842. * Default : `true`
  95843. */
  95844. depthSortParticles: boolean;
  95845. /**
  95846. * Gets if the SPS is created as expandable at construction time.
  95847. * Default : `false`
  95848. */
  95849. readonly expandable: boolean;
  95850. /**
  95851. * Gets if the SPS supports the Multi Materials
  95852. */
  95853. readonly multimaterialEnabled: boolean;
  95854. /**
  95855. * Gets if the SPS uses the model materials for its own multimaterial.
  95856. */
  95857. readonly useModelMaterial: boolean;
  95858. /**
  95859. * The SPS used material array.
  95860. */
  95861. readonly materials: Material[];
  95862. /**
  95863. * Sets the SPS MultiMaterial from the passed materials.
  95864. * Note : the passed array is internally copied and not used then by reference.
  95865. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  95866. */
  95867. setMultiMaterial(materials: Material[]): void;
  95868. /**
  95869. * The SPS computed multimaterial object
  95870. */
  95871. multimaterial: MultiMaterial;
  95872. /**
  95873. * If the subMeshes must be updated on the next call to setParticles()
  95874. */
  95875. autoUpdateSubMeshes: boolean;
  95876. /**
  95877. * This function does nothing. It may be overwritten to set all the particle first values.
  95878. * The SPS doesn't call this function, you may have to call it by your own.
  95879. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  95880. */
  95881. initParticles(): void;
  95882. /**
  95883. * This function does nothing. It may be overwritten to recycle a particle.
  95884. * The SPS doesn't call this function, you may have to call it by your own.
  95885. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  95886. * @param particle The particle to recycle
  95887. * @returns the recycled particle
  95888. */
  95889. recycleParticle(particle: SolidParticle): SolidParticle;
  95890. /**
  95891. * Updates a particle : this function should be overwritten by the user.
  95892. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  95893. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  95894. * @example : just set a particle position or velocity and recycle conditions
  95895. * @param particle The particle to update
  95896. * @returns the updated particle
  95897. */
  95898. updateParticle(particle: SolidParticle): SolidParticle;
  95899. /**
  95900. * Updates a vertex of a particle : it can be overwritten by the user.
  95901. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  95902. * @param particle the current particle
  95903. * @param vertex the current index of the current particle
  95904. * @param pt the index of the current vertex in the particle shape
  95905. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  95906. * @example : just set a vertex particle position
  95907. * @returns the updated vertex
  95908. */
  95909. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  95910. /**
  95911. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  95912. * This does nothing and may be overwritten by the user.
  95913. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  95914. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  95915. * @param update the boolean update value actually passed to setParticles()
  95916. */
  95917. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  95918. /**
  95919. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  95920. * This will be passed three parameters.
  95921. * This does nothing and may be overwritten by the user.
  95922. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  95923. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  95924. * @param update the boolean update value actually passed to setParticles()
  95925. */
  95926. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  95927. }
  95928. }
  95929. declare module BABYLON {
  95930. /**
  95931. * Represents one particle of a solid particle system.
  95932. */
  95933. export class SolidParticle {
  95934. /**
  95935. * particle global index
  95936. */
  95937. idx: number;
  95938. /**
  95939. * particle identifier
  95940. */
  95941. id: number;
  95942. /**
  95943. * The color of the particle
  95944. */
  95945. color: Nullable<Color4>;
  95946. /**
  95947. * The world space position of the particle.
  95948. */
  95949. position: Vector3;
  95950. /**
  95951. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  95952. */
  95953. rotation: Vector3;
  95954. /**
  95955. * The world space rotation quaternion of the particle.
  95956. */
  95957. rotationQuaternion: Nullable<Quaternion>;
  95958. /**
  95959. * The scaling of the particle.
  95960. */
  95961. scaling: Vector3;
  95962. /**
  95963. * The uvs of the particle.
  95964. */
  95965. uvs: Vector4;
  95966. /**
  95967. * The current speed of the particle.
  95968. */
  95969. velocity: Vector3;
  95970. /**
  95971. * The pivot point in the particle local space.
  95972. */
  95973. pivot: Vector3;
  95974. /**
  95975. * Must the particle be translated from its pivot point in its local space ?
  95976. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  95977. * Default : false
  95978. */
  95979. translateFromPivot: boolean;
  95980. /**
  95981. * Is the particle active or not ?
  95982. */
  95983. alive: boolean;
  95984. /**
  95985. * Is the particle visible or not ?
  95986. */
  95987. isVisible: boolean;
  95988. /**
  95989. * Index of this particle in the global "positions" array (Internal use)
  95990. * @hidden
  95991. */
  95992. _pos: number;
  95993. /**
  95994. * @hidden Index of this particle in the global "indices" array (Internal use)
  95995. */
  95996. _ind: number;
  95997. /**
  95998. * @hidden ModelShape of this particle (Internal use)
  95999. */
  96000. _model: ModelShape;
  96001. /**
  96002. * ModelShape id of this particle
  96003. */
  96004. shapeId: number;
  96005. /**
  96006. * Index of the particle in its shape id
  96007. */
  96008. idxInShape: number;
  96009. /**
  96010. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  96011. */
  96012. _modelBoundingInfo: BoundingInfo;
  96013. /**
  96014. * @hidden Particle BoundingInfo object (Internal use)
  96015. */
  96016. _boundingInfo: BoundingInfo;
  96017. /**
  96018. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  96019. */
  96020. _sps: SolidParticleSystem;
  96021. /**
  96022. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  96023. */
  96024. _stillInvisible: boolean;
  96025. /**
  96026. * @hidden Last computed particle rotation matrix
  96027. */
  96028. _rotationMatrix: number[];
  96029. /**
  96030. * Parent particle Id, if any.
  96031. * Default null.
  96032. */
  96033. parentId: Nullable<number>;
  96034. /**
  96035. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  96036. */
  96037. materialIndex: Nullable<number>;
  96038. /**
  96039. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  96040. * The possible values are :
  96041. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  96042. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  96043. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  96044. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  96045. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  96046. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  96047. * */
  96048. cullingStrategy: number;
  96049. /**
  96050. * @hidden Internal global position in the SPS.
  96051. */
  96052. _globalPosition: Vector3;
  96053. /**
  96054. * Creates a Solid Particle object.
  96055. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  96056. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  96057. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  96058. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  96059. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  96060. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  96061. * @param shapeId (integer) is the model shape identifier in the SPS.
  96062. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  96063. * @param sps defines the sps it is associated to
  96064. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  96065. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  96066. */
  96067. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  96068. /**
  96069. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  96070. * @param target the particle target
  96071. * @returns the current particle
  96072. */
  96073. copyToRef(target: SolidParticle): SolidParticle;
  96074. /**
  96075. * Legacy support, changed scale to scaling
  96076. */
  96077. /**
  96078. * Legacy support, changed scale to scaling
  96079. */
  96080. scale: Vector3;
  96081. /**
  96082. * Legacy support, changed quaternion to rotationQuaternion
  96083. */
  96084. /**
  96085. * Legacy support, changed quaternion to rotationQuaternion
  96086. */
  96087. quaternion: Nullable<Quaternion>;
  96088. /**
  96089. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  96090. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  96091. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  96092. * @returns true if it intersects
  96093. */
  96094. intersectsMesh(target: Mesh | SolidParticle): boolean;
  96095. /**
  96096. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  96097. * A particle is in the frustum if its bounding box intersects the frustum
  96098. * @param frustumPlanes defines the frustum to test
  96099. * @returns true if the particle is in the frustum planes
  96100. */
  96101. isInFrustum(frustumPlanes: Plane[]): boolean;
  96102. /**
  96103. * get the rotation matrix of the particle
  96104. * @hidden
  96105. */
  96106. getRotationMatrix(m: Matrix): void;
  96107. }
  96108. /**
  96109. * Represents the shape of the model used by one particle of a solid particle system.
  96110. * SPS internal tool, don't use it manually.
  96111. */
  96112. export class ModelShape {
  96113. /**
  96114. * The shape id
  96115. * @hidden
  96116. */
  96117. shapeID: number;
  96118. /**
  96119. * flat array of model positions (internal use)
  96120. * @hidden
  96121. */
  96122. _shape: Vector3[];
  96123. /**
  96124. * flat array of model UVs (internal use)
  96125. * @hidden
  96126. */
  96127. _shapeUV: number[];
  96128. /**
  96129. * color array of the model
  96130. * @hidden
  96131. */
  96132. _shapeColors: number[];
  96133. /**
  96134. * indices array of the model
  96135. * @hidden
  96136. */
  96137. _indices: number[];
  96138. /**
  96139. * normals array of the model
  96140. * @hidden
  96141. */
  96142. _normals: number[];
  96143. /**
  96144. * length of the shape in the model indices array (internal use)
  96145. * @hidden
  96146. */
  96147. _indicesLength: number;
  96148. /**
  96149. * Custom position function (internal use)
  96150. * @hidden
  96151. */
  96152. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  96153. /**
  96154. * Custom vertex function (internal use)
  96155. * @hidden
  96156. */
  96157. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  96158. /**
  96159. * Model material (internal use)
  96160. * @hidden
  96161. */
  96162. _material: Nullable<Material>;
  96163. /**
  96164. * 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.
  96165. * SPS internal tool, don't use it manually.
  96166. * @hidden
  96167. */
  96168. 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>, material: Nullable<Material>);
  96169. }
  96170. /**
  96171. * Represents a Depth Sorted Particle in the solid particle system.
  96172. * @hidden
  96173. */
  96174. export class DepthSortedParticle {
  96175. /**
  96176. * Index of the particle in the "indices" array
  96177. */
  96178. ind: number;
  96179. /**
  96180. * Length of the particle shape in the "indices" array
  96181. */
  96182. indicesLength: number;
  96183. /**
  96184. * Squared distance from the particle to the camera
  96185. */
  96186. sqDistance: number;
  96187. /**
  96188. * Material index when used with MultiMaterials
  96189. */
  96190. materialIndex: number;
  96191. /**
  96192. * Creates a new sorted particle
  96193. * @param materialIndex
  96194. */
  96195. constructor(ind: number, indLength: number, materialIndex: number);
  96196. }
  96197. }
  96198. declare module BABYLON {
  96199. /**
  96200. * @hidden
  96201. */
  96202. export class _MeshCollisionData {
  96203. _checkCollisions: boolean;
  96204. _collisionMask: number;
  96205. _collisionGroup: number;
  96206. _collider: Nullable<Collider>;
  96207. _oldPositionForCollisions: Vector3;
  96208. _diffPositionForCollisions: Vector3;
  96209. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  96210. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  96211. }
  96212. }
  96213. declare module BABYLON {
  96214. /** @hidden */
  96215. class _FacetDataStorage {
  96216. facetPositions: Vector3[];
  96217. facetNormals: Vector3[];
  96218. facetPartitioning: number[][];
  96219. facetNb: number;
  96220. partitioningSubdivisions: number;
  96221. partitioningBBoxRatio: number;
  96222. facetDataEnabled: boolean;
  96223. facetParameters: any;
  96224. bbSize: Vector3;
  96225. subDiv: {
  96226. max: number;
  96227. X: number;
  96228. Y: number;
  96229. Z: number;
  96230. };
  96231. facetDepthSort: boolean;
  96232. facetDepthSortEnabled: boolean;
  96233. depthSortedIndices: IndicesArray;
  96234. depthSortedFacets: {
  96235. ind: number;
  96236. sqDistance: number;
  96237. }[];
  96238. facetDepthSortFunction: (f1: {
  96239. ind: number;
  96240. sqDistance: number;
  96241. }, f2: {
  96242. ind: number;
  96243. sqDistance: number;
  96244. }) => number;
  96245. facetDepthSortFrom: Vector3;
  96246. facetDepthSortOrigin: Vector3;
  96247. invertedMatrix: Matrix;
  96248. }
  96249. /**
  96250. * @hidden
  96251. **/
  96252. class _InternalAbstractMeshDataInfo {
  96253. _hasVertexAlpha: boolean;
  96254. _useVertexColors: boolean;
  96255. _numBoneInfluencers: number;
  96256. _applyFog: boolean;
  96257. _receiveShadows: boolean;
  96258. _facetData: _FacetDataStorage;
  96259. _visibility: number;
  96260. _skeleton: Nullable<Skeleton>;
  96261. _layerMask: number;
  96262. _computeBonesUsingShaders: boolean;
  96263. _isActive: boolean;
  96264. _onlyForInstances: boolean;
  96265. _isActiveIntermediate: boolean;
  96266. _onlyForInstancesIntermediate: boolean;
  96267. _actAsRegularMesh: boolean;
  96268. }
  96269. /**
  96270. * Class used to store all common mesh properties
  96271. */
  96272. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  96273. /** No occlusion */
  96274. static OCCLUSION_TYPE_NONE: number;
  96275. /** Occlusion set to optimisitic */
  96276. static OCCLUSION_TYPE_OPTIMISTIC: number;
  96277. /** Occlusion set to strict */
  96278. static OCCLUSION_TYPE_STRICT: number;
  96279. /** Use an accurante occlusion algorithm */
  96280. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  96281. /** Use a conservative occlusion algorithm */
  96282. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  96283. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  96284. * Test order :
  96285. * Is the bounding sphere outside the frustum ?
  96286. * If not, are the bounding box vertices outside the frustum ?
  96287. * It not, then the cullable object is in the frustum.
  96288. */
  96289. static readonly CULLINGSTRATEGY_STANDARD: number;
  96290. /** Culling strategy : Bounding Sphere Only.
  96291. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  96292. * It's also less accurate than the standard because some not visible objects can still be selected.
  96293. * Test : is the bounding sphere outside the frustum ?
  96294. * If not, then the cullable object is in the frustum.
  96295. */
  96296. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  96297. /** Culling strategy : Optimistic Inclusion.
  96298. * This in an inclusion test first, then the standard exclusion test.
  96299. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  96300. * 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.
  96301. * Anyway, it's as accurate as the standard strategy.
  96302. * Test :
  96303. * Is the cullable object bounding sphere center in the frustum ?
  96304. * If not, apply the default culling strategy.
  96305. */
  96306. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  96307. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  96308. * This in an inclusion test first, then the bounding sphere only exclusion test.
  96309. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  96310. * 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.
  96311. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  96312. * Test :
  96313. * Is the cullable object bounding sphere center in the frustum ?
  96314. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  96315. */
  96316. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  96317. /**
  96318. * No billboard
  96319. */
  96320. static readonly BILLBOARDMODE_NONE: number;
  96321. /** Billboard on X axis */
  96322. static readonly BILLBOARDMODE_X: number;
  96323. /** Billboard on Y axis */
  96324. static readonly BILLBOARDMODE_Y: number;
  96325. /** Billboard on Z axis */
  96326. static readonly BILLBOARDMODE_Z: number;
  96327. /** Billboard on all axes */
  96328. static readonly BILLBOARDMODE_ALL: number;
  96329. /** Billboard on using position instead of orientation */
  96330. static readonly BILLBOARDMODE_USE_POSITION: number;
  96331. /** @hidden */
  96332. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  96333. /**
  96334. * The culling strategy to use to check whether the mesh must be rendered or not.
  96335. * This value can be changed at any time and will be used on the next render mesh selection.
  96336. * The possible values are :
  96337. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  96338. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  96339. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  96340. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  96341. * Please read each static variable documentation to get details about the culling process.
  96342. * */
  96343. cullingStrategy: number;
  96344. /**
  96345. * Gets the number of facets in the mesh
  96346. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  96347. */
  96348. readonly facetNb: number;
  96349. /**
  96350. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  96351. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  96352. */
  96353. partitioningSubdivisions: number;
  96354. /**
  96355. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  96356. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  96357. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  96358. */
  96359. partitioningBBoxRatio: number;
  96360. /**
  96361. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  96362. * Works only for updatable meshes.
  96363. * Doesn't work with multi-materials
  96364. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  96365. */
  96366. mustDepthSortFacets: boolean;
  96367. /**
  96368. * The location (Vector3) where the facet depth sort must be computed from.
  96369. * By default, the active camera position.
  96370. * Used only when facet depth sort is enabled
  96371. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  96372. */
  96373. facetDepthSortFrom: Vector3;
  96374. /**
  96375. * gets a boolean indicating if facetData is enabled
  96376. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  96377. */
  96378. readonly isFacetDataEnabled: boolean;
  96379. /** @hidden */
  96380. _updateNonUniformScalingState(value: boolean): boolean;
  96381. /**
  96382. * An event triggered when this mesh collides with another one
  96383. */
  96384. onCollideObservable: Observable<AbstractMesh>;
  96385. /** Set a function to call when this mesh collides with another one */
  96386. onCollide: () => void;
  96387. /**
  96388. * An event triggered when the collision's position changes
  96389. */
  96390. onCollisionPositionChangeObservable: Observable<Vector3>;
  96391. /** Set a function to call when the collision's position changes */
  96392. onCollisionPositionChange: () => void;
  96393. /**
  96394. * An event triggered when material is changed
  96395. */
  96396. onMaterialChangedObservable: Observable<AbstractMesh>;
  96397. /**
  96398. * Gets or sets the orientation for POV movement & rotation
  96399. */
  96400. definedFacingForward: boolean;
  96401. /** @hidden */
  96402. _occlusionQuery: Nullable<WebGLQuery>;
  96403. /** @hidden */
  96404. _renderingGroup: Nullable<RenderingGroup>;
  96405. /**
  96406. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  96407. */
  96408. /**
  96409. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  96410. */
  96411. visibility: number;
  96412. /** Gets or sets the alpha index used to sort transparent meshes
  96413. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  96414. */
  96415. alphaIndex: number;
  96416. /**
  96417. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  96418. */
  96419. isVisible: boolean;
  96420. /**
  96421. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  96422. */
  96423. isPickable: boolean;
  96424. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  96425. showSubMeshesBoundingBox: boolean;
  96426. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  96427. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  96428. */
  96429. isBlocker: boolean;
  96430. /**
  96431. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  96432. */
  96433. enablePointerMoveEvents: boolean;
  96434. /**
  96435. * Specifies the rendering group id for this mesh (0 by default)
  96436. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  96437. */
  96438. renderingGroupId: number;
  96439. private _material;
  96440. /** Gets or sets current material */
  96441. material: Nullable<Material>;
  96442. /**
  96443. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  96444. * @see http://doc.babylonjs.com/babylon101/shadows
  96445. */
  96446. receiveShadows: boolean;
  96447. /** Defines color to use when rendering outline */
  96448. outlineColor: Color3;
  96449. /** Define width to use when rendering outline */
  96450. outlineWidth: number;
  96451. /** Defines color to use when rendering overlay */
  96452. overlayColor: Color3;
  96453. /** Defines alpha to use when rendering overlay */
  96454. overlayAlpha: number;
  96455. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  96456. hasVertexAlpha: boolean;
  96457. /** 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) */
  96458. useVertexColors: boolean;
  96459. /**
  96460. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  96461. */
  96462. computeBonesUsingShaders: boolean;
  96463. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  96464. numBoneInfluencers: number;
  96465. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  96466. applyFog: boolean;
  96467. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  96468. useOctreeForRenderingSelection: boolean;
  96469. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  96470. useOctreeForPicking: boolean;
  96471. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  96472. useOctreeForCollisions: boolean;
  96473. /**
  96474. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  96475. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  96476. */
  96477. layerMask: number;
  96478. /**
  96479. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  96480. */
  96481. alwaysSelectAsActiveMesh: boolean;
  96482. /**
  96483. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  96484. */
  96485. doNotSyncBoundingInfo: boolean;
  96486. /**
  96487. * Gets or sets the current action manager
  96488. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  96489. */
  96490. actionManager: Nullable<AbstractActionManager>;
  96491. private _meshCollisionData;
  96492. /**
  96493. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  96494. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  96495. */
  96496. ellipsoid: Vector3;
  96497. /**
  96498. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  96499. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  96500. */
  96501. ellipsoidOffset: Vector3;
  96502. /**
  96503. * Gets or sets a collision mask used to mask collisions (default is -1).
  96504. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  96505. */
  96506. collisionMask: number;
  96507. /**
  96508. * Gets or sets the current collision group mask (-1 by default).
  96509. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  96510. */
  96511. collisionGroup: number;
  96512. /**
  96513. * Defines edge width used when edgesRenderer is enabled
  96514. * @see https://www.babylonjs-playground.com/#10OJSG#13
  96515. */
  96516. edgesWidth: number;
  96517. /**
  96518. * Defines edge color used when edgesRenderer is enabled
  96519. * @see https://www.babylonjs-playground.com/#10OJSG#13
  96520. */
  96521. edgesColor: Color4;
  96522. /** @hidden */
  96523. _edgesRenderer: Nullable<IEdgesRenderer>;
  96524. /** @hidden */
  96525. _masterMesh: Nullable<AbstractMesh>;
  96526. /** @hidden */
  96527. _boundingInfo: Nullable<BoundingInfo>;
  96528. /** @hidden */
  96529. _renderId: number;
  96530. /**
  96531. * Gets or sets the list of subMeshes
  96532. * @see http://doc.babylonjs.com/how_to/multi_materials
  96533. */
  96534. subMeshes: SubMesh[];
  96535. /** @hidden */
  96536. _intersectionsInProgress: AbstractMesh[];
  96537. /** @hidden */
  96538. _unIndexed: boolean;
  96539. /** @hidden */
  96540. _lightSources: Light[];
  96541. /** Gets the list of lights affecting that mesh */
  96542. readonly lightSources: Light[];
  96543. /** @hidden */
  96544. readonly _positions: Nullable<Vector3[]>;
  96545. /** @hidden */
  96546. _waitingData: {
  96547. lods: Nullable<any>;
  96548. actions: Nullable<any>;
  96549. freezeWorldMatrix: Nullable<boolean>;
  96550. };
  96551. /** @hidden */
  96552. _bonesTransformMatrices: Nullable<Float32Array>;
  96553. /** @hidden */
  96554. _transformMatrixTexture: Nullable<RawTexture>;
  96555. /**
  96556. * Gets or sets a skeleton to apply skining transformations
  96557. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  96558. */
  96559. skeleton: Nullable<Skeleton>;
  96560. /**
  96561. * An event triggered when the mesh is rebuilt.
  96562. */
  96563. onRebuildObservable: Observable<AbstractMesh>;
  96564. /**
  96565. * Creates a new AbstractMesh
  96566. * @param name defines the name of the mesh
  96567. * @param scene defines the hosting scene
  96568. */
  96569. constructor(name: string, scene?: Nullable<Scene>);
  96570. /**
  96571. * Returns the string "AbstractMesh"
  96572. * @returns "AbstractMesh"
  96573. */
  96574. getClassName(): string;
  96575. /**
  96576. * Gets a string representation of the current mesh
  96577. * @param fullDetails defines a boolean indicating if full details must be included
  96578. * @returns a string representation of the current mesh
  96579. */
  96580. toString(fullDetails?: boolean): string;
  96581. /**
  96582. * @hidden
  96583. */
  96584. protected _getEffectiveParent(): Nullable<Node>;
  96585. /** @hidden */
  96586. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  96587. /** @hidden */
  96588. _rebuild(): void;
  96589. /** @hidden */
  96590. _resyncLightSources(): void;
  96591. /** @hidden */
  96592. _resyncLightSource(light: Light): void;
  96593. /** @hidden */
  96594. _unBindEffect(): void;
  96595. /** @hidden */
  96596. _removeLightSource(light: Light, dispose: boolean): void;
  96597. private _markSubMeshesAsDirty;
  96598. /** @hidden */
  96599. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  96600. /** @hidden */
  96601. _markSubMeshesAsAttributesDirty(): void;
  96602. /** @hidden */
  96603. _markSubMeshesAsMiscDirty(): void;
  96604. /**
  96605. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  96606. */
  96607. scaling: Vector3;
  96608. /**
  96609. * Returns true if the mesh is blocked. Implemented by child classes
  96610. */
  96611. readonly isBlocked: boolean;
  96612. /**
  96613. * Returns the mesh itself by default. Implemented by child classes
  96614. * @param camera defines the camera to use to pick the right LOD level
  96615. * @returns the currentAbstractMesh
  96616. */
  96617. getLOD(camera: Camera): Nullable<AbstractMesh>;
  96618. /**
  96619. * Returns 0 by default. Implemented by child classes
  96620. * @returns an integer
  96621. */
  96622. getTotalVertices(): number;
  96623. /**
  96624. * Returns a positive integer : the total number of indices in this mesh geometry.
  96625. * @returns the numner of indices or zero if the mesh has no geometry.
  96626. */
  96627. getTotalIndices(): number;
  96628. /**
  96629. * Returns null by default. Implemented by child classes
  96630. * @returns null
  96631. */
  96632. getIndices(): Nullable<IndicesArray>;
  96633. /**
  96634. * Returns the array of the requested vertex data kind. Implemented by child classes
  96635. * @param kind defines the vertex data kind to use
  96636. * @returns null
  96637. */
  96638. getVerticesData(kind: string): Nullable<FloatArray>;
  96639. /**
  96640. * Sets the vertex data of the mesh geometry for the requested `kind`.
  96641. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  96642. * Note that a new underlying VertexBuffer object is created each call.
  96643. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  96644. * @param kind defines vertex data kind:
  96645. * * VertexBuffer.PositionKind
  96646. * * VertexBuffer.UVKind
  96647. * * VertexBuffer.UV2Kind
  96648. * * VertexBuffer.UV3Kind
  96649. * * VertexBuffer.UV4Kind
  96650. * * VertexBuffer.UV5Kind
  96651. * * VertexBuffer.UV6Kind
  96652. * * VertexBuffer.ColorKind
  96653. * * VertexBuffer.MatricesIndicesKind
  96654. * * VertexBuffer.MatricesIndicesExtraKind
  96655. * * VertexBuffer.MatricesWeightsKind
  96656. * * VertexBuffer.MatricesWeightsExtraKind
  96657. * @param data defines the data source
  96658. * @param updatable defines if the data must be flagged as updatable (or static)
  96659. * @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
  96660. * @returns the current mesh
  96661. */
  96662. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  96663. /**
  96664. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  96665. * If the mesh has no geometry, it is simply returned as it is.
  96666. * @param kind defines vertex data kind:
  96667. * * VertexBuffer.PositionKind
  96668. * * VertexBuffer.UVKind
  96669. * * VertexBuffer.UV2Kind
  96670. * * VertexBuffer.UV3Kind
  96671. * * VertexBuffer.UV4Kind
  96672. * * VertexBuffer.UV5Kind
  96673. * * VertexBuffer.UV6Kind
  96674. * * VertexBuffer.ColorKind
  96675. * * VertexBuffer.MatricesIndicesKind
  96676. * * VertexBuffer.MatricesIndicesExtraKind
  96677. * * VertexBuffer.MatricesWeightsKind
  96678. * * VertexBuffer.MatricesWeightsExtraKind
  96679. * @param data defines the data source
  96680. * @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
  96681. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  96682. * @returns the current mesh
  96683. */
  96684. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  96685. /**
  96686. * Sets the mesh indices,
  96687. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  96688. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  96689. * @param totalVertices Defines the total number of vertices
  96690. * @returns the current mesh
  96691. */
  96692. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  96693. /**
  96694. * Gets a boolean indicating if specific vertex data is present
  96695. * @param kind defines the vertex data kind to use
  96696. * @returns true is data kind is present
  96697. */
  96698. isVerticesDataPresent(kind: string): boolean;
  96699. /**
  96700. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  96701. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  96702. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  96703. * @returns a BoundingInfo
  96704. */
  96705. getBoundingInfo(): BoundingInfo;
  96706. /**
  96707. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  96708. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  96709. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  96710. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  96711. * @returns the current mesh
  96712. */
  96713. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  96714. /**
  96715. * Overwrite the current bounding info
  96716. * @param boundingInfo defines the new bounding info
  96717. * @returns the current mesh
  96718. */
  96719. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  96720. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  96721. readonly useBones: boolean;
  96722. /** @hidden */
  96723. _preActivate(): void;
  96724. /** @hidden */
  96725. _preActivateForIntermediateRendering(renderId: number): void;
  96726. /** @hidden */
  96727. _activate(renderId: number, intermediateRendering: boolean): boolean;
  96728. /** @hidden */
  96729. _postActivate(): void;
  96730. /** @hidden */
  96731. _freeze(): void;
  96732. /** @hidden */
  96733. _unFreeze(): void;
  96734. /**
  96735. * Gets the current world matrix
  96736. * @returns a Matrix
  96737. */
  96738. getWorldMatrix(): Matrix;
  96739. /** @hidden */
  96740. _getWorldMatrixDeterminant(): number;
  96741. /**
  96742. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  96743. */
  96744. readonly isAnInstance: boolean;
  96745. /**
  96746. * Gets a boolean indicating if this mesh has instances
  96747. */
  96748. readonly hasInstances: boolean;
  96749. /**
  96750. * Perform relative position change from the point of view of behind the front of the mesh.
  96751. * This is performed taking into account the meshes current rotation, so you do not have to care.
  96752. * Supports definition of mesh facing forward or backward
  96753. * @param amountRight defines the distance on the right axis
  96754. * @param amountUp defines the distance on the up axis
  96755. * @param amountForward defines the distance on the forward axis
  96756. * @returns the current mesh
  96757. */
  96758. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  96759. /**
  96760. * Calculate relative position change from the point of view of behind the front of the mesh.
  96761. * This is performed taking into account the meshes current rotation, so you do not have to care.
  96762. * Supports definition of mesh facing forward or backward
  96763. * @param amountRight defines the distance on the right axis
  96764. * @param amountUp defines the distance on the up axis
  96765. * @param amountForward defines the distance on the forward axis
  96766. * @returns the new displacement vector
  96767. */
  96768. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  96769. /**
  96770. * Perform relative rotation change from the point of view of behind the front of the mesh.
  96771. * Supports definition of mesh facing forward or backward
  96772. * @param flipBack defines the flip
  96773. * @param twirlClockwise defines the twirl
  96774. * @param tiltRight defines the tilt
  96775. * @returns the current mesh
  96776. */
  96777. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  96778. /**
  96779. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  96780. * Supports definition of mesh facing forward or backward.
  96781. * @param flipBack defines the flip
  96782. * @param twirlClockwise defines the twirl
  96783. * @param tiltRight defines the tilt
  96784. * @returns the new rotation vector
  96785. */
  96786. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  96787. /**
  96788. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  96789. * This means the mesh underlying bounding box and sphere are recomputed.
  96790. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  96791. * @returns the current mesh
  96792. */
  96793. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  96794. /** @hidden */
  96795. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  96796. /** @hidden */
  96797. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  96798. /** @hidden */
  96799. _updateBoundingInfo(): AbstractMesh;
  96800. /** @hidden */
  96801. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  96802. /** @hidden */
  96803. protected _afterComputeWorldMatrix(): void;
  96804. /** @hidden */
  96805. readonly _effectiveMesh: AbstractMesh;
  96806. /**
  96807. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  96808. * A mesh is in the frustum if its bounding box intersects the frustum
  96809. * @param frustumPlanes defines the frustum to test
  96810. * @returns true if the mesh is in the frustum planes
  96811. */
  96812. isInFrustum(frustumPlanes: Plane[]): boolean;
  96813. /**
  96814. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  96815. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  96816. * @param frustumPlanes defines the frustum to test
  96817. * @returns true if the mesh is completely in the frustum planes
  96818. */
  96819. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  96820. /**
  96821. * True if the mesh intersects another mesh or a SolidParticle object
  96822. * @param mesh defines a target mesh or SolidParticle to test
  96823. * @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)
  96824. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  96825. * @returns true if there is an intersection
  96826. */
  96827. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  96828. /**
  96829. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  96830. * @param point defines the point to test
  96831. * @returns true if there is an intersection
  96832. */
  96833. intersectsPoint(point: Vector3): boolean;
  96834. /**
  96835. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  96836. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  96837. */
  96838. checkCollisions: boolean;
  96839. /**
  96840. * Gets Collider object used to compute collisions (not physics)
  96841. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  96842. */
  96843. readonly collider: Nullable<Collider>;
  96844. /**
  96845. * Move the mesh using collision engine
  96846. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  96847. * @param displacement defines the requested displacement vector
  96848. * @returns the current mesh
  96849. */
  96850. moveWithCollisions(displacement: Vector3): AbstractMesh;
  96851. private _onCollisionPositionChange;
  96852. /** @hidden */
  96853. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  96854. /** @hidden */
  96855. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  96856. /** @hidden */
  96857. _checkCollision(collider: Collider): AbstractMesh;
  96858. /** @hidden */
  96859. _generatePointsArray(): boolean;
  96860. /**
  96861. * Checks if the passed Ray intersects with the mesh
  96862. * @param ray defines the ray to use
  96863. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  96864. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96865. * @returns the picking info
  96866. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  96867. */
  96868. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  96869. /**
  96870. * Clones the current mesh
  96871. * @param name defines the mesh name
  96872. * @param newParent defines the new mesh parent
  96873. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  96874. * @returns the new mesh
  96875. */
  96876. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  96877. /**
  96878. * Disposes all the submeshes of the current meshnp
  96879. * @returns the current mesh
  96880. */
  96881. releaseSubMeshes(): AbstractMesh;
  96882. /**
  96883. * Releases resources associated with this abstract mesh.
  96884. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  96885. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  96886. */
  96887. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96888. /**
  96889. * Adds the passed mesh as a child to the current mesh
  96890. * @param mesh defines the child mesh
  96891. * @returns the current mesh
  96892. */
  96893. addChild(mesh: AbstractMesh): AbstractMesh;
  96894. /**
  96895. * Removes the passed mesh from the current mesh children list
  96896. * @param mesh defines the child mesh
  96897. * @returns the current mesh
  96898. */
  96899. removeChild(mesh: AbstractMesh): AbstractMesh;
  96900. /** @hidden */
  96901. private _initFacetData;
  96902. /**
  96903. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  96904. * This method can be called within the render loop.
  96905. * 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
  96906. * @returns the current mesh
  96907. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96908. */
  96909. updateFacetData(): AbstractMesh;
  96910. /**
  96911. * Returns the facetLocalNormals array.
  96912. * The normals are expressed in the mesh local spac
  96913. * @returns an array of Vector3
  96914. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96915. */
  96916. getFacetLocalNormals(): Vector3[];
  96917. /**
  96918. * Returns the facetLocalPositions array.
  96919. * The facet positions are expressed in the mesh local space
  96920. * @returns an array of Vector3
  96921. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96922. */
  96923. getFacetLocalPositions(): Vector3[];
  96924. /**
  96925. * Returns the facetLocalPartioning array
  96926. * @returns an array of array of numbers
  96927. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96928. */
  96929. getFacetLocalPartitioning(): number[][];
  96930. /**
  96931. * Returns the i-th facet position in the world system.
  96932. * This method allocates a new Vector3 per call
  96933. * @param i defines the facet index
  96934. * @returns a new Vector3
  96935. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96936. */
  96937. getFacetPosition(i: number): Vector3;
  96938. /**
  96939. * Sets the reference Vector3 with the i-th facet position in the world system
  96940. * @param i defines the facet index
  96941. * @param ref defines the target vector
  96942. * @returns the current mesh
  96943. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96944. */
  96945. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  96946. /**
  96947. * Returns the i-th facet normal in the world system.
  96948. * This method allocates a new Vector3 per call
  96949. * @param i defines the facet index
  96950. * @returns a new Vector3
  96951. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96952. */
  96953. getFacetNormal(i: number): Vector3;
  96954. /**
  96955. * Sets the reference Vector3 with the i-th facet normal in the world system
  96956. * @param i defines the facet index
  96957. * @param ref defines the target vector
  96958. * @returns the current mesh
  96959. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96960. */
  96961. getFacetNormalToRef(i: number, ref: Vector3): this;
  96962. /**
  96963. * 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)
  96964. * @param x defines x coordinate
  96965. * @param y defines y coordinate
  96966. * @param z defines z coordinate
  96967. * @returns the array of facet indexes
  96968. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96969. */
  96970. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  96971. /**
  96972. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  96973. * @param projected sets as the (x,y,z) world projection on the facet
  96974. * @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
  96975. * @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
  96976. * @param x defines x coordinate
  96977. * @param y defines y coordinate
  96978. * @param z defines z coordinate
  96979. * @returns the face index if found (or null instead)
  96980. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96981. */
  96982. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  96983. /**
  96984. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  96985. * @param projected sets as the (x,y,z) local projection on the facet
  96986. * @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
  96987. * @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
  96988. * @param x defines x coordinate
  96989. * @param y defines y coordinate
  96990. * @param z defines z coordinate
  96991. * @returns the face index if found (or null instead)
  96992. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96993. */
  96994. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  96995. /**
  96996. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  96997. * @returns the parameters
  96998. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96999. */
  97000. getFacetDataParameters(): any;
  97001. /**
  97002. * Disables the feature FacetData and frees the related memory
  97003. * @returns the current mesh
  97004. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97005. */
  97006. disableFacetData(): AbstractMesh;
  97007. /**
  97008. * Updates the AbstractMesh indices array
  97009. * @param indices defines the data source
  97010. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  97011. * @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)
  97012. * @returns the current mesh
  97013. */
  97014. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  97015. /**
  97016. * Creates new normals data for the mesh
  97017. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  97018. * @returns the current mesh
  97019. */
  97020. createNormals(updatable: boolean): AbstractMesh;
  97021. /**
  97022. * Align the mesh with a normal
  97023. * @param normal defines the normal to use
  97024. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  97025. * @returns the current mesh
  97026. */
  97027. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  97028. /** @hidden */
  97029. _checkOcclusionQuery(): boolean;
  97030. /**
  97031. * Disables the mesh edge rendering mode
  97032. * @returns the currentAbstractMesh
  97033. */
  97034. disableEdgesRendering(): AbstractMesh;
  97035. /**
  97036. * Enables the edge rendering mode on the mesh.
  97037. * This mode makes the mesh edges visible
  97038. * @param epsilon defines the maximal distance between two angles to detect a face
  97039. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  97040. * @returns the currentAbstractMesh
  97041. * @see https://www.babylonjs-playground.com/#19O9TU#0
  97042. */
  97043. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  97044. }
  97045. }
  97046. declare module BABYLON {
  97047. /**
  97048. * Interface used to define ActionEvent
  97049. */
  97050. export interface IActionEvent {
  97051. /** The mesh or sprite that triggered the action */
  97052. source: any;
  97053. /** The X mouse cursor position at the time of the event */
  97054. pointerX: number;
  97055. /** The Y mouse cursor position at the time of the event */
  97056. pointerY: number;
  97057. /** The mesh that is currently pointed at (can be null) */
  97058. meshUnderPointer: Nullable<AbstractMesh>;
  97059. /** the original (browser) event that triggered the ActionEvent */
  97060. sourceEvent?: any;
  97061. /** additional data for the event */
  97062. additionalData?: any;
  97063. }
  97064. /**
  97065. * ActionEvent is the event being sent when an action is triggered.
  97066. */
  97067. export class ActionEvent implements IActionEvent {
  97068. /** The mesh or sprite that triggered the action */
  97069. source: any;
  97070. /** The X mouse cursor position at the time of the event */
  97071. pointerX: number;
  97072. /** The Y mouse cursor position at the time of the event */
  97073. pointerY: number;
  97074. /** The mesh that is currently pointed at (can be null) */
  97075. meshUnderPointer: Nullable<AbstractMesh>;
  97076. /** the original (browser) event that triggered the ActionEvent */
  97077. sourceEvent?: any;
  97078. /** additional data for the event */
  97079. additionalData?: any;
  97080. /**
  97081. * Creates a new ActionEvent
  97082. * @param source The mesh or sprite that triggered the action
  97083. * @param pointerX The X mouse cursor position at the time of the event
  97084. * @param pointerY The Y mouse cursor position at the time of the event
  97085. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  97086. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  97087. * @param additionalData additional data for the event
  97088. */
  97089. constructor(
  97090. /** The mesh or sprite that triggered the action */
  97091. source: any,
  97092. /** The X mouse cursor position at the time of the event */
  97093. pointerX: number,
  97094. /** The Y mouse cursor position at the time of the event */
  97095. pointerY: number,
  97096. /** The mesh that is currently pointed at (can be null) */
  97097. meshUnderPointer: Nullable<AbstractMesh>,
  97098. /** the original (browser) event that triggered the ActionEvent */
  97099. sourceEvent?: any,
  97100. /** additional data for the event */
  97101. additionalData?: any);
  97102. /**
  97103. * Helper function to auto-create an ActionEvent from a source mesh.
  97104. * @param source The source mesh that triggered the event
  97105. * @param evt The original (browser) event
  97106. * @param additionalData additional data for the event
  97107. * @returns the new ActionEvent
  97108. */
  97109. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  97110. /**
  97111. * Helper function to auto-create an ActionEvent from a source sprite
  97112. * @param source The source sprite that triggered the event
  97113. * @param scene Scene associated with the sprite
  97114. * @param evt The original (browser) event
  97115. * @param additionalData additional data for the event
  97116. * @returns the new ActionEvent
  97117. */
  97118. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  97119. /**
  97120. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  97121. * @param scene the scene where the event occurred
  97122. * @param evt The original (browser) event
  97123. * @returns the new ActionEvent
  97124. */
  97125. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  97126. /**
  97127. * Helper function to auto-create an ActionEvent from a primitive
  97128. * @param prim defines the target primitive
  97129. * @param pointerPos defines the pointer position
  97130. * @param evt The original (browser) event
  97131. * @param additionalData additional data for the event
  97132. * @returns the new ActionEvent
  97133. */
  97134. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  97135. }
  97136. }
  97137. declare module BABYLON {
  97138. /**
  97139. * Abstract class used to decouple action Manager from scene and meshes.
  97140. * Do not instantiate.
  97141. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  97142. */
  97143. export abstract class AbstractActionManager implements IDisposable {
  97144. /** Gets the list of active triggers */
  97145. static Triggers: {
  97146. [key: string]: number;
  97147. };
  97148. /** Gets the cursor to use when hovering items */
  97149. hoverCursor: string;
  97150. /** Gets the list of actions */
  97151. actions: IAction[];
  97152. /**
  97153. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  97154. */
  97155. isRecursive: boolean;
  97156. /**
  97157. * Releases all associated resources
  97158. */
  97159. abstract dispose(): void;
  97160. /**
  97161. * Does this action manager has pointer triggers
  97162. */
  97163. abstract readonly hasPointerTriggers: boolean;
  97164. /**
  97165. * Does this action manager has pick triggers
  97166. */
  97167. abstract readonly hasPickTriggers: boolean;
  97168. /**
  97169. * Process a specific trigger
  97170. * @param trigger defines the trigger to process
  97171. * @param evt defines the event details to be processed
  97172. */
  97173. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  97174. /**
  97175. * Does this action manager handles actions of any of the given triggers
  97176. * @param triggers defines the triggers to be tested
  97177. * @return a boolean indicating whether one (or more) of the triggers is handled
  97178. */
  97179. abstract hasSpecificTriggers(triggers: number[]): boolean;
  97180. /**
  97181. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  97182. * speed.
  97183. * @param triggerA defines the trigger to be tested
  97184. * @param triggerB defines the trigger to be tested
  97185. * @return a boolean indicating whether one (or more) of the triggers is handled
  97186. */
  97187. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  97188. /**
  97189. * Does this action manager handles actions of a given trigger
  97190. * @param trigger defines the trigger to be tested
  97191. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  97192. * @return whether the trigger is handled
  97193. */
  97194. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  97195. /**
  97196. * Serialize this manager to a JSON object
  97197. * @param name defines the property name to store this manager
  97198. * @returns a JSON representation of this manager
  97199. */
  97200. abstract serialize(name: string): any;
  97201. /**
  97202. * Registers an action to this action manager
  97203. * @param action defines the action to be registered
  97204. * @return the action amended (prepared) after registration
  97205. */
  97206. abstract registerAction(action: IAction): Nullable<IAction>;
  97207. /**
  97208. * Unregisters an action to this action manager
  97209. * @param action defines the action to be unregistered
  97210. * @return a boolean indicating whether the action has been unregistered
  97211. */
  97212. abstract unregisterAction(action: IAction): Boolean;
  97213. /**
  97214. * Does exist one action manager with at least one trigger
  97215. **/
  97216. static readonly HasTriggers: boolean;
  97217. /**
  97218. * Does exist one action manager with at least one pick trigger
  97219. **/
  97220. static readonly HasPickTriggers: boolean;
  97221. /**
  97222. * Does exist one action manager that handles actions of a given trigger
  97223. * @param trigger defines the trigger to be tested
  97224. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  97225. **/
  97226. static HasSpecificTrigger(trigger: number): boolean;
  97227. }
  97228. }
  97229. declare module BABYLON {
  97230. /**
  97231. * Defines how a node can be built from a string name.
  97232. */
  97233. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  97234. /**
  97235. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  97236. */
  97237. export class Node implements IBehaviorAware<Node> {
  97238. /** @hidden */
  97239. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  97240. private static _NodeConstructors;
  97241. /**
  97242. * Add a new node constructor
  97243. * @param type defines the type name of the node to construct
  97244. * @param constructorFunc defines the constructor function
  97245. */
  97246. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  97247. /**
  97248. * Returns a node constructor based on type name
  97249. * @param type defines the type name
  97250. * @param name defines the new node name
  97251. * @param scene defines the hosting scene
  97252. * @param options defines optional options to transmit to constructors
  97253. * @returns the new constructor or null
  97254. */
  97255. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  97256. /**
  97257. * Gets or sets the name of the node
  97258. */
  97259. name: string;
  97260. /**
  97261. * Gets or sets the id of the node
  97262. */
  97263. id: string;
  97264. /**
  97265. * Gets or sets the unique id of the node
  97266. */
  97267. uniqueId: number;
  97268. /**
  97269. * Gets or sets a string used to store user defined state for the node
  97270. */
  97271. state: string;
  97272. /**
  97273. * Gets or sets an object used to store user defined information for the node
  97274. */
  97275. metadata: any;
  97276. /**
  97277. * For internal use only. Please do not use.
  97278. */
  97279. reservedDataStore: any;
  97280. /**
  97281. * List of inspectable custom properties (used by the Inspector)
  97282. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  97283. */
  97284. inspectableCustomProperties: IInspectable[];
  97285. private _doNotSerialize;
  97286. /**
  97287. * Gets or sets a boolean used to define if the node must be serialized
  97288. */
  97289. doNotSerialize: boolean;
  97290. /** @hidden */
  97291. _isDisposed: boolean;
  97292. /**
  97293. * Gets a list of Animations associated with the node
  97294. */
  97295. animations: Animation[];
  97296. protected _ranges: {
  97297. [name: string]: Nullable<AnimationRange>;
  97298. };
  97299. /**
  97300. * Callback raised when the node is ready to be used
  97301. */
  97302. onReady: Nullable<(node: Node) => void>;
  97303. private _isEnabled;
  97304. private _isParentEnabled;
  97305. private _isReady;
  97306. /** @hidden */
  97307. _currentRenderId: number;
  97308. private _parentUpdateId;
  97309. /** @hidden */
  97310. _childUpdateId: number;
  97311. /** @hidden */
  97312. _waitingParentId: Nullable<string>;
  97313. /** @hidden */
  97314. _scene: Scene;
  97315. /** @hidden */
  97316. _cache: any;
  97317. private _parentNode;
  97318. private _children;
  97319. /** @hidden */
  97320. _worldMatrix: Matrix;
  97321. /** @hidden */
  97322. _worldMatrixDeterminant: number;
  97323. /** @hidden */
  97324. _worldMatrixDeterminantIsDirty: boolean;
  97325. /** @hidden */
  97326. private _sceneRootNodesIndex;
  97327. /**
  97328. * Gets a boolean indicating if the node has been disposed
  97329. * @returns true if the node was disposed
  97330. */
  97331. isDisposed(): boolean;
  97332. /**
  97333. * Gets or sets the parent of the node (without keeping the current position in the scene)
  97334. * @see https://doc.babylonjs.com/how_to/parenting
  97335. */
  97336. parent: Nullable<Node>;
  97337. /** @hidden */
  97338. _addToSceneRootNodes(): void;
  97339. /** @hidden */
  97340. _removeFromSceneRootNodes(): void;
  97341. private _animationPropertiesOverride;
  97342. /**
  97343. * Gets or sets the animation properties override
  97344. */
  97345. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  97346. /**
  97347. * Gets a string idenfifying the name of the class
  97348. * @returns "Node" string
  97349. */
  97350. getClassName(): string;
  97351. /** @hidden */
  97352. readonly _isNode: boolean;
  97353. /**
  97354. * An event triggered when the mesh is disposed
  97355. */
  97356. onDisposeObservable: Observable<Node>;
  97357. private _onDisposeObserver;
  97358. /**
  97359. * Sets a callback that will be raised when the node will be disposed
  97360. */
  97361. onDispose: () => void;
  97362. /**
  97363. * Creates a new Node
  97364. * @param name the name and id to be given to this node
  97365. * @param scene the scene this node will be added to
  97366. */
  97367. constructor(name: string, scene?: Nullable<Scene>);
  97368. /**
  97369. * Gets the scene of the node
  97370. * @returns a scene
  97371. */
  97372. getScene(): Scene;
  97373. /**
  97374. * Gets the engine of the node
  97375. * @returns a Engine
  97376. */
  97377. getEngine(): Engine;
  97378. private _behaviors;
  97379. /**
  97380. * Attach a behavior to the node
  97381. * @see http://doc.babylonjs.com/features/behaviour
  97382. * @param behavior defines the behavior to attach
  97383. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  97384. * @returns the current Node
  97385. */
  97386. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  97387. /**
  97388. * Remove an attached behavior
  97389. * @see http://doc.babylonjs.com/features/behaviour
  97390. * @param behavior defines the behavior to attach
  97391. * @returns the current Node
  97392. */
  97393. removeBehavior(behavior: Behavior<Node>): Node;
  97394. /**
  97395. * Gets the list of attached behaviors
  97396. * @see http://doc.babylonjs.com/features/behaviour
  97397. */
  97398. readonly behaviors: Behavior<Node>[];
  97399. /**
  97400. * Gets an attached behavior by name
  97401. * @param name defines the name of the behavior to look for
  97402. * @see http://doc.babylonjs.com/features/behaviour
  97403. * @returns null if behavior was not found else the requested behavior
  97404. */
  97405. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  97406. /**
  97407. * Returns the latest update of the World matrix
  97408. * @returns a Matrix
  97409. */
  97410. getWorldMatrix(): Matrix;
  97411. /** @hidden */
  97412. _getWorldMatrixDeterminant(): number;
  97413. /**
  97414. * Returns directly the latest state of the mesh World matrix.
  97415. * A Matrix is returned.
  97416. */
  97417. readonly worldMatrixFromCache: Matrix;
  97418. /** @hidden */
  97419. _initCache(): void;
  97420. /** @hidden */
  97421. updateCache(force?: boolean): void;
  97422. /** @hidden */
  97423. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  97424. /** @hidden */
  97425. _updateCache(ignoreParentClass?: boolean): void;
  97426. /** @hidden */
  97427. _isSynchronized(): boolean;
  97428. /** @hidden */
  97429. _markSyncedWithParent(): void;
  97430. /** @hidden */
  97431. isSynchronizedWithParent(): boolean;
  97432. /** @hidden */
  97433. isSynchronized(): boolean;
  97434. /**
  97435. * Is this node ready to be used/rendered
  97436. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  97437. * @return true if the node is ready
  97438. */
  97439. isReady(completeCheck?: boolean): boolean;
  97440. /**
  97441. * Is this node enabled?
  97442. * 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
  97443. * @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
  97444. * @return whether this node (and its parent) is enabled
  97445. */
  97446. isEnabled(checkAncestors?: boolean): boolean;
  97447. /** @hidden */
  97448. protected _syncParentEnabledState(): void;
  97449. /**
  97450. * Set the enabled state of this node
  97451. * @param value defines the new enabled state
  97452. */
  97453. setEnabled(value: boolean): void;
  97454. /**
  97455. * Is this node a descendant of the given node?
  97456. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  97457. * @param ancestor defines the parent node to inspect
  97458. * @returns a boolean indicating if this node is a descendant of the given node
  97459. */
  97460. isDescendantOf(ancestor: Node): boolean;
  97461. /** @hidden */
  97462. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  97463. /**
  97464. * Will return all nodes that have this node as ascendant
  97465. * @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
  97466. * @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
  97467. * @return all children nodes of all types
  97468. */
  97469. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  97470. /**
  97471. * Get all child-meshes of this node
  97472. * @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)
  97473. * @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
  97474. * @returns an array of AbstractMesh
  97475. */
  97476. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  97477. /**
  97478. * Get all direct children of this node
  97479. * @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
  97480. * @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)
  97481. * @returns an array of Node
  97482. */
  97483. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  97484. /** @hidden */
  97485. _setReady(state: boolean): void;
  97486. /**
  97487. * Get an animation by name
  97488. * @param name defines the name of the animation to look for
  97489. * @returns null if not found else the requested animation
  97490. */
  97491. getAnimationByName(name: string): Nullable<Animation>;
  97492. /**
  97493. * Creates an animation range for this node
  97494. * @param name defines the name of the range
  97495. * @param from defines the starting key
  97496. * @param to defines the end key
  97497. */
  97498. createAnimationRange(name: string, from: number, to: number): void;
  97499. /**
  97500. * Delete a specific animation range
  97501. * @param name defines the name of the range to delete
  97502. * @param deleteFrames defines if animation frames from the range must be deleted as well
  97503. */
  97504. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  97505. /**
  97506. * Get an animation range by name
  97507. * @param name defines the name of the animation range to look for
  97508. * @returns null if not found else the requested animation range
  97509. */
  97510. getAnimationRange(name: string): Nullable<AnimationRange>;
  97511. /**
  97512. * Gets the list of all animation ranges defined on this node
  97513. * @returns an array
  97514. */
  97515. getAnimationRanges(): Nullable<AnimationRange>[];
  97516. /**
  97517. * Will start the animation sequence
  97518. * @param name defines the range frames for animation sequence
  97519. * @param loop defines if the animation should loop (false by default)
  97520. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  97521. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  97522. * @returns the object created for this animation. If range does not exist, it will return null
  97523. */
  97524. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  97525. /**
  97526. * Serialize animation ranges into a JSON compatible object
  97527. * @returns serialization object
  97528. */
  97529. serializeAnimationRanges(): any;
  97530. /**
  97531. * Computes the world matrix of the node
  97532. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  97533. * @returns the world matrix
  97534. */
  97535. computeWorldMatrix(force?: boolean): Matrix;
  97536. /**
  97537. * Releases resources associated with this node.
  97538. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  97539. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  97540. */
  97541. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  97542. /**
  97543. * Parse animation range data from a serialization object and store them into a given node
  97544. * @param node defines where to store the animation ranges
  97545. * @param parsedNode defines the serialization object to read data from
  97546. * @param scene defines the hosting scene
  97547. */
  97548. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  97549. /**
  97550. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  97551. * @param includeDescendants Include bounding info from descendants as well (true by default)
  97552. * @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
  97553. * @returns the new bounding vectors
  97554. */
  97555. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  97556. min: Vector3;
  97557. max: Vector3;
  97558. };
  97559. }
  97560. }
  97561. declare module BABYLON {
  97562. /**
  97563. * @hidden
  97564. */
  97565. export class _IAnimationState {
  97566. key: number;
  97567. repeatCount: number;
  97568. workValue?: any;
  97569. loopMode?: number;
  97570. offsetValue?: any;
  97571. highLimitValue?: any;
  97572. }
  97573. /**
  97574. * Class used to store any kind of animation
  97575. */
  97576. export class Animation {
  97577. /**Name of the animation */
  97578. name: string;
  97579. /**Property to animate */
  97580. targetProperty: string;
  97581. /**The frames per second of the animation */
  97582. framePerSecond: number;
  97583. /**The data type of the animation */
  97584. dataType: number;
  97585. /**The loop mode of the animation */
  97586. loopMode?: number | undefined;
  97587. /**Specifies if blending should be enabled */
  97588. enableBlending?: boolean | undefined;
  97589. /**
  97590. * Use matrix interpolation instead of using direct key value when animating matrices
  97591. */
  97592. static AllowMatricesInterpolation: boolean;
  97593. /**
  97594. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  97595. */
  97596. static AllowMatrixDecomposeForInterpolation: boolean;
  97597. /**
  97598. * Stores the key frames of the animation
  97599. */
  97600. private _keys;
  97601. /**
  97602. * Stores the easing function of the animation
  97603. */
  97604. private _easingFunction;
  97605. /**
  97606. * @hidden Internal use only
  97607. */
  97608. _runtimeAnimations: RuntimeAnimation[];
  97609. /**
  97610. * The set of event that will be linked to this animation
  97611. */
  97612. private _events;
  97613. /**
  97614. * Stores an array of target property paths
  97615. */
  97616. targetPropertyPath: string[];
  97617. /**
  97618. * Stores the blending speed of the animation
  97619. */
  97620. blendingSpeed: number;
  97621. /**
  97622. * Stores the animation ranges for the animation
  97623. */
  97624. private _ranges;
  97625. /**
  97626. * @hidden Internal use
  97627. */
  97628. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  97629. /**
  97630. * Sets up an animation
  97631. * @param property The property to animate
  97632. * @param animationType The animation type to apply
  97633. * @param framePerSecond The frames per second of the animation
  97634. * @param easingFunction The easing function used in the animation
  97635. * @returns The created animation
  97636. */
  97637. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  97638. /**
  97639. * Create and start an animation on a node
  97640. * @param name defines the name of the global animation that will be run on all nodes
  97641. * @param node defines the root node where the animation will take place
  97642. * @param targetProperty defines property to animate
  97643. * @param framePerSecond defines the number of frame per second yo use
  97644. * @param totalFrame defines the number of frames in total
  97645. * @param from defines the initial value
  97646. * @param to defines the final value
  97647. * @param loopMode defines which loop mode you want to use (off by default)
  97648. * @param easingFunction defines the easing function to use (linear by default)
  97649. * @param onAnimationEnd defines the callback to call when animation end
  97650. * @returns the animatable created for this animation
  97651. */
  97652. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  97653. /**
  97654. * Create and start an animation on a node and its descendants
  97655. * @param name defines the name of the global animation that will be run on all nodes
  97656. * @param node defines the root node where the animation will take place
  97657. * @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
  97658. * @param targetProperty defines property to animate
  97659. * @param framePerSecond defines the number of frame per second to use
  97660. * @param totalFrame defines the number of frames in total
  97661. * @param from defines the initial value
  97662. * @param to defines the final value
  97663. * @param loopMode defines which loop mode you want to use (off by default)
  97664. * @param easingFunction defines the easing function to use (linear by default)
  97665. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  97666. * @returns the list of animatables created for all nodes
  97667. * @example https://www.babylonjs-playground.com/#MH0VLI
  97668. */
  97669. 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[]>;
  97670. /**
  97671. * Creates a new animation, merges it with the existing animations and starts it
  97672. * @param name Name of the animation
  97673. * @param node Node which contains the scene that begins the animations
  97674. * @param targetProperty Specifies which property to animate
  97675. * @param framePerSecond The frames per second of the animation
  97676. * @param totalFrame The total number of frames
  97677. * @param from The frame at the beginning of the animation
  97678. * @param to The frame at the end of the animation
  97679. * @param loopMode Specifies the loop mode of the animation
  97680. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  97681. * @param onAnimationEnd Callback to run once the animation is complete
  97682. * @returns Nullable animation
  97683. */
  97684. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  97685. /**
  97686. * Transition property of an host to the target Value
  97687. * @param property The property to transition
  97688. * @param targetValue The target Value of the property
  97689. * @param host The object where the property to animate belongs
  97690. * @param scene Scene used to run the animation
  97691. * @param frameRate Framerate (in frame/s) to use
  97692. * @param transition The transition type we want to use
  97693. * @param duration The duration of the animation, in milliseconds
  97694. * @param onAnimationEnd Callback trigger at the end of the animation
  97695. * @returns Nullable animation
  97696. */
  97697. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  97698. /**
  97699. * Return the array of runtime animations currently using this animation
  97700. */
  97701. readonly runtimeAnimations: RuntimeAnimation[];
  97702. /**
  97703. * Specifies if any of the runtime animations are currently running
  97704. */
  97705. readonly hasRunningRuntimeAnimations: boolean;
  97706. /**
  97707. * Initializes the animation
  97708. * @param name Name of the animation
  97709. * @param targetProperty Property to animate
  97710. * @param framePerSecond The frames per second of the animation
  97711. * @param dataType The data type of the animation
  97712. * @param loopMode The loop mode of the animation
  97713. * @param enableBlending Specifies if blending should be enabled
  97714. */
  97715. constructor(
  97716. /**Name of the animation */
  97717. name: string,
  97718. /**Property to animate */
  97719. targetProperty: string,
  97720. /**The frames per second of the animation */
  97721. framePerSecond: number,
  97722. /**The data type of the animation */
  97723. dataType: number,
  97724. /**The loop mode of the animation */
  97725. loopMode?: number | undefined,
  97726. /**Specifies if blending should be enabled */
  97727. enableBlending?: boolean | undefined);
  97728. /**
  97729. * Converts the animation to a string
  97730. * @param fullDetails support for multiple levels of logging within scene loading
  97731. * @returns String form of the animation
  97732. */
  97733. toString(fullDetails?: boolean): string;
  97734. /**
  97735. * Add an event to this animation
  97736. * @param event Event to add
  97737. */
  97738. addEvent(event: AnimationEvent): void;
  97739. /**
  97740. * Remove all events found at the given frame
  97741. * @param frame The frame to remove events from
  97742. */
  97743. removeEvents(frame: number): void;
  97744. /**
  97745. * Retrieves all the events from the animation
  97746. * @returns Events from the animation
  97747. */
  97748. getEvents(): AnimationEvent[];
  97749. /**
  97750. * Creates an animation range
  97751. * @param name Name of the animation range
  97752. * @param from Starting frame of the animation range
  97753. * @param to Ending frame of the animation
  97754. */
  97755. createRange(name: string, from: number, to: number): void;
  97756. /**
  97757. * Deletes an animation range by name
  97758. * @param name Name of the animation range to delete
  97759. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  97760. */
  97761. deleteRange(name: string, deleteFrames?: boolean): void;
  97762. /**
  97763. * Gets the animation range by name, or null if not defined
  97764. * @param name Name of the animation range
  97765. * @returns Nullable animation range
  97766. */
  97767. getRange(name: string): Nullable<AnimationRange>;
  97768. /**
  97769. * Gets the key frames from the animation
  97770. * @returns The key frames of the animation
  97771. */
  97772. getKeys(): Array<IAnimationKey>;
  97773. /**
  97774. * Gets the highest frame rate of the animation
  97775. * @returns Highest frame rate of the animation
  97776. */
  97777. getHighestFrame(): number;
  97778. /**
  97779. * Gets the easing function of the animation
  97780. * @returns Easing function of the animation
  97781. */
  97782. getEasingFunction(): IEasingFunction;
  97783. /**
  97784. * Sets the easing function of the animation
  97785. * @param easingFunction A custom mathematical formula for animation
  97786. */
  97787. setEasingFunction(easingFunction: EasingFunction): void;
  97788. /**
  97789. * Interpolates a scalar linearly
  97790. * @param startValue Start value of the animation curve
  97791. * @param endValue End value of the animation curve
  97792. * @param gradient Scalar amount to interpolate
  97793. * @returns Interpolated scalar value
  97794. */
  97795. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  97796. /**
  97797. * Interpolates a scalar cubically
  97798. * @param startValue Start value of the animation curve
  97799. * @param outTangent End tangent of the animation
  97800. * @param endValue End value of the animation curve
  97801. * @param inTangent Start tangent of the animation curve
  97802. * @param gradient Scalar amount to interpolate
  97803. * @returns Interpolated scalar value
  97804. */
  97805. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  97806. /**
  97807. * Interpolates a quaternion using a spherical linear interpolation
  97808. * @param startValue Start value of the animation curve
  97809. * @param endValue End value of the animation curve
  97810. * @param gradient Scalar amount to interpolate
  97811. * @returns Interpolated quaternion value
  97812. */
  97813. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  97814. /**
  97815. * Interpolates a quaternion cubically
  97816. * @param startValue Start value of the animation curve
  97817. * @param outTangent End tangent of the animation curve
  97818. * @param endValue End value of the animation curve
  97819. * @param inTangent Start tangent of the animation curve
  97820. * @param gradient Scalar amount to interpolate
  97821. * @returns Interpolated quaternion value
  97822. */
  97823. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  97824. /**
  97825. * Interpolates a Vector3 linearl
  97826. * @param startValue Start value of the animation curve
  97827. * @param endValue End value of the animation curve
  97828. * @param gradient Scalar amount to interpolate
  97829. * @returns Interpolated scalar value
  97830. */
  97831. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  97832. /**
  97833. * Interpolates a Vector3 cubically
  97834. * @param startValue Start value of the animation curve
  97835. * @param outTangent End tangent of the animation
  97836. * @param endValue End value of the animation curve
  97837. * @param inTangent Start tangent of the animation curve
  97838. * @param gradient Scalar amount to interpolate
  97839. * @returns InterpolatedVector3 value
  97840. */
  97841. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  97842. /**
  97843. * Interpolates a Vector2 linearly
  97844. * @param startValue Start value of the animation curve
  97845. * @param endValue End value of the animation curve
  97846. * @param gradient Scalar amount to interpolate
  97847. * @returns Interpolated Vector2 value
  97848. */
  97849. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  97850. /**
  97851. * Interpolates a Vector2 cubically
  97852. * @param startValue Start value of the animation curve
  97853. * @param outTangent End tangent of the animation
  97854. * @param endValue End value of the animation curve
  97855. * @param inTangent Start tangent of the animation curve
  97856. * @param gradient Scalar amount to interpolate
  97857. * @returns Interpolated Vector2 value
  97858. */
  97859. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  97860. /**
  97861. * Interpolates a size linearly
  97862. * @param startValue Start value of the animation curve
  97863. * @param endValue End value of the animation curve
  97864. * @param gradient Scalar amount to interpolate
  97865. * @returns Interpolated Size value
  97866. */
  97867. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  97868. /**
  97869. * Interpolates a Color3 linearly
  97870. * @param startValue Start value of the animation curve
  97871. * @param endValue End value of the animation curve
  97872. * @param gradient Scalar amount to interpolate
  97873. * @returns Interpolated Color3 value
  97874. */
  97875. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  97876. /**
  97877. * Interpolates a Color4 linearly
  97878. * @param startValue Start value of the animation curve
  97879. * @param endValue End value of the animation curve
  97880. * @param gradient Scalar amount to interpolate
  97881. * @returns Interpolated Color3 value
  97882. */
  97883. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  97884. /**
  97885. * @hidden Internal use only
  97886. */
  97887. _getKeyValue(value: any): any;
  97888. /**
  97889. * @hidden Internal use only
  97890. */
  97891. _interpolate(currentFrame: number, state: _IAnimationState): any;
  97892. /**
  97893. * Defines the function to use to interpolate matrices
  97894. * @param startValue defines the start matrix
  97895. * @param endValue defines the end matrix
  97896. * @param gradient defines the gradient between both matrices
  97897. * @param result defines an optional target matrix where to store the interpolation
  97898. * @returns the interpolated matrix
  97899. */
  97900. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  97901. /**
  97902. * Makes a copy of the animation
  97903. * @returns Cloned animation
  97904. */
  97905. clone(): Animation;
  97906. /**
  97907. * Sets the key frames of the animation
  97908. * @param values The animation key frames to set
  97909. */
  97910. setKeys(values: Array<IAnimationKey>): void;
  97911. /**
  97912. * Serializes the animation to an object
  97913. * @returns Serialized object
  97914. */
  97915. serialize(): any;
  97916. /**
  97917. * Float animation type
  97918. */
  97919. static readonly ANIMATIONTYPE_FLOAT: number;
  97920. /**
  97921. * Vector3 animation type
  97922. */
  97923. static readonly ANIMATIONTYPE_VECTOR3: number;
  97924. /**
  97925. * Quaternion animation type
  97926. */
  97927. static readonly ANIMATIONTYPE_QUATERNION: number;
  97928. /**
  97929. * Matrix animation type
  97930. */
  97931. static readonly ANIMATIONTYPE_MATRIX: number;
  97932. /**
  97933. * Color3 animation type
  97934. */
  97935. static readonly ANIMATIONTYPE_COLOR3: number;
  97936. /**
  97937. * Color3 animation type
  97938. */
  97939. static readonly ANIMATIONTYPE_COLOR4: number;
  97940. /**
  97941. * Vector2 animation type
  97942. */
  97943. static readonly ANIMATIONTYPE_VECTOR2: number;
  97944. /**
  97945. * Size animation type
  97946. */
  97947. static readonly ANIMATIONTYPE_SIZE: number;
  97948. /**
  97949. * Relative Loop Mode
  97950. */
  97951. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  97952. /**
  97953. * Cycle Loop Mode
  97954. */
  97955. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  97956. /**
  97957. * Constant Loop Mode
  97958. */
  97959. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  97960. /** @hidden */
  97961. static _UniversalLerp(left: any, right: any, amount: number): any;
  97962. /**
  97963. * Parses an animation object and creates an animation
  97964. * @param parsedAnimation Parsed animation object
  97965. * @returns Animation object
  97966. */
  97967. static Parse(parsedAnimation: any): Animation;
  97968. /**
  97969. * Appends the serialized animations from the source animations
  97970. * @param source Source containing the animations
  97971. * @param destination Target to store the animations
  97972. */
  97973. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  97974. }
  97975. }
  97976. declare module BABYLON {
  97977. /**
  97978. * Interface containing an array of animations
  97979. */
  97980. export interface IAnimatable {
  97981. /**
  97982. * Array of animations
  97983. */
  97984. animations: Nullable<Array<Animation>>;
  97985. }
  97986. }
  97987. declare module BABYLON {
  97988. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  97989. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97990. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97991. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97992. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97993. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97994. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97995. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97996. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97997. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97998. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97999. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  98000. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  98001. /**
  98002. * Decorator used to define property that can be serialized as reference to a camera
  98003. * @param sourceName defines the name of the property to decorate
  98004. */
  98005. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  98006. /**
  98007. * Class used to help serialization objects
  98008. */
  98009. export class SerializationHelper {
  98010. /** @hidden */
  98011. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  98012. /** @hidden */
  98013. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  98014. /** @hidden */
  98015. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  98016. /** @hidden */
  98017. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  98018. /**
  98019. * Appends the serialized animations from the source animations
  98020. * @param source Source containing the animations
  98021. * @param destination Target to store the animations
  98022. */
  98023. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  98024. /**
  98025. * Static function used to serialized a specific entity
  98026. * @param entity defines the entity to serialize
  98027. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  98028. * @returns a JSON compatible object representing the serialization of the entity
  98029. */
  98030. static Serialize<T>(entity: T, serializationObject?: any): any;
  98031. /**
  98032. * Creates a new entity from a serialization data object
  98033. * @param creationFunction defines a function used to instanciated the new entity
  98034. * @param source defines the source serialization data
  98035. * @param scene defines the hosting scene
  98036. * @param rootUrl defines the root url for resources
  98037. * @returns a new entity
  98038. */
  98039. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  98040. /**
  98041. * Clones an object
  98042. * @param creationFunction defines the function used to instanciate the new object
  98043. * @param source defines the source object
  98044. * @returns the cloned object
  98045. */
  98046. static Clone<T>(creationFunction: () => T, source: T): T;
  98047. /**
  98048. * Instanciates a new object based on a source one (some data will be shared between both object)
  98049. * @param creationFunction defines the function used to instanciate the new object
  98050. * @param source defines the source object
  98051. * @returns the new object
  98052. */
  98053. static Instanciate<T>(creationFunction: () => T, source: T): T;
  98054. }
  98055. }
  98056. declare module BABYLON {
  98057. /**
  98058. * Class used to manipulate GUIDs
  98059. */
  98060. export class GUID {
  98061. /**
  98062. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  98063. * Be aware Math.random() could cause collisions, but:
  98064. * "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"
  98065. * @returns a pseudo random id
  98066. */
  98067. static RandomId(): string;
  98068. }
  98069. }
  98070. declare module BABYLON {
  98071. /**
  98072. * Base class of all the textures in babylon.
  98073. * It groups all the common properties the materials, post process, lights... might need
  98074. * in order to make a correct use of the texture.
  98075. */
  98076. export class BaseTexture implements IAnimatable {
  98077. /**
  98078. * Default anisotropic filtering level for the application.
  98079. * It is set to 4 as a good tradeoff between perf and quality.
  98080. */
  98081. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  98082. /**
  98083. * Gets or sets the unique id of the texture
  98084. */
  98085. uniqueId: number;
  98086. /**
  98087. * Define the name of the texture.
  98088. */
  98089. name: string;
  98090. /**
  98091. * Gets or sets an object used to store user defined information.
  98092. */
  98093. metadata: any;
  98094. /**
  98095. * For internal use only. Please do not use.
  98096. */
  98097. reservedDataStore: any;
  98098. private _hasAlpha;
  98099. /**
  98100. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  98101. */
  98102. hasAlpha: boolean;
  98103. /**
  98104. * Defines if the alpha value should be determined via the rgb values.
  98105. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  98106. */
  98107. getAlphaFromRGB: boolean;
  98108. /**
  98109. * Intensity or strength of the texture.
  98110. * It is commonly used by materials to fine tune the intensity of the texture
  98111. */
  98112. level: number;
  98113. /**
  98114. * Define the UV chanel to use starting from 0 and defaulting to 0.
  98115. * This is part of the texture as textures usually maps to one uv set.
  98116. */
  98117. coordinatesIndex: number;
  98118. private _coordinatesMode;
  98119. /**
  98120. * How a texture is mapped.
  98121. *
  98122. * | Value | Type | Description |
  98123. * | ----- | ----------------------------------- | ----------- |
  98124. * | 0 | EXPLICIT_MODE | |
  98125. * | 1 | SPHERICAL_MODE | |
  98126. * | 2 | PLANAR_MODE | |
  98127. * | 3 | CUBIC_MODE | |
  98128. * | 4 | PROJECTION_MODE | |
  98129. * | 5 | SKYBOX_MODE | |
  98130. * | 6 | INVCUBIC_MODE | |
  98131. * | 7 | EQUIRECTANGULAR_MODE | |
  98132. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  98133. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  98134. */
  98135. coordinatesMode: number;
  98136. /**
  98137. * | Value | Type | Description |
  98138. * | ----- | ------------------ | ----------- |
  98139. * | 0 | CLAMP_ADDRESSMODE | |
  98140. * | 1 | WRAP_ADDRESSMODE | |
  98141. * | 2 | MIRROR_ADDRESSMODE | |
  98142. */
  98143. wrapU: number;
  98144. /**
  98145. * | Value | Type | Description |
  98146. * | ----- | ------------------ | ----------- |
  98147. * | 0 | CLAMP_ADDRESSMODE | |
  98148. * | 1 | WRAP_ADDRESSMODE | |
  98149. * | 2 | MIRROR_ADDRESSMODE | |
  98150. */
  98151. wrapV: number;
  98152. /**
  98153. * | Value | Type | Description |
  98154. * | ----- | ------------------ | ----------- |
  98155. * | 0 | CLAMP_ADDRESSMODE | |
  98156. * | 1 | WRAP_ADDRESSMODE | |
  98157. * | 2 | MIRROR_ADDRESSMODE | |
  98158. */
  98159. wrapR: number;
  98160. /**
  98161. * With compliant hardware and browser (supporting anisotropic filtering)
  98162. * this defines the level of anisotropic filtering in the texture.
  98163. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  98164. */
  98165. anisotropicFilteringLevel: number;
  98166. /**
  98167. * Define if the texture is a cube texture or if false a 2d texture.
  98168. */
  98169. isCube: boolean;
  98170. /**
  98171. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  98172. */
  98173. is3D: boolean;
  98174. /**
  98175. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  98176. */
  98177. is2DArray: boolean;
  98178. /**
  98179. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  98180. * HDR texture are usually stored in linear space.
  98181. * This only impacts the PBR and Background materials
  98182. */
  98183. gammaSpace: boolean;
  98184. /**
  98185. * Gets or sets whether or not the texture contains RGBD data.
  98186. */
  98187. isRGBD: boolean;
  98188. /**
  98189. * Is Z inverted in the texture (useful in a cube texture).
  98190. */
  98191. invertZ: boolean;
  98192. /**
  98193. * Are mip maps generated for this texture or not.
  98194. */
  98195. readonly noMipmap: boolean;
  98196. /**
  98197. * @hidden
  98198. */
  98199. lodLevelInAlpha: boolean;
  98200. /**
  98201. * With prefiltered texture, defined the offset used during the prefiltering steps.
  98202. */
  98203. lodGenerationOffset: number;
  98204. /**
  98205. * With prefiltered texture, defined the scale used during the prefiltering steps.
  98206. */
  98207. lodGenerationScale: number;
  98208. /**
  98209. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  98210. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  98211. * average roughness values.
  98212. */
  98213. linearSpecularLOD: boolean;
  98214. /**
  98215. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  98216. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  98217. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  98218. */
  98219. irradianceTexture: Nullable<BaseTexture>;
  98220. /**
  98221. * Define if the texture is a render target.
  98222. */
  98223. isRenderTarget: boolean;
  98224. /**
  98225. * Define the unique id of the texture in the scene.
  98226. */
  98227. readonly uid: string;
  98228. /**
  98229. * Return a string representation of the texture.
  98230. * @returns the texture as a string
  98231. */
  98232. toString(): string;
  98233. /**
  98234. * Get the class name of the texture.
  98235. * @returns "BaseTexture"
  98236. */
  98237. getClassName(): string;
  98238. /**
  98239. * Define the list of animation attached to the texture.
  98240. */
  98241. animations: Animation[];
  98242. /**
  98243. * An event triggered when the texture is disposed.
  98244. */
  98245. onDisposeObservable: Observable<BaseTexture>;
  98246. private _onDisposeObserver;
  98247. /**
  98248. * Callback triggered when the texture has been disposed.
  98249. * Kept for back compatibility, you can use the onDisposeObservable instead.
  98250. */
  98251. onDispose: () => void;
  98252. /**
  98253. * Define the current state of the loading sequence when in delayed load mode.
  98254. */
  98255. delayLoadState: number;
  98256. private _scene;
  98257. /** @hidden */
  98258. _texture: Nullable<InternalTexture>;
  98259. private _uid;
  98260. /**
  98261. * Define if the texture is preventinga material to render or not.
  98262. * If not and the texture is not ready, the engine will use a default black texture instead.
  98263. */
  98264. readonly isBlocking: boolean;
  98265. /**
  98266. * Instantiates a new BaseTexture.
  98267. * Base class of all the textures in babylon.
  98268. * It groups all the common properties the materials, post process, lights... might need
  98269. * in order to make a correct use of the texture.
  98270. * @param scene Define the scene the texture blongs to
  98271. */
  98272. constructor(scene: Nullable<Scene>);
  98273. /**
  98274. * Get the scene the texture belongs to.
  98275. * @returns the scene or null if undefined
  98276. */
  98277. getScene(): Nullable<Scene>;
  98278. /**
  98279. * Get the texture transform matrix used to offset tile the texture for istance.
  98280. * @returns the transformation matrix
  98281. */
  98282. getTextureMatrix(): Matrix;
  98283. /**
  98284. * Get the texture reflection matrix used to rotate/transform the reflection.
  98285. * @returns the reflection matrix
  98286. */
  98287. getReflectionTextureMatrix(): Matrix;
  98288. /**
  98289. * Get the underlying lower level texture from Babylon.
  98290. * @returns the insternal texture
  98291. */
  98292. getInternalTexture(): Nullable<InternalTexture>;
  98293. /**
  98294. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  98295. * @returns true if ready or not blocking
  98296. */
  98297. isReadyOrNotBlocking(): boolean;
  98298. /**
  98299. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  98300. * @returns true if fully ready
  98301. */
  98302. isReady(): boolean;
  98303. private _cachedSize;
  98304. /**
  98305. * Get the size of the texture.
  98306. * @returns the texture size.
  98307. */
  98308. getSize(): ISize;
  98309. /**
  98310. * Get the base size of the texture.
  98311. * It can be different from the size if the texture has been resized for POT for instance
  98312. * @returns the base size
  98313. */
  98314. getBaseSize(): ISize;
  98315. /**
  98316. * Update the sampling mode of the texture.
  98317. * Default is Trilinear mode.
  98318. *
  98319. * | Value | Type | Description |
  98320. * | ----- | ------------------ | ----------- |
  98321. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  98322. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  98323. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  98324. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  98325. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  98326. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  98327. * | 7 | NEAREST_LINEAR | |
  98328. * | 8 | NEAREST_NEAREST | |
  98329. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  98330. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  98331. * | 11 | LINEAR_LINEAR | |
  98332. * | 12 | LINEAR_NEAREST | |
  98333. *
  98334. * > _mag_: magnification filter (close to the viewer)
  98335. * > _min_: minification filter (far from the viewer)
  98336. * > _mip_: filter used between mip map levels
  98337. *@param samplingMode Define the new sampling mode of the texture
  98338. */
  98339. updateSamplingMode(samplingMode: number): void;
  98340. /**
  98341. * Scales the texture if is `canRescale()`
  98342. * @param ratio the resize factor we want to use to rescale
  98343. */
  98344. scale(ratio: number): void;
  98345. /**
  98346. * Get if the texture can rescale.
  98347. */
  98348. readonly canRescale: boolean;
  98349. /** @hidden */
  98350. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  98351. /** @hidden */
  98352. _rebuild(): void;
  98353. /**
  98354. * Triggers the load sequence in delayed load mode.
  98355. */
  98356. delayLoad(): void;
  98357. /**
  98358. * Clones the texture.
  98359. * @returns the cloned texture
  98360. */
  98361. clone(): Nullable<BaseTexture>;
  98362. /**
  98363. * Get the texture underlying type (INT, FLOAT...)
  98364. */
  98365. readonly textureType: number;
  98366. /**
  98367. * Get the texture underlying format (RGB, RGBA...)
  98368. */
  98369. readonly textureFormat: number;
  98370. /**
  98371. * Indicates that textures need to be re-calculated for all materials
  98372. */
  98373. protected _markAllSubMeshesAsTexturesDirty(): void;
  98374. /**
  98375. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  98376. * This will returns an RGBA array buffer containing either in values (0-255) or
  98377. * float values (0-1) depending of the underlying buffer type.
  98378. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  98379. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  98380. * @param buffer defines a user defined buffer to fill with data (can be null)
  98381. * @returns The Array buffer containing the pixels data.
  98382. */
  98383. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  98384. /**
  98385. * Release and destroy the underlying lower level texture aka internalTexture.
  98386. */
  98387. releaseInternalTexture(): void;
  98388. /** @hidden */
  98389. readonly _lodTextureHigh: Nullable<BaseTexture>;
  98390. /** @hidden */
  98391. readonly _lodTextureMid: Nullable<BaseTexture>;
  98392. /** @hidden */
  98393. readonly _lodTextureLow: Nullable<BaseTexture>;
  98394. /**
  98395. * Dispose the texture and release its associated resources.
  98396. */
  98397. dispose(): void;
  98398. /**
  98399. * Serialize the texture into a JSON representation that can be parsed later on.
  98400. * @returns the JSON representation of the texture
  98401. */
  98402. serialize(): any;
  98403. /**
  98404. * Helper function to be called back once a list of texture contains only ready textures.
  98405. * @param textures Define the list of textures to wait for
  98406. * @param callback Define the callback triggered once the entire list will be ready
  98407. */
  98408. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  98409. }
  98410. }
  98411. declare module BABYLON {
  98412. /**
  98413. * Options to be used when creating an effect.
  98414. */
  98415. export interface IEffectCreationOptions {
  98416. /**
  98417. * Atrributes that will be used in the shader.
  98418. */
  98419. attributes: string[];
  98420. /**
  98421. * Uniform varible names that will be set in the shader.
  98422. */
  98423. uniformsNames: string[];
  98424. /**
  98425. * Uniform buffer variable names that will be set in the shader.
  98426. */
  98427. uniformBuffersNames: string[];
  98428. /**
  98429. * Sampler texture variable names that will be set in the shader.
  98430. */
  98431. samplers: string[];
  98432. /**
  98433. * Define statements that will be set in the shader.
  98434. */
  98435. defines: any;
  98436. /**
  98437. * Possible fallbacks for this effect to improve performance when needed.
  98438. */
  98439. fallbacks: Nullable<IEffectFallbacks>;
  98440. /**
  98441. * Callback that will be called when the shader is compiled.
  98442. */
  98443. onCompiled: Nullable<(effect: Effect) => void>;
  98444. /**
  98445. * Callback that will be called if an error occurs during shader compilation.
  98446. */
  98447. onError: Nullable<(effect: Effect, errors: string) => void>;
  98448. /**
  98449. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  98450. */
  98451. indexParameters?: any;
  98452. /**
  98453. * Max number of lights that can be used in the shader.
  98454. */
  98455. maxSimultaneousLights?: number;
  98456. /**
  98457. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  98458. */
  98459. transformFeedbackVaryings?: Nullable<string[]>;
  98460. }
  98461. /**
  98462. * Effect containing vertex and fragment shader that can be executed on an object.
  98463. */
  98464. export class Effect implements IDisposable {
  98465. /**
  98466. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  98467. */
  98468. static ShadersRepository: string;
  98469. /**
  98470. * Name of the effect.
  98471. */
  98472. name: any;
  98473. /**
  98474. * String container all the define statements that should be set on the shader.
  98475. */
  98476. defines: string;
  98477. /**
  98478. * Callback that will be called when the shader is compiled.
  98479. */
  98480. onCompiled: Nullable<(effect: Effect) => void>;
  98481. /**
  98482. * Callback that will be called if an error occurs during shader compilation.
  98483. */
  98484. onError: Nullable<(effect: Effect, errors: string) => void>;
  98485. /**
  98486. * Callback that will be called when effect is bound.
  98487. */
  98488. onBind: Nullable<(effect: Effect) => void>;
  98489. /**
  98490. * Unique ID of the effect.
  98491. */
  98492. uniqueId: number;
  98493. /**
  98494. * Observable that will be called when the shader is compiled.
  98495. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  98496. */
  98497. onCompileObservable: Observable<Effect>;
  98498. /**
  98499. * Observable that will be called if an error occurs during shader compilation.
  98500. */
  98501. onErrorObservable: Observable<Effect>;
  98502. /** @hidden */
  98503. _onBindObservable: Nullable<Observable<Effect>>;
  98504. /**
  98505. * Observable that will be called when effect is bound.
  98506. */
  98507. readonly onBindObservable: Observable<Effect>;
  98508. /** @hidden */
  98509. _bonesComputationForcedToCPU: boolean;
  98510. private static _uniqueIdSeed;
  98511. private _engine;
  98512. private _uniformBuffersNames;
  98513. private _uniformsNames;
  98514. private _samplerList;
  98515. private _samplers;
  98516. private _isReady;
  98517. private _compilationError;
  98518. private _allFallbacksProcessed;
  98519. private _attributesNames;
  98520. private _attributes;
  98521. private _uniforms;
  98522. /**
  98523. * Key for the effect.
  98524. * @hidden
  98525. */
  98526. _key: string;
  98527. private _indexParameters;
  98528. private _fallbacks;
  98529. private _vertexSourceCode;
  98530. private _fragmentSourceCode;
  98531. private _vertexSourceCodeOverride;
  98532. private _fragmentSourceCodeOverride;
  98533. private _transformFeedbackVaryings;
  98534. /**
  98535. * Compiled shader to webGL program.
  98536. * @hidden
  98537. */
  98538. _pipelineContext: Nullable<IPipelineContext>;
  98539. private _valueCache;
  98540. private static _baseCache;
  98541. /**
  98542. * Instantiates an effect.
  98543. * An effect can be used to create/manage/execute vertex and fragment shaders.
  98544. * @param baseName Name of the effect.
  98545. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  98546. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  98547. * @param samplers List of sampler variables that will be passed to the shader.
  98548. * @param engine Engine to be used to render the effect
  98549. * @param defines Define statements to be added to the shader.
  98550. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  98551. * @param onCompiled Callback that will be called when the shader is compiled.
  98552. * @param onError Callback that will be called if an error occurs during shader compilation.
  98553. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  98554. */
  98555. 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);
  98556. private _useFinalCode;
  98557. /**
  98558. * Unique key for this effect
  98559. */
  98560. readonly key: string;
  98561. /**
  98562. * If the effect has been compiled and prepared.
  98563. * @returns if the effect is compiled and prepared.
  98564. */
  98565. isReady(): boolean;
  98566. private _isReadyInternal;
  98567. /**
  98568. * The engine the effect was initialized with.
  98569. * @returns the engine.
  98570. */
  98571. getEngine(): Engine;
  98572. /**
  98573. * The pipeline context for this effect
  98574. * @returns the associated pipeline context
  98575. */
  98576. getPipelineContext(): Nullable<IPipelineContext>;
  98577. /**
  98578. * The set of names of attribute variables for the shader.
  98579. * @returns An array of attribute names.
  98580. */
  98581. getAttributesNames(): string[];
  98582. /**
  98583. * Returns the attribute at the given index.
  98584. * @param index The index of the attribute.
  98585. * @returns The location of the attribute.
  98586. */
  98587. getAttributeLocation(index: number): number;
  98588. /**
  98589. * Returns the attribute based on the name of the variable.
  98590. * @param name of the attribute to look up.
  98591. * @returns the attribute location.
  98592. */
  98593. getAttributeLocationByName(name: string): number;
  98594. /**
  98595. * The number of attributes.
  98596. * @returns the numnber of attributes.
  98597. */
  98598. getAttributesCount(): number;
  98599. /**
  98600. * Gets the index of a uniform variable.
  98601. * @param uniformName of the uniform to look up.
  98602. * @returns the index.
  98603. */
  98604. getUniformIndex(uniformName: string): number;
  98605. /**
  98606. * Returns the attribute based on the name of the variable.
  98607. * @param uniformName of the uniform to look up.
  98608. * @returns the location of the uniform.
  98609. */
  98610. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  98611. /**
  98612. * Returns an array of sampler variable names
  98613. * @returns The array of sampler variable neames.
  98614. */
  98615. getSamplers(): string[];
  98616. /**
  98617. * The error from the last compilation.
  98618. * @returns the error string.
  98619. */
  98620. getCompilationError(): string;
  98621. /**
  98622. * Gets a boolean indicating that all fallbacks were used during compilation
  98623. * @returns true if all fallbacks were used
  98624. */
  98625. allFallbacksProcessed(): boolean;
  98626. /**
  98627. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  98628. * @param func The callback to be used.
  98629. */
  98630. executeWhenCompiled(func: (effect: Effect) => void): void;
  98631. private _checkIsReady;
  98632. private _loadShader;
  98633. /**
  98634. * Recompiles the webGL program
  98635. * @param vertexSourceCode The source code for the vertex shader.
  98636. * @param fragmentSourceCode The source code for the fragment shader.
  98637. * @param onCompiled Callback called when completed.
  98638. * @param onError Callback called on error.
  98639. * @hidden
  98640. */
  98641. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  98642. /**
  98643. * Prepares the effect
  98644. * @hidden
  98645. */
  98646. _prepareEffect(): void;
  98647. private _processCompilationErrors;
  98648. /**
  98649. * Checks if the effect is supported. (Must be called after compilation)
  98650. */
  98651. readonly isSupported: boolean;
  98652. /**
  98653. * Binds a texture to the engine to be used as output of the shader.
  98654. * @param channel Name of the output variable.
  98655. * @param texture Texture to bind.
  98656. * @hidden
  98657. */
  98658. _bindTexture(channel: string, texture: InternalTexture): void;
  98659. /**
  98660. * Sets a texture on the engine to be used in the shader.
  98661. * @param channel Name of the sampler variable.
  98662. * @param texture Texture to set.
  98663. */
  98664. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  98665. /**
  98666. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  98667. * @param channel Name of the sampler variable.
  98668. * @param texture Texture to set.
  98669. */
  98670. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  98671. /**
  98672. * Sets an array of textures on the engine to be used in the shader.
  98673. * @param channel Name of the variable.
  98674. * @param textures Textures to set.
  98675. */
  98676. setTextureArray(channel: string, textures: BaseTexture[]): void;
  98677. /**
  98678. * 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)
  98679. * @param channel Name of the sampler variable.
  98680. * @param postProcess Post process to get the input texture from.
  98681. */
  98682. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  98683. /**
  98684. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  98685. * 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)
  98686. * @param channel Name of the sampler variable.
  98687. * @param postProcess Post process to get the output texture from.
  98688. */
  98689. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  98690. /** @hidden */
  98691. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  98692. /** @hidden */
  98693. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  98694. /** @hidden */
  98695. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  98696. /** @hidden */
  98697. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  98698. /**
  98699. * Binds a buffer to a uniform.
  98700. * @param buffer Buffer to bind.
  98701. * @param name Name of the uniform variable to bind to.
  98702. */
  98703. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  98704. /**
  98705. * Binds block to a uniform.
  98706. * @param blockName Name of the block to bind.
  98707. * @param index Index to bind.
  98708. */
  98709. bindUniformBlock(blockName: string, index: number): void;
  98710. /**
  98711. * Sets an interger value on a uniform variable.
  98712. * @param uniformName Name of the variable.
  98713. * @param value Value to be set.
  98714. * @returns this effect.
  98715. */
  98716. setInt(uniformName: string, value: number): Effect;
  98717. /**
  98718. * Sets an int array on a uniform variable.
  98719. * @param uniformName Name of the variable.
  98720. * @param array array to be set.
  98721. * @returns this effect.
  98722. */
  98723. setIntArray(uniformName: string, array: Int32Array): Effect;
  98724. /**
  98725. * 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)
  98726. * @param uniformName Name of the variable.
  98727. * @param array array to be set.
  98728. * @returns this effect.
  98729. */
  98730. setIntArray2(uniformName: string, array: Int32Array): Effect;
  98731. /**
  98732. * 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)
  98733. * @param uniformName Name of the variable.
  98734. * @param array array to be set.
  98735. * @returns this effect.
  98736. */
  98737. setIntArray3(uniformName: string, array: Int32Array): Effect;
  98738. /**
  98739. * 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)
  98740. * @param uniformName Name of the variable.
  98741. * @param array array to be set.
  98742. * @returns this effect.
  98743. */
  98744. setIntArray4(uniformName: string, array: Int32Array): Effect;
  98745. /**
  98746. * Sets an float array on a uniform variable.
  98747. * @param uniformName Name of the variable.
  98748. * @param array array to be set.
  98749. * @returns this effect.
  98750. */
  98751. setFloatArray(uniformName: string, array: Float32Array): Effect;
  98752. /**
  98753. * 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)
  98754. * @param uniformName Name of the variable.
  98755. * @param array array to be set.
  98756. * @returns this effect.
  98757. */
  98758. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  98759. /**
  98760. * 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)
  98761. * @param uniformName Name of the variable.
  98762. * @param array array to be set.
  98763. * @returns this effect.
  98764. */
  98765. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  98766. /**
  98767. * 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)
  98768. * @param uniformName Name of the variable.
  98769. * @param array array to be set.
  98770. * @returns this effect.
  98771. */
  98772. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  98773. /**
  98774. * Sets an array on a uniform variable.
  98775. * @param uniformName Name of the variable.
  98776. * @param array array to be set.
  98777. * @returns this effect.
  98778. */
  98779. setArray(uniformName: string, array: number[]): Effect;
  98780. /**
  98781. * 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)
  98782. * @param uniformName Name of the variable.
  98783. * @param array array to be set.
  98784. * @returns this effect.
  98785. */
  98786. setArray2(uniformName: string, array: number[]): Effect;
  98787. /**
  98788. * 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)
  98789. * @param uniformName Name of the variable.
  98790. * @param array array to be set.
  98791. * @returns this effect.
  98792. */
  98793. setArray3(uniformName: string, array: number[]): Effect;
  98794. /**
  98795. * 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)
  98796. * @param uniformName Name of the variable.
  98797. * @param array array to be set.
  98798. * @returns this effect.
  98799. */
  98800. setArray4(uniformName: string, array: number[]): Effect;
  98801. /**
  98802. * Sets matrices on a uniform variable.
  98803. * @param uniformName Name of the variable.
  98804. * @param matrices matrices to be set.
  98805. * @returns this effect.
  98806. */
  98807. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  98808. /**
  98809. * Sets matrix on a uniform variable.
  98810. * @param uniformName Name of the variable.
  98811. * @param matrix matrix to be set.
  98812. * @returns this effect.
  98813. */
  98814. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  98815. /**
  98816. * 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)
  98817. * @param uniformName Name of the variable.
  98818. * @param matrix matrix to be set.
  98819. * @returns this effect.
  98820. */
  98821. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  98822. /**
  98823. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  98824. * @param uniformName Name of the variable.
  98825. * @param matrix matrix to be set.
  98826. * @returns this effect.
  98827. */
  98828. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  98829. /**
  98830. * Sets a float on a uniform variable.
  98831. * @param uniformName Name of the variable.
  98832. * @param value value to be set.
  98833. * @returns this effect.
  98834. */
  98835. setFloat(uniformName: string, value: number): Effect;
  98836. /**
  98837. * Sets a boolean on a uniform variable.
  98838. * @param uniformName Name of the variable.
  98839. * @param bool value to be set.
  98840. * @returns this effect.
  98841. */
  98842. setBool(uniformName: string, bool: boolean): Effect;
  98843. /**
  98844. * Sets a Vector2 on a uniform variable.
  98845. * @param uniformName Name of the variable.
  98846. * @param vector2 vector2 to be set.
  98847. * @returns this effect.
  98848. */
  98849. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  98850. /**
  98851. * Sets a float2 on a uniform variable.
  98852. * @param uniformName Name of the variable.
  98853. * @param x First float in float2.
  98854. * @param y Second float in float2.
  98855. * @returns this effect.
  98856. */
  98857. setFloat2(uniformName: string, x: number, y: number): Effect;
  98858. /**
  98859. * Sets a Vector3 on a uniform variable.
  98860. * @param uniformName Name of the variable.
  98861. * @param vector3 Value to be set.
  98862. * @returns this effect.
  98863. */
  98864. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  98865. /**
  98866. * Sets a float3 on a uniform variable.
  98867. * @param uniformName Name of the variable.
  98868. * @param x First float in float3.
  98869. * @param y Second float in float3.
  98870. * @param z Third float in float3.
  98871. * @returns this effect.
  98872. */
  98873. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  98874. /**
  98875. * Sets a Vector4 on a uniform variable.
  98876. * @param uniformName Name of the variable.
  98877. * @param vector4 Value to be set.
  98878. * @returns this effect.
  98879. */
  98880. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  98881. /**
  98882. * Sets a float4 on a uniform variable.
  98883. * @param uniformName Name of the variable.
  98884. * @param x First float in float4.
  98885. * @param y Second float in float4.
  98886. * @param z Third float in float4.
  98887. * @param w Fourth float in float4.
  98888. * @returns this effect.
  98889. */
  98890. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  98891. /**
  98892. * Sets a Color3 on a uniform variable.
  98893. * @param uniformName Name of the variable.
  98894. * @param color3 Value to be set.
  98895. * @returns this effect.
  98896. */
  98897. setColor3(uniformName: string, color3: IColor3Like): Effect;
  98898. /**
  98899. * Sets a Color4 on a uniform variable.
  98900. * @param uniformName Name of the variable.
  98901. * @param color3 Value to be set.
  98902. * @param alpha Alpha value to be set.
  98903. * @returns this effect.
  98904. */
  98905. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  98906. /**
  98907. * Sets a Color4 on a uniform variable
  98908. * @param uniformName defines the name of the variable
  98909. * @param color4 defines the value to be set
  98910. * @returns this effect.
  98911. */
  98912. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  98913. /** Release all associated resources */
  98914. dispose(): void;
  98915. /**
  98916. * This function will add a new shader to the shader store
  98917. * @param name the name of the shader
  98918. * @param pixelShader optional pixel shader content
  98919. * @param vertexShader optional vertex shader content
  98920. */
  98921. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  98922. /**
  98923. * Store of each shader (The can be looked up using effect.key)
  98924. */
  98925. static ShadersStore: {
  98926. [key: string]: string;
  98927. };
  98928. /**
  98929. * Store of each included file for a shader (The can be looked up using effect.key)
  98930. */
  98931. static IncludesShadersStore: {
  98932. [key: string]: string;
  98933. };
  98934. /**
  98935. * Resets the cache of effects.
  98936. */
  98937. static ResetCache(): void;
  98938. }
  98939. }
  98940. declare module BABYLON {
  98941. /**
  98942. * Interface used to describe the capabilities of the engine relatively to the current browser
  98943. */
  98944. export interface EngineCapabilities {
  98945. /** Maximum textures units per fragment shader */
  98946. maxTexturesImageUnits: number;
  98947. /** Maximum texture units per vertex shader */
  98948. maxVertexTextureImageUnits: number;
  98949. /** Maximum textures units in the entire pipeline */
  98950. maxCombinedTexturesImageUnits: number;
  98951. /** Maximum texture size */
  98952. maxTextureSize: number;
  98953. /** Maximum texture samples */
  98954. maxSamples?: number;
  98955. /** Maximum cube texture size */
  98956. maxCubemapTextureSize: number;
  98957. /** Maximum render texture size */
  98958. maxRenderTextureSize: number;
  98959. /** Maximum number of vertex attributes */
  98960. maxVertexAttribs: number;
  98961. /** Maximum number of varyings */
  98962. maxVaryingVectors: number;
  98963. /** Maximum number of uniforms per vertex shader */
  98964. maxVertexUniformVectors: number;
  98965. /** Maximum number of uniforms per fragment shader */
  98966. maxFragmentUniformVectors: number;
  98967. /** Defines if standard derivates (dx/dy) are supported */
  98968. standardDerivatives: boolean;
  98969. /** Defines if s3tc texture compression is supported */
  98970. s3tc?: WEBGL_compressed_texture_s3tc;
  98971. /** Defines if pvrtc texture compression is supported */
  98972. pvrtc: any;
  98973. /** Defines if etc1 texture compression is supported */
  98974. etc1: any;
  98975. /** Defines if etc2 texture compression is supported */
  98976. etc2: any;
  98977. /** Defines if astc texture compression is supported */
  98978. astc: any;
  98979. /** Defines if float textures are supported */
  98980. textureFloat: boolean;
  98981. /** Defines if vertex array objects are supported */
  98982. vertexArrayObject: boolean;
  98983. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  98984. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  98985. /** Gets the maximum level of anisotropy supported */
  98986. maxAnisotropy: number;
  98987. /** Defines if instancing is supported */
  98988. instancedArrays: boolean;
  98989. /** Defines if 32 bits indices are supported */
  98990. uintIndices: boolean;
  98991. /** Defines if high precision shaders are supported */
  98992. highPrecisionShaderSupported: boolean;
  98993. /** Defines if depth reading in the fragment shader is supported */
  98994. fragmentDepthSupported: boolean;
  98995. /** Defines if float texture linear filtering is supported*/
  98996. textureFloatLinearFiltering: boolean;
  98997. /** Defines if rendering to float textures is supported */
  98998. textureFloatRender: boolean;
  98999. /** Defines if half float textures are supported*/
  99000. textureHalfFloat: boolean;
  99001. /** Defines if half float texture linear filtering is supported*/
  99002. textureHalfFloatLinearFiltering: boolean;
  99003. /** Defines if rendering to half float textures is supported */
  99004. textureHalfFloatRender: boolean;
  99005. /** Defines if textureLOD shader command is supported */
  99006. textureLOD: boolean;
  99007. /** Defines if draw buffers extension is supported */
  99008. drawBuffersExtension: boolean;
  99009. /** Defines if depth textures are supported */
  99010. depthTextureExtension: boolean;
  99011. /** Defines if float color buffer are supported */
  99012. colorBufferFloat: boolean;
  99013. /** Gets disjoint timer query extension (null if not supported) */
  99014. timerQuery?: EXT_disjoint_timer_query;
  99015. /** Defines if timestamp can be used with timer query */
  99016. canUseTimestampForTimerQuery: boolean;
  99017. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  99018. multiview?: any;
  99019. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  99020. oculusMultiview?: any;
  99021. /** Function used to let the system compiles shaders in background */
  99022. parallelShaderCompile?: {
  99023. COMPLETION_STATUS_KHR: number;
  99024. };
  99025. /** Max number of texture samples for MSAA */
  99026. maxMSAASamples: number;
  99027. /** Defines if the blend min max extension is supported */
  99028. blendMinMax: boolean;
  99029. }
  99030. }
  99031. declare module BABYLON {
  99032. /**
  99033. * @hidden
  99034. **/
  99035. export class DepthCullingState {
  99036. private _isDepthTestDirty;
  99037. private _isDepthMaskDirty;
  99038. private _isDepthFuncDirty;
  99039. private _isCullFaceDirty;
  99040. private _isCullDirty;
  99041. private _isZOffsetDirty;
  99042. private _isFrontFaceDirty;
  99043. private _depthTest;
  99044. private _depthMask;
  99045. private _depthFunc;
  99046. private _cull;
  99047. private _cullFace;
  99048. private _zOffset;
  99049. private _frontFace;
  99050. /**
  99051. * Initializes the state.
  99052. */
  99053. constructor();
  99054. readonly isDirty: boolean;
  99055. zOffset: number;
  99056. cullFace: Nullable<number>;
  99057. cull: Nullable<boolean>;
  99058. depthFunc: Nullable<number>;
  99059. depthMask: boolean;
  99060. depthTest: boolean;
  99061. frontFace: Nullable<number>;
  99062. reset(): void;
  99063. apply(gl: WebGLRenderingContext): void;
  99064. }
  99065. }
  99066. declare module BABYLON {
  99067. /**
  99068. * @hidden
  99069. **/
  99070. export class StencilState {
  99071. /** 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 */
  99072. static readonly ALWAYS: number;
  99073. /** Passed to stencilOperation to specify that stencil value must be kept */
  99074. static readonly KEEP: number;
  99075. /** Passed to stencilOperation to specify that stencil value must be replaced */
  99076. static readonly REPLACE: number;
  99077. private _isStencilTestDirty;
  99078. private _isStencilMaskDirty;
  99079. private _isStencilFuncDirty;
  99080. private _isStencilOpDirty;
  99081. private _stencilTest;
  99082. private _stencilMask;
  99083. private _stencilFunc;
  99084. private _stencilFuncRef;
  99085. private _stencilFuncMask;
  99086. private _stencilOpStencilFail;
  99087. private _stencilOpDepthFail;
  99088. private _stencilOpStencilDepthPass;
  99089. readonly isDirty: boolean;
  99090. stencilFunc: number;
  99091. stencilFuncRef: number;
  99092. stencilFuncMask: number;
  99093. stencilOpStencilFail: number;
  99094. stencilOpDepthFail: number;
  99095. stencilOpStencilDepthPass: number;
  99096. stencilMask: number;
  99097. stencilTest: boolean;
  99098. constructor();
  99099. reset(): void;
  99100. apply(gl: WebGLRenderingContext): void;
  99101. }
  99102. }
  99103. declare module BABYLON {
  99104. /**
  99105. * @hidden
  99106. **/
  99107. export class AlphaState {
  99108. private _isAlphaBlendDirty;
  99109. private _isBlendFunctionParametersDirty;
  99110. private _isBlendEquationParametersDirty;
  99111. private _isBlendConstantsDirty;
  99112. private _alphaBlend;
  99113. private _blendFunctionParameters;
  99114. private _blendEquationParameters;
  99115. private _blendConstants;
  99116. /**
  99117. * Initializes the state.
  99118. */
  99119. constructor();
  99120. readonly isDirty: boolean;
  99121. alphaBlend: boolean;
  99122. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  99123. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  99124. setAlphaEquationParameters(rgb: number, alpha: number): void;
  99125. reset(): void;
  99126. apply(gl: WebGLRenderingContext): void;
  99127. }
  99128. }
  99129. declare module BABYLON {
  99130. /** @hidden */
  99131. export class WebGL2ShaderProcessor implements IShaderProcessor {
  99132. attributeProcessor(attribute: string): string;
  99133. varyingProcessor(varying: string, isFragment: boolean): string;
  99134. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  99135. }
  99136. }
  99137. declare module BABYLON {
  99138. /**
  99139. * Interface for attribute information associated with buffer instanciation
  99140. */
  99141. export interface InstancingAttributeInfo {
  99142. /**
  99143. * Index/offset of the attribute in the vertex shader
  99144. */
  99145. index: number;
  99146. /**
  99147. * size of the attribute, 1, 2, 3 or 4
  99148. */
  99149. attributeSize: number;
  99150. /**
  99151. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  99152. * default is FLOAT
  99153. */
  99154. attributeType: number;
  99155. /**
  99156. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  99157. */
  99158. normalized: boolean;
  99159. /**
  99160. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  99161. */
  99162. offset: number;
  99163. /**
  99164. * Name of the GLSL attribute, for debugging purpose only
  99165. */
  99166. attributeName: string;
  99167. }
  99168. }
  99169. declare module BABYLON {
  99170. interface ThinEngine {
  99171. /**
  99172. * Update a video texture
  99173. * @param texture defines the texture to update
  99174. * @param video defines the video element to use
  99175. * @param invertY defines if data must be stored with Y axis inverted
  99176. */
  99177. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  99178. }
  99179. }
  99180. declare module BABYLON {
  99181. /**
  99182. * Settings for finer control over video usage
  99183. */
  99184. export interface VideoTextureSettings {
  99185. /**
  99186. * Applies `autoplay` to video, if specified
  99187. */
  99188. autoPlay?: boolean;
  99189. /**
  99190. * Applies `loop` to video, if specified
  99191. */
  99192. loop?: boolean;
  99193. /**
  99194. * Automatically updates internal texture from video at every frame in the render loop
  99195. */
  99196. autoUpdateTexture: boolean;
  99197. /**
  99198. * Image src displayed during the video loading or until the user interacts with the video.
  99199. */
  99200. poster?: string;
  99201. }
  99202. /**
  99203. * If you want to display a video in your scene, this is the special texture for that.
  99204. * This special texture works similar to other textures, with the exception of a few parameters.
  99205. * @see https://doc.babylonjs.com/how_to/video_texture
  99206. */
  99207. export class VideoTexture extends Texture {
  99208. /**
  99209. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  99210. */
  99211. readonly autoUpdateTexture: boolean;
  99212. /**
  99213. * The video instance used by the texture internally
  99214. */
  99215. readonly video: HTMLVideoElement;
  99216. private _onUserActionRequestedObservable;
  99217. /**
  99218. * Event triggerd when a dom action is required by the user to play the video.
  99219. * This happens due to recent changes in browser policies preventing video to auto start.
  99220. */
  99221. readonly onUserActionRequestedObservable: Observable<Texture>;
  99222. private _generateMipMaps;
  99223. private _engine;
  99224. private _stillImageCaptured;
  99225. private _displayingPosterTexture;
  99226. private _settings;
  99227. private _createInternalTextureOnEvent;
  99228. private _frameId;
  99229. /**
  99230. * Creates a video texture.
  99231. * If you want to display a video in your scene, this is the special texture for that.
  99232. * This special texture works similar to other textures, with the exception of a few parameters.
  99233. * @see https://doc.babylonjs.com/how_to/video_texture
  99234. * @param name optional name, will detect from video source, if not defined
  99235. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  99236. * @param scene is obviously the current scene.
  99237. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  99238. * @param invertY is false by default but can be used to invert video on Y axis
  99239. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  99240. * @param settings allows finer control over video usage
  99241. */
  99242. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  99243. private _getName;
  99244. private _getVideo;
  99245. private _createInternalTexture;
  99246. private reset;
  99247. /**
  99248. * @hidden Internal method to initiate `update`.
  99249. */
  99250. _rebuild(): void;
  99251. /**
  99252. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  99253. */
  99254. update(): void;
  99255. /**
  99256. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  99257. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  99258. */
  99259. updateTexture(isVisible: boolean): void;
  99260. protected _updateInternalTexture: () => void;
  99261. /**
  99262. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  99263. * @param url New url.
  99264. */
  99265. updateURL(url: string): void;
  99266. /**
  99267. * Dispose the texture and release its associated resources.
  99268. */
  99269. dispose(): void;
  99270. /**
  99271. * Creates a video texture straight from a stream.
  99272. * @param scene Define the scene the texture should be created in
  99273. * @param stream Define the stream the texture should be created from
  99274. * @returns The created video texture as a promise
  99275. */
  99276. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  99277. /**
  99278. * Creates a video texture straight from your WebCam video feed.
  99279. * @param scene Define the scene the texture should be created in
  99280. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  99281. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  99282. * @returns The created video texture as a promise
  99283. */
  99284. static CreateFromWebCamAsync(scene: Scene, constraints: {
  99285. minWidth: number;
  99286. maxWidth: number;
  99287. minHeight: number;
  99288. maxHeight: number;
  99289. deviceId: string;
  99290. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  99291. /**
  99292. * Creates a video texture straight from your WebCam video feed.
  99293. * @param scene Define the scene the texture should be created in
  99294. * @param onReady Define a callback to triggered once the texture will be ready
  99295. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  99296. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  99297. */
  99298. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  99299. minWidth: number;
  99300. maxWidth: number;
  99301. minHeight: number;
  99302. maxHeight: number;
  99303. deviceId: string;
  99304. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  99305. }
  99306. }
  99307. declare module BABYLON {
  99308. /**
  99309. * Defines the interface used by objects working like Scene
  99310. * @hidden
  99311. */
  99312. interface ISceneLike {
  99313. _addPendingData(data: any): void;
  99314. _removePendingData(data: any): void;
  99315. offlineProvider: IOfflineProvider;
  99316. }
  99317. /** Interface defining initialization parameters for Engine class */
  99318. export interface EngineOptions extends WebGLContextAttributes {
  99319. /**
  99320. * Defines if the engine should no exceed a specified device ratio
  99321. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  99322. */
  99323. limitDeviceRatio?: number;
  99324. /**
  99325. * Defines if webvr should be enabled automatically
  99326. * @see http://doc.babylonjs.com/how_to/webvr_camera
  99327. */
  99328. autoEnableWebVR?: boolean;
  99329. /**
  99330. * Defines if webgl2 should be turned off even if supported
  99331. * @see http://doc.babylonjs.com/features/webgl2
  99332. */
  99333. disableWebGL2Support?: boolean;
  99334. /**
  99335. * Defines if webaudio should be initialized as well
  99336. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99337. */
  99338. audioEngine?: boolean;
  99339. /**
  99340. * Defines if animations should run using a deterministic lock step
  99341. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99342. */
  99343. deterministicLockstep?: boolean;
  99344. /** Defines the maximum steps to use with deterministic lock step mode */
  99345. lockstepMaxSteps?: number;
  99346. /** Defines the seconds between each deterministic lock step */
  99347. timeStep?: number;
  99348. /**
  99349. * Defines that engine should ignore context lost events
  99350. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  99351. */
  99352. doNotHandleContextLost?: boolean;
  99353. /**
  99354. * Defines that engine should ignore modifying touch action attribute and style
  99355. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  99356. */
  99357. doNotHandleTouchAction?: boolean;
  99358. /**
  99359. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  99360. */
  99361. useHighPrecisionFloats?: boolean;
  99362. }
  99363. /**
  99364. * The base engine class (root of all engines)
  99365. */
  99366. export class ThinEngine {
  99367. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  99368. static ExceptionList: ({
  99369. key: string;
  99370. capture: string;
  99371. captureConstraint: number;
  99372. targets: string[];
  99373. } | {
  99374. key: string;
  99375. capture: null;
  99376. captureConstraint: null;
  99377. targets: string[];
  99378. })[];
  99379. /** @hidden */
  99380. static _TextureLoaders: IInternalTextureLoader[];
  99381. /**
  99382. * Returns the current npm package of the sdk
  99383. */
  99384. static readonly NpmPackage: string;
  99385. /**
  99386. * Returns the current version of the framework
  99387. */
  99388. static readonly Version: string;
  99389. /**
  99390. * Returns a string describing the current engine
  99391. */
  99392. readonly description: string;
  99393. /**
  99394. * Gets or sets the epsilon value used by collision engine
  99395. */
  99396. static CollisionsEpsilon: number;
  99397. /**
  99398. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  99399. */
  99400. static ShadersRepository: string;
  99401. /**
  99402. * Gets or sets the textures that the engine should not attempt to load as compressed
  99403. */
  99404. protected _excludedCompressedTextures: string[];
  99405. /**
  99406. * Filters the compressed texture formats to only include
  99407. * files that are not included in the skippable list
  99408. *
  99409. * @param url the current extension
  99410. * @param textureFormatInUse the current compressed texture format
  99411. * @returns "format" string
  99412. */
  99413. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  99414. /** @hidden */
  99415. _shaderProcessor: IShaderProcessor;
  99416. /**
  99417. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  99418. */
  99419. forcePOTTextures: boolean;
  99420. /**
  99421. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  99422. */
  99423. isFullscreen: boolean;
  99424. /**
  99425. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  99426. */
  99427. cullBackFaces: boolean;
  99428. /**
  99429. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  99430. */
  99431. renderEvenInBackground: boolean;
  99432. /**
  99433. * Gets or sets a boolean indicating that cache can be kept between frames
  99434. */
  99435. preventCacheWipeBetweenFrames: boolean;
  99436. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  99437. validateShaderPrograms: boolean;
  99438. /**
  99439. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  99440. * This can provide greater z depth for distant objects.
  99441. */
  99442. useReverseDepthBuffer: boolean;
  99443. /**
  99444. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  99445. */
  99446. disableUniformBuffers: boolean;
  99447. /** @hidden */
  99448. _uniformBuffers: UniformBuffer[];
  99449. /**
  99450. * Gets a boolean indicating that the engine supports uniform buffers
  99451. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  99452. */
  99453. readonly supportsUniformBuffers: boolean;
  99454. /** @hidden */
  99455. _gl: WebGLRenderingContext;
  99456. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  99457. protected _windowIsBackground: boolean;
  99458. protected _webGLVersion: number;
  99459. protected _creationOptions: EngineOptions;
  99460. protected _highPrecisionShadersAllowed: boolean;
  99461. /** @hidden */
  99462. readonly _shouldUseHighPrecisionShader: boolean;
  99463. /**
  99464. * Gets a boolean indicating that only power of 2 textures are supported
  99465. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  99466. */
  99467. readonly needPOTTextures: boolean;
  99468. /** @hidden */
  99469. _badOS: boolean;
  99470. /** @hidden */
  99471. _badDesktopOS: boolean;
  99472. private _hardwareScalingLevel;
  99473. /** @hidden */
  99474. _caps: EngineCapabilities;
  99475. private _isStencilEnable;
  99476. protected _colorWrite: boolean;
  99477. private _glVersion;
  99478. private _glRenderer;
  99479. private _glVendor;
  99480. /** @hidden */
  99481. _videoTextureSupported: boolean;
  99482. protected _renderingQueueLaunched: boolean;
  99483. protected _activeRenderLoops: (() => void)[];
  99484. /**
  99485. * Observable signaled when a context lost event is raised
  99486. */
  99487. onContextLostObservable: Observable<ThinEngine>;
  99488. /**
  99489. * Observable signaled when a context restored event is raised
  99490. */
  99491. onContextRestoredObservable: Observable<ThinEngine>;
  99492. private _onContextLost;
  99493. private _onContextRestored;
  99494. protected _contextWasLost: boolean;
  99495. /** @hidden */
  99496. _doNotHandleContextLost: boolean;
  99497. /**
  99498. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  99499. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  99500. */
  99501. doNotHandleContextLost: boolean;
  99502. /**
  99503. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  99504. */
  99505. disableVertexArrayObjects: boolean;
  99506. /** @hidden */
  99507. protected _depthCullingState: DepthCullingState;
  99508. /** @hidden */
  99509. protected _stencilState: StencilState;
  99510. /** @hidden */
  99511. protected _alphaState: AlphaState;
  99512. /** @hidden */
  99513. _internalTexturesCache: InternalTexture[];
  99514. /** @hidden */
  99515. protected _activeChannel: number;
  99516. private _currentTextureChannel;
  99517. /** @hidden */
  99518. protected _boundTexturesCache: {
  99519. [key: string]: Nullable<InternalTexture>;
  99520. };
  99521. /** @hidden */
  99522. protected _currentEffect: Nullable<Effect>;
  99523. /** @hidden */
  99524. protected _currentProgram: Nullable<WebGLProgram>;
  99525. private _compiledEffects;
  99526. private _vertexAttribArraysEnabled;
  99527. /** @hidden */
  99528. protected _cachedViewport: Nullable<IViewportLike>;
  99529. private _cachedVertexArrayObject;
  99530. /** @hidden */
  99531. protected _cachedVertexBuffers: any;
  99532. /** @hidden */
  99533. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  99534. /** @hidden */
  99535. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  99536. /** @hidden */
  99537. _currentRenderTarget: Nullable<InternalTexture>;
  99538. private _uintIndicesCurrentlySet;
  99539. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  99540. /** @hidden */
  99541. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  99542. private _currentBufferPointers;
  99543. private _currentInstanceLocations;
  99544. private _currentInstanceBuffers;
  99545. private _textureUnits;
  99546. /** @hidden */
  99547. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  99548. /** @hidden */
  99549. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  99550. /** @hidden */
  99551. _boundRenderFunction: any;
  99552. private _vaoRecordInProgress;
  99553. private _mustWipeVertexAttributes;
  99554. private _emptyTexture;
  99555. private _emptyCubeTexture;
  99556. private _emptyTexture3D;
  99557. private _emptyTexture2DArray;
  99558. /** @hidden */
  99559. _frameHandler: number;
  99560. private _nextFreeTextureSlots;
  99561. private _maxSimultaneousTextures;
  99562. private _activeRequests;
  99563. protected _texturesSupported: string[];
  99564. /** @hidden */
  99565. _textureFormatInUse: Nullable<string>;
  99566. protected readonly _supportsHardwareTextureRescaling: boolean;
  99567. /**
  99568. * Gets the list of texture formats supported
  99569. */
  99570. readonly texturesSupported: Array<string>;
  99571. /**
  99572. * Gets the list of texture formats in use
  99573. */
  99574. readonly textureFormatInUse: Nullable<string>;
  99575. /**
  99576. * Gets the current viewport
  99577. */
  99578. readonly currentViewport: Nullable<IViewportLike>;
  99579. /**
  99580. * Gets the default empty texture
  99581. */
  99582. readonly emptyTexture: InternalTexture;
  99583. /**
  99584. * Gets the default empty 3D texture
  99585. */
  99586. readonly emptyTexture3D: InternalTexture;
  99587. /**
  99588. * Gets the default empty 2D array texture
  99589. */
  99590. readonly emptyTexture2DArray: InternalTexture;
  99591. /**
  99592. * Gets the default empty cube texture
  99593. */
  99594. readonly emptyCubeTexture: InternalTexture;
  99595. /**
  99596. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  99597. */
  99598. readonly premultipliedAlpha: boolean;
  99599. /**
  99600. * Observable event triggered before each texture is initialized
  99601. */
  99602. onBeforeTextureInitObservable: Observable<Texture>;
  99603. /**
  99604. * Creates a new engine
  99605. * @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
  99606. * @param antialias defines enable antialiasing (default: false)
  99607. * @param options defines further options to be sent to the getContext() function
  99608. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  99609. */
  99610. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  99611. private _rebuildInternalTextures;
  99612. private _rebuildEffects;
  99613. /**
  99614. * Gets a boolean indicating if all created effects are ready
  99615. * @returns true if all effects are ready
  99616. */
  99617. areAllEffectsReady(): boolean;
  99618. protected _rebuildBuffers(): void;
  99619. private _initGLContext;
  99620. /**
  99621. * Gets version of the current webGL context
  99622. */
  99623. readonly webGLVersion: number;
  99624. /**
  99625. * Gets a string idenfifying the name of the class
  99626. * @returns "Engine" string
  99627. */
  99628. getClassName(): string;
  99629. /**
  99630. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  99631. */
  99632. readonly isStencilEnable: boolean;
  99633. /** @hidden */
  99634. _prepareWorkingCanvas(): void;
  99635. /**
  99636. * Reset the texture cache to empty state
  99637. */
  99638. resetTextureCache(): void;
  99639. /**
  99640. * Gets an object containing information about the current webGL context
  99641. * @returns an object containing the vender, the renderer and the version of the current webGL context
  99642. */
  99643. getGlInfo(): {
  99644. vendor: string;
  99645. renderer: string;
  99646. version: string;
  99647. };
  99648. /**
  99649. * Defines the hardware scaling level.
  99650. * By default the hardware scaling level is computed from the window device ratio.
  99651. * 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.
  99652. * @param level defines the level to use
  99653. */
  99654. setHardwareScalingLevel(level: number): void;
  99655. /**
  99656. * Gets the current hardware scaling level.
  99657. * By default the hardware scaling level is computed from the window device ratio.
  99658. * 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.
  99659. * @returns a number indicating the current hardware scaling level
  99660. */
  99661. getHardwareScalingLevel(): number;
  99662. /**
  99663. * Gets the list of loaded textures
  99664. * @returns an array containing all loaded textures
  99665. */
  99666. getLoadedTexturesCache(): InternalTexture[];
  99667. /**
  99668. * Gets the object containing all engine capabilities
  99669. * @returns the EngineCapabilities object
  99670. */
  99671. getCaps(): EngineCapabilities;
  99672. /**
  99673. * stop executing a render loop function and remove it from the execution array
  99674. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  99675. */
  99676. stopRenderLoop(renderFunction?: () => void): void;
  99677. /** @hidden */
  99678. _renderLoop(): void;
  99679. /**
  99680. * Gets the HTML canvas attached with the current webGL context
  99681. * @returns a HTML canvas
  99682. */
  99683. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  99684. /**
  99685. * Gets host window
  99686. * @returns the host window object
  99687. */
  99688. getHostWindow(): Nullable<Window>;
  99689. /**
  99690. * Gets the current render width
  99691. * @param useScreen defines if screen size must be used (or the current render target if any)
  99692. * @returns a number defining the current render width
  99693. */
  99694. getRenderWidth(useScreen?: boolean): number;
  99695. /**
  99696. * Gets the current render height
  99697. * @param useScreen defines if screen size must be used (or the current render target if any)
  99698. * @returns a number defining the current render height
  99699. */
  99700. getRenderHeight(useScreen?: boolean): number;
  99701. /**
  99702. * Can be used to override the current requestAnimationFrame requester.
  99703. * @hidden
  99704. */
  99705. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  99706. /**
  99707. * Register and execute a render loop. The engine can have more than one render function
  99708. * @param renderFunction defines the function to continuously execute
  99709. */
  99710. runRenderLoop(renderFunction: () => void): void;
  99711. /**
  99712. * Clear the current render buffer or the current render target (if any is set up)
  99713. * @param color defines the color to use
  99714. * @param backBuffer defines if the back buffer must be cleared
  99715. * @param depth defines if the depth buffer must be cleared
  99716. * @param stencil defines if the stencil buffer must be cleared
  99717. */
  99718. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  99719. private _viewportCached;
  99720. /** @hidden */
  99721. _viewport(x: number, y: number, width: number, height: number): void;
  99722. /**
  99723. * Set the WebGL's viewport
  99724. * @param viewport defines the viewport element to be used
  99725. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  99726. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  99727. */
  99728. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  99729. /**
  99730. * Begin a new frame
  99731. */
  99732. beginFrame(): void;
  99733. /**
  99734. * Enf the current frame
  99735. */
  99736. endFrame(): void;
  99737. /**
  99738. * Resize the view according to the canvas' size
  99739. */
  99740. resize(): void;
  99741. /**
  99742. * Force a specific size of the canvas
  99743. * @param width defines the new canvas' width
  99744. * @param height defines the new canvas' height
  99745. */
  99746. setSize(width: number, height: number): void;
  99747. /**
  99748. * Binds the frame buffer to the specified texture.
  99749. * @param texture The texture to render to or null for the default canvas
  99750. * @param faceIndex The face of the texture to render to in case of cube texture
  99751. * @param requiredWidth The width of the target to render to
  99752. * @param requiredHeight The height of the target to render to
  99753. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  99754. * @param depthStencilTexture The depth stencil texture to use to render
  99755. * @param lodLevel defines le lod level to bind to the frame buffer
  99756. */
  99757. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  99758. /** @hidden */
  99759. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  99760. /**
  99761. * Unbind the current render target texture from the webGL context
  99762. * @param texture defines the render target texture to unbind
  99763. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  99764. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  99765. */
  99766. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  99767. /**
  99768. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  99769. */
  99770. flushFramebuffer(): void;
  99771. /**
  99772. * Unbind the current render target and bind the default framebuffer
  99773. */
  99774. restoreDefaultFramebuffer(): void;
  99775. /** @hidden */
  99776. protected _resetVertexBufferBinding(): void;
  99777. /**
  99778. * Creates a vertex buffer
  99779. * @param data the data for the vertex buffer
  99780. * @returns the new WebGL static buffer
  99781. */
  99782. createVertexBuffer(data: DataArray): DataBuffer;
  99783. private _createVertexBuffer;
  99784. /**
  99785. * Creates a dynamic vertex buffer
  99786. * @param data the data for the dynamic vertex buffer
  99787. * @returns the new WebGL dynamic buffer
  99788. */
  99789. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  99790. protected _resetIndexBufferBinding(): void;
  99791. /**
  99792. * Creates a new index buffer
  99793. * @param indices defines the content of the index buffer
  99794. * @param updatable defines if the index buffer must be updatable
  99795. * @returns a new webGL buffer
  99796. */
  99797. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  99798. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  99799. /**
  99800. * Bind a webGL buffer to the webGL context
  99801. * @param buffer defines the buffer to bind
  99802. */
  99803. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  99804. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  99805. private bindBuffer;
  99806. /**
  99807. * update the bound buffer with the given data
  99808. * @param data defines the data to update
  99809. */
  99810. updateArrayBuffer(data: Float32Array): void;
  99811. private _vertexAttribPointer;
  99812. private _bindIndexBufferWithCache;
  99813. private _bindVertexBuffersAttributes;
  99814. /**
  99815. * Records a vertex array object
  99816. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  99817. * @param vertexBuffers defines the list of vertex buffers to store
  99818. * @param indexBuffer defines the index buffer to store
  99819. * @param effect defines the effect to store
  99820. * @returns the new vertex array object
  99821. */
  99822. recordVertexArrayObject(vertexBuffers: {
  99823. [key: string]: VertexBuffer;
  99824. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  99825. /**
  99826. * Bind a specific vertex array object
  99827. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  99828. * @param vertexArrayObject defines the vertex array object to bind
  99829. * @param indexBuffer defines the index buffer to bind
  99830. */
  99831. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  99832. /**
  99833. * Bind webGl buffers directly to the webGL context
  99834. * @param vertexBuffer defines the vertex buffer to bind
  99835. * @param indexBuffer defines the index buffer to bind
  99836. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  99837. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  99838. * @param effect defines the effect associated with the vertex buffer
  99839. */
  99840. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  99841. private _unbindVertexArrayObject;
  99842. /**
  99843. * Bind a list of vertex buffers to the webGL context
  99844. * @param vertexBuffers defines the list of vertex buffers to bind
  99845. * @param indexBuffer defines the index buffer to bind
  99846. * @param effect defines the effect associated with the vertex buffers
  99847. */
  99848. bindBuffers(vertexBuffers: {
  99849. [key: string]: Nullable<VertexBuffer>;
  99850. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  99851. /**
  99852. * Unbind all instance attributes
  99853. */
  99854. unbindInstanceAttributes(): void;
  99855. /**
  99856. * Release and free the memory of a vertex array object
  99857. * @param vao defines the vertex array object to delete
  99858. */
  99859. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  99860. /** @hidden */
  99861. _releaseBuffer(buffer: DataBuffer): boolean;
  99862. protected _deleteBuffer(buffer: DataBuffer): void;
  99863. /**
  99864. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  99865. * @param instancesBuffer defines the webGL buffer to update and bind
  99866. * @param data defines the data to store in the buffer
  99867. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  99868. */
  99869. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  99870. /**
  99871. * Apply all cached states (depth, culling, stencil and alpha)
  99872. */
  99873. applyStates(): void;
  99874. /**
  99875. * Send a draw order
  99876. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  99877. * @param indexStart defines the starting index
  99878. * @param indexCount defines the number of index to draw
  99879. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  99880. */
  99881. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  99882. /**
  99883. * Draw a list of points
  99884. * @param verticesStart defines the index of first vertex to draw
  99885. * @param verticesCount defines the count of vertices to draw
  99886. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  99887. */
  99888. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  99889. /**
  99890. * Draw a list of unindexed primitives
  99891. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  99892. * @param verticesStart defines the index of first vertex to draw
  99893. * @param verticesCount defines the count of vertices to draw
  99894. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  99895. */
  99896. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  99897. /**
  99898. * Draw a list of indexed primitives
  99899. * @param fillMode defines the primitive to use
  99900. * @param indexStart defines the starting index
  99901. * @param indexCount defines the number of index to draw
  99902. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  99903. */
  99904. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  99905. /**
  99906. * Draw a list of unindexed primitives
  99907. * @param fillMode defines the primitive to use
  99908. * @param verticesStart defines the index of first vertex to draw
  99909. * @param verticesCount defines the count of vertices to draw
  99910. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  99911. */
  99912. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  99913. private _drawMode;
  99914. /** @hidden */
  99915. protected _reportDrawCall(): void;
  99916. /** @hidden */
  99917. _releaseEffect(effect: Effect): void;
  99918. /** @hidden */
  99919. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  99920. /**
  99921. * Create a new effect (used to store vertex/fragment shaders)
  99922. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  99923. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  99924. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  99925. * @param samplers defines an array of string used to represent textures
  99926. * @param defines defines the string containing the defines to use to compile the shaders
  99927. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  99928. * @param onCompiled defines a function to call when the effect creation is successful
  99929. * @param onError defines a function to call when the effect creation has failed
  99930. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  99931. * @returns the new Effect
  99932. */
  99933. 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;
  99934. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  99935. private _compileShader;
  99936. private _compileRawShader;
  99937. /**
  99938. * Directly creates a webGL program
  99939. * @param pipelineContext defines the pipeline context to attach to
  99940. * @param vertexCode defines the vertex shader code to use
  99941. * @param fragmentCode defines the fragment shader code to use
  99942. * @param context defines the webGL context to use (if not set, the current one will be used)
  99943. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  99944. * @returns the new webGL program
  99945. */
  99946. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  99947. /**
  99948. * Creates a webGL program
  99949. * @param pipelineContext defines the pipeline context to attach to
  99950. * @param vertexCode defines the vertex shader code to use
  99951. * @param fragmentCode defines the fragment shader code to use
  99952. * @param defines defines the string containing the defines to use to compile the shaders
  99953. * @param context defines the webGL context to use (if not set, the current one will be used)
  99954. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  99955. * @returns the new webGL program
  99956. */
  99957. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  99958. /**
  99959. * Creates a new pipeline context
  99960. * @returns the new pipeline
  99961. */
  99962. createPipelineContext(): IPipelineContext;
  99963. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  99964. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  99965. /** @hidden */
  99966. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  99967. /** @hidden */
  99968. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  99969. /** @hidden */
  99970. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  99971. /**
  99972. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  99973. * @param pipelineContext defines the pipeline context to use
  99974. * @param uniformsNames defines the list of uniform names
  99975. * @returns an array of webGL uniform locations
  99976. */
  99977. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  99978. /**
  99979. * Gets the lsit of active attributes for a given webGL program
  99980. * @param pipelineContext defines the pipeline context to use
  99981. * @param attributesNames defines the list of attribute names to get
  99982. * @returns an array of indices indicating the offset of each attribute
  99983. */
  99984. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  99985. /**
  99986. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  99987. * @param effect defines the effect to activate
  99988. */
  99989. enableEffect(effect: Nullable<Effect>): void;
  99990. /**
  99991. * Set the value of an uniform to a number (int)
  99992. * @param uniform defines the webGL uniform location where to store the value
  99993. * @param value defines the int number to store
  99994. */
  99995. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  99996. /**
  99997. * Set the value of an uniform to an array of int32
  99998. * @param uniform defines the webGL uniform location where to store the value
  99999. * @param array defines the array of int32 to store
  100000. */
  100001. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  100002. /**
  100003. * Set the value of an uniform to an array of int32 (stored as vec2)
  100004. * @param uniform defines the webGL uniform location where to store the value
  100005. * @param array defines the array of int32 to store
  100006. */
  100007. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  100008. /**
  100009. * Set the value of an uniform to an array of int32 (stored as vec3)
  100010. * @param uniform defines the webGL uniform location where to store the value
  100011. * @param array defines the array of int32 to store
  100012. */
  100013. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  100014. /**
  100015. * Set the value of an uniform to an array of int32 (stored as vec4)
  100016. * @param uniform defines the webGL uniform location where to store the value
  100017. * @param array defines the array of int32 to store
  100018. */
  100019. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  100020. /**
  100021. * Set the value of an uniform to an array of number
  100022. * @param uniform defines the webGL uniform location where to store the value
  100023. * @param array defines the array of number to store
  100024. */
  100025. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  100026. /**
  100027. * Set the value of an uniform to an array of number (stored as vec2)
  100028. * @param uniform defines the webGL uniform location where to store the value
  100029. * @param array defines the array of number to store
  100030. */
  100031. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  100032. /**
  100033. * Set the value of an uniform to an array of number (stored as vec3)
  100034. * @param uniform defines the webGL uniform location where to store the value
  100035. * @param array defines the array of number to store
  100036. */
  100037. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  100038. /**
  100039. * Set the value of an uniform to an array of number (stored as vec4)
  100040. * @param uniform defines the webGL uniform location where to store the value
  100041. * @param array defines the array of number to store
  100042. */
  100043. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  100044. /**
  100045. * Set the value of an uniform to an array of float32 (stored as matrices)
  100046. * @param uniform defines the webGL uniform location where to store the value
  100047. * @param matrices defines the array of float32 to store
  100048. */
  100049. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  100050. /**
  100051. * Set the value of an uniform to a matrix (3x3)
  100052. * @param uniform defines the webGL uniform location where to store the value
  100053. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  100054. */
  100055. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  100056. /**
  100057. * Set the value of an uniform to a matrix (2x2)
  100058. * @param uniform defines the webGL uniform location where to store the value
  100059. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  100060. */
  100061. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  100062. /**
  100063. * Set the value of an uniform to a number (float)
  100064. * @param uniform defines the webGL uniform location where to store the value
  100065. * @param value defines the float number to store
  100066. */
  100067. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  100068. /**
  100069. * Set the value of an uniform to a vec2
  100070. * @param uniform defines the webGL uniform location where to store the value
  100071. * @param x defines the 1st component of the value
  100072. * @param y defines the 2nd component of the value
  100073. */
  100074. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  100075. /**
  100076. * Set the value of an uniform to a vec3
  100077. * @param uniform defines the webGL uniform location where to store the value
  100078. * @param x defines the 1st component of the value
  100079. * @param y defines the 2nd component of the value
  100080. * @param z defines the 3rd component of the value
  100081. */
  100082. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  100083. /**
  100084. * Set the value of an uniform to a vec4
  100085. * @param uniform defines the webGL uniform location where to store the value
  100086. * @param x defines the 1st component of the value
  100087. * @param y defines the 2nd component of the value
  100088. * @param z defines the 3rd component of the value
  100089. * @param w defines the 4th component of the value
  100090. */
  100091. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  100092. /**
  100093. * Gets the depth culling state manager
  100094. */
  100095. readonly depthCullingState: DepthCullingState;
  100096. /**
  100097. * Gets the alpha state manager
  100098. */
  100099. readonly alphaState: AlphaState;
  100100. /**
  100101. * Gets the stencil state manager
  100102. */
  100103. readonly stencilState: StencilState;
  100104. /**
  100105. * Clears the list of texture accessible through engine.
  100106. * This can help preventing texture load conflict due to name collision.
  100107. */
  100108. clearInternalTexturesCache(): void;
  100109. /**
  100110. * Force the entire cache to be cleared
  100111. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  100112. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  100113. */
  100114. wipeCaches(bruteForce?: boolean): void;
  100115. /** @hidden */
  100116. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  100117. min: number;
  100118. mag: number;
  100119. };
  100120. /** @hidden */
  100121. _createTexture(): WebGLTexture;
  100122. /**
  100123. * Usually called from Texture.ts.
  100124. * Passed information to create a WebGLTexture
  100125. * @param urlArg defines a value which contains one of the following:
  100126. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  100127. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  100128. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  100129. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  100130. * @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)
  100131. * @param scene needed for loading to the correct scene
  100132. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  100133. * @param onLoad optional callback to be called upon successful completion
  100134. * @param onError optional callback to be called upon failure
  100135. * @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
  100136. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  100137. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  100138. * @param forcedExtension defines the extension to use to pick the right loader
  100139. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  100140. * @param mimeType defines an optional mime type
  100141. * @returns a InternalTexture for assignment back into BABYLON.Texture
  100142. */
  100143. 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;
  100144. /**
  100145. * @hidden
  100146. */
  100147. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  100148. /**
  100149. * Creates a raw texture
  100150. * @param data defines the data to store in the texture
  100151. * @param width defines the width of the texture
  100152. * @param height defines the height of the texture
  100153. * @param format defines the format of the data
  100154. * @param generateMipMaps defines if the engine should generate the mip levels
  100155. * @param invertY defines if data must be stored with Y axis inverted
  100156. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  100157. * @param compression defines the compression used (null by default)
  100158. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  100159. * @returns the raw texture inside an InternalTexture
  100160. */
  100161. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  100162. /**
  100163. * Creates a new raw cube texture
  100164. * @param data defines the array of data to use to create each face
  100165. * @param size defines the size of the textures
  100166. * @param format defines the format of the data
  100167. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  100168. * @param generateMipMaps defines if the engine should generate the mip levels
  100169. * @param invertY defines if data must be stored with Y axis inverted
  100170. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  100171. * @param compression defines the compression used (null by default)
  100172. * @returns the cube texture as an InternalTexture
  100173. */
  100174. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  100175. /**
  100176. * Creates a new raw 3D texture
  100177. * @param data defines the data used to create the texture
  100178. * @param width defines the width of the texture
  100179. * @param height defines the height of the texture
  100180. * @param depth defines the depth of the texture
  100181. * @param format defines the format of the texture
  100182. * @param generateMipMaps defines if the engine must generate mip levels
  100183. * @param invertY defines if data must be stored with Y axis inverted
  100184. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  100185. * @param compression defines the compressed used (can be null)
  100186. * @param textureType defines the compressed used (can be null)
  100187. * @returns a new raw 3D texture (stored in an InternalTexture)
  100188. */
  100189. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  100190. /**
  100191. * Creates a new raw 2D array texture
  100192. * @param data defines the data used to create the texture
  100193. * @param width defines the width of the texture
  100194. * @param height defines the height of the texture
  100195. * @param depth defines the number of layers of the texture
  100196. * @param format defines the format of the texture
  100197. * @param generateMipMaps defines if the engine must generate mip levels
  100198. * @param invertY defines if data must be stored with Y axis inverted
  100199. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  100200. * @param compression defines the compressed used (can be null)
  100201. * @param textureType defines the compressed used (can be null)
  100202. * @returns a new raw 2D array texture (stored in an InternalTexture)
  100203. */
  100204. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  100205. private _unpackFlipYCached;
  100206. /**
  100207. * In case you are sharing the context with other applications, it might
  100208. * be interested to not cache the unpack flip y state to ensure a consistent
  100209. * value would be set.
  100210. */
  100211. enableUnpackFlipYCached: boolean;
  100212. /** @hidden */
  100213. _unpackFlipY(value: boolean): void;
  100214. /** @hidden */
  100215. _getUnpackAlignement(): number;
  100216. /**
  100217. * Update the sampling mode of a given texture
  100218. * @param samplingMode defines the required sampling mode
  100219. * @param texture defines the texture to update
  100220. */
  100221. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  100222. /** @hidden */
  100223. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  100224. width: number;
  100225. height: number;
  100226. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  100227. /** @hidden */
  100228. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100229. /** @hidden */
  100230. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  100231. /** @hidden */
  100232. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100233. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  100234. private _prepareWebGLTexture;
  100235. /** @hidden */
  100236. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  100237. /** @hidden */
  100238. _releaseFramebufferObjects(texture: InternalTexture): void;
  100239. /** @hidden */
  100240. _releaseTexture(texture: InternalTexture): void;
  100241. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  100242. protected _setProgram(program: WebGLProgram): void;
  100243. protected _boundUniforms: {
  100244. [key: number]: WebGLUniformLocation;
  100245. };
  100246. /**
  100247. * Binds an effect to the webGL context
  100248. * @param effect defines the effect to bind
  100249. */
  100250. bindSamplers(effect: Effect): void;
  100251. private _activateCurrentTexture;
  100252. /** @hidden */
  100253. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  100254. /** @hidden */
  100255. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  100256. /**
  100257. * Unbind all textures from the webGL context
  100258. */
  100259. unbindAllTextures(): void;
  100260. /**
  100261. * Sets a texture to the according uniform.
  100262. * @param channel The texture channel
  100263. * @param uniform The uniform to set
  100264. * @param texture The texture to apply
  100265. */
  100266. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  100267. private _bindSamplerUniformToChannel;
  100268. private _getTextureWrapMode;
  100269. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  100270. /**
  100271. * Sets an array of texture to the webGL context
  100272. * @param channel defines the channel where the texture array must be set
  100273. * @param uniform defines the associated uniform location
  100274. * @param textures defines the array of textures to bind
  100275. */
  100276. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  100277. /** @hidden */
  100278. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  100279. private _setTextureParameterFloat;
  100280. private _setTextureParameterInteger;
  100281. /**
  100282. * Unbind all vertex attributes from the webGL context
  100283. */
  100284. unbindAllAttributes(): void;
  100285. /**
  100286. * 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
  100287. */
  100288. releaseEffects(): void;
  100289. /**
  100290. * Dispose and release all associated resources
  100291. */
  100292. dispose(): void;
  100293. /**
  100294. * Attach a new callback raised when context lost event is fired
  100295. * @param callback defines the callback to call
  100296. */
  100297. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  100298. /**
  100299. * Attach a new callback raised when context restored event is fired
  100300. * @param callback defines the callback to call
  100301. */
  100302. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  100303. /**
  100304. * Get the current error code of the webGL context
  100305. * @returns the error code
  100306. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  100307. */
  100308. getError(): number;
  100309. private _canRenderToFloatFramebuffer;
  100310. private _canRenderToHalfFloatFramebuffer;
  100311. private _canRenderToFramebuffer;
  100312. /** @hidden */
  100313. _getWebGLTextureType(type: number): number;
  100314. /** @hidden */
  100315. _getInternalFormat(format: number): number;
  100316. /** @hidden */
  100317. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  100318. /** @hidden */
  100319. _getRGBAMultiSampleBufferFormat(type: number): number;
  100320. /** @hidden */
  100321. _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;
  100322. /**
  100323. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  100324. * @returns true if the engine can be created
  100325. * @ignorenaming
  100326. */
  100327. static isSupported(): boolean;
  100328. /**
  100329. * Find the next highest power of two.
  100330. * @param x Number to start search from.
  100331. * @return Next highest power of two.
  100332. */
  100333. static CeilingPOT(x: number): number;
  100334. /**
  100335. * Find the next lowest power of two.
  100336. * @param x Number to start search from.
  100337. * @return Next lowest power of two.
  100338. */
  100339. static FloorPOT(x: number): number;
  100340. /**
  100341. * Find the nearest power of two.
  100342. * @param x Number to start search from.
  100343. * @return Next nearest power of two.
  100344. */
  100345. static NearestPOT(x: number): number;
  100346. /**
  100347. * Get the closest exponent of two
  100348. * @param value defines the value to approximate
  100349. * @param max defines the maximum value to return
  100350. * @param mode defines how to define the closest value
  100351. * @returns closest exponent of two of the given value
  100352. */
  100353. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  100354. /**
  100355. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  100356. * @param func - the function to be called
  100357. * @param requester - the object that will request the next frame. Falls back to window.
  100358. * @returns frame number
  100359. */
  100360. static QueueNewFrame(func: () => void, requester?: any): number;
  100361. /**
  100362. * Gets host document
  100363. * @returns the host document object
  100364. */
  100365. getHostDocument(): Document;
  100366. }
  100367. }
  100368. declare module BABYLON {
  100369. /**
  100370. * Class representing spherical harmonics coefficients to the 3rd degree
  100371. */
  100372. export class SphericalHarmonics {
  100373. /**
  100374. * Defines whether or not the harmonics have been prescaled for rendering.
  100375. */
  100376. preScaled: boolean;
  100377. /**
  100378. * The l0,0 coefficients of the spherical harmonics
  100379. */
  100380. l00: Vector3;
  100381. /**
  100382. * The l1,-1 coefficients of the spherical harmonics
  100383. */
  100384. l1_1: Vector3;
  100385. /**
  100386. * The l1,0 coefficients of the spherical harmonics
  100387. */
  100388. l10: Vector3;
  100389. /**
  100390. * The l1,1 coefficients of the spherical harmonics
  100391. */
  100392. l11: Vector3;
  100393. /**
  100394. * The l2,-2 coefficients of the spherical harmonics
  100395. */
  100396. l2_2: Vector3;
  100397. /**
  100398. * The l2,-1 coefficients of the spherical harmonics
  100399. */
  100400. l2_1: Vector3;
  100401. /**
  100402. * The l2,0 coefficients of the spherical harmonics
  100403. */
  100404. l20: Vector3;
  100405. /**
  100406. * The l2,1 coefficients of the spherical harmonics
  100407. */
  100408. l21: Vector3;
  100409. /**
  100410. * The l2,2 coefficients of the spherical harmonics
  100411. */
  100412. l22: Vector3;
  100413. /**
  100414. * Adds a light to the spherical harmonics
  100415. * @param direction the direction of the light
  100416. * @param color the color of the light
  100417. * @param deltaSolidAngle the delta solid angle of the light
  100418. */
  100419. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  100420. /**
  100421. * Scales the spherical harmonics by the given amount
  100422. * @param scale the amount to scale
  100423. */
  100424. scaleInPlace(scale: number): void;
  100425. /**
  100426. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  100427. *
  100428. * ```
  100429. * E_lm = A_l * L_lm
  100430. * ```
  100431. *
  100432. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  100433. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  100434. * the scaling factors are given in equation 9.
  100435. */
  100436. convertIncidentRadianceToIrradiance(): void;
  100437. /**
  100438. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  100439. *
  100440. * ```
  100441. * L = (1/pi) * E * rho
  100442. * ```
  100443. *
  100444. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  100445. */
  100446. convertIrradianceToLambertianRadiance(): void;
  100447. /**
  100448. * Integrates the reconstruction coefficients directly in to the SH preventing further
  100449. * required operations at run time.
  100450. *
  100451. * This is simply done by scaling back the SH with Ylm constants parameter.
  100452. * The trigonometric part being applied by the shader at run time.
  100453. */
  100454. preScaleForRendering(): void;
  100455. /**
  100456. * Constructs a spherical harmonics from an array.
  100457. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  100458. * @returns the spherical harmonics
  100459. */
  100460. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  100461. /**
  100462. * Gets the spherical harmonics from polynomial
  100463. * @param polynomial the spherical polynomial
  100464. * @returns the spherical harmonics
  100465. */
  100466. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  100467. }
  100468. /**
  100469. * Class representing spherical polynomial coefficients to the 3rd degree
  100470. */
  100471. export class SphericalPolynomial {
  100472. private _harmonics;
  100473. /**
  100474. * The spherical harmonics used to create the polynomials.
  100475. */
  100476. readonly preScaledHarmonics: SphericalHarmonics;
  100477. /**
  100478. * The x coefficients of the spherical polynomial
  100479. */
  100480. x: Vector3;
  100481. /**
  100482. * The y coefficients of the spherical polynomial
  100483. */
  100484. y: Vector3;
  100485. /**
  100486. * The z coefficients of the spherical polynomial
  100487. */
  100488. z: Vector3;
  100489. /**
  100490. * The xx coefficients of the spherical polynomial
  100491. */
  100492. xx: Vector3;
  100493. /**
  100494. * The yy coefficients of the spherical polynomial
  100495. */
  100496. yy: Vector3;
  100497. /**
  100498. * The zz coefficients of the spherical polynomial
  100499. */
  100500. zz: Vector3;
  100501. /**
  100502. * The xy coefficients of the spherical polynomial
  100503. */
  100504. xy: Vector3;
  100505. /**
  100506. * The yz coefficients of the spherical polynomial
  100507. */
  100508. yz: Vector3;
  100509. /**
  100510. * The zx coefficients of the spherical polynomial
  100511. */
  100512. zx: Vector3;
  100513. /**
  100514. * Adds an ambient color to the spherical polynomial
  100515. * @param color the color to add
  100516. */
  100517. addAmbient(color: Color3): void;
  100518. /**
  100519. * Scales the spherical polynomial by the given amount
  100520. * @param scale the amount to scale
  100521. */
  100522. scaleInPlace(scale: number): void;
  100523. /**
  100524. * Gets the spherical polynomial from harmonics
  100525. * @param harmonics the spherical harmonics
  100526. * @returns the spherical polynomial
  100527. */
  100528. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  100529. /**
  100530. * Constructs a spherical polynomial from an array.
  100531. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  100532. * @returns the spherical polynomial
  100533. */
  100534. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  100535. }
  100536. }
  100537. declare module BABYLON {
  100538. /**
  100539. * Defines the source of the internal texture
  100540. */
  100541. export enum InternalTextureSource {
  100542. /**
  100543. * The source of the texture data is unknown
  100544. */
  100545. Unknown = 0,
  100546. /**
  100547. * Texture data comes from an URL
  100548. */
  100549. Url = 1,
  100550. /**
  100551. * Texture data is only used for temporary storage
  100552. */
  100553. Temp = 2,
  100554. /**
  100555. * Texture data comes from raw data (ArrayBuffer)
  100556. */
  100557. Raw = 3,
  100558. /**
  100559. * Texture content is dynamic (video or dynamic texture)
  100560. */
  100561. Dynamic = 4,
  100562. /**
  100563. * Texture content is generated by rendering to it
  100564. */
  100565. RenderTarget = 5,
  100566. /**
  100567. * Texture content is part of a multi render target process
  100568. */
  100569. MultiRenderTarget = 6,
  100570. /**
  100571. * Texture data comes from a cube data file
  100572. */
  100573. Cube = 7,
  100574. /**
  100575. * Texture data comes from a raw cube data
  100576. */
  100577. CubeRaw = 8,
  100578. /**
  100579. * Texture data come from a prefiltered cube data file
  100580. */
  100581. CubePrefiltered = 9,
  100582. /**
  100583. * Texture content is raw 3D data
  100584. */
  100585. Raw3D = 10,
  100586. /**
  100587. * Texture content is raw 2D array data
  100588. */
  100589. Raw2DArray = 11,
  100590. /**
  100591. * Texture content is a depth texture
  100592. */
  100593. Depth = 12,
  100594. /**
  100595. * Texture data comes from a raw cube data encoded with RGBD
  100596. */
  100597. CubeRawRGBD = 13
  100598. }
  100599. /**
  100600. * Class used to store data associated with WebGL texture data for the engine
  100601. * This class should not be used directly
  100602. */
  100603. export class InternalTexture {
  100604. /** @hidden */
  100605. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  100606. /**
  100607. * Defines if the texture is ready
  100608. */
  100609. isReady: boolean;
  100610. /**
  100611. * Defines if the texture is a cube texture
  100612. */
  100613. isCube: boolean;
  100614. /**
  100615. * Defines if the texture contains 3D data
  100616. */
  100617. is3D: boolean;
  100618. /**
  100619. * Defines if the texture contains 2D array data
  100620. */
  100621. is2DArray: boolean;
  100622. /**
  100623. * Defines if the texture contains multiview data
  100624. */
  100625. isMultiview: boolean;
  100626. /**
  100627. * Gets the URL used to load this texture
  100628. */
  100629. url: string;
  100630. /**
  100631. * Gets the sampling mode of the texture
  100632. */
  100633. samplingMode: number;
  100634. /**
  100635. * Gets a boolean indicating if the texture needs mipmaps generation
  100636. */
  100637. generateMipMaps: boolean;
  100638. /**
  100639. * Gets the number of samples used by the texture (WebGL2+ only)
  100640. */
  100641. samples: number;
  100642. /**
  100643. * Gets the type of the texture (int, float...)
  100644. */
  100645. type: number;
  100646. /**
  100647. * Gets the format of the texture (RGB, RGBA...)
  100648. */
  100649. format: number;
  100650. /**
  100651. * Observable called when the texture is loaded
  100652. */
  100653. onLoadedObservable: Observable<InternalTexture>;
  100654. /**
  100655. * Gets the width of the texture
  100656. */
  100657. width: number;
  100658. /**
  100659. * Gets the height of the texture
  100660. */
  100661. height: number;
  100662. /**
  100663. * Gets the depth of the texture
  100664. */
  100665. depth: number;
  100666. /**
  100667. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  100668. */
  100669. baseWidth: number;
  100670. /**
  100671. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  100672. */
  100673. baseHeight: number;
  100674. /**
  100675. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  100676. */
  100677. baseDepth: number;
  100678. /**
  100679. * Gets a boolean indicating if the texture is inverted on Y axis
  100680. */
  100681. invertY: boolean;
  100682. /** @hidden */
  100683. _invertVScale: boolean;
  100684. /** @hidden */
  100685. _associatedChannel: number;
  100686. /** @hidden */
  100687. _source: InternalTextureSource;
  100688. /** @hidden */
  100689. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  100690. /** @hidden */
  100691. _bufferView: Nullable<ArrayBufferView>;
  100692. /** @hidden */
  100693. _bufferViewArray: Nullable<ArrayBufferView[]>;
  100694. /** @hidden */
  100695. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  100696. /** @hidden */
  100697. _size: number;
  100698. /** @hidden */
  100699. _extension: string;
  100700. /** @hidden */
  100701. _files: Nullable<string[]>;
  100702. /** @hidden */
  100703. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  100704. /** @hidden */
  100705. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  100706. /** @hidden */
  100707. _framebuffer: Nullable<WebGLFramebuffer>;
  100708. /** @hidden */
  100709. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  100710. /** @hidden */
  100711. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  100712. /** @hidden */
  100713. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  100714. /** @hidden */
  100715. _attachments: Nullable<number[]>;
  100716. /** @hidden */
  100717. _cachedCoordinatesMode: Nullable<number>;
  100718. /** @hidden */
  100719. _cachedWrapU: Nullable<number>;
  100720. /** @hidden */
  100721. _cachedWrapV: Nullable<number>;
  100722. /** @hidden */
  100723. _cachedWrapR: Nullable<number>;
  100724. /** @hidden */
  100725. _cachedAnisotropicFilteringLevel: Nullable<number>;
  100726. /** @hidden */
  100727. _isDisabled: boolean;
  100728. /** @hidden */
  100729. _compression: Nullable<string>;
  100730. /** @hidden */
  100731. _generateStencilBuffer: boolean;
  100732. /** @hidden */
  100733. _generateDepthBuffer: boolean;
  100734. /** @hidden */
  100735. _comparisonFunction: number;
  100736. /** @hidden */
  100737. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  100738. /** @hidden */
  100739. _lodGenerationScale: number;
  100740. /** @hidden */
  100741. _lodGenerationOffset: number;
  100742. /** @hidden */
  100743. _colorTextureArray: Nullable<WebGLTexture>;
  100744. /** @hidden */
  100745. _depthStencilTextureArray: Nullable<WebGLTexture>;
  100746. /** @hidden */
  100747. _lodTextureHigh: Nullable<BaseTexture>;
  100748. /** @hidden */
  100749. _lodTextureMid: Nullable<BaseTexture>;
  100750. /** @hidden */
  100751. _lodTextureLow: Nullable<BaseTexture>;
  100752. /** @hidden */
  100753. _isRGBD: boolean;
  100754. /** @hidden */
  100755. _linearSpecularLOD: boolean;
  100756. /** @hidden */
  100757. _irradianceTexture: Nullable<BaseTexture>;
  100758. /** @hidden */
  100759. _webGLTexture: Nullable<WebGLTexture>;
  100760. /** @hidden */
  100761. _references: number;
  100762. private _engine;
  100763. /**
  100764. * Gets the Engine the texture belongs to.
  100765. * @returns The babylon engine
  100766. */
  100767. getEngine(): ThinEngine;
  100768. /**
  100769. * Gets the data source type of the texture
  100770. */
  100771. readonly source: InternalTextureSource;
  100772. /**
  100773. * Creates a new InternalTexture
  100774. * @param engine defines the engine to use
  100775. * @param source defines the type of data that will be used
  100776. * @param delayAllocation if the texture allocation should be delayed (default: false)
  100777. */
  100778. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  100779. /**
  100780. * Increments the number of references (ie. the number of Texture that point to it)
  100781. */
  100782. incrementReferences(): void;
  100783. /**
  100784. * Change the size of the texture (not the size of the content)
  100785. * @param width defines the new width
  100786. * @param height defines the new height
  100787. * @param depth defines the new depth (1 by default)
  100788. */
  100789. updateSize(width: int, height: int, depth?: int): void;
  100790. /** @hidden */
  100791. _rebuild(): void;
  100792. /** @hidden */
  100793. _swapAndDie(target: InternalTexture): void;
  100794. /**
  100795. * Dispose the current allocated resources
  100796. */
  100797. dispose(): void;
  100798. }
  100799. }
  100800. declare module BABYLON {
  100801. /**
  100802. * Class used to work with sound analyzer using fast fourier transform (FFT)
  100803. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100804. */
  100805. export class Analyser {
  100806. /**
  100807. * Gets or sets the smoothing
  100808. * @ignorenaming
  100809. */
  100810. SMOOTHING: number;
  100811. /**
  100812. * Gets or sets the FFT table size
  100813. * @ignorenaming
  100814. */
  100815. FFT_SIZE: number;
  100816. /**
  100817. * Gets or sets the bar graph amplitude
  100818. * @ignorenaming
  100819. */
  100820. BARGRAPHAMPLITUDE: number;
  100821. /**
  100822. * Gets or sets the position of the debug canvas
  100823. * @ignorenaming
  100824. */
  100825. DEBUGCANVASPOS: {
  100826. x: number;
  100827. y: number;
  100828. };
  100829. /**
  100830. * Gets or sets the debug canvas size
  100831. * @ignorenaming
  100832. */
  100833. DEBUGCANVASSIZE: {
  100834. width: number;
  100835. height: number;
  100836. };
  100837. private _byteFreqs;
  100838. private _byteTime;
  100839. private _floatFreqs;
  100840. private _webAudioAnalyser;
  100841. private _debugCanvas;
  100842. private _debugCanvasContext;
  100843. private _scene;
  100844. private _registerFunc;
  100845. private _audioEngine;
  100846. /**
  100847. * Creates a new analyser
  100848. * @param scene defines hosting scene
  100849. */
  100850. constructor(scene: Scene);
  100851. /**
  100852. * Get the number of data values you will have to play with for the visualization
  100853. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  100854. * @returns a number
  100855. */
  100856. getFrequencyBinCount(): number;
  100857. /**
  100858. * Gets the current frequency data as a byte array
  100859. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  100860. * @returns a Uint8Array
  100861. */
  100862. getByteFrequencyData(): Uint8Array;
  100863. /**
  100864. * Gets the current waveform as a byte array
  100865. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  100866. * @returns a Uint8Array
  100867. */
  100868. getByteTimeDomainData(): Uint8Array;
  100869. /**
  100870. * Gets the current frequency data as a float array
  100871. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  100872. * @returns a Float32Array
  100873. */
  100874. getFloatFrequencyData(): Float32Array;
  100875. /**
  100876. * Renders the debug canvas
  100877. */
  100878. drawDebugCanvas(): void;
  100879. /**
  100880. * Stops rendering the debug canvas and removes it
  100881. */
  100882. stopDebugCanvas(): void;
  100883. /**
  100884. * Connects two audio nodes
  100885. * @param inputAudioNode defines first node to connect
  100886. * @param outputAudioNode defines second node to connect
  100887. */
  100888. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  100889. /**
  100890. * Releases all associated resources
  100891. */
  100892. dispose(): void;
  100893. }
  100894. }
  100895. declare module BABYLON {
  100896. /**
  100897. * This represents an audio engine and it is responsible
  100898. * to play, synchronize and analyse sounds throughout the application.
  100899. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100900. */
  100901. export interface IAudioEngine extends IDisposable {
  100902. /**
  100903. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  100904. */
  100905. readonly canUseWebAudio: boolean;
  100906. /**
  100907. * Gets the current AudioContext if available.
  100908. */
  100909. readonly audioContext: Nullable<AudioContext>;
  100910. /**
  100911. * The master gain node defines the global audio volume of your audio engine.
  100912. */
  100913. readonly masterGain: GainNode;
  100914. /**
  100915. * Gets whether or not mp3 are supported by your browser.
  100916. */
  100917. readonly isMP3supported: boolean;
  100918. /**
  100919. * Gets whether or not ogg are supported by your browser.
  100920. */
  100921. readonly isOGGsupported: boolean;
  100922. /**
  100923. * Defines if Babylon should emit a warning if WebAudio is not supported.
  100924. * @ignoreNaming
  100925. */
  100926. WarnedWebAudioUnsupported: boolean;
  100927. /**
  100928. * Defines if the audio engine relies on a custom unlocked button.
  100929. * In this case, the embedded button will not be displayed.
  100930. */
  100931. useCustomUnlockedButton: boolean;
  100932. /**
  100933. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  100934. */
  100935. readonly unlocked: boolean;
  100936. /**
  100937. * Event raised when audio has been unlocked on the browser.
  100938. */
  100939. onAudioUnlockedObservable: Observable<AudioEngine>;
  100940. /**
  100941. * Event raised when audio has been locked on the browser.
  100942. */
  100943. onAudioLockedObservable: Observable<AudioEngine>;
  100944. /**
  100945. * Flags the audio engine in Locked state.
  100946. * This happens due to new browser policies preventing audio to autoplay.
  100947. */
  100948. lock(): void;
  100949. /**
  100950. * Unlocks the audio engine once a user action has been done on the dom.
  100951. * This is helpful to resume play once browser policies have been satisfied.
  100952. */
  100953. unlock(): void;
  100954. }
  100955. /**
  100956. * This represents the default audio engine used in babylon.
  100957. * It is responsible to play, synchronize and analyse sounds throughout the application.
  100958. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100959. */
  100960. export class AudioEngine implements IAudioEngine {
  100961. private _audioContext;
  100962. private _audioContextInitialized;
  100963. private _muteButton;
  100964. private _hostElement;
  100965. /**
  100966. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  100967. */
  100968. canUseWebAudio: boolean;
  100969. /**
  100970. * The master gain node defines the global audio volume of your audio engine.
  100971. */
  100972. masterGain: GainNode;
  100973. /**
  100974. * Defines if Babylon should emit a warning if WebAudio is not supported.
  100975. * @ignoreNaming
  100976. */
  100977. WarnedWebAudioUnsupported: boolean;
  100978. /**
  100979. * Gets whether or not mp3 are supported by your browser.
  100980. */
  100981. isMP3supported: boolean;
  100982. /**
  100983. * Gets whether or not ogg are supported by your browser.
  100984. */
  100985. isOGGsupported: boolean;
  100986. /**
  100987. * Gets whether audio has been unlocked on the device.
  100988. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  100989. * a user interaction has happened.
  100990. */
  100991. unlocked: boolean;
  100992. /**
  100993. * Defines if the audio engine relies on a custom unlocked button.
  100994. * In this case, the embedded button will not be displayed.
  100995. */
  100996. useCustomUnlockedButton: boolean;
  100997. /**
  100998. * Event raised when audio has been unlocked on the browser.
  100999. */
  101000. onAudioUnlockedObservable: Observable<AudioEngine>;
  101001. /**
  101002. * Event raised when audio has been locked on the browser.
  101003. */
  101004. onAudioLockedObservable: Observable<AudioEngine>;
  101005. /**
  101006. * Gets the current AudioContext if available.
  101007. */
  101008. readonly audioContext: Nullable<AudioContext>;
  101009. private _connectedAnalyser;
  101010. /**
  101011. * Instantiates a new audio engine.
  101012. *
  101013. * There should be only one per page as some browsers restrict the number
  101014. * of audio contexts you can create.
  101015. * @param hostElement defines the host element where to display the mute icon if necessary
  101016. */
  101017. constructor(hostElement?: Nullable<HTMLElement>);
  101018. /**
  101019. * Flags the audio engine in Locked state.
  101020. * This happens due to new browser policies preventing audio to autoplay.
  101021. */
  101022. lock(): void;
  101023. /**
  101024. * Unlocks the audio engine once a user action has been done on the dom.
  101025. * This is helpful to resume play once browser policies have been satisfied.
  101026. */
  101027. unlock(): void;
  101028. private _resumeAudioContext;
  101029. private _initializeAudioContext;
  101030. private _tryToRun;
  101031. private _triggerRunningState;
  101032. private _triggerSuspendedState;
  101033. private _displayMuteButton;
  101034. private _moveButtonToTopLeft;
  101035. private _onResize;
  101036. private _hideMuteButton;
  101037. /**
  101038. * Destroy and release the resources associated with the audio ccontext.
  101039. */
  101040. dispose(): void;
  101041. /**
  101042. * Gets the global volume sets on the master gain.
  101043. * @returns the global volume if set or -1 otherwise
  101044. */
  101045. getGlobalVolume(): number;
  101046. /**
  101047. * Sets the global volume of your experience (sets on the master gain).
  101048. * @param newVolume Defines the new global volume of the application
  101049. */
  101050. setGlobalVolume(newVolume: number): void;
  101051. /**
  101052. * Connect the audio engine to an audio analyser allowing some amazing
  101053. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  101054. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  101055. * @param analyser The analyser to connect to the engine
  101056. */
  101057. connectToAnalyser(analyser: Analyser): void;
  101058. }
  101059. }
  101060. declare module BABYLON {
  101061. /**
  101062. * Interface used to present a loading screen while loading a scene
  101063. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  101064. */
  101065. export interface ILoadingScreen {
  101066. /**
  101067. * Function called to display the loading screen
  101068. */
  101069. displayLoadingUI: () => void;
  101070. /**
  101071. * Function called to hide the loading screen
  101072. */
  101073. hideLoadingUI: () => void;
  101074. /**
  101075. * Gets or sets the color to use for the background
  101076. */
  101077. loadingUIBackgroundColor: string;
  101078. /**
  101079. * Gets or sets the text to display while loading
  101080. */
  101081. loadingUIText: string;
  101082. }
  101083. /**
  101084. * Class used for the default loading screen
  101085. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  101086. */
  101087. export class DefaultLoadingScreen implements ILoadingScreen {
  101088. private _renderingCanvas;
  101089. private _loadingText;
  101090. private _loadingDivBackgroundColor;
  101091. private _loadingDiv;
  101092. private _loadingTextDiv;
  101093. /** Gets or sets the logo url to use for the default loading screen */
  101094. static DefaultLogoUrl: string;
  101095. /** Gets or sets the spinner url to use for the default loading screen */
  101096. static DefaultSpinnerUrl: string;
  101097. /**
  101098. * Creates a new default loading screen
  101099. * @param _renderingCanvas defines the canvas used to render the scene
  101100. * @param _loadingText defines the default text to display
  101101. * @param _loadingDivBackgroundColor defines the default background color
  101102. */
  101103. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  101104. /**
  101105. * Function called to display the loading screen
  101106. */
  101107. displayLoadingUI(): void;
  101108. /**
  101109. * Function called to hide the loading screen
  101110. */
  101111. hideLoadingUI(): void;
  101112. /**
  101113. * Gets or sets the text to display while loading
  101114. */
  101115. loadingUIText: string;
  101116. /**
  101117. * Gets or sets the color to use for the background
  101118. */
  101119. loadingUIBackgroundColor: string;
  101120. private _resizeLoadingUI;
  101121. }
  101122. }
  101123. declare module BABYLON {
  101124. /**
  101125. * Interface for any object that can request an animation frame
  101126. */
  101127. export interface ICustomAnimationFrameRequester {
  101128. /**
  101129. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  101130. */
  101131. renderFunction?: Function;
  101132. /**
  101133. * Called to request the next frame to render to
  101134. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  101135. */
  101136. requestAnimationFrame: Function;
  101137. /**
  101138. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  101139. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  101140. */
  101141. requestID?: number;
  101142. }
  101143. }
  101144. declare module BABYLON {
  101145. /**
  101146. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  101147. */
  101148. export class PerformanceMonitor {
  101149. private _enabled;
  101150. private _rollingFrameTime;
  101151. private _lastFrameTimeMs;
  101152. /**
  101153. * constructor
  101154. * @param frameSampleSize The number of samples required to saturate the sliding window
  101155. */
  101156. constructor(frameSampleSize?: number);
  101157. /**
  101158. * Samples current frame
  101159. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  101160. */
  101161. sampleFrame(timeMs?: number): void;
  101162. /**
  101163. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  101164. */
  101165. readonly averageFrameTime: number;
  101166. /**
  101167. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  101168. */
  101169. readonly averageFrameTimeVariance: number;
  101170. /**
  101171. * Returns the frame time of the most recent frame
  101172. */
  101173. readonly instantaneousFrameTime: number;
  101174. /**
  101175. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  101176. */
  101177. readonly averageFPS: number;
  101178. /**
  101179. * Returns the average framerate in frames per second using the most recent frame time
  101180. */
  101181. readonly instantaneousFPS: number;
  101182. /**
  101183. * Returns true if enough samples have been taken to completely fill the sliding window
  101184. */
  101185. readonly isSaturated: boolean;
  101186. /**
  101187. * Enables contributions to the sliding window sample set
  101188. */
  101189. enable(): void;
  101190. /**
  101191. * Disables contributions to the sliding window sample set
  101192. * Samples will not be interpolated over the disabled period
  101193. */
  101194. disable(): void;
  101195. /**
  101196. * Returns true if sampling is enabled
  101197. */
  101198. readonly isEnabled: boolean;
  101199. /**
  101200. * Resets performance monitor
  101201. */
  101202. reset(): void;
  101203. }
  101204. /**
  101205. * RollingAverage
  101206. *
  101207. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  101208. */
  101209. export class RollingAverage {
  101210. /**
  101211. * Current average
  101212. */
  101213. average: number;
  101214. /**
  101215. * Current variance
  101216. */
  101217. variance: number;
  101218. protected _samples: Array<number>;
  101219. protected _sampleCount: number;
  101220. protected _pos: number;
  101221. protected _m2: number;
  101222. /**
  101223. * constructor
  101224. * @param length The number of samples required to saturate the sliding window
  101225. */
  101226. constructor(length: number);
  101227. /**
  101228. * Adds a sample to the sample set
  101229. * @param v The sample value
  101230. */
  101231. add(v: number): void;
  101232. /**
  101233. * Returns previously added values or null if outside of history or outside the sliding window domain
  101234. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  101235. * @return Value previously recorded with add() or null if outside of range
  101236. */
  101237. history(i: number): number;
  101238. /**
  101239. * Returns true if enough samples have been taken to completely fill the sliding window
  101240. * @return true if sample-set saturated
  101241. */
  101242. isSaturated(): boolean;
  101243. /**
  101244. * Resets the rolling average (equivalent to 0 samples taken so far)
  101245. */
  101246. reset(): void;
  101247. /**
  101248. * Wraps a value around the sample range boundaries
  101249. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  101250. * @return Wrapped position in sample range
  101251. */
  101252. protected _wrapPosition(i: number): number;
  101253. }
  101254. }
  101255. declare module BABYLON {
  101256. /**
  101257. * This class is used to track a performance counter which is number based.
  101258. * The user has access to many properties which give statistics of different nature.
  101259. *
  101260. * The implementer can track two kinds of Performance Counter: time and count.
  101261. * 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.
  101262. * 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.
  101263. */
  101264. export class PerfCounter {
  101265. /**
  101266. * Gets or sets a global boolean to turn on and off all the counters
  101267. */
  101268. static Enabled: boolean;
  101269. /**
  101270. * Returns the smallest value ever
  101271. */
  101272. readonly min: number;
  101273. /**
  101274. * Returns the biggest value ever
  101275. */
  101276. readonly max: number;
  101277. /**
  101278. * Returns the average value since the performance counter is running
  101279. */
  101280. readonly average: number;
  101281. /**
  101282. * Returns the average value of the last second the counter was monitored
  101283. */
  101284. readonly lastSecAverage: number;
  101285. /**
  101286. * Returns the current value
  101287. */
  101288. readonly current: number;
  101289. /**
  101290. * Gets the accumulated total
  101291. */
  101292. readonly total: number;
  101293. /**
  101294. * Gets the total value count
  101295. */
  101296. readonly count: number;
  101297. /**
  101298. * Creates a new counter
  101299. */
  101300. constructor();
  101301. /**
  101302. * Call this method to start monitoring a new frame.
  101303. * 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.
  101304. */
  101305. fetchNewFrame(): void;
  101306. /**
  101307. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  101308. * @param newCount the count value to add to the monitored count
  101309. * @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.
  101310. */
  101311. addCount(newCount: number, fetchResult: boolean): void;
  101312. /**
  101313. * Start monitoring this performance counter
  101314. */
  101315. beginMonitoring(): void;
  101316. /**
  101317. * Compute the time lapsed since the previous beginMonitoring() call.
  101318. * @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
  101319. */
  101320. endMonitoring(newFrame?: boolean): void;
  101321. private _fetchResult;
  101322. private _startMonitoringTime;
  101323. private _min;
  101324. private _max;
  101325. private _average;
  101326. private _current;
  101327. private _totalValueCount;
  101328. private _totalAccumulated;
  101329. private _lastSecAverage;
  101330. private _lastSecAccumulated;
  101331. private _lastSecTime;
  101332. private _lastSecValueCount;
  101333. }
  101334. }
  101335. declare module BABYLON {
  101336. /**
  101337. * Defines the interface used by display changed events
  101338. */
  101339. export interface IDisplayChangedEventArgs {
  101340. /** Gets the vrDisplay object (if any) */
  101341. vrDisplay: Nullable<any>;
  101342. /** Gets a boolean indicating if webVR is supported */
  101343. vrSupported: boolean;
  101344. }
  101345. /**
  101346. * Defines the interface used by objects containing a viewport (like a camera)
  101347. */
  101348. interface IViewportOwnerLike {
  101349. /**
  101350. * Gets or sets the viewport
  101351. */
  101352. viewport: IViewportLike;
  101353. }
  101354. /**
  101355. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  101356. */
  101357. export class Engine extends ThinEngine {
  101358. /** Defines that alpha blending is disabled */
  101359. static readonly ALPHA_DISABLE: number;
  101360. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  101361. static readonly ALPHA_ADD: number;
  101362. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  101363. static readonly ALPHA_COMBINE: number;
  101364. /** Defines that alpha blending to DEST - SRC * DEST */
  101365. static readonly ALPHA_SUBTRACT: number;
  101366. /** Defines that alpha blending to SRC * DEST */
  101367. static readonly ALPHA_MULTIPLY: number;
  101368. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  101369. static readonly ALPHA_MAXIMIZED: number;
  101370. /** Defines that alpha blending to SRC + DEST */
  101371. static readonly ALPHA_ONEONE: number;
  101372. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  101373. static readonly ALPHA_PREMULTIPLIED: number;
  101374. /**
  101375. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  101376. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  101377. */
  101378. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  101379. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  101380. static readonly ALPHA_INTERPOLATE: number;
  101381. /**
  101382. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  101383. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  101384. */
  101385. static readonly ALPHA_SCREENMODE: number;
  101386. /** Defines that the ressource is not delayed*/
  101387. static readonly DELAYLOADSTATE_NONE: number;
  101388. /** Defines that the ressource was successfully delay loaded */
  101389. static readonly DELAYLOADSTATE_LOADED: number;
  101390. /** Defines that the ressource is currently delay loading */
  101391. static readonly DELAYLOADSTATE_LOADING: number;
  101392. /** Defines that the ressource is delayed and has not started loading */
  101393. static readonly DELAYLOADSTATE_NOTLOADED: number;
  101394. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  101395. static readonly NEVER: number;
  101396. /** 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 */
  101397. static readonly ALWAYS: number;
  101398. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  101399. static readonly LESS: number;
  101400. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  101401. static readonly EQUAL: number;
  101402. /** 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 */
  101403. static readonly LEQUAL: number;
  101404. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  101405. static readonly GREATER: number;
  101406. /** 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 */
  101407. static readonly GEQUAL: number;
  101408. /** 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 */
  101409. static readonly NOTEQUAL: number;
  101410. /** Passed to stencilOperation to specify that stencil value must be kept */
  101411. static readonly KEEP: number;
  101412. /** Passed to stencilOperation to specify that stencil value must be replaced */
  101413. static readonly REPLACE: number;
  101414. /** Passed to stencilOperation to specify that stencil value must be incremented */
  101415. static readonly INCR: number;
  101416. /** Passed to stencilOperation to specify that stencil value must be decremented */
  101417. static readonly DECR: number;
  101418. /** Passed to stencilOperation to specify that stencil value must be inverted */
  101419. static readonly INVERT: number;
  101420. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  101421. static readonly INCR_WRAP: number;
  101422. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  101423. static readonly DECR_WRAP: number;
  101424. /** Texture is not repeating outside of 0..1 UVs */
  101425. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  101426. /** Texture is repeating outside of 0..1 UVs */
  101427. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  101428. /** Texture is repeating and mirrored */
  101429. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  101430. /** ALPHA */
  101431. static readonly TEXTUREFORMAT_ALPHA: number;
  101432. /** LUMINANCE */
  101433. static readonly TEXTUREFORMAT_LUMINANCE: number;
  101434. /** LUMINANCE_ALPHA */
  101435. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  101436. /** RGB */
  101437. static readonly TEXTUREFORMAT_RGB: number;
  101438. /** RGBA */
  101439. static readonly TEXTUREFORMAT_RGBA: number;
  101440. /** RED */
  101441. static readonly TEXTUREFORMAT_RED: number;
  101442. /** RED (2nd reference) */
  101443. static readonly TEXTUREFORMAT_R: number;
  101444. /** RG */
  101445. static readonly TEXTUREFORMAT_RG: number;
  101446. /** RED_INTEGER */
  101447. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  101448. /** RED_INTEGER (2nd reference) */
  101449. static readonly TEXTUREFORMAT_R_INTEGER: number;
  101450. /** RG_INTEGER */
  101451. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  101452. /** RGB_INTEGER */
  101453. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  101454. /** RGBA_INTEGER */
  101455. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  101456. /** UNSIGNED_BYTE */
  101457. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  101458. /** UNSIGNED_BYTE (2nd reference) */
  101459. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  101460. /** FLOAT */
  101461. static readonly TEXTURETYPE_FLOAT: number;
  101462. /** HALF_FLOAT */
  101463. static readonly TEXTURETYPE_HALF_FLOAT: number;
  101464. /** BYTE */
  101465. static readonly TEXTURETYPE_BYTE: number;
  101466. /** SHORT */
  101467. static readonly TEXTURETYPE_SHORT: number;
  101468. /** UNSIGNED_SHORT */
  101469. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  101470. /** INT */
  101471. static readonly TEXTURETYPE_INT: number;
  101472. /** UNSIGNED_INT */
  101473. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  101474. /** UNSIGNED_SHORT_4_4_4_4 */
  101475. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  101476. /** UNSIGNED_SHORT_5_5_5_1 */
  101477. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  101478. /** UNSIGNED_SHORT_5_6_5 */
  101479. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  101480. /** UNSIGNED_INT_2_10_10_10_REV */
  101481. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  101482. /** UNSIGNED_INT_24_8 */
  101483. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  101484. /** UNSIGNED_INT_10F_11F_11F_REV */
  101485. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  101486. /** UNSIGNED_INT_5_9_9_9_REV */
  101487. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  101488. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  101489. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  101490. /** nearest is mag = nearest and min = nearest and mip = linear */
  101491. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  101492. /** Bilinear is mag = linear and min = linear and mip = nearest */
  101493. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  101494. /** Trilinear is mag = linear and min = linear and mip = linear */
  101495. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  101496. /** nearest is mag = nearest and min = nearest and mip = linear */
  101497. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  101498. /** Bilinear is mag = linear and min = linear and mip = nearest */
  101499. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  101500. /** Trilinear is mag = linear and min = linear and mip = linear */
  101501. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  101502. /** mag = nearest and min = nearest and mip = nearest */
  101503. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  101504. /** mag = nearest and min = linear and mip = nearest */
  101505. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  101506. /** mag = nearest and min = linear and mip = linear */
  101507. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  101508. /** mag = nearest and min = linear and mip = none */
  101509. static readonly TEXTURE_NEAREST_LINEAR: number;
  101510. /** mag = nearest and min = nearest and mip = none */
  101511. static readonly TEXTURE_NEAREST_NEAREST: number;
  101512. /** mag = linear and min = nearest and mip = nearest */
  101513. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  101514. /** mag = linear and min = nearest and mip = linear */
  101515. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  101516. /** mag = linear and min = linear and mip = none */
  101517. static readonly TEXTURE_LINEAR_LINEAR: number;
  101518. /** mag = linear and min = nearest and mip = none */
  101519. static readonly TEXTURE_LINEAR_NEAREST: number;
  101520. /** Explicit coordinates mode */
  101521. static readonly TEXTURE_EXPLICIT_MODE: number;
  101522. /** Spherical coordinates mode */
  101523. static readonly TEXTURE_SPHERICAL_MODE: number;
  101524. /** Planar coordinates mode */
  101525. static readonly TEXTURE_PLANAR_MODE: number;
  101526. /** Cubic coordinates mode */
  101527. static readonly TEXTURE_CUBIC_MODE: number;
  101528. /** Projection coordinates mode */
  101529. static readonly TEXTURE_PROJECTION_MODE: number;
  101530. /** Skybox coordinates mode */
  101531. static readonly TEXTURE_SKYBOX_MODE: number;
  101532. /** Inverse Cubic coordinates mode */
  101533. static readonly TEXTURE_INVCUBIC_MODE: number;
  101534. /** Equirectangular coordinates mode */
  101535. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  101536. /** Equirectangular Fixed coordinates mode */
  101537. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  101538. /** Equirectangular Fixed Mirrored coordinates mode */
  101539. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  101540. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  101541. static readonly SCALEMODE_FLOOR: number;
  101542. /** Defines that texture rescaling will look for the nearest power of 2 size */
  101543. static readonly SCALEMODE_NEAREST: number;
  101544. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  101545. static readonly SCALEMODE_CEILING: number;
  101546. /**
  101547. * Returns the current npm package of the sdk
  101548. */
  101549. static readonly NpmPackage: string;
  101550. /**
  101551. * Returns the current version of the framework
  101552. */
  101553. static readonly Version: string;
  101554. /** Gets the list of created engines */
  101555. static readonly Instances: Engine[];
  101556. /**
  101557. * Gets the latest created engine
  101558. */
  101559. static readonly LastCreatedEngine: Nullable<Engine>;
  101560. /**
  101561. * Gets the latest created scene
  101562. */
  101563. static readonly LastCreatedScene: Nullable<Scene>;
  101564. /**
  101565. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  101566. * @param flag defines which part of the materials must be marked as dirty
  101567. * @param predicate defines a predicate used to filter which materials should be affected
  101568. */
  101569. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  101570. /**
  101571. * Method called to create the default loading screen.
  101572. * This can be overriden in your own app.
  101573. * @param canvas The rendering canvas element
  101574. * @returns The loading screen
  101575. */
  101576. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  101577. /**
  101578. * Method called to create the default rescale post process on each engine.
  101579. */
  101580. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  101581. /**
  101582. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  101583. **/
  101584. enableOfflineSupport: boolean;
  101585. /**
  101586. * 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)
  101587. **/
  101588. disableManifestCheck: boolean;
  101589. /**
  101590. * Gets the list of created scenes
  101591. */
  101592. scenes: Scene[];
  101593. /**
  101594. * Event raised when a new scene is created
  101595. */
  101596. onNewSceneAddedObservable: Observable<Scene>;
  101597. /**
  101598. * Gets the list of created postprocesses
  101599. */
  101600. postProcesses: PostProcess[];
  101601. /**
  101602. * Gets a boolean indicating if the pointer is currently locked
  101603. */
  101604. isPointerLock: boolean;
  101605. /**
  101606. * Observable event triggered each time the rendering canvas is resized
  101607. */
  101608. onResizeObservable: Observable<Engine>;
  101609. /**
  101610. * Observable event triggered each time the canvas loses focus
  101611. */
  101612. onCanvasBlurObservable: Observable<Engine>;
  101613. /**
  101614. * Observable event triggered each time the canvas gains focus
  101615. */
  101616. onCanvasFocusObservable: Observable<Engine>;
  101617. /**
  101618. * Observable event triggered each time the canvas receives pointerout event
  101619. */
  101620. onCanvasPointerOutObservable: Observable<PointerEvent>;
  101621. /**
  101622. * Observable raised when the engine begins a new frame
  101623. */
  101624. onBeginFrameObservable: Observable<Engine>;
  101625. /**
  101626. * If set, will be used to request the next animation frame for the render loop
  101627. */
  101628. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  101629. /**
  101630. * Observable raised when the engine ends the current frame
  101631. */
  101632. onEndFrameObservable: Observable<Engine>;
  101633. /**
  101634. * Observable raised when the engine is about to compile a shader
  101635. */
  101636. onBeforeShaderCompilationObservable: Observable<Engine>;
  101637. /**
  101638. * Observable raised when the engine has jsut compiled a shader
  101639. */
  101640. onAfterShaderCompilationObservable: Observable<Engine>;
  101641. /**
  101642. * Gets the audio engine
  101643. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101644. * @ignorenaming
  101645. */
  101646. static audioEngine: IAudioEngine;
  101647. /**
  101648. * Default AudioEngine factory responsible of creating the Audio Engine.
  101649. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  101650. */
  101651. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  101652. /**
  101653. * Default offline support factory responsible of creating a tool used to store data locally.
  101654. * By default, this will create a Database object if the workload has been embedded.
  101655. */
  101656. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  101657. private _loadingScreen;
  101658. private _pointerLockRequested;
  101659. private _dummyFramebuffer;
  101660. private _rescalePostProcess;
  101661. /** @hidden */
  101662. protected _alphaMode: number;
  101663. /** @hidden */
  101664. protected _alphaEquation: number;
  101665. private _deterministicLockstep;
  101666. private _lockstepMaxSteps;
  101667. private _timeStep;
  101668. protected readonly _supportsHardwareTextureRescaling: boolean;
  101669. private _fps;
  101670. private _deltaTime;
  101671. /** @hidden */
  101672. _drawCalls: PerfCounter;
  101673. /**
  101674. * Turn this value on if you want to pause FPS computation when in background
  101675. */
  101676. disablePerformanceMonitorInBackground: boolean;
  101677. private _performanceMonitor;
  101678. /**
  101679. * Gets the performance monitor attached to this engine
  101680. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  101681. */
  101682. readonly performanceMonitor: PerformanceMonitor;
  101683. private _onFocus;
  101684. private _onBlur;
  101685. private _onCanvasPointerOut;
  101686. private _onCanvasBlur;
  101687. private _onCanvasFocus;
  101688. private _onFullscreenChange;
  101689. private _onPointerLockChange;
  101690. /**
  101691. * Gets the HTML element used to attach event listeners
  101692. * @returns a HTML element
  101693. */
  101694. getInputElement(): Nullable<HTMLElement>;
  101695. /**
  101696. * Creates a new engine
  101697. * @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
  101698. * @param antialias defines enable antialiasing (default: false)
  101699. * @param options defines further options to be sent to the getContext() function
  101700. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  101701. */
  101702. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  101703. /**
  101704. * Gets current aspect ratio
  101705. * @param viewportOwner defines the camera to use to get the aspect ratio
  101706. * @param useScreen defines if screen size must be used (or the current render target if any)
  101707. * @returns a number defining the aspect ratio
  101708. */
  101709. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  101710. /**
  101711. * Gets current screen aspect ratio
  101712. * @returns a number defining the aspect ratio
  101713. */
  101714. getScreenAspectRatio(): number;
  101715. /**
  101716. * Gets the client rect of the HTML canvas attached with the current webGL context
  101717. * @returns a client rectanglee
  101718. */
  101719. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  101720. /**
  101721. * Gets the client rect of the HTML element used for events
  101722. * @returns a client rectanglee
  101723. */
  101724. getInputElementClientRect(): Nullable<ClientRect>;
  101725. /**
  101726. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  101727. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101728. * @returns true if engine is in deterministic lock step mode
  101729. */
  101730. isDeterministicLockStep(): boolean;
  101731. /**
  101732. * Gets the max steps when engine is running in deterministic lock step
  101733. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101734. * @returns the max steps
  101735. */
  101736. getLockstepMaxSteps(): number;
  101737. /**
  101738. * Returns the time in ms between steps when using deterministic lock step.
  101739. * @returns time step in (ms)
  101740. */
  101741. getTimeStep(): number;
  101742. /**
  101743. * Force the mipmap generation for the given render target texture
  101744. * @param texture defines the render target texture to use
  101745. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  101746. */
  101747. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  101748. /** States */
  101749. /**
  101750. * Set various states to the webGL context
  101751. * @param culling defines backface culling state
  101752. * @param zOffset defines the value to apply to zOffset (0 by default)
  101753. * @param force defines if states must be applied even if cache is up to date
  101754. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  101755. */
  101756. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  101757. /**
  101758. * Set the z offset to apply to current rendering
  101759. * @param value defines the offset to apply
  101760. */
  101761. setZOffset(value: number): void;
  101762. /**
  101763. * Gets the current value of the zOffset
  101764. * @returns the current zOffset state
  101765. */
  101766. getZOffset(): number;
  101767. /**
  101768. * Enable or disable depth buffering
  101769. * @param enable defines the state to set
  101770. */
  101771. setDepthBuffer(enable: boolean): void;
  101772. /**
  101773. * Gets a boolean indicating if depth writing is enabled
  101774. * @returns the current depth writing state
  101775. */
  101776. getDepthWrite(): boolean;
  101777. /**
  101778. * Enable or disable depth writing
  101779. * @param enable defines the state to set
  101780. */
  101781. setDepthWrite(enable: boolean): void;
  101782. /**
  101783. * Enable or disable color writing
  101784. * @param enable defines the state to set
  101785. */
  101786. setColorWrite(enable: boolean): void;
  101787. /**
  101788. * Gets a boolean indicating if color writing is enabled
  101789. * @returns the current color writing state
  101790. */
  101791. getColorWrite(): boolean;
  101792. /**
  101793. * Sets alpha constants used by some alpha blending modes
  101794. * @param r defines the red component
  101795. * @param g defines the green component
  101796. * @param b defines the blue component
  101797. * @param a defines the alpha component
  101798. */
  101799. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  101800. /**
  101801. * Sets the current alpha mode
  101802. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  101803. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  101804. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  101805. */
  101806. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  101807. /**
  101808. * Gets the current alpha mode
  101809. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  101810. * @returns the current alpha mode
  101811. */
  101812. getAlphaMode(): number;
  101813. /**
  101814. * Sets the current alpha equation
  101815. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  101816. */
  101817. setAlphaEquation(equation: number): void;
  101818. /**
  101819. * Gets the current alpha equation.
  101820. * @returns the current alpha equation
  101821. */
  101822. getAlphaEquation(): number;
  101823. /**
  101824. * Gets a boolean indicating if stencil buffer is enabled
  101825. * @returns the current stencil buffer state
  101826. */
  101827. getStencilBuffer(): boolean;
  101828. /**
  101829. * Enable or disable the stencil buffer
  101830. * @param enable defines if the stencil buffer must be enabled or disabled
  101831. */
  101832. setStencilBuffer(enable: boolean): void;
  101833. /**
  101834. * Gets the current stencil mask
  101835. * @returns a number defining the new stencil mask to use
  101836. */
  101837. getStencilMask(): number;
  101838. /**
  101839. * Sets the current stencil mask
  101840. * @param mask defines the new stencil mask to use
  101841. */
  101842. setStencilMask(mask: number): void;
  101843. /**
  101844. * Gets the current stencil function
  101845. * @returns a number defining the stencil function to use
  101846. */
  101847. getStencilFunction(): number;
  101848. /**
  101849. * Gets the current stencil reference value
  101850. * @returns a number defining the stencil reference value to use
  101851. */
  101852. getStencilFunctionReference(): number;
  101853. /**
  101854. * Gets the current stencil mask
  101855. * @returns a number defining the stencil mask to use
  101856. */
  101857. getStencilFunctionMask(): number;
  101858. /**
  101859. * Sets the current stencil function
  101860. * @param stencilFunc defines the new stencil function to use
  101861. */
  101862. setStencilFunction(stencilFunc: number): void;
  101863. /**
  101864. * Sets the current stencil reference
  101865. * @param reference defines the new stencil reference to use
  101866. */
  101867. setStencilFunctionReference(reference: number): void;
  101868. /**
  101869. * Sets the current stencil mask
  101870. * @param mask defines the new stencil mask to use
  101871. */
  101872. setStencilFunctionMask(mask: number): void;
  101873. /**
  101874. * Gets the current stencil operation when stencil fails
  101875. * @returns a number defining stencil operation to use when stencil fails
  101876. */
  101877. getStencilOperationFail(): number;
  101878. /**
  101879. * Gets the current stencil operation when depth fails
  101880. * @returns a number defining stencil operation to use when depth fails
  101881. */
  101882. getStencilOperationDepthFail(): number;
  101883. /**
  101884. * Gets the current stencil operation when stencil passes
  101885. * @returns a number defining stencil operation to use when stencil passes
  101886. */
  101887. getStencilOperationPass(): number;
  101888. /**
  101889. * Sets the stencil operation to use when stencil fails
  101890. * @param operation defines the stencil operation to use when stencil fails
  101891. */
  101892. setStencilOperationFail(operation: number): void;
  101893. /**
  101894. * Sets the stencil operation to use when depth fails
  101895. * @param operation defines the stencil operation to use when depth fails
  101896. */
  101897. setStencilOperationDepthFail(operation: number): void;
  101898. /**
  101899. * Sets the stencil operation to use when stencil passes
  101900. * @param operation defines the stencil operation to use when stencil passes
  101901. */
  101902. setStencilOperationPass(operation: number): void;
  101903. /**
  101904. * Sets a boolean indicating if the dithering state is enabled or disabled
  101905. * @param value defines the dithering state
  101906. */
  101907. setDitheringState(value: boolean): void;
  101908. /**
  101909. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  101910. * @param value defines the rasterizer state
  101911. */
  101912. setRasterizerState(value: boolean): void;
  101913. /**
  101914. * Gets the current depth function
  101915. * @returns a number defining the depth function
  101916. */
  101917. getDepthFunction(): Nullable<number>;
  101918. /**
  101919. * Sets the current depth function
  101920. * @param depthFunc defines the function to use
  101921. */
  101922. setDepthFunction(depthFunc: number): void;
  101923. /**
  101924. * Sets the current depth function to GREATER
  101925. */
  101926. setDepthFunctionToGreater(): void;
  101927. /**
  101928. * Sets the current depth function to GEQUAL
  101929. */
  101930. setDepthFunctionToGreaterOrEqual(): void;
  101931. /**
  101932. * Sets the current depth function to LESS
  101933. */
  101934. setDepthFunctionToLess(): void;
  101935. /**
  101936. * Sets the current depth function to LEQUAL
  101937. */
  101938. setDepthFunctionToLessOrEqual(): void;
  101939. private _cachedStencilBuffer;
  101940. private _cachedStencilFunction;
  101941. private _cachedStencilMask;
  101942. private _cachedStencilOperationPass;
  101943. private _cachedStencilOperationFail;
  101944. private _cachedStencilOperationDepthFail;
  101945. private _cachedStencilReference;
  101946. /**
  101947. * Caches the the state of the stencil buffer
  101948. */
  101949. cacheStencilState(): void;
  101950. /**
  101951. * Restores the state of the stencil buffer
  101952. */
  101953. restoreStencilState(): void;
  101954. /**
  101955. * Directly set the WebGL Viewport
  101956. * @param x defines the x coordinate of the viewport (in screen space)
  101957. * @param y defines the y coordinate of the viewport (in screen space)
  101958. * @param width defines the width of the viewport (in screen space)
  101959. * @param height defines the height of the viewport (in screen space)
  101960. * @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
  101961. */
  101962. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  101963. /**
  101964. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  101965. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  101966. * @param y defines the y-coordinate of the corner of the clear rectangle
  101967. * @param width defines the width of the clear rectangle
  101968. * @param height defines the height of the clear rectangle
  101969. * @param clearColor defines the clear color
  101970. */
  101971. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  101972. /**
  101973. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  101974. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  101975. * @param y defines the y-coordinate of the corner of the clear rectangle
  101976. * @param width defines the width of the clear rectangle
  101977. * @param height defines the height of the clear rectangle
  101978. */
  101979. enableScissor(x: number, y: number, width: number, height: number): void;
  101980. /**
  101981. * Disable previously set scissor test rectangle
  101982. */
  101983. disableScissor(): void;
  101984. protected _reportDrawCall(): void;
  101985. /**
  101986. * Initializes a webVR display and starts listening to display change events
  101987. * The onVRDisplayChangedObservable will be notified upon these changes
  101988. * @returns The onVRDisplayChangedObservable
  101989. */
  101990. initWebVR(): Observable<IDisplayChangedEventArgs>;
  101991. /** @hidden */
  101992. _prepareVRComponent(): void;
  101993. /** @hidden */
  101994. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  101995. /** @hidden */
  101996. _submitVRFrame(): void;
  101997. /**
  101998. * Call this function to leave webVR mode
  101999. * Will do nothing if webVR is not supported or if there is no webVR device
  102000. * @see http://doc.babylonjs.com/how_to/webvr_camera
  102001. */
  102002. disableVR(): void;
  102003. /**
  102004. * Gets a boolean indicating that the system is in VR mode and is presenting
  102005. * @returns true if VR mode is engaged
  102006. */
  102007. isVRPresenting(): boolean;
  102008. /** @hidden */
  102009. _requestVRFrame(): void;
  102010. /** @hidden */
  102011. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  102012. /**
  102013. * Gets the source code of the vertex shader associated with a specific webGL program
  102014. * @param program defines the program to use
  102015. * @returns a string containing the source code of the vertex shader associated with the program
  102016. */
  102017. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  102018. /**
  102019. * Gets the source code of the fragment shader associated with a specific webGL program
  102020. * @param program defines the program to use
  102021. * @returns a string containing the source code of the fragment shader associated with the program
  102022. */
  102023. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  102024. /**
  102025. * Reads pixels from the current frame buffer. Please note that this function can be slow
  102026. * @param x defines the x coordinate of the rectangle where pixels must be read
  102027. * @param y defines the y coordinate of the rectangle where pixels must be read
  102028. * @param width defines the width of the rectangle where pixels must be read
  102029. * @param height defines the height of the rectangle where pixels must be read
  102030. * @returns a Uint8Array containing RGBA colors
  102031. */
  102032. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  102033. /**
  102034. * Sets a depth stencil texture from a render target to the according uniform.
  102035. * @param channel The texture channel
  102036. * @param uniform The uniform to set
  102037. * @param texture The render target texture containing the depth stencil texture to apply
  102038. */
  102039. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  102040. /**
  102041. * Sets a texture to the webGL context from a postprocess
  102042. * @param channel defines the channel to use
  102043. * @param postProcess defines the source postprocess
  102044. */
  102045. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  102046. /**
  102047. * Binds the output of the passed in post process to the texture channel specified
  102048. * @param channel The channel the texture should be bound to
  102049. * @param postProcess The post process which's output should be bound
  102050. */
  102051. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  102052. /** @hidden */
  102053. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  102054. protected _rebuildBuffers(): void;
  102055. /** @hidden */
  102056. _renderFrame(): void;
  102057. _renderLoop(): void;
  102058. /** @hidden */
  102059. _renderViews(): boolean;
  102060. /**
  102061. * Toggle full screen mode
  102062. * @param requestPointerLock defines if a pointer lock should be requested from the user
  102063. */
  102064. switchFullscreen(requestPointerLock: boolean): void;
  102065. /**
  102066. * Enters full screen mode
  102067. * @param requestPointerLock defines if a pointer lock should be requested from the user
  102068. */
  102069. enterFullscreen(requestPointerLock: boolean): void;
  102070. /**
  102071. * Exits full screen mode
  102072. */
  102073. exitFullscreen(): void;
  102074. /**
  102075. * Enters Pointerlock mode
  102076. */
  102077. enterPointerlock(): void;
  102078. /**
  102079. * Exits Pointerlock mode
  102080. */
  102081. exitPointerlock(): void;
  102082. /**
  102083. * Begin a new frame
  102084. */
  102085. beginFrame(): void;
  102086. /**
  102087. * Enf the current frame
  102088. */
  102089. endFrame(): void;
  102090. resize(): void;
  102091. /**
  102092. * Set the compressed texture format to use, based on the formats you have, and the formats
  102093. * supported by the hardware / browser.
  102094. *
  102095. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  102096. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  102097. * to API arguments needed to compressed textures. This puts the burden on the container
  102098. * generator to house the arcane code for determining these for current & future formats.
  102099. *
  102100. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  102101. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  102102. *
  102103. * Note: The result of this call is not taken into account when a texture is base64.
  102104. *
  102105. * @param formatsAvailable defines the list of those format families you have created
  102106. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  102107. *
  102108. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  102109. * @returns The extension selected.
  102110. */
  102111. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  102112. /**
  102113. * Set the compressed texture extensions or file names to skip.
  102114. *
  102115. * @param skippedFiles defines the list of those texture files you want to skip
  102116. * Example: [".dds", ".env", "myfile.png"]
  102117. */
  102118. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  102119. /**
  102120. * Force a specific size of the canvas
  102121. * @param width defines the new canvas' width
  102122. * @param height defines the new canvas' height
  102123. */
  102124. setSize(width: number, height: number): void;
  102125. /**
  102126. * Updates a dynamic vertex buffer.
  102127. * @param vertexBuffer the vertex buffer to update
  102128. * @param data the data used to update the vertex buffer
  102129. * @param byteOffset the byte offset of the data
  102130. * @param byteLength the byte length of the data
  102131. */
  102132. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  102133. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  102134. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  102135. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  102136. _releaseTexture(texture: InternalTexture): void;
  102137. /**
  102138. * @hidden
  102139. * Rescales a texture
  102140. * @param source input texutre
  102141. * @param destination destination texture
  102142. * @param scene scene to use to render the resize
  102143. * @param internalFormat format to use when resizing
  102144. * @param onComplete callback to be called when resize has completed
  102145. */
  102146. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  102147. /**
  102148. * Gets the current framerate
  102149. * @returns a number representing the framerate
  102150. */
  102151. getFps(): number;
  102152. /**
  102153. * Gets the time spent between current and previous frame
  102154. * @returns a number representing the delta time in ms
  102155. */
  102156. getDeltaTime(): number;
  102157. private _measureFps;
  102158. /** @hidden */
  102159. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  102160. /**
  102161. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  102162. * @param renderTarget The render target to set the frame buffer for
  102163. */
  102164. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  102165. /**
  102166. * Update a dynamic index buffer
  102167. * @param indexBuffer defines the target index buffer
  102168. * @param indices defines the data to update
  102169. * @param offset defines the offset in the target index buffer where update should start
  102170. */
  102171. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  102172. /**
  102173. * Updates the sample count of a render target texture
  102174. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  102175. * @param texture defines the texture to update
  102176. * @param samples defines the sample count to set
  102177. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  102178. */
  102179. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  102180. /**
  102181. * Updates a depth texture Comparison Mode and Function.
  102182. * If the comparison Function is equal to 0, the mode will be set to none.
  102183. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  102184. * @param texture The texture to set the comparison function for
  102185. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  102186. */
  102187. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  102188. /**
  102189. * Creates a webGL buffer to use with instanciation
  102190. * @param capacity defines the size of the buffer
  102191. * @returns the webGL buffer
  102192. */
  102193. createInstancesBuffer(capacity: number): DataBuffer;
  102194. /**
  102195. * Delete a webGL buffer used with instanciation
  102196. * @param buffer defines the webGL buffer to delete
  102197. */
  102198. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  102199. /** @hidden */
  102200. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  102201. dispose(): void;
  102202. private _disableTouchAction;
  102203. /**
  102204. * Display the loading screen
  102205. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102206. */
  102207. displayLoadingUI(): void;
  102208. /**
  102209. * Hide the loading screen
  102210. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102211. */
  102212. hideLoadingUI(): void;
  102213. /**
  102214. * Gets the current loading screen object
  102215. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102216. */
  102217. /**
  102218. * Sets the current loading screen object
  102219. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102220. */
  102221. loadingScreen: ILoadingScreen;
  102222. /**
  102223. * Sets the current loading screen text
  102224. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102225. */
  102226. loadingUIText: string;
  102227. /**
  102228. * Sets the current loading screen background color
  102229. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102230. */
  102231. loadingUIBackgroundColor: string;
  102232. /** Pointerlock and fullscreen */
  102233. /**
  102234. * Ask the browser to promote the current element to pointerlock mode
  102235. * @param element defines the DOM element to promote
  102236. */
  102237. static _RequestPointerlock(element: HTMLElement): void;
  102238. /**
  102239. * Asks the browser to exit pointerlock mode
  102240. */
  102241. static _ExitPointerlock(): void;
  102242. /**
  102243. * Ask the browser to promote the current element to fullscreen rendering mode
  102244. * @param element defines the DOM element to promote
  102245. */
  102246. static _RequestFullscreen(element: HTMLElement): void;
  102247. /**
  102248. * Asks the browser to exit fullscreen mode
  102249. */
  102250. static _ExitFullscreen(): void;
  102251. }
  102252. }
  102253. declare module BABYLON {
  102254. /**
  102255. * The engine store class is responsible to hold all the instances of Engine and Scene created
  102256. * during the life time of the application.
  102257. */
  102258. export class EngineStore {
  102259. /** Gets the list of created engines */
  102260. static Instances: Engine[];
  102261. /** @hidden */
  102262. static _LastCreatedScene: Nullable<Scene>;
  102263. /**
  102264. * Gets the latest created engine
  102265. */
  102266. static readonly LastCreatedEngine: Nullable<Engine>;
  102267. /**
  102268. * Gets the latest created scene
  102269. */
  102270. static readonly LastCreatedScene: Nullable<Scene>;
  102271. /**
  102272. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  102273. * @ignorenaming
  102274. */
  102275. static UseFallbackTexture: boolean;
  102276. /**
  102277. * Texture content used if a texture cannot loaded
  102278. * @ignorenaming
  102279. */
  102280. static FallbackTexture: string;
  102281. }
  102282. }
  102283. declare module BABYLON {
  102284. /**
  102285. * Helper class that provides a small promise polyfill
  102286. */
  102287. export class PromisePolyfill {
  102288. /**
  102289. * Static function used to check if the polyfill is required
  102290. * If this is the case then the function will inject the polyfill to window.Promise
  102291. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  102292. */
  102293. static Apply(force?: boolean): void;
  102294. }
  102295. }
  102296. declare module BABYLON {
  102297. /**
  102298. * Interface for screenshot methods with describe argument called `size` as object with options
  102299. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  102300. */
  102301. export interface IScreenshotSize {
  102302. /**
  102303. * number in pixels for canvas height
  102304. */
  102305. height?: number;
  102306. /**
  102307. * multiplier allowing render at a higher or lower resolution
  102308. * If value is defined then height and width will be ignored and taken from camera
  102309. */
  102310. precision?: number;
  102311. /**
  102312. * number in pixels for canvas width
  102313. */
  102314. width?: number;
  102315. }
  102316. }
  102317. declare module BABYLON {
  102318. interface IColor4Like {
  102319. r: float;
  102320. g: float;
  102321. b: float;
  102322. a: float;
  102323. }
  102324. /**
  102325. * Class containing a set of static utilities functions
  102326. */
  102327. export class Tools {
  102328. /**
  102329. * Gets or sets the base URL to use to load assets
  102330. */
  102331. static BaseUrl: string;
  102332. /**
  102333. * Enable/Disable Custom HTTP Request Headers globally.
  102334. * default = false
  102335. * @see CustomRequestHeaders
  102336. */
  102337. static UseCustomRequestHeaders: boolean;
  102338. /**
  102339. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  102340. * i.e. when loading files, where the server/service expects an Authorization header
  102341. */
  102342. static CustomRequestHeaders: {
  102343. [key: string]: string;
  102344. };
  102345. /**
  102346. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  102347. */
  102348. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  102349. /**
  102350. * Default behaviour for cors in the application.
  102351. * It can be a string if the expected behavior is identical in the entire app.
  102352. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  102353. */
  102354. static CorsBehavior: string | ((url: string | string[]) => string);
  102355. /**
  102356. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  102357. * @ignorenaming
  102358. */
  102359. static UseFallbackTexture: boolean;
  102360. /**
  102361. * Use this object to register external classes like custom textures or material
  102362. * to allow the laoders to instantiate them
  102363. */
  102364. static RegisteredExternalClasses: {
  102365. [key: string]: Object;
  102366. };
  102367. /**
  102368. * Texture content used if a texture cannot loaded
  102369. * @ignorenaming
  102370. */
  102371. static fallbackTexture: string;
  102372. /**
  102373. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  102374. * @param u defines the coordinate on X axis
  102375. * @param v defines the coordinate on Y axis
  102376. * @param width defines the width of the source data
  102377. * @param height defines the height of the source data
  102378. * @param pixels defines the source byte array
  102379. * @param color defines the output color
  102380. */
  102381. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  102382. /**
  102383. * Interpolates between a and b via alpha
  102384. * @param a The lower value (returned when alpha = 0)
  102385. * @param b The upper value (returned when alpha = 1)
  102386. * @param alpha The interpolation-factor
  102387. * @return The mixed value
  102388. */
  102389. static Mix(a: number, b: number, alpha: number): number;
  102390. /**
  102391. * Tries to instantiate a new object from a given class name
  102392. * @param className defines the class name to instantiate
  102393. * @returns the new object or null if the system was not able to do the instantiation
  102394. */
  102395. static Instantiate(className: string): any;
  102396. /**
  102397. * Provides a slice function that will work even on IE
  102398. * @param data defines the array to slice
  102399. * @param start defines the start of the data (optional)
  102400. * @param end defines the end of the data (optional)
  102401. * @returns the new sliced array
  102402. */
  102403. static Slice<T>(data: T, start?: number, end?: number): T;
  102404. /**
  102405. * Polyfill for setImmediate
  102406. * @param action defines the action to execute after the current execution block
  102407. */
  102408. static SetImmediate(action: () => void): void;
  102409. /**
  102410. * Function indicating if a number is an exponent of 2
  102411. * @param value defines the value to test
  102412. * @returns true if the value is an exponent of 2
  102413. */
  102414. static IsExponentOfTwo(value: number): boolean;
  102415. private static _tmpFloatArray;
  102416. /**
  102417. * Returns the nearest 32-bit single precision float representation of a Number
  102418. * @param value A Number. If the parameter is of a different type, it will get converted
  102419. * to a number or to NaN if it cannot be converted
  102420. * @returns number
  102421. */
  102422. static FloatRound(value: number): number;
  102423. /**
  102424. * Extracts the filename from a path
  102425. * @param path defines the path to use
  102426. * @returns the filename
  102427. */
  102428. static GetFilename(path: string): string;
  102429. /**
  102430. * Extracts the "folder" part of a path (everything before the filename).
  102431. * @param uri The URI to extract the info from
  102432. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  102433. * @returns The "folder" part of the path
  102434. */
  102435. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  102436. /**
  102437. * Extracts text content from a DOM element hierarchy
  102438. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  102439. */
  102440. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  102441. /**
  102442. * Convert an angle in radians to degrees
  102443. * @param angle defines the angle to convert
  102444. * @returns the angle in degrees
  102445. */
  102446. static ToDegrees(angle: number): number;
  102447. /**
  102448. * Convert an angle in degrees to radians
  102449. * @param angle defines the angle to convert
  102450. * @returns the angle in radians
  102451. */
  102452. static ToRadians(angle: number): number;
  102453. /**
  102454. * Returns an array if obj is not an array
  102455. * @param obj defines the object to evaluate as an array
  102456. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  102457. * @returns either obj directly if obj is an array or a new array containing obj
  102458. */
  102459. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  102460. /**
  102461. * Gets the pointer prefix to use
  102462. * @returns "pointer" if touch is enabled. Else returns "mouse"
  102463. */
  102464. static GetPointerPrefix(): string;
  102465. /**
  102466. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  102467. * @param url define the url we are trying
  102468. * @param element define the dom element where to configure the cors policy
  102469. */
  102470. static SetCorsBehavior(url: string | string[], element: {
  102471. crossOrigin: string | null;
  102472. }): void;
  102473. /**
  102474. * Removes unwanted characters from an url
  102475. * @param url defines the url to clean
  102476. * @returns the cleaned url
  102477. */
  102478. static CleanUrl(url: string): string;
  102479. /**
  102480. * Gets or sets a function used to pre-process url before using them to load assets
  102481. */
  102482. static PreprocessUrl: (url: string) => string;
  102483. /**
  102484. * Loads an image as an HTMLImageElement.
  102485. * @param input url string, ArrayBuffer, or Blob to load
  102486. * @param onLoad callback called when the image successfully loads
  102487. * @param onError callback called when the image fails to load
  102488. * @param offlineProvider offline provider for caching
  102489. * @param mimeType optional mime type
  102490. * @returns the HTMLImageElement of the loaded image
  102491. */
  102492. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  102493. /**
  102494. * Loads a file from a url
  102495. * @param url url string, ArrayBuffer, or Blob to load
  102496. * @param onSuccess callback called when the file successfully loads
  102497. * @param onProgress callback called while file is loading (if the server supports this mode)
  102498. * @param offlineProvider defines the offline provider for caching
  102499. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  102500. * @param onError callback called when the file fails to load
  102501. * @returns a file request object
  102502. */
  102503. 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;
  102504. /**
  102505. * Loads a file from a url
  102506. * @param url the file url to load
  102507. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  102508. */
  102509. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  102510. /**
  102511. * Load a script (identified by an url). When the url returns, the
  102512. * content of this file is added into a new script element, attached to the DOM (body element)
  102513. * @param scriptUrl defines the url of the script to laod
  102514. * @param onSuccess defines the callback called when the script is loaded
  102515. * @param onError defines the callback to call if an error occurs
  102516. * @param scriptId defines the id of the script element
  102517. */
  102518. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  102519. /**
  102520. * Load an asynchronous script (identified by an url). When the url returns, the
  102521. * content of this file is added into a new script element, attached to the DOM (body element)
  102522. * @param scriptUrl defines the url of the script to laod
  102523. * @param scriptId defines the id of the script element
  102524. * @returns a promise request object
  102525. */
  102526. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  102527. /**
  102528. * Loads a file from a blob
  102529. * @param fileToLoad defines the blob to use
  102530. * @param callback defines the callback to call when data is loaded
  102531. * @param progressCallback defines the callback to call during loading process
  102532. * @returns a file request object
  102533. */
  102534. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  102535. /**
  102536. * Reads a file from a File object
  102537. * @param file defines the file to load
  102538. * @param onSuccess defines the callback to call when data is loaded
  102539. * @param onProgress defines the callback to call during loading process
  102540. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  102541. * @param onError defines the callback to call when an error occurs
  102542. * @returns a file request object
  102543. */
  102544. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  102545. /**
  102546. * Creates a data url from a given string content
  102547. * @param content defines the content to convert
  102548. * @returns the new data url link
  102549. */
  102550. static FileAsURL(content: string): string;
  102551. /**
  102552. * Format the given number to a specific decimal format
  102553. * @param value defines the number to format
  102554. * @param decimals defines the number of decimals to use
  102555. * @returns the formatted string
  102556. */
  102557. static Format(value: number, decimals?: number): string;
  102558. /**
  102559. * Tries to copy an object by duplicating every property
  102560. * @param source defines the source object
  102561. * @param destination defines the target object
  102562. * @param doNotCopyList defines a list of properties to avoid
  102563. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  102564. */
  102565. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  102566. /**
  102567. * Gets a boolean indicating if the given object has no own property
  102568. * @param obj defines the object to test
  102569. * @returns true if object has no own property
  102570. */
  102571. static IsEmpty(obj: any): boolean;
  102572. /**
  102573. * Function used to register events at window level
  102574. * @param windowElement defines the Window object to use
  102575. * @param events defines the events to register
  102576. */
  102577. static RegisterTopRootEvents(windowElement: Window, events: {
  102578. name: string;
  102579. handler: Nullable<(e: FocusEvent) => any>;
  102580. }[]): void;
  102581. /**
  102582. * Function used to unregister events from window level
  102583. * @param windowElement defines the Window object to use
  102584. * @param events defines the events to unregister
  102585. */
  102586. static UnregisterTopRootEvents(windowElement: Window, events: {
  102587. name: string;
  102588. handler: Nullable<(e: FocusEvent) => any>;
  102589. }[]): void;
  102590. /**
  102591. * @ignore
  102592. */
  102593. static _ScreenshotCanvas: HTMLCanvasElement;
  102594. /**
  102595. * Dumps the current bound framebuffer
  102596. * @param width defines the rendering width
  102597. * @param height defines the rendering height
  102598. * @param engine defines the hosting engine
  102599. * @param successCallback defines the callback triggered once the data are available
  102600. * @param mimeType defines the mime type of the result
  102601. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  102602. */
  102603. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  102604. /**
  102605. * Converts the canvas data to blob.
  102606. * This acts as a polyfill for browsers not supporting the to blob function.
  102607. * @param canvas Defines the canvas to extract the data from
  102608. * @param successCallback Defines the callback triggered once the data are available
  102609. * @param mimeType Defines the mime type of the result
  102610. */
  102611. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  102612. /**
  102613. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  102614. * @param successCallback defines the callback triggered once the data are available
  102615. * @param mimeType defines the mime type of the result
  102616. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  102617. */
  102618. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  102619. /**
  102620. * Downloads a blob in the browser
  102621. * @param blob defines the blob to download
  102622. * @param fileName defines the name of the downloaded file
  102623. */
  102624. static Download(blob: Blob, fileName: string): void;
  102625. /**
  102626. * Captures a screenshot of the current rendering
  102627. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  102628. * @param engine defines the rendering engine
  102629. * @param camera defines the source camera
  102630. * @param size This parameter can be set to a single number or to an object with the
  102631. * following (optional) properties: precision, width, height. If a single number is passed,
  102632. * it will be used for both width and height. If an object is passed, the screenshot size
  102633. * will be derived from the parameters. The precision property is a multiplier allowing
  102634. * rendering at a higher or lower resolution
  102635. * @param successCallback defines the callback receives a single parameter which contains the
  102636. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  102637. * src parameter of an <img> to display it
  102638. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  102639. * Check your browser for supported MIME types
  102640. */
  102641. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  102642. /**
  102643. * Captures a screenshot of the current rendering
  102644. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  102645. * @param engine defines the rendering engine
  102646. * @param camera defines the source camera
  102647. * @param size This parameter can be set to a single number or to an object with the
  102648. * following (optional) properties: precision, width, height. If a single number is passed,
  102649. * it will be used for both width and height. If an object is passed, the screenshot size
  102650. * will be derived from the parameters. The precision property is a multiplier allowing
  102651. * rendering at a higher or lower resolution
  102652. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  102653. * Check your browser for supported MIME types
  102654. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  102655. * to the src parameter of an <img> to display it
  102656. */
  102657. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  102658. /**
  102659. * Generates an image screenshot from the specified camera.
  102660. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  102661. * @param engine The engine to use for rendering
  102662. * @param camera The camera to use for rendering
  102663. * @param size This parameter can be set to a single number or to an object with the
  102664. * following (optional) properties: precision, width, height. If a single number is passed,
  102665. * it will be used for both width and height. If an object is passed, the screenshot size
  102666. * will be derived from the parameters. The precision property is a multiplier allowing
  102667. * rendering at a higher or lower resolution
  102668. * @param successCallback The callback receives a single parameter which contains the
  102669. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  102670. * src parameter of an <img> to display it
  102671. * @param mimeType The MIME type of the screenshot image (default: image/png).
  102672. * Check your browser for supported MIME types
  102673. * @param samples Texture samples (default: 1)
  102674. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  102675. * @param fileName A name for for the downloaded file.
  102676. */
  102677. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  102678. /**
  102679. * Generates an image screenshot from the specified camera.
  102680. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  102681. * @param engine The engine to use for rendering
  102682. * @param camera The camera to use for rendering
  102683. * @param size This parameter can be set to a single number or to an object with the
  102684. * following (optional) properties: precision, width, height. If a single number is passed,
  102685. * it will be used for both width and height. If an object is passed, the screenshot size
  102686. * will be derived from the parameters. The precision property is a multiplier allowing
  102687. * rendering at a higher or lower resolution
  102688. * @param mimeType The MIME type of the screenshot image (default: image/png).
  102689. * Check your browser for supported MIME types
  102690. * @param samples Texture samples (default: 1)
  102691. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  102692. * @param fileName A name for for the downloaded file.
  102693. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  102694. * to the src parameter of an <img> to display it
  102695. */
  102696. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  102697. /**
  102698. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  102699. * Be aware Math.random() could cause collisions, but:
  102700. * "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"
  102701. * @returns a pseudo random id
  102702. */
  102703. static RandomId(): string;
  102704. /**
  102705. * Test if the given uri is a base64 string
  102706. * @param uri The uri to test
  102707. * @return True if the uri is a base64 string or false otherwise
  102708. */
  102709. static IsBase64(uri: string): boolean;
  102710. /**
  102711. * Decode the given base64 uri.
  102712. * @param uri The uri to decode
  102713. * @return The decoded base64 data.
  102714. */
  102715. static DecodeBase64(uri: string): ArrayBuffer;
  102716. /**
  102717. * Gets the absolute url.
  102718. * @param url the input url
  102719. * @return the absolute url
  102720. */
  102721. static GetAbsoluteUrl(url: string): string;
  102722. /**
  102723. * No log
  102724. */
  102725. static readonly NoneLogLevel: number;
  102726. /**
  102727. * Only message logs
  102728. */
  102729. static readonly MessageLogLevel: number;
  102730. /**
  102731. * Only warning logs
  102732. */
  102733. static readonly WarningLogLevel: number;
  102734. /**
  102735. * Only error logs
  102736. */
  102737. static readonly ErrorLogLevel: number;
  102738. /**
  102739. * All logs
  102740. */
  102741. static readonly AllLogLevel: number;
  102742. /**
  102743. * Gets a value indicating the number of loading errors
  102744. * @ignorenaming
  102745. */
  102746. static readonly errorsCount: number;
  102747. /**
  102748. * Callback called when a new log is added
  102749. */
  102750. static OnNewCacheEntry: (entry: string) => void;
  102751. /**
  102752. * Log a message to the console
  102753. * @param message defines the message to log
  102754. */
  102755. static Log(message: string): void;
  102756. /**
  102757. * Write a warning message to the console
  102758. * @param message defines the message to log
  102759. */
  102760. static Warn(message: string): void;
  102761. /**
  102762. * Write an error message to the console
  102763. * @param message defines the message to log
  102764. */
  102765. static Error(message: string): void;
  102766. /**
  102767. * Gets current log cache (list of logs)
  102768. */
  102769. static readonly LogCache: string;
  102770. /**
  102771. * Clears the log cache
  102772. */
  102773. static ClearLogCache(): void;
  102774. /**
  102775. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  102776. */
  102777. static LogLevels: number;
  102778. /**
  102779. * Checks if the window object exists
  102780. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  102781. */
  102782. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  102783. /**
  102784. * No performance log
  102785. */
  102786. static readonly PerformanceNoneLogLevel: number;
  102787. /**
  102788. * Use user marks to log performance
  102789. */
  102790. static readonly PerformanceUserMarkLogLevel: number;
  102791. /**
  102792. * Log performance to the console
  102793. */
  102794. static readonly PerformanceConsoleLogLevel: number;
  102795. private static _performance;
  102796. /**
  102797. * Sets the current performance log level
  102798. */
  102799. static PerformanceLogLevel: number;
  102800. private static _StartPerformanceCounterDisabled;
  102801. private static _EndPerformanceCounterDisabled;
  102802. private static _StartUserMark;
  102803. private static _EndUserMark;
  102804. private static _StartPerformanceConsole;
  102805. private static _EndPerformanceConsole;
  102806. /**
  102807. * Starts a performance counter
  102808. */
  102809. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  102810. /**
  102811. * Ends a specific performance coutner
  102812. */
  102813. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  102814. /**
  102815. * Gets either window.performance.now() if supported or Date.now() else
  102816. */
  102817. static readonly Now: number;
  102818. /**
  102819. * This method will return the name of the class used to create the instance of the given object.
  102820. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  102821. * @param object the object to get the class name from
  102822. * @param isType defines if the object is actually a type
  102823. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  102824. */
  102825. static GetClassName(object: any, isType?: boolean): string;
  102826. /**
  102827. * Gets the first element of an array satisfying a given predicate
  102828. * @param array defines the array to browse
  102829. * @param predicate defines the predicate to use
  102830. * @returns null if not found or the element
  102831. */
  102832. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  102833. /**
  102834. * This method will return the name of the full name of the class, including its owning module (if any).
  102835. * 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).
  102836. * @param object the object to get the class name from
  102837. * @param isType defines if the object is actually a type
  102838. * @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.
  102839. * @ignorenaming
  102840. */
  102841. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  102842. /**
  102843. * Returns a promise that resolves after the given amount of time.
  102844. * @param delay Number of milliseconds to delay
  102845. * @returns Promise that resolves after the given amount of time
  102846. */
  102847. static DelayAsync(delay: number): Promise<void>;
  102848. }
  102849. /**
  102850. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  102851. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  102852. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  102853. * @param name The name of the class, case should be preserved
  102854. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  102855. */
  102856. export function className(name: string, module?: string): (target: Object) => void;
  102857. /**
  102858. * An implementation of a loop for asynchronous functions.
  102859. */
  102860. export class AsyncLoop {
  102861. /**
  102862. * Defines the number of iterations for the loop
  102863. */
  102864. iterations: number;
  102865. /**
  102866. * Defines the current index of the loop.
  102867. */
  102868. index: number;
  102869. private _done;
  102870. private _fn;
  102871. private _successCallback;
  102872. /**
  102873. * Constructor.
  102874. * @param iterations the number of iterations.
  102875. * @param func the function to run each iteration
  102876. * @param successCallback the callback that will be called upon succesful execution
  102877. * @param offset starting offset.
  102878. */
  102879. constructor(
  102880. /**
  102881. * Defines the number of iterations for the loop
  102882. */
  102883. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  102884. /**
  102885. * Execute the next iteration. Must be called after the last iteration was finished.
  102886. */
  102887. executeNext(): void;
  102888. /**
  102889. * Break the loop and run the success callback.
  102890. */
  102891. breakLoop(): void;
  102892. /**
  102893. * Create and run an async loop.
  102894. * @param iterations the number of iterations.
  102895. * @param fn the function to run each iteration
  102896. * @param successCallback the callback that will be called upon succesful execution
  102897. * @param offset starting offset.
  102898. * @returns the created async loop object
  102899. */
  102900. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  102901. /**
  102902. * A for-loop that will run a given number of iterations synchronous and the rest async.
  102903. * @param iterations total number of iterations
  102904. * @param syncedIterations number of synchronous iterations in each async iteration.
  102905. * @param fn the function to call each iteration.
  102906. * @param callback a success call back that will be called when iterating stops.
  102907. * @param breakFunction a break condition (optional)
  102908. * @param timeout timeout settings for the setTimeout function. default - 0.
  102909. * @returns the created async loop object
  102910. */
  102911. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  102912. }
  102913. }
  102914. declare module BABYLON {
  102915. /**
  102916. * This class implement a typical dictionary using a string as key and the generic type T as value.
  102917. * The underlying implementation relies on an associative array to ensure the best performances.
  102918. * The value can be anything including 'null' but except 'undefined'
  102919. */
  102920. export class StringDictionary<T> {
  102921. /**
  102922. * This will clear this dictionary and copy the content from the 'source' one.
  102923. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  102924. * @param source the dictionary to take the content from and copy to this dictionary
  102925. */
  102926. copyFrom(source: StringDictionary<T>): void;
  102927. /**
  102928. * Get a value based from its key
  102929. * @param key the given key to get the matching value from
  102930. * @return the value if found, otherwise undefined is returned
  102931. */
  102932. get(key: string): T | undefined;
  102933. /**
  102934. * Get a value from its key or add it if it doesn't exist.
  102935. * This method will ensure you that a given key/data will be present in the dictionary.
  102936. * @param key the given key to get the matching value from
  102937. * @param factory the factory that will create the value if the key is not present in the dictionary.
  102938. * The factory will only be invoked if there's no data for the given key.
  102939. * @return the value corresponding to the key.
  102940. */
  102941. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  102942. /**
  102943. * Get a value from its key if present in the dictionary otherwise add it
  102944. * @param key the key to get the value from
  102945. * @param val if there's no such key/value pair in the dictionary add it with this value
  102946. * @return the value corresponding to the key
  102947. */
  102948. getOrAdd(key: string, val: T): T;
  102949. /**
  102950. * Check if there's a given key in the dictionary
  102951. * @param key the key to check for
  102952. * @return true if the key is present, false otherwise
  102953. */
  102954. contains(key: string): boolean;
  102955. /**
  102956. * Add a new key and its corresponding value
  102957. * @param key the key to add
  102958. * @param value the value corresponding to the key
  102959. * @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
  102960. */
  102961. add(key: string, value: T): boolean;
  102962. /**
  102963. * Update a specific value associated to a key
  102964. * @param key defines the key to use
  102965. * @param value defines the value to store
  102966. * @returns true if the value was updated (or false if the key was not found)
  102967. */
  102968. set(key: string, value: T): boolean;
  102969. /**
  102970. * Get the element of the given key and remove it from the dictionary
  102971. * @param key defines the key to search
  102972. * @returns the value associated with the key or null if not found
  102973. */
  102974. getAndRemove(key: string): Nullable<T>;
  102975. /**
  102976. * Remove a key/value from the dictionary.
  102977. * @param key the key to remove
  102978. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  102979. */
  102980. remove(key: string): boolean;
  102981. /**
  102982. * Clear the whole content of the dictionary
  102983. */
  102984. clear(): void;
  102985. /**
  102986. * Gets the current count
  102987. */
  102988. readonly count: number;
  102989. /**
  102990. * Execute a callback on each key/val of the dictionary.
  102991. * Note that you can remove any element in this dictionary in the callback implementation
  102992. * @param callback the callback to execute on a given key/value pair
  102993. */
  102994. forEach(callback: (key: string, val: T) => void): void;
  102995. /**
  102996. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  102997. * If the callback returns null or undefined the method will iterate to the next key/value pair
  102998. * Note that you can remove any element in this dictionary in the callback implementation
  102999. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  103000. * @returns the first item
  103001. */
  103002. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  103003. private _count;
  103004. private _data;
  103005. }
  103006. }
  103007. declare module BABYLON {
  103008. /** @hidden */
  103009. export interface ICollisionCoordinator {
  103010. createCollider(): Collider;
  103011. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  103012. init(scene: Scene): void;
  103013. }
  103014. /** @hidden */
  103015. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  103016. private _scene;
  103017. private _scaledPosition;
  103018. private _scaledVelocity;
  103019. private _finalPosition;
  103020. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  103021. createCollider(): Collider;
  103022. init(scene: Scene): void;
  103023. private _collideWithWorld;
  103024. }
  103025. }
  103026. declare module BABYLON {
  103027. /**
  103028. * Class used to manage all inputs for the scene.
  103029. */
  103030. export class InputManager {
  103031. /** The distance in pixel that you have to move to prevent some events */
  103032. static DragMovementThreshold: number;
  103033. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  103034. static LongPressDelay: number;
  103035. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  103036. static DoubleClickDelay: number;
  103037. /** If you need to check double click without raising a single click at first click, enable this flag */
  103038. static ExclusiveDoubleClickMode: boolean;
  103039. private _wheelEventName;
  103040. private _onPointerMove;
  103041. private _onPointerDown;
  103042. private _onPointerUp;
  103043. private _initClickEvent;
  103044. private _initActionManager;
  103045. private _delayedSimpleClick;
  103046. private _delayedSimpleClickTimeout;
  103047. private _previousDelayedSimpleClickTimeout;
  103048. private _meshPickProceed;
  103049. private _previousButtonPressed;
  103050. private _currentPickResult;
  103051. private _previousPickResult;
  103052. private _totalPointersPressed;
  103053. private _doubleClickOccured;
  103054. private _pointerOverMesh;
  103055. private _pickedDownMesh;
  103056. private _pickedUpMesh;
  103057. private _pointerX;
  103058. private _pointerY;
  103059. private _unTranslatedPointerX;
  103060. private _unTranslatedPointerY;
  103061. private _startingPointerPosition;
  103062. private _previousStartingPointerPosition;
  103063. private _startingPointerTime;
  103064. private _previousStartingPointerTime;
  103065. private _pointerCaptures;
  103066. private _onKeyDown;
  103067. private _onKeyUp;
  103068. private _onCanvasFocusObserver;
  103069. private _onCanvasBlurObserver;
  103070. private _scene;
  103071. /**
  103072. * Creates a new InputManager
  103073. * @param scene defines the hosting scene
  103074. */
  103075. constructor(scene: Scene);
  103076. /**
  103077. * Gets the mesh that is currently under the pointer
  103078. */
  103079. readonly meshUnderPointer: Nullable<AbstractMesh>;
  103080. /**
  103081. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  103082. */
  103083. readonly unTranslatedPointer: Vector2;
  103084. /**
  103085. * Gets or sets the current on-screen X position of the pointer
  103086. */
  103087. pointerX: number;
  103088. /**
  103089. * Gets or sets the current on-screen Y position of the pointer
  103090. */
  103091. pointerY: number;
  103092. private _updatePointerPosition;
  103093. private _processPointerMove;
  103094. private _setRayOnPointerInfo;
  103095. private _checkPrePointerObservable;
  103096. /**
  103097. * Use this method to simulate a pointer move on a mesh
  103098. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  103099. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  103100. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  103101. */
  103102. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  103103. /**
  103104. * Use this method to simulate a pointer down on a mesh
  103105. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  103106. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  103107. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  103108. */
  103109. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  103110. private _processPointerDown;
  103111. /** @hidden */
  103112. _isPointerSwiping(): boolean;
  103113. /**
  103114. * Use this method to simulate a pointer up on a mesh
  103115. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  103116. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  103117. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  103118. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  103119. */
  103120. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  103121. private _processPointerUp;
  103122. /**
  103123. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  103124. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  103125. * @returns true if the pointer was captured
  103126. */
  103127. isPointerCaptured(pointerId?: number): boolean;
  103128. /**
  103129. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  103130. * @param attachUp defines if you want to attach events to pointerup
  103131. * @param attachDown defines if you want to attach events to pointerdown
  103132. * @param attachMove defines if you want to attach events to pointermove
  103133. */
  103134. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  103135. /**
  103136. * Detaches all event handlers
  103137. */
  103138. detachControl(): void;
  103139. /**
  103140. * Force the value of meshUnderPointer
  103141. * @param mesh defines the mesh to use
  103142. */
  103143. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  103144. /**
  103145. * Gets the mesh under the pointer
  103146. * @returns a Mesh or null if no mesh is under the pointer
  103147. */
  103148. getPointerOverMesh(): Nullable<AbstractMesh>;
  103149. }
  103150. }
  103151. declare module BABYLON {
  103152. /**
  103153. * Helper class used to generate session unique ID
  103154. */
  103155. export class UniqueIdGenerator {
  103156. private static _UniqueIdCounter;
  103157. /**
  103158. * Gets an unique (relatively to the current scene) Id
  103159. */
  103160. static readonly UniqueId: number;
  103161. }
  103162. }
  103163. declare module BABYLON {
  103164. /**
  103165. * This class defines the direct association between an animation and a target
  103166. */
  103167. export class TargetedAnimation {
  103168. /**
  103169. * Animation to perform
  103170. */
  103171. animation: Animation;
  103172. /**
  103173. * Target to animate
  103174. */
  103175. target: any;
  103176. /**
  103177. * Serialize the object
  103178. * @returns the JSON object representing the current entity
  103179. */
  103180. serialize(): any;
  103181. }
  103182. /**
  103183. * Use this class to create coordinated animations on multiple targets
  103184. */
  103185. export class AnimationGroup implements IDisposable {
  103186. /** The name of the animation group */
  103187. name: string;
  103188. private _scene;
  103189. private _targetedAnimations;
  103190. private _animatables;
  103191. private _from;
  103192. private _to;
  103193. private _isStarted;
  103194. private _isPaused;
  103195. private _speedRatio;
  103196. private _loopAnimation;
  103197. /**
  103198. * Gets or sets the unique id of the node
  103199. */
  103200. uniqueId: number;
  103201. /**
  103202. * This observable will notify when one animation have ended
  103203. */
  103204. onAnimationEndObservable: Observable<TargetedAnimation>;
  103205. /**
  103206. * Observer raised when one animation loops
  103207. */
  103208. onAnimationLoopObservable: Observable<TargetedAnimation>;
  103209. /**
  103210. * Observer raised when all animations have looped
  103211. */
  103212. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  103213. /**
  103214. * This observable will notify when all animations have ended.
  103215. */
  103216. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  103217. /**
  103218. * This observable will notify when all animations have paused.
  103219. */
  103220. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  103221. /**
  103222. * This observable will notify when all animations are playing.
  103223. */
  103224. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  103225. /**
  103226. * Gets the first frame
  103227. */
  103228. readonly from: number;
  103229. /**
  103230. * Gets the last frame
  103231. */
  103232. readonly to: number;
  103233. /**
  103234. * Define if the animations are started
  103235. */
  103236. readonly isStarted: boolean;
  103237. /**
  103238. * Gets a value indicating that the current group is playing
  103239. */
  103240. readonly isPlaying: boolean;
  103241. /**
  103242. * Gets or sets the speed ratio to use for all animations
  103243. */
  103244. /**
  103245. * Gets or sets the speed ratio to use for all animations
  103246. */
  103247. speedRatio: number;
  103248. /**
  103249. * Gets or sets if all animations should loop or not
  103250. */
  103251. loopAnimation: boolean;
  103252. /**
  103253. * Gets the targeted animations for this animation group
  103254. */
  103255. readonly targetedAnimations: Array<TargetedAnimation>;
  103256. /**
  103257. * returning the list of animatables controlled by this animation group.
  103258. */
  103259. readonly animatables: Array<Animatable>;
  103260. /**
  103261. * Instantiates a new Animation Group.
  103262. * This helps managing several animations at once.
  103263. * @see http://doc.babylonjs.com/how_to/group
  103264. * @param name Defines the name of the group
  103265. * @param scene Defines the scene the group belongs to
  103266. */
  103267. constructor(
  103268. /** The name of the animation group */
  103269. name: string, scene?: Nullable<Scene>);
  103270. /**
  103271. * Add an animation (with its target) in the group
  103272. * @param animation defines the animation we want to add
  103273. * @param target defines the target of the animation
  103274. * @returns the TargetedAnimation object
  103275. */
  103276. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  103277. /**
  103278. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  103279. * It can add constant keys at begin or end
  103280. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  103281. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  103282. * @returns the animation group
  103283. */
  103284. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  103285. private _animationLoopCount;
  103286. private _animationLoopFlags;
  103287. private _processLoop;
  103288. /**
  103289. * Start all animations on given targets
  103290. * @param loop defines if animations must loop
  103291. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  103292. * @param from defines the from key (optional)
  103293. * @param to defines the to key (optional)
  103294. * @returns the current animation group
  103295. */
  103296. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  103297. /**
  103298. * Pause all animations
  103299. * @returns the animation group
  103300. */
  103301. pause(): AnimationGroup;
  103302. /**
  103303. * Play all animations to initial state
  103304. * This function will start() the animations if they were not started or will restart() them if they were paused
  103305. * @param loop defines if animations must loop
  103306. * @returns the animation group
  103307. */
  103308. play(loop?: boolean): AnimationGroup;
  103309. /**
  103310. * Reset all animations to initial state
  103311. * @returns the animation group
  103312. */
  103313. reset(): AnimationGroup;
  103314. /**
  103315. * Restart animations from key 0
  103316. * @returns the animation group
  103317. */
  103318. restart(): AnimationGroup;
  103319. /**
  103320. * Stop all animations
  103321. * @returns the animation group
  103322. */
  103323. stop(): AnimationGroup;
  103324. /**
  103325. * Set animation weight for all animatables
  103326. * @param weight defines the weight to use
  103327. * @return the animationGroup
  103328. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  103329. */
  103330. setWeightForAllAnimatables(weight: number): AnimationGroup;
  103331. /**
  103332. * Synchronize and normalize all animatables with a source animatable
  103333. * @param root defines the root animatable to synchronize with
  103334. * @return the animationGroup
  103335. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  103336. */
  103337. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  103338. /**
  103339. * Goes to a specific frame in this animation group
  103340. * @param frame the frame number to go to
  103341. * @return the animationGroup
  103342. */
  103343. goToFrame(frame: number): AnimationGroup;
  103344. /**
  103345. * Dispose all associated resources
  103346. */
  103347. dispose(): void;
  103348. private _checkAnimationGroupEnded;
  103349. /**
  103350. * Clone the current animation group and returns a copy
  103351. * @param newName defines the name of the new group
  103352. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  103353. * @returns the new aniamtion group
  103354. */
  103355. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  103356. /**
  103357. * Serializes the animationGroup to an object
  103358. * @returns Serialized object
  103359. */
  103360. serialize(): any;
  103361. /**
  103362. * Returns a new AnimationGroup object parsed from the source provided.
  103363. * @param parsedAnimationGroup defines the source
  103364. * @param scene defines the scene that will receive the animationGroup
  103365. * @returns a new AnimationGroup
  103366. */
  103367. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  103368. /**
  103369. * Returns the string "AnimationGroup"
  103370. * @returns "AnimationGroup"
  103371. */
  103372. getClassName(): string;
  103373. /**
  103374. * Creates a detailled string about the object
  103375. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  103376. * @returns a string representing the object
  103377. */
  103378. toString(fullDetails?: boolean): string;
  103379. }
  103380. }
  103381. declare module BABYLON {
  103382. /**
  103383. * Define an interface for all classes that will hold resources
  103384. */
  103385. export interface IDisposable {
  103386. /**
  103387. * Releases all held resources
  103388. */
  103389. dispose(): void;
  103390. }
  103391. /** Interface defining initialization parameters for Scene class */
  103392. export interface SceneOptions {
  103393. /**
  103394. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  103395. * It will improve performance when the number of geometries becomes important.
  103396. */
  103397. useGeometryUniqueIdsMap?: boolean;
  103398. /**
  103399. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  103400. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  103401. */
  103402. useMaterialMeshMap?: boolean;
  103403. /**
  103404. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  103405. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  103406. */
  103407. useClonedMeshhMap?: boolean;
  103408. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  103409. virtual?: boolean;
  103410. }
  103411. /**
  103412. * Represents a scene to be rendered by the engine.
  103413. * @see http://doc.babylonjs.com/features/scene
  103414. */
  103415. export class Scene extends AbstractScene implements IAnimatable {
  103416. /** The fog is deactivated */
  103417. static readonly FOGMODE_NONE: number;
  103418. /** The fog density is following an exponential function */
  103419. static readonly FOGMODE_EXP: number;
  103420. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  103421. static readonly FOGMODE_EXP2: number;
  103422. /** The fog density is following a linear function. */
  103423. static readonly FOGMODE_LINEAR: number;
  103424. /**
  103425. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  103426. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103427. */
  103428. static MinDeltaTime: number;
  103429. /**
  103430. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  103431. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103432. */
  103433. static MaxDeltaTime: number;
  103434. /**
  103435. * Factory used to create the default material.
  103436. * @param name The name of the material to create
  103437. * @param scene The scene to create the material for
  103438. * @returns The default material
  103439. */
  103440. static DefaultMaterialFactory(scene: Scene): Material;
  103441. /**
  103442. * Factory used to create the a collision coordinator.
  103443. * @returns The collision coordinator
  103444. */
  103445. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  103446. /** @hidden */
  103447. _inputManager: InputManager;
  103448. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  103449. cameraToUseForPointers: Nullable<Camera>;
  103450. /** @hidden */
  103451. readonly _isScene: boolean;
  103452. /**
  103453. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  103454. */
  103455. autoClear: boolean;
  103456. /**
  103457. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  103458. */
  103459. autoClearDepthAndStencil: boolean;
  103460. /**
  103461. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  103462. */
  103463. clearColor: Color4;
  103464. /**
  103465. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  103466. */
  103467. ambientColor: Color3;
  103468. /**
  103469. * This is use to store the default BRDF lookup for PBR materials in your scene.
  103470. * It should only be one of the following (if not the default embedded one):
  103471. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  103472. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  103473. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  103474. * The material properties need to be setup according to the type of texture in use.
  103475. */
  103476. environmentBRDFTexture: BaseTexture;
  103477. /** @hidden */
  103478. protected _environmentTexture: Nullable<BaseTexture>;
  103479. /**
  103480. * Texture used in all pbr material as the reflection texture.
  103481. * As in the majority of the scene they are the same (exception for multi room and so on),
  103482. * this is easier to reference from here than from all the materials.
  103483. */
  103484. /**
  103485. * Texture used in all pbr material as the reflection texture.
  103486. * As in the majority of the scene they are the same (exception for multi room and so on),
  103487. * this is easier to set here than in all the materials.
  103488. */
  103489. environmentTexture: Nullable<BaseTexture>;
  103490. /** @hidden */
  103491. protected _environmentIntensity: number;
  103492. /**
  103493. * Intensity of the environment in all pbr material.
  103494. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  103495. * As in the majority of the scene they are the same (exception for multi room and so on),
  103496. * this is easier to reference from here than from all the materials.
  103497. */
  103498. /**
  103499. * Intensity of the environment in all pbr material.
  103500. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  103501. * As in the majority of the scene they are the same (exception for multi room and so on),
  103502. * this is easier to set here than in all the materials.
  103503. */
  103504. environmentIntensity: number;
  103505. /** @hidden */
  103506. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103507. /**
  103508. * Default image processing configuration used either in the rendering
  103509. * Forward main pass or through the imageProcessingPostProcess if present.
  103510. * As in the majority of the scene they are the same (exception for multi camera),
  103511. * this is easier to reference from here than from all the materials and post process.
  103512. *
  103513. * No setter as we it is a shared configuration, you can set the values instead.
  103514. */
  103515. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  103516. private _forceWireframe;
  103517. /**
  103518. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  103519. */
  103520. forceWireframe: boolean;
  103521. private _forcePointsCloud;
  103522. /**
  103523. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  103524. */
  103525. forcePointsCloud: boolean;
  103526. /**
  103527. * Gets or sets the active clipplane 1
  103528. */
  103529. clipPlane: Nullable<Plane>;
  103530. /**
  103531. * Gets or sets the active clipplane 2
  103532. */
  103533. clipPlane2: Nullable<Plane>;
  103534. /**
  103535. * Gets or sets the active clipplane 3
  103536. */
  103537. clipPlane3: Nullable<Plane>;
  103538. /**
  103539. * Gets or sets the active clipplane 4
  103540. */
  103541. clipPlane4: Nullable<Plane>;
  103542. /**
  103543. * Gets or sets a boolean indicating if animations are enabled
  103544. */
  103545. animationsEnabled: boolean;
  103546. private _animationPropertiesOverride;
  103547. /**
  103548. * Gets or sets the animation properties override
  103549. */
  103550. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  103551. /**
  103552. * Gets or sets a boolean indicating if a constant deltatime has to be used
  103553. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  103554. */
  103555. useConstantAnimationDeltaTime: boolean;
  103556. /**
  103557. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  103558. * Please note that it requires to run a ray cast through the scene on every frame
  103559. */
  103560. constantlyUpdateMeshUnderPointer: boolean;
  103561. /**
  103562. * Defines the HTML cursor to use when hovering over interactive elements
  103563. */
  103564. hoverCursor: string;
  103565. /**
  103566. * Defines the HTML default cursor to use (empty by default)
  103567. */
  103568. defaultCursor: string;
  103569. /**
  103570. * Defines wether cursors are handled by the scene.
  103571. */
  103572. doNotHandleCursors: boolean;
  103573. /**
  103574. * This is used to call preventDefault() on pointer down
  103575. * in order to block unwanted artifacts like system double clicks
  103576. */
  103577. preventDefaultOnPointerDown: boolean;
  103578. /**
  103579. * This is used to call preventDefault() on pointer up
  103580. * in order to block unwanted artifacts like system double clicks
  103581. */
  103582. preventDefaultOnPointerUp: boolean;
  103583. /**
  103584. * Gets or sets user defined metadata
  103585. */
  103586. metadata: any;
  103587. /**
  103588. * For internal use only. Please do not use.
  103589. */
  103590. reservedDataStore: any;
  103591. /**
  103592. * Gets the name of the plugin used to load this scene (null by default)
  103593. */
  103594. loadingPluginName: string;
  103595. /**
  103596. * Use this array to add regular expressions used to disable offline support for specific urls
  103597. */
  103598. disableOfflineSupportExceptionRules: RegExp[];
  103599. /**
  103600. * An event triggered when the scene is disposed.
  103601. */
  103602. onDisposeObservable: Observable<Scene>;
  103603. private _onDisposeObserver;
  103604. /** Sets a function to be executed when this scene is disposed. */
  103605. onDispose: () => void;
  103606. /**
  103607. * An event triggered before rendering the scene (right after animations and physics)
  103608. */
  103609. onBeforeRenderObservable: Observable<Scene>;
  103610. private _onBeforeRenderObserver;
  103611. /** Sets a function to be executed before rendering this scene */
  103612. beforeRender: Nullable<() => void>;
  103613. /**
  103614. * An event triggered after rendering the scene
  103615. */
  103616. onAfterRenderObservable: Observable<Scene>;
  103617. /**
  103618. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  103619. */
  103620. onAfterRenderCameraObservable: Observable<Camera>;
  103621. private _onAfterRenderObserver;
  103622. /** Sets a function to be executed after rendering this scene */
  103623. afterRender: Nullable<() => void>;
  103624. /**
  103625. * An event triggered before animating the scene
  103626. */
  103627. onBeforeAnimationsObservable: Observable<Scene>;
  103628. /**
  103629. * An event triggered after animations processing
  103630. */
  103631. onAfterAnimationsObservable: Observable<Scene>;
  103632. /**
  103633. * An event triggered before draw calls are ready to be sent
  103634. */
  103635. onBeforeDrawPhaseObservable: Observable<Scene>;
  103636. /**
  103637. * An event triggered after draw calls have been sent
  103638. */
  103639. onAfterDrawPhaseObservable: Observable<Scene>;
  103640. /**
  103641. * An event triggered when the scene is ready
  103642. */
  103643. onReadyObservable: Observable<Scene>;
  103644. /**
  103645. * An event triggered before rendering a camera
  103646. */
  103647. onBeforeCameraRenderObservable: Observable<Camera>;
  103648. private _onBeforeCameraRenderObserver;
  103649. /** Sets a function to be executed before rendering a camera*/
  103650. beforeCameraRender: () => void;
  103651. /**
  103652. * An event triggered after rendering a camera
  103653. */
  103654. onAfterCameraRenderObservable: Observable<Camera>;
  103655. private _onAfterCameraRenderObserver;
  103656. /** Sets a function to be executed after rendering a camera*/
  103657. afterCameraRender: () => void;
  103658. /**
  103659. * An event triggered when active meshes evaluation is about to start
  103660. */
  103661. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  103662. /**
  103663. * An event triggered when active meshes evaluation is done
  103664. */
  103665. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  103666. /**
  103667. * An event triggered when particles rendering is about to start
  103668. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  103669. */
  103670. onBeforeParticlesRenderingObservable: Observable<Scene>;
  103671. /**
  103672. * An event triggered when particles rendering is done
  103673. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  103674. */
  103675. onAfterParticlesRenderingObservable: Observable<Scene>;
  103676. /**
  103677. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  103678. */
  103679. onDataLoadedObservable: Observable<Scene>;
  103680. /**
  103681. * An event triggered when a camera is created
  103682. */
  103683. onNewCameraAddedObservable: Observable<Camera>;
  103684. /**
  103685. * An event triggered when a camera is removed
  103686. */
  103687. onCameraRemovedObservable: Observable<Camera>;
  103688. /**
  103689. * An event triggered when a light is created
  103690. */
  103691. onNewLightAddedObservable: Observable<Light>;
  103692. /**
  103693. * An event triggered when a light is removed
  103694. */
  103695. onLightRemovedObservable: Observable<Light>;
  103696. /**
  103697. * An event triggered when a geometry is created
  103698. */
  103699. onNewGeometryAddedObservable: Observable<Geometry>;
  103700. /**
  103701. * An event triggered when a geometry is removed
  103702. */
  103703. onGeometryRemovedObservable: Observable<Geometry>;
  103704. /**
  103705. * An event triggered when a transform node is created
  103706. */
  103707. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  103708. /**
  103709. * An event triggered when a transform node is removed
  103710. */
  103711. onTransformNodeRemovedObservable: Observable<TransformNode>;
  103712. /**
  103713. * An event triggered when a mesh is created
  103714. */
  103715. onNewMeshAddedObservable: Observable<AbstractMesh>;
  103716. /**
  103717. * An event triggered when a mesh is removed
  103718. */
  103719. onMeshRemovedObservable: Observable<AbstractMesh>;
  103720. /**
  103721. * An event triggered when a skeleton is created
  103722. */
  103723. onNewSkeletonAddedObservable: Observable<Skeleton>;
  103724. /**
  103725. * An event triggered when a skeleton is removed
  103726. */
  103727. onSkeletonRemovedObservable: Observable<Skeleton>;
  103728. /**
  103729. * An event triggered when a material is created
  103730. */
  103731. onNewMaterialAddedObservable: Observable<Material>;
  103732. /**
  103733. * An event triggered when a material is removed
  103734. */
  103735. onMaterialRemovedObservable: Observable<Material>;
  103736. /**
  103737. * An event triggered when a texture is created
  103738. */
  103739. onNewTextureAddedObservable: Observable<BaseTexture>;
  103740. /**
  103741. * An event triggered when a texture is removed
  103742. */
  103743. onTextureRemovedObservable: Observable<BaseTexture>;
  103744. /**
  103745. * An event triggered when render targets are about to be rendered
  103746. * Can happen multiple times per frame.
  103747. */
  103748. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  103749. /**
  103750. * An event triggered when render targets were rendered.
  103751. * Can happen multiple times per frame.
  103752. */
  103753. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  103754. /**
  103755. * An event triggered before calculating deterministic simulation step
  103756. */
  103757. onBeforeStepObservable: Observable<Scene>;
  103758. /**
  103759. * An event triggered after calculating deterministic simulation step
  103760. */
  103761. onAfterStepObservable: Observable<Scene>;
  103762. /**
  103763. * An event triggered when the activeCamera property is updated
  103764. */
  103765. onActiveCameraChanged: Observable<Scene>;
  103766. /**
  103767. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  103768. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  103769. * 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)
  103770. */
  103771. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  103772. /**
  103773. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  103774. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  103775. * 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)
  103776. */
  103777. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  103778. /**
  103779. * This Observable will when a mesh has been imported into the scene.
  103780. */
  103781. onMeshImportedObservable: Observable<AbstractMesh>;
  103782. /**
  103783. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  103784. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  103785. */
  103786. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  103787. /** @hidden */
  103788. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  103789. /**
  103790. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  103791. */
  103792. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  103793. /**
  103794. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  103795. */
  103796. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  103797. /**
  103798. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  103799. */
  103800. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  103801. /** Callback called when a pointer move is detected */
  103802. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  103803. /** Callback called when a pointer down is detected */
  103804. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  103805. /** Callback called when a pointer up is detected */
  103806. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  103807. /** Callback called when a pointer pick is detected */
  103808. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  103809. /**
  103810. * 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).
  103811. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  103812. */
  103813. onPrePointerObservable: Observable<PointerInfoPre>;
  103814. /**
  103815. * Observable event triggered each time an input event is received from the rendering canvas
  103816. */
  103817. onPointerObservable: Observable<PointerInfo>;
  103818. /**
  103819. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  103820. */
  103821. readonly unTranslatedPointer: Vector2;
  103822. /**
  103823. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  103824. */
  103825. static DragMovementThreshold: number;
  103826. /**
  103827. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  103828. */
  103829. static LongPressDelay: number;
  103830. /**
  103831. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  103832. */
  103833. static DoubleClickDelay: number;
  103834. /** If you need to check double click without raising a single click at first click, enable this flag */
  103835. static ExclusiveDoubleClickMode: boolean;
  103836. /** @hidden */
  103837. _mirroredCameraPosition: Nullable<Vector3>;
  103838. /**
  103839. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  103840. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  103841. */
  103842. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  103843. /**
  103844. * Observable event triggered each time an keyboard event is received from the hosting window
  103845. */
  103846. onKeyboardObservable: Observable<KeyboardInfo>;
  103847. private _useRightHandedSystem;
  103848. /**
  103849. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  103850. */
  103851. useRightHandedSystem: boolean;
  103852. private _timeAccumulator;
  103853. private _currentStepId;
  103854. private _currentInternalStep;
  103855. /**
  103856. * Sets the step Id used by deterministic lock step
  103857. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103858. * @param newStepId defines the step Id
  103859. */
  103860. setStepId(newStepId: number): void;
  103861. /**
  103862. * Gets the step Id used by deterministic lock step
  103863. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103864. * @returns the step Id
  103865. */
  103866. getStepId(): number;
  103867. /**
  103868. * Gets the internal step used by deterministic lock step
  103869. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103870. * @returns the internal step
  103871. */
  103872. getInternalStep(): number;
  103873. private _fogEnabled;
  103874. /**
  103875. * Gets or sets a boolean indicating if fog is enabled on this scene
  103876. * @see http://doc.babylonjs.com/babylon101/environment#fog
  103877. * (Default is true)
  103878. */
  103879. fogEnabled: boolean;
  103880. private _fogMode;
  103881. /**
  103882. * Gets or sets the fog mode to use
  103883. * @see http://doc.babylonjs.com/babylon101/environment#fog
  103884. * | mode | value |
  103885. * | --- | --- |
  103886. * | FOGMODE_NONE | 0 |
  103887. * | FOGMODE_EXP | 1 |
  103888. * | FOGMODE_EXP2 | 2 |
  103889. * | FOGMODE_LINEAR | 3 |
  103890. */
  103891. fogMode: number;
  103892. /**
  103893. * Gets or sets the fog color to use
  103894. * @see http://doc.babylonjs.com/babylon101/environment#fog
  103895. * (Default is Color3(0.2, 0.2, 0.3))
  103896. */
  103897. fogColor: Color3;
  103898. /**
  103899. * Gets or sets the fog density to use
  103900. * @see http://doc.babylonjs.com/babylon101/environment#fog
  103901. * (Default is 0.1)
  103902. */
  103903. fogDensity: number;
  103904. /**
  103905. * Gets or sets the fog start distance to use
  103906. * @see http://doc.babylonjs.com/babylon101/environment#fog
  103907. * (Default is 0)
  103908. */
  103909. fogStart: number;
  103910. /**
  103911. * Gets or sets the fog end distance to use
  103912. * @see http://doc.babylonjs.com/babylon101/environment#fog
  103913. * (Default is 1000)
  103914. */
  103915. fogEnd: number;
  103916. private _shadowsEnabled;
  103917. /**
  103918. * Gets or sets a boolean indicating if shadows are enabled on this scene
  103919. */
  103920. shadowsEnabled: boolean;
  103921. private _lightsEnabled;
  103922. /**
  103923. * Gets or sets a boolean indicating if lights are enabled on this scene
  103924. */
  103925. lightsEnabled: boolean;
  103926. /** All of the active cameras added to this scene. */
  103927. activeCameras: Camera[];
  103928. /** @hidden */
  103929. _activeCamera: Nullable<Camera>;
  103930. /** Gets or sets the current active camera */
  103931. activeCamera: Nullable<Camera>;
  103932. private _defaultMaterial;
  103933. /** The default material used on meshes when no material is affected */
  103934. /** The default material used on meshes when no material is affected */
  103935. defaultMaterial: Material;
  103936. private _texturesEnabled;
  103937. /**
  103938. * Gets or sets a boolean indicating if textures are enabled on this scene
  103939. */
  103940. texturesEnabled: boolean;
  103941. /**
  103942. * Gets or sets a boolean indicating if particles are enabled on this scene
  103943. */
  103944. particlesEnabled: boolean;
  103945. /**
  103946. * Gets or sets a boolean indicating if sprites are enabled on this scene
  103947. */
  103948. spritesEnabled: boolean;
  103949. private _skeletonsEnabled;
  103950. /**
  103951. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  103952. */
  103953. skeletonsEnabled: boolean;
  103954. /**
  103955. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  103956. */
  103957. lensFlaresEnabled: boolean;
  103958. /**
  103959. * Gets or sets a boolean indicating if collisions are enabled on this scene
  103960. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  103961. */
  103962. collisionsEnabled: boolean;
  103963. private _collisionCoordinator;
  103964. /** @hidden */
  103965. readonly collisionCoordinator: ICollisionCoordinator;
  103966. /**
  103967. * Defines the gravity applied to this scene (used only for collisions)
  103968. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  103969. */
  103970. gravity: Vector3;
  103971. /**
  103972. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  103973. */
  103974. postProcessesEnabled: boolean;
  103975. /**
  103976. * The list of postprocesses added to the scene
  103977. */
  103978. postProcesses: PostProcess[];
  103979. /**
  103980. * Gets the current postprocess manager
  103981. */
  103982. postProcessManager: PostProcessManager;
  103983. /**
  103984. * Gets or sets a boolean indicating if render targets are enabled on this scene
  103985. */
  103986. renderTargetsEnabled: boolean;
  103987. /**
  103988. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  103989. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  103990. */
  103991. dumpNextRenderTargets: boolean;
  103992. /**
  103993. * The list of user defined render targets added to the scene
  103994. */
  103995. customRenderTargets: RenderTargetTexture[];
  103996. /**
  103997. * Defines if texture loading must be delayed
  103998. * If true, textures will only be loaded when they need to be rendered
  103999. */
  104000. useDelayedTextureLoading: boolean;
  104001. /**
  104002. * Gets the list of meshes imported to the scene through SceneLoader
  104003. */
  104004. importedMeshesFiles: String[];
  104005. /**
  104006. * Gets or sets a boolean indicating if probes are enabled on this scene
  104007. */
  104008. probesEnabled: boolean;
  104009. /**
  104010. * Gets or sets the current offline provider to use to store scene data
  104011. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  104012. */
  104013. offlineProvider: IOfflineProvider;
  104014. /**
  104015. * Gets or sets the action manager associated with the scene
  104016. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  104017. */
  104018. actionManager: AbstractActionManager;
  104019. private _meshesForIntersections;
  104020. /**
  104021. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  104022. */
  104023. proceduralTexturesEnabled: boolean;
  104024. private _engine;
  104025. private _totalVertices;
  104026. /** @hidden */
  104027. _activeIndices: PerfCounter;
  104028. /** @hidden */
  104029. _activeParticles: PerfCounter;
  104030. /** @hidden */
  104031. _activeBones: PerfCounter;
  104032. private _animationRatio;
  104033. /** @hidden */
  104034. _animationTimeLast: number;
  104035. /** @hidden */
  104036. _animationTime: number;
  104037. /**
  104038. * Gets or sets a general scale for animation speed
  104039. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  104040. */
  104041. animationTimeScale: number;
  104042. /** @hidden */
  104043. _cachedMaterial: Nullable<Material>;
  104044. /** @hidden */
  104045. _cachedEffect: Nullable<Effect>;
  104046. /** @hidden */
  104047. _cachedVisibility: Nullable<number>;
  104048. private _renderId;
  104049. private _frameId;
  104050. private _executeWhenReadyTimeoutId;
  104051. private _intermediateRendering;
  104052. private _viewUpdateFlag;
  104053. private _projectionUpdateFlag;
  104054. /** @hidden */
  104055. _toBeDisposed: Nullable<IDisposable>[];
  104056. private _activeRequests;
  104057. /** @hidden */
  104058. _pendingData: any[];
  104059. private _isDisposed;
  104060. /**
  104061. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  104062. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  104063. */
  104064. dispatchAllSubMeshesOfActiveMeshes: boolean;
  104065. private _activeMeshes;
  104066. private _processedMaterials;
  104067. private _renderTargets;
  104068. /** @hidden */
  104069. _activeParticleSystems: SmartArray<IParticleSystem>;
  104070. private _activeSkeletons;
  104071. private _softwareSkinnedMeshes;
  104072. private _renderingManager;
  104073. /** @hidden */
  104074. _activeAnimatables: Animatable[];
  104075. private _transformMatrix;
  104076. private _sceneUbo;
  104077. /** @hidden */
  104078. _viewMatrix: Matrix;
  104079. private _projectionMatrix;
  104080. /** @hidden */
  104081. _forcedViewPosition: Nullable<Vector3>;
  104082. /** @hidden */
  104083. _frustumPlanes: Plane[];
  104084. /**
  104085. * Gets the list of frustum planes (built from the active camera)
  104086. */
  104087. readonly frustumPlanes: Plane[];
  104088. /**
  104089. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  104090. * This is useful if there are more lights that the maximum simulteanous authorized
  104091. */
  104092. requireLightSorting: boolean;
  104093. /** @hidden */
  104094. readonly useMaterialMeshMap: boolean;
  104095. /** @hidden */
  104096. readonly useClonedMeshhMap: boolean;
  104097. private _externalData;
  104098. private _uid;
  104099. /**
  104100. * @hidden
  104101. * Backing store of defined scene components.
  104102. */
  104103. _components: ISceneComponent[];
  104104. /**
  104105. * @hidden
  104106. * Backing store of defined scene components.
  104107. */
  104108. _serializableComponents: ISceneSerializableComponent[];
  104109. /**
  104110. * List of components to register on the next registration step.
  104111. */
  104112. private _transientComponents;
  104113. /**
  104114. * Registers the transient components if needed.
  104115. */
  104116. private _registerTransientComponents;
  104117. /**
  104118. * @hidden
  104119. * Add a component to the scene.
  104120. * Note that the ccomponent could be registered on th next frame if this is called after
  104121. * the register component stage.
  104122. * @param component Defines the component to add to the scene
  104123. */
  104124. _addComponent(component: ISceneComponent): void;
  104125. /**
  104126. * @hidden
  104127. * Gets a component from the scene.
  104128. * @param name defines the name of the component to retrieve
  104129. * @returns the component or null if not present
  104130. */
  104131. _getComponent(name: string): Nullable<ISceneComponent>;
  104132. /**
  104133. * @hidden
  104134. * Defines the actions happening before camera updates.
  104135. */
  104136. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  104137. /**
  104138. * @hidden
  104139. * Defines the actions happening before clear the canvas.
  104140. */
  104141. _beforeClearStage: Stage<SimpleStageAction>;
  104142. /**
  104143. * @hidden
  104144. * Defines the actions when collecting render targets for the frame.
  104145. */
  104146. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  104147. /**
  104148. * @hidden
  104149. * Defines the actions happening for one camera in the frame.
  104150. */
  104151. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  104152. /**
  104153. * @hidden
  104154. * Defines the actions happening during the per mesh ready checks.
  104155. */
  104156. _isReadyForMeshStage: Stage<MeshStageAction>;
  104157. /**
  104158. * @hidden
  104159. * Defines the actions happening before evaluate active mesh checks.
  104160. */
  104161. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  104162. /**
  104163. * @hidden
  104164. * Defines the actions happening during the evaluate sub mesh checks.
  104165. */
  104166. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  104167. /**
  104168. * @hidden
  104169. * Defines the actions happening during the active mesh stage.
  104170. */
  104171. _activeMeshStage: Stage<ActiveMeshStageAction>;
  104172. /**
  104173. * @hidden
  104174. * Defines the actions happening during the per camera render target step.
  104175. */
  104176. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  104177. /**
  104178. * @hidden
  104179. * Defines the actions happening just before the active camera is drawing.
  104180. */
  104181. _beforeCameraDrawStage: Stage<CameraStageAction>;
  104182. /**
  104183. * @hidden
  104184. * Defines the actions happening just before a render target is drawing.
  104185. */
  104186. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  104187. /**
  104188. * @hidden
  104189. * Defines the actions happening just before a rendering group is drawing.
  104190. */
  104191. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  104192. /**
  104193. * @hidden
  104194. * Defines the actions happening just before a mesh is drawing.
  104195. */
  104196. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  104197. /**
  104198. * @hidden
  104199. * Defines the actions happening just after a mesh has been drawn.
  104200. */
  104201. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  104202. /**
  104203. * @hidden
  104204. * Defines the actions happening just after a rendering group has been drawn.
  104205. */
  104206. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  104207. /**
  104208. * @hidden
  104209. * Defines the actions happening just after the active camera has been drawn.
  104210. */
  104211. _afterCameraDrawStage: Stage<CameraStageAction>;
  104212. /**
  104213. * @hidden
  104214. * Defines the actions happening just after a render target has been drawn.
  104215. */
  104216. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  104217. /**
  104218. * @hidden
  104219. * Defines the actions happening just after rendering all cameras and computing intersections.
  104220. */
  104221. _afterRenderStage: Stage<SimpleStageAction>;
  104222. /**
  104223. * @hidden
  104224. * Defines the actions happening when a pointer move event happens.
  104225. */
  104226. _pointerMoveStage: Stage<PointerMoveStageAction>;
  104227. /**
  104228. * @hidden
  104229. * Defines the actions happening when a pointer down event happens.
  104230. */
  104231. _pointerDownStage: Stage<PointerUpDownStageAction>;
  104232. /**
  104233. * @hidden
  104234. * Defines the actions happening when a pointer up event happens.
  104235. */
  104236. _pointerUpStage: Stage<PointerUpDownStageAction>;
  104237. /**
  104238. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  104239. */
  104240. private geometriesByUniqueId;
  104241. /**
  104242. * Creates a new Scene
  104243. * @param engine defines the engine to use to render this scene
  104244. * @param options defines the scene options
  104245. */
  104246. constructor(engine: Engine, options?: SceneOptions);
  104247. /**
  104248. * Gets a string idenfifying the name of the class
  104249. * @returns "Scene" string
  104250. */
  104251. getClassName(): string;
  104252. private _defaultMeshCandidates;
  104253. /**
  104254. * @hidden
  104255. */
  104256. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  104257. private _defaultSubMeshCandidates;
  104258. /**
  104259. * @hidden
  104260. */
  104261. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  104262. /**
  104263. * Sets the default candidate providers for the scene.
  104264. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  104265. * and getCollidingSubMeshCandidates to their default function
  104266. */
  104267. setDefaultCandidateProviders(): void;
  104268. /**
  104269. * Gets the mesh that is currently under the pointer
  104270. */
  104271. readonly meshUnderPointer: Nullable<AbstractMesh>;
  104272. /**
  104273. * Gets or sets the current on-screen X position of the pointer
  104274. */
  104275. pointerX: number;
  104276. /**
  104277. * Gets or sets the current on-screen Y position of the pointer
  104278. */
  104279. pointerY: number;
  104280. /**
  104281. * Gets the cached material (ie. the latest rendered one)
  104282. * @returns the cached material
  104283. */
  104284. getCachedMaterial(): Nullable<Material>;
  104285. /**
  104286. * Gets the cached effect (ie. the latest rendered one)
  104287. * @returns the cached effect
  104288. */
  104289. getCachedEffect(): Nullable<Effect>;
  104290. /**
  104291. * Gets the cached visibility state (ie. the latest rendered one)
  104292. * @returns the cached visibility state
  104293. */
  104294. getCachedVisibility(): Nullable<number>;
  104295. /**
  104296. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  104297. * @param material defines the current material
  104298. * @param effect defines the current effect
  104299. * @param visibility defines the current visibility state
  104300. * @returns true if one parameter is not cached
  104301. */
  104302. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  104303. /**
  104304. * Gets the engine associated with the scene
  104305. * @returns an Engine
  104306. */
  104307. getEngine(): Engine;
  104308. /**
  104309. * Gets the total number of vertices rendered per frame
  104310. * @returns the total number of vertices rendered per frame
  104311. */
  104312. getTotalVertices(): number;
  104313. /**
  104314. * Gets the performance counter for total vertices
  104315. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  104316. */
  104317. readonly totalVerticesPerfCounter: PerfCounter;
  104318. /**
  104319. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  104320. * @returns the total number of active indices rendered per frame
  104321. */
  104322. getActiveIndices(): number;
  104323. /**
  104324. * Gets the performance counter for active indices
  104325. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  104326. */
  104327. readonly totalActiveIndicesPerfCounter: PerfCounter;
  104328. /**
  104329. * Gets the total number of active particles rendered per frame
  104330. * @returns the total number of active particles rendered per frame
  104331. */
  104332. getActiveParticles(): number;
  104333. /**
  104334. * Gets the performance counter for active particles
  104335. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  104336. */
  104337. readonly activeParticlesPerfCounter: PerfCounter;
  104338. /**
  104339. * Gets the total number of active bones rendered per frame
  104340. * @returns the total number of active bones rendered per frame
  104341. */
  104342. getActiveBones(): number;
  104343. /**
  104344. * Gets the performance counter for active bones
  104345. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  104346. */
  104347. readonly activeBonesPerfCounter: PerfCounter;
  104348. /**
  104349. * Gets the array of active meshes
  104350. * @returns an array of AbstractMesh
  104351. */
  104352. getActiveMeshes(): SmartArray<AbstractMesh>;
  104353. /**
  104354. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  104355. * @returns a number
  104356. */
  104357. getAnimationRatio(): number;
  104358. /**
  104359. * Gets an unique Id for the current render phase
  104360. * @returns a number
  104361. */
  104362. getRenderId(): number;
  104363. /**
  104364. * Gets an unique Id for the current frame
  104365. * @returns a number
  104366. */
  104367. getFrameId(): number;
  104368. /** Call this function if you want to manually increment the render Id*/
  104369. incrementRenderId(): void;
  104370. private _createUbo;
  104371. /**
  104372. * Use this method to simulate a pointer move on a mesh
  104373. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  104374. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  104375. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  104376. * @returns the current scene
  104377. */
  104378. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  104379. /**
  104380. * Use this method to simulate a pointer down on a mesh
  104381. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  104382. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  104383. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  104384. * @returns the current scene
  104385. */
  104386. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  104387. /**
  104388. * Use this method to simulate a pointer up on a mesh
  104389. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  104390. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  104391. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  104392. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  104393. * @returns the current scene
  104394. */
  104395. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  104396. /**
  104397. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  104398. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  104399. * @returns true if the pointer was captured
  104400. */
  104401. isPointerCaptured(pointerId?: number): boolean;
  104402. /**
  104403. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  104404. * @param attachUp defines if you want to attach events to pointerup
  104405. * @param attachDown defines if you want to attach events to pointerdown
  104406. * @param attachMove defines if you want to attach events to pointermove
  104407. */
  104408. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  104409. /** Detaches all event handlers*/
  104410. detachControl(): void;
  104411. /**
  104412. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  104413. * Delay loaded resources are not taking in account
  104414. * @return true if all required resources are ready
  104415. */
  104416. isReady(): boolean;
  104417. /** Resets all cached information relative to material (including effect and visibility) */
  104418. resetCachedMaterial(): void;
  104419. /**
  104420. * Registers a function to be called before every frame render
  104421. * @param func defines the function to register
  104422. */
  104423. registerBeforeRender(func: () => void): void;
  104424. /**
  104425. * Unregisters a function called before every frame render
  104426. * @param func defines the function to unregister
  104427. */
  104428. unregisterBeforeRender(func: () => void): void;
  104429. /**
  104430. * Registers a function to be called after every frame render
  104431. * @param func defines the function to register
  104432. */
  104433. registerAfterRender(func: () => void): void;
  104434. /**
  104435. * Unregisters a function called after every frame render
  104436. * @param func defines the function to unregister
  104437. */
  104438. unregisterAfterRender(func: () => void): void;
  104439. private _executeOnceBeforeRender;
  104440. /**
  104441. * The provided function will run before render once and will be disposed afterwards.
  104442. * A timeout delay can be provided so that the function will be executed in N ms.
  104443. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  104444. * @param func The function to be executed.
  104445. * @param timeout optional delay in ms
  104446. */
  104447. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  104448. /** @hidden */
  104449. _addPendingData(data: any): void;
  104450. /** @hidden */
  104451. _removePendingData(data: any): void;
  104452. /**
  104453. * Returns the number of items waiting to be loaded
  104454. * @returns the number of items waiting to be loaded
  104455. */
  104456. getWaitingItemsCount(): number;
  104457. /**
  104458. * Returns a boolean indicating if the scene is still loading data
  104459. */
  104460. readonly isLoading: boolean;
  104461. /**
  104462. * Registers a function to be executed when the scene is ready
  104463. * @param {Function} func - the function to be executed
  104464. */
  104465. executeWhenReady(func: () => void): void;
  104466. /**
  104467. * Returns a promise that resolves when the scene is ready
  104468. * @returns A promise that resolves when the scene is ready
  104469. */
  104470. whenReadyAsync(): Promise<void>;
  104471. /** @hidden */
  104472. _checkIsReady(): void;
  104473. /**
  104474. * Gets all animatable attached to the scene
  104475. */
  104476. readonly animatables: Animatable[];
  104477. /**
  104478. * Resets the last animation time frame.
  104479. * Useful to override when animations start running when loading a scene for the first time.
  104480. */
  104481. resetLastAnimationTimeFrame(): void;
  104482. /**
  104483. * Gets the current view matrix
  104484. * @returns a Matrix
  104485. */
  104486. getViewMatrix(): Matrix;
  104487. /**
  104488. * Gets the current projection matrix
  104489. * @returns a Matrix
  104490. */
  104491. getProjectionMatrix(): Matrix;
  104492. /**
  104493. * Gets the current transform matrix
  104494. * @returns a Matrix made of View * Projection
  104495. */
  104496. getTransformMatrix(): Matrix;
  104497. /**
  104498. * Sets the current transform matrix
  104499. * @param viewL defines the View matrix to use
  104500. * @param projectionL defines the Projection matrix to use
  104501. * @param viewR defines the right View matrix to use (if provided)
  104502. * @param projectionR defines the right Projection matrix to use (if provided)
  104503. */
  104504. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  104505. /**
  104506. * Gets the uniform buffer used to store scene data
  104507. * @returns a UniformBuffer
  104508. */
  104509. getSceneUniformBuffer(): UniformBuffer;
  104510. /**
  104511. * Gets an unique (relatively to the current scene) Id
  104512. * @returns an unique number for the scene
  104513. */
  104514. getUniqueId(): number;
  104515. /**
  104516. * Add a mesh to the list of scene's meshes
  104517. * @param newMesh defines the mesh to add
  104518. * @param recursive if all child meshes should also be added to the scene
  104519. */
  104520. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  104521. /**
  104522. * Remove a mesh for the list of scene's meshes
  104523. * @param toRemove defines the mesh to remove
  104524. * @param recursive if all child meshes should also be removed from the scene
  104525. * @returns the index where the mesh was in the mesh list
  104526. */
  104527. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  104528. /**
  104529. * Add a transform node to the list of scene's transform nodes
  104530. * @param newTransformNode defines the transform node to add
  104531. */
  104532. addTransformNode(newTransformNode: TransformNode): void;
  104533. /**
  104534. * Remove a transform node for the list of scene's transform nodes
  104535. * @param toRemove defines the transform node to remove
  104536. * @returns the index where the transform node was in the transform node list
  104537. */
  104538. removeTransformNode(toRemove: TransformNode): number;
  104539. /**
  104540. * Remove a skeleton for the list of scene's skeletons
  104541. * @param toRemove defines the skeleton to remove
  104542. * @returns the index where the skeleton was in the skeleton list
  104543. */
  104544. removeSkeleton(toRemove: Skeleton): number;
  104545. /**
  104546. * Remove a morph target for the list of scene's morph targets
  104547. * @param toRemove defines the morph target to remove
  104548. * @returns the index where the morph target was in the morph target list
  104549. */
  104550. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  104551. /**
  104552. * Remove a light for the list of scene's lights
  104553. * @param toRemove defines the light to remove
  104554. * @returns the index where the light was in the light list
  104555. */
  104556. removeLight(toRemove: Light): number;
  104557. /**
  104558. * Remove a camera for the list of scene's cameras
  104559. * @param toRemove defines the camera to remove
  104560. * @returns the index where the camera was in the camera list
  104561. */
  104562. removeCamera(toRemove: Camera): number;
  104563. /**
  104564. * Remove a particle system for the list of scene's particle systems
  104565. * @param toRemove defines the particle system to remove
  104566. * @returns the index where the particle system was in the particle system list
  104567. */
  104568. removeParticleSystem(toRemove: IParticleSystem): number;
  104569. /**
  104570. * Remove a animation for the list of scene's animations
  104571. * @param toRemove defines the animation to remove
  104572. * @returns the index where the animation was in the animation list
  104573. */
  104574. removeAnimation(toRemove: Animation): number;
  104575. /**
  104576. * Will stop the animation of the given target
  104577. * @param target - the target
  104578. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  104579. * @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)
  104580. */
  104581. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  104582. /**
  104583. * Removes the given animation group from this scene.
  104584. * @param toRemove The animation group to remove
  104585. * @returns The index of the removed animation group
  104586. */
  104587. removeAnimationGroup(toRemove: AnimationGroup): number;
  104588. /**
  104589. * Removes the given multi-material from this scene.
  104590. * @param toRemove The multi-material to remove
  104591. * @returns The index of the removed multi-material
  104592. */
  104593. removeMultiMaterial(toRemove: MultiMaterial): number;
  104594. /**
  104595. * Removes the given material from this scene.
  104596. * @param toRemove The material to remove
  104597. * @returns The index of the removed material
  104598. */
  104599. removeMaterial(toRemove: Material): number;
  104600. /**
  104601. * Removes the given action manager from this scene.
  104602. * @param toRemove The action manager to remove
  104603. * @returns The index of the removed action manager
  104604. */
  104605. removeActionManager(toRemove: AbstractActionManager): number;
  104606. /**
  104607. * Removes the given texture from this scene.
  104608. * @param toRemove The texture to remove
  104609. * @returns The index of the removed texture
  104610. */
  104611. removeTexture(toRemove: BaseTexture): number;
  104612. /**
  104613. * Adds the given light to this scene
  104614. * @param newLight The light to add
  104615. */
  104616. addLight(newLight: Light): void;
  104617. /**
  104618. * Sorts the list list based on light priorities
  104619. */
  104620. sortLightsByPriority(): void;
  104621. /**
  104622. * Adds the given camera to this scene
  104623. * @param newCamera The camera to add
  104624. */
  104625. addCamera(newCamera: Camera): void;
  104626. /**
  104627. * Adds the given skeleton to this scene
  104628. * @param newSkeleton The skeleton to add
  104629. */
  104630. addSkeleton(newSkeleton: Skeleton): void;
  104631. /**
  104632. * Adds the given particle system to this scene
  104633. * @param newParticleSystem The particle system to add
  104634. */
  104635. addParticleSystem(newParticleSystem: IParticleSystem): void;
  104636. /**
  104637. * Adds the given animation to this scene
  104638. * @param newAnimation The animation to add
  104639. */
  104640. addAnimation(newAnimation: Animation): void;
  104641. /**
  104642. * Adds the given animation group to this scene.
  104643. * @param newAnimationGroup The animation group to add
  104644. */
  104645. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  104646. /**
  104647. * Adds the given multi-material to this scene
  104648. * @param newMultiMaterial The multi-material to add
  104649. */
  104650. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  104651. /**
  104652. * Adds the given material to this scene
  104653. * @param newMaterial The material to add
  104654. */
  104655. addMaterial(newMaterial: Material): void;
  104656. /**
  104657. * Adds the given morph target to this scene
  104658. * @param newMorphTargetManager The morph target to add
  104659. */
  104660. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  104661. /**
  104662. * Adds the given geometry to this scene
  104663. * @param newGeometry The geometry to add
  104664. */
  104665. addGeometry(newGeometry: Geometry): void;
  104666. /**
  104667. * Adds the given action manager to this scene
  104668. * @param newActionManager The action manager to add
  104669. */
  104670. addActionManager(newActionManager: AbstractActionManager): void;
  104671. /**
  104672. * Adds the given texture to this scene.
  104673. * @param newTexture The texture to add
  104674. */
  104675. addTexture(newTexture: BaseTexture): void;
  104676. /**
  104677. * Switch active camera
  104678. * @param newCamera defines the new active camera
  104679. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  104680. */
  104681. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  104682. /**
  104683. * sets the active camera of the scene using its ID
  104684. * @param id defines the camera's ID
  104685. * @return the new active camera or null if none found.
  104686. */
  104687. setActiveCameraByID(id: string): Nullable<Camera>;
  104688. /**
  104689. * sets the active camera of the scene using its name
  104690. * @param name defines the camera's name
  104691. * @returns the new active camera or null if none found.
  104692. */
  104693. setActiveCameraByName(name: string): Nullable<Camera>;
  104694. /**
  104695. * get an animation group using its name
  104696. * @param name defines the material's name
  104697. * @return the animation group or null if none found.
  104698. */
  104699. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  104700. /**
  104701. * Get a material using its unique id
  104702. * @param uniqueId defines the material's unique id
  104703. * @return the material or null if none found.
  104704. */
  104705. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  104706. /**
  104707. * get a material using its id
  104708. * @param id defines the material's ID
  104709. * @return the material or null if none found.
  104710. */
  104711. getMaterialByID(id: string): Nullable<Material>;
  104712. /**
  104713. * Gets a the last added material using a given id
  104714. * @param id defines the material's ID
  104715. * @return the last material with the given id or null if none found.
  104716. */
  104717. getLastMaterialByID(id: string): Nullable<Material>;
  104718. /**
  104719. * Gets a material using its name
  104720. * @param name defines the material's name
  104721. * @return the material or null if none found.
  104722. */
  104723. getMaterialByName(name: string): Nullable<Material>;
  104724. /**
  104725. * Get a texture using its unique id
  104726. * @param uniqueId defines the texture's unique id
  104727. * @return the texture or null if none found.
  104728. */
  104729. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  104730. /**
  104731. * Gets a camera using its id
  104732. * @param id defines the id to look for
  104733. * @returns the camera or null if not found
  104734. */
  104735. getCameraByID(id: string): Nullable<Camera>;
  104736. /**
  104737. * Gets a camera using its unique id
  104738. * @param uniqueId defines the unique id to look for
  104739. * @returns the camera or null if not found
  104740. */
  104741. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  104742. /**
  104743. * Gets a camera using its name
  104744. * @param name defines the camera's name
  104745. * @return the camera or null if none found.
  104746. */
  104747. getCameraByName(name: string): Nullable<Camera>;
  104748. /**
  104749. * Gets a bone using its id
  104750. * @param id defines the bone's id
  104751. * @return the bone or null if not found
  104752. */
  104753. getBoneByID(id: string): Nullable<Bone>;
  104754. /**
  104755. * Gets a bone using its id
  104756. * @param name defines the bone's name
  104757. * @return the bone or null if not found
  104758. */
  104759. getBoneByName(name: string): Nullable<Bone>;
  104760. /**
  104761. * Gets a light node using its name
  104762. * @param name defines the the light's name
  104763. * @return the light or null if none found.
  104764. */
  104765. getLightByName(name: string): Nullable<Light>;
  104766. /**
  104767. * Gets a light node using its id
  104768. * @param id defines the light's id
  104769. * @return the light or null if none found.
  104770. */
  104771. getLightByID(id: string): Nullable<Light>;
  104772. /**
  104773. * Gets a light node using its scene-generated unique ID
  104774. * @param uniqueId defines the light's unique id
  104775. * @return the light or null if none found.
  104776. */
  104777. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  104778. /**
  104779. * Gets a particle system by id
  104780. * @param id defines the particle system id
  104781. * @return the corresponding system or null if none found
  104782. */
  104783. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  104784. /**
  104785. * Gets a geometry using its ID
  104786. * @param id defines the geometry's id
  104787. * @return the geometry or null if none found.
  104788. */
  104789. getGeometryByID(id: string): Nullable<Geometry>;
  104790. private _getGeometryByUniqueID;
  104791. /**
  104792. * Add a new geometry to this scene
  104793. * @param geometry defines the geometry to be added to the scene.
  104794. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  104795. * @return a boolean defining if the geometry was added or not
  104796. */
  104797. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  104798. /**
  104799. * Removes an existing geometry
  104800. * @param geometry defines the geometry to be removed from the scene
  104801. * @return a boolean defining if the geometry was removed or not
  104802. */
  104803. removeGeometry(geometry: Geometry): boolean;
  104804. /**
  104805. * Gets the list of geometries attached to the scene
  104806. * @returns an array of Geometry
  104807. */
  104808. getGeometries(): Geometry[];
  104809. /**
  104810. * Gets the first added mesh found of a given ID
  104811. * @param id defines the id to search for
  104812. * @return the mesh found or null if not found at all
  104813. */
  104814. getMeshByID(id: string): Nullable<AbstractMesh>;
  104815. /**
  104816. * Gets a list of meshes using their id
  104817. * @param id defines the id to search for
  104818. * @returns a list of meshes
  104819. */
  104820. getMeshesByID(id: string): Array<AbstractMesh>;
  104821. /**
  104822. * Gets the first added transform node found of a given ID
  104823. * @param id defines the id to search for
  104824. * @return the found transform node or null if not found at all.
  104825. */
  104826. getTransformNodeByID(id: string): Nullable<TransformNode>;
  104827. /**
  104828. * Gets a transform node with its auto-generated unique id
  104829. * @param uniqueId efines the unique id to search for
  104830. * @return the found transform node or null if not found at all.
  104831. */
  104832. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  104833. /**
  104834. * Gets a list of transform nodes using their id
  104835. * @param id defines the id to search for
  104836. * @returns a list of transform nodes
  104837. */
  104838. getTransformNodesByID(id: string): Array<TransformNode>;
  104839. /**
  104840. * Gets a mesh with its auto-generated unique id
  104841. * @param uniqueId defines the unique id to search for
  104842. * @return the found mesh or null if not found at all.
  104843. */
  104844. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  104845. /**
  104846. * Gets a the last added mesh using a given id
  104847. * @param id defines the id to search for
  104848. * @return the found mesh or null if not found at all.
  104849. */
  104850. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  104851. /**
  104852. * Gets a the last added node (Mesh, Camera, Light) using a given id
  104853. * @param id defines the id to search for
  104854. * @return the found node or null if not found at all
  104855. */
  104856. getLastEntryByID(id: string): Nullable<Node>;
  104857. /**
  104858. * Gets a node (Mesh, Camera, Light) using a given id
  104859. * @param id defines the id to search for
  104860. * @return the found node or null if not found at all
  104861. */
  104862. getNodeByID(id: string): Nullable<Node>;
  104863. /**
  104864. * Gets a node (Mesh, Camera, Light) using a given name
  104865. * @param name defines the name to search for
  104866. * @return the found node or null if not found at all.
  104867. */
  104868. getNodeByName(name: string): Nullable<Node>;
  104869. /**
  104870. * Gets a mesh using a given name
  104871. * @param name defines the name to search for
  104872. * @return the found mesh or null if not found at all.
  104873. */
  104874. getMeshByName(name: string): Nullable<AbstractMesh>;
  104875. /**
  104876. * Gets a transform node using a given name
  104877. * @param name defines the name to search for
  104878. * @return the found transform node or null if not found at all.
  104879. */
  104880. getTransformNodeByName(name: string): Nullable<TransformNode>;
  104881. /**
  104882. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  104883. * @param id defines the id to search for
  104884. * @return the found skeleton or null if not found at all.
  104885. */
  104886. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  104887. /**
  104888. * Gets a skeleton using a given auto generated unique id
  104889. * @param uniqueId defines the unique id to search for
  104890. * @return the found skeleton or null if not found at all.
  104891. */
  104892. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  104893. /**
  104894. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  104895. * @param id defines the id to search for
  104896. * @return the found skeleton or null if not found at all.
  104897. */
  104898. getSkeletonById(id: string): Nullable<Skeleton>;
  104899. /**
  104900. * Gets a skeleton using a given name
  104901. * @param name defines the name to search for
  104902. * @return the found skeleton or null if not found at all.
  104903. */
  104904. getSkeletonByName(name: string): Nullable<Skeleton>;
  104905. /**
  104906. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  104907. * @param id defines the id to search for
  104908. * @return the found morph target manager or null if not found at all.
  104909. */
  104910. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  104911. /**
  104912. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  104913. * @param id defines the id to search for
  104914. * @return the found morph target or null if not found at all.
  104915. */
  104916. getMorphTargetById(id: string): Nullable<MorphTarget>;
  104917. /**
  104918. * Gets a boolean indicating if the given mesh is active
  104919. * @param mesh defines the mesh to look for
  104920. * @returns true if the mesh is in the active list
  104921. */
  104922. isActiveMesh(mesh: AbstractMesh): boolean;
  104923. /**
  104924. * Return a unique id as a string which can serve as an identifier for the scene
  104925. */
  104926. readonly uid: string;
  104927. /**
  104928. * Add an externaly attached data from its key.
  104929. * This method call will fail and return false, if such key already exists.
  104930. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  104931. * @param key the unique key that identifies the data
  104932. * @param data the data object to associate to the key for this Engine instance
  104933. * @return true if no such key were already present and the data was added successfully, false otherwise
  104934. */
  104935. addExternalData<T>(key: string, data: T): boolean;
  104936. /**
  104937. * Get an externaly attached data from its key
  104938. * @param key the unique key that identifies the data
  104939. * @return the associated data, if present (can be null), or undefined if not present
  104940. */
  104941. getExternalData<T>(key: string): Nullable<T>;
  104942. /**
  104943. * Get an externaly attached data from its key, create it using a factory if it's not already present
  104944. * @param key the unique key that identifies the data
  104945. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  104946. * @return the associated data, can be null if the factory returned null.
  104947. */
  104948. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  104949. /**
  104950. * Remove an externaly attached data from the Engine instance
  104951. * @param key the unique key that identifies the data
  104952. * @return true if the data was successfully removed, false if it doesn't exist
  104953. */
  104954. removeExternalData(key: string): boolean;
  104955. private _evaluateSubMesh;
  104956. /**
  104957. * Clear the processed materials smart array preventing retention point in material dispose.
  104958. */
  104959. freeProcessedMaterials(): void;
  104960. private _preventFreeActiveMeshesAndRenderingGroups;
  104961. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  104962. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  104963. * when disposing several meshes in a row or a hierarchy of meshes.
  104964. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  104965. */
  104966. blockfreeActiveMeshesAndRenderingGroups: boolean;
  104967. /**
  104968. * Clear the active meshes smart array preventing retention point in mesh dispose.
  104969. */
  104970. freeActiveMeshes(): void;
  104971. /**
  104972. * Clear the info related to rendering groups preventing retention points during dispose.
  104973. */
  104974. freeRenderingGroups(): void;
  104975. /** @hidden */
  104976. _isInIntermediateRendering(): boolean;
  104977. /**
  104978. * Lambda returning the list of potentially active meshes.
  104979. */
  104980. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  104981. /**
  104982. * Lambda returning the list of potentially active sub meshes.
  104983. */
  104984. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  104985. /**
  104986. * Lambda returning the list of potentially intersecting sub meshes.
  104987. */
  104988. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  104989. /**
  104990. * Lambda returning the list of potentially colliding sub meshes.
  104991. */
  104992. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  104993. private _activeMeshesFrozen;
  104994. private _skipEvaluateActiveMeshesCompletely;
  104995. /**
  104996. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  104997. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  104998. * @returns the current scene
  104999. */
  105000. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  105001. /**
  105002. * Use this function to restart evaluating active meshes on every frame
  105003. * @returns the current scene
  105004. */
  105005. unfreezeActiveMeshes(): Scene;
  105006. private _evaluateActiveMeshes;
  105007. private _activeMesh;
  105008. /**
  105009. * Update the transform matrix to update from the current active camera
  105010. * @param force defines a boolean used to force the update even if cache is up to date
  105011. */
  105012. updateTransformMatrix(force?: boolean): void;
  105013. private _bindFrameBuffer;
  105014. /** @hidden */
  105015. _allowPostProcessClearColor: boolean;
  105016. /** @hidden */
  105017. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  105018. private _processSubCameras;
  105019. private _checkIntersections;
  105020. /** @hidden */
  105021. _advancePhysicsEngineStep(step: number): void;
  105022. /**
  105023. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  105024. */
  105025. getDeterministicFrameTime: () => number;
  105026. /** @hidden */
  105027. _animate(): void;
  105028. /** Execute all animations (for a frame) */
  105029. animate(): void;
  105030. /**
  105031. * Render the scene
  105032. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  105033. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  105034. */
  105035. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  105036. /**
  105037. * Freeze all materials
  105038. * A frozen material will not be updatable but should be faster to render
  105039. */
  105040. freezeMaterials(): void;
  105041. /**
  105042. * Unfreeze all materials
  105043. * A frozen material will not be updatable but should be faster to render
  105044. */
  105045. unfreezeMaterials(): void;
  105046. /**
  105047. * Releases all held ressources
  105048. */
  105049. dispose(): void;
  105050. /**
  105051. * Gets if the scene is already disposed
  105052. */
  105053. readonly isDisposed: boolean;
  105054. /**
  105055. * Call this function to reduce memory footprint of the scene.
  105056. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  105057. */
  105058. clearCachedVertexData(): void;
  105059. /**
  105060. * This function will remove the local cached buffer data from texture.
  105061. * It will save memory but will prevent the texture from being rebuilt
  105062. */
  105063. cleanCachedTextureBuffer(): void;
  105064. /**
  105065. * Get the world extend vectors with an optional filter
  105066. *
  105067. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  105068. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  105069. */
  105070. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  105071. min: Vector3;
  105072. max: Vector3;
  105073. };
  105074. /**
  105075. * Creates a ray that can be used to pick in the scene
  105076. * @param x defines the x coordinate of the origin (on-screen)
  105077. * @param y defines the y coordinate of the origin (on-screen)
  105078. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  105079. * @param camera defines the camera to use for the picking
  105080. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  105081. * @returns a Ray
  105082. */
  105083. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  105084. /**
  105085. * Creates a ray that can be used to pick in the scene
  105086. * @param x defines the x coordinate of the origin (on-screen)
  105087. * @param y defines the y coordinate of the origin (on-screen)
  105088. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  105089. * @param result defines the ray where to store the picking ray
  105090. * @param camera defines the camera to use for the picking
  105091. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  105092. * @returns the current scene
  105093. */
  105094. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  105095. /**
  105096. * Creates a ray that can be used to pick in the scene
  105097. * @param x defines the x coordinate of the origin (on-screen)
  105098. * @param y defines the y coordinate of the origin (on-screen)
  105099. * @param camera defines the camera to use for the picking
  105100. * @returns a Ray
  105101. */
  105102. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  105103. /**
  105104. * Creates a ray that can be used to pick in the scene
  105105. * @param x defines the x coordinate of the origin (on-screen)
  105106. * @param y defines the y coordinate of the origin (on-screen)
  105107. * @param result defines the ray where to store the picking ray
  105108. * @param camera defines the camera to use for the picking
  105109. * @returns the current scene
  105110. */
  105111. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  105112. /** Launch a ray to try to pick a mesh in the scene
  105113. * @param x position on screen
  105114. * @param y position on screen
  105115. * @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
  105116. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  105117. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  105118. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  105119. * @returns a PickingInfo
  105120. */
  105121. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  105122. /** Use the given ray to pick a mesh in the scene
  105123. * @param ray The ray to use to pick meshes
  105124. * @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
  105125. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  105126. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  105127. * @returns a PickingInfo
  105128. */
  105129. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  105130. /**
  105131. * Launch a ray to try to pick a mesh in the scene
  105132. * @param x X position on screen
  105133. * @param y Y position on screen
  105134. * @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
  105135. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  105136. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  105137. * @returns an array of PickingInfo
  105138. */
  105139. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  105140. /**
  105141. * Launch a ray to try to pick a mesh in the scene
  105142. * @param ray Ray to use
  105143. * @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
  105144. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  105145. * @returns an array of PickingInfo
  105146. */
  105147. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  105148. /**
  105149. * Force the value of meshUnderPointer
  105150. * @param mesh defines the mesh to use
  105151. */
  105152. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  105153. /**
  105154. * Gets the mesh under the pointer
  105155. * @returns a Mesh or null if no mesh is under the pointer
  105156. */
  105157. getPointerOverMesh(): Nullable<AbstractMesh>;
  105158. /** @hidden */
  105159. _rebuildGeometries(): void;
  105160. /** @hidden */
  105161. _rebuildTextures(): void;
  105162. private _getByTags;
  105163. /**
  105164. * Get a list of meshes by tags
  105165. * @param tagsQuery defines the tags query to use
  105166. * @param forEach defines a predicate used to filter results
  105167. * @returns an array of Mesh
  105168. */
  105169. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  105170. /**
  105171. * Get a list of cameras by tags
  105172. * @param tagsQuery defines the tags query to use
  105173. * @param forEach defines a predicate used to filter results
  105174. * @returns an array of Camera
  105175. */
  105176. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  105177. /**
  105178. * Get a list of lights by tags
  105179. * @param tagsQuery defines the tags query to use
  105180. * @param forEach defines a predicate used to filter results
  105181. * @returns an array of Light
  105182. */
  105183. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  105184. /**
  105185. * Get a list of materials by tags
  105186. * @param tagsQuery defines the tags query to use
  105187. * @param forEach defines a predicate used to filter results
  105188. * @returns an array of Material
  105189. */
  105190. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  105191. /**
  105192. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  105193. * This allowed control for front to back rendering or reversly depending of the special needs.
  105194. *
  105195. * @param renderingGroupId The rendering group id corresponding to its index
  105196. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  105197. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  105198. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  105199. */
  105200. 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;
  105201. /**
  105202. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  105203. *
  105204. * @param renderingGroupId The rendering group id corresponding to its index
  105205. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  105206. * @param depth Automatically clears depth between groups if true and autoClear is true.
  105207. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  105208. */
  105209. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  105210. /**
  105211. * Gets the current auto clear configuration for one rendering group of the rendering
  105212. * manager.
  105213. * @param index the rendering group index to get the information for
  105214. * @returns The auto clear setup for the requested rendering group
  105215. */
  105216. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  105217. private _blockMaterialDirtyMechanism;
  105218. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  105219. blockMaterialDirtyMechanism: boolean;
  105220. /**
  105221. * Will flag all materials as dirty to trigger new shader compilation
  105222. * @param flag defines the flag used to specify which material part must be marked as dirty
  105223. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  105224. */
  105225. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  105226. /** @hidden */
  105227. _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;
  105228. /** @hidden */
  105229. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  105230. /** @hidden */
  105231. _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;
  105232. /** @hidden */
  105233. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  105234. /** @hidden */
  105235. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  105236. /** @hidden */
  105237. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  105238. }
  105239. }
  105240. declare module BABYLON {
  105241. /**
  105242. * Set of assets to keep when moving a scene into an asset container.
  105243. */
  105244. export class KeepAssets extends AbstractScene {
  105245. }
  105246. /**
  105247. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  105248. */
  105249. export class InstantiatedEntries {
  105250. /**
  105251. * List of new root nodes (eg. nodes with no parent)
  105252. */
  105253. rootNodes: TransformNode[];
  105254. /**
  105255. * List of new skeletons
  105256. */
  105257. skeletons: Skeleton[];
  105258. /**
  105259. * List of new animation groups
  105260. */
  105261. animationGroups: AnimationGroup[];
  105262. }
  105263. /**
  105264. * Container with a set of assets that can be added or removed from a scene.
  105265. */
  105266. export class AssetContainer extends AbstractScene {
  105267. /**
  105268. * The scene the AssetContainer belongs to.
  105269. */
  105270. scene: Scene;
  105271. /**
  105272. * Instantiates an AssetContainer.
  105273. * @param scene The scene the AssetContainer belongs to.
  105274. */
  105275. constructor(scene: Scene);
  105276. /**
  105277. * Instantiate or clone all meshes and add the new ones to the scene.
  105278. * Skeletons and animation groups will all be cloned
  105279. * @param nameFunction defines an optional function used to get new names for clones
  105280. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  105281. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  105282. */
  105283. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  105284. /**
  105285. * Adds all the assets from the container to the scene.
  105286. */
  105287. addAllToScene(): void;
  105288. /**
  105289. * Removes all the assets in the container from the scene
  105290. */
  105291. removeAllFromScene(): void;
  105292. /**
  105293. * Disposes all the assets in the container
  105294. */
  105295. dispose(): void;
  105296. private _moveAssets;
  105297. /**
  105298. * Removes all the assets contained in the scene and adds them to the container.
  105299. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  105300. */
  105301. moveAllFromScene(keepAssets?: KeepAssets): void;
  105302. /**
  105303. * 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.
  105304. * @returns the root mesh
  105305. */
  105306. createRootMesh(): Mesh;
  105307. }
  105308. }
  105309. declare module BABYLON {
  105310. /**
  105311. * Defines how the parser contract is defined.
  105312. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  105313. */
  105314. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  105315. /**
  105316. * Defines how the individual parser contract is defined.
  105317. * These parser can parse an individual asset
  105318. */
  105319. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  105320. /**
  105321. * Base class of the scene acting as a container for the different elements composing a scene.
  105322. * This class is dynamically extended by the different components of the scene increasing
  105323. * flexibility and reducing coupling
  105324. */
  105325. export abstract class AbstractScene {
  105326. /**
  105327. * Stores the list of available parsers in the application.
  105328. */
  105329. private static _BabylonFileParsers;
  105330. /**
  105331. * Stores the list of available individual parsers in the application.
  105332. */
  105333. private static _IndividualBabylonFileParsers;
  105334. /**
  105335. * Adds a parser in the list of available ones
  105336. * @param name Defines the name of the parser
  105337. * @param parser Defines the parser to add
  105338. */
  105339. static AddParser(name: string, parser: BabylonFileParser): void;
  105340. /**
  105341. * Gets a general parser from the list of avaialble ones
  105342. * @param name Defines the name of the parser
  105343. * @returns the requested parser or null
  105344. */
  105345. static GetParser(name: string): Nullable<BabylonFileParser>;
  105346. /**
  105347. * Adds n individual parser in the list of available ones
  105348. * @param name Defines the name of the parser
  105349. * @param parser Defines the parser to add
  105350. */
  105351. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  105352. /**
  105353. * Gets an individual parser from the list of avaialble ones
  105354. * @param name Defines the name of the parser
  105355. * @returns the requested parser or null
  105356. */
  105357. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  105358. /**
  105359. * Parser json data and populate both a scene and its associated container object
  105360. * @param jsonData Defines the data to parse
  105361. * @param scene Defines the scene to parse the data for
  105362. * @param container Defines the container attached to the parsing sequence
  105363. * @param rootUrl Defines the root url of the data
  105364. */
  105365. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  105366. /**
  105367. * Gets the list of root nodes (ie. nodes with no parent)
  105368. */
  105369. rootNodes: Node[];
  105370. /** All of the cameras added to this scene
  105371. * @see http://doc.babylonjs.com/babylon101/cameras
  105372. */
  105373. cameras: Camera[];
  105374. /**
  105375. * All of the lights added to this scene
  105376. * @see http://doc.babylonjs.com/babylon101/lights
  105377. */
  105378. lights: Light[];
  105379. /**
  105380. * All of the (abstract) meshes added to this scene
  105381. */
  105382. meshes: AbstractMesh[];
  105383. /**
  105384. * The list of skeletons added to the scene
  105385. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  105386. */
  105387. skeletons: Skeleton[];
  105388. /**
  105389. * All of the particle systems added to this scene
  105390. * @see http://doc.babylonjs.com/babylon101/particles
  105391. */
  105392. particleSystems: IParticleSystem[];
  105393. /**
  105394. * Gets a list of Animations associated with the scene
  105395. */
  105396. animations: Animation[];
  105397. /**
  105398. * All of the animation groups added to this scene
  105399. * @see http://doc.babylonjs.com/how_to/group
  105400. */
  105401. animationGroups: AnimationGroup[];
  105402. /**
  105403. * All of the multi-materials added to this scene
  105404. * @see http://doc.babylonjs.com/how_to/multi_materials
  105405. */
  105406. multiMaterials: MultiMaterial[];
  105407. /**
  105408. * All of the materials added to this scene
  105409. * In the context of a Scene, it is not supposed to be modified manually.
  105410. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  105411. * Note also that the order of the Material within the array is not significant and might change.
  105412. * @see http://doc.babylonjs.com/babylon101/materials
  105413. */
  105414. materials: Material[];
  105415. /**
  105416. * The list of morph target managers added to the scene
  105417. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  105418. */
  105419. morphTargetManagers: MorphTargetManager[];
  105420. /**
  105421. * The list of geometries used in the scene.
  105422. */
  105423. geometries: Geometry[];
  105424. /**
  105425. * All of the tranform nodes added to this scene
  105426. * In the context of a Scene, it is not supposed to be modified manually.
  105427. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  105428. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  105429. * @see http://doc.babylonjs.com/how_to/transformnode
  105430. */
  105431. transformNodes: TransformNode[];
  105432. /**
  105433. * ActionManagers available on the scene.
  105434. */
  105435. actionManagers: AbstractActionManager[];
  105436. /**
  105437. * Textures to keep.
  105438. */
  105439. textures: BaseTexture[];
  105440. /**
  105441. * Environment texture for the scene
  105442. */
  105443. environmentTexture: Nullable<BaseTexture>;
  105444. }
  105445. }
  105446. declare module BABYLON {
  105447. /**
  105448. * Interface used to define options for Sound class
  105449. */
  105450. export interface ISoundOptions {
  105451. /**
  105452. * Does the sound autoplay once loaded.
  105453. */
  105454. autoplay?: boolean;
  105455. /**
  105456. * Does the sound loop after it finishes playing once.
  105457. */
  105458. loop?: boolean;
  105459. /**
  105460. * Sound's volume
  105461. */
  105462. volume?: number;
  105463. /**
  105464. * Is it a spatial sound?
  105465. */
  105466. spatialSound?: boolean;
  105467. /**
  105468. * Maximum distance to hear that sound
  105469. */
  105470. maxDistance?: number;
  105471. /**
  105472. * Uses user defined attenuation function
  105473. */
  105474. useCustomAttenuation?: boolean;
  105475. /**
  105476. * Define the roll off factor of spatial sounds.
  105477. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105478. */
  105479. rolloffFactor?: number;
  105480. /**
  105481. * Define the reference distance the sound should be heard perfectly.
  105482. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105483. */
  105484. refDistance?: number;
  105485. /**
  105486. * Define the distance attenuation model the sound will follow.
  105487. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105488. */
  105489. distanceModel?: string;
  105490. /**
  105491. * Defines the playback speed (1 by default)
  105492. */
  105493. playbackRate?: number;
  105494. /**
  105495. * Defines if the sound is from a streaming source
  105496. */
  105497. streaming?: boolean;
  105498. /**
  105499. * Defines an optional length (in seconds) inside the sound file
  105500. */
  105501. length?: number;
  105502. /**
  105503. * Defines an optional offset (in seconds) inside the sound file
  105504. */
  105505. offset?: number;
  105506. /**
  105507. * If true, URLs will not be required to state the audio file codec to use.
  105508. */
  105509. skipCodecCheck?: boolean;
  105510. }
  105511. /**
  105512. * Defines a sound that can be played in the application.
  105513. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  105514. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105515. */
  105516. export class Sound {
  105517. /**
  105518. * The name of the sound in the scene.
  105519. */
  105520. name: string;
  105521. /**
  105522. * Does the sound autoplay once loaded.
  105523. */
  105524. autoplay: boolean;
  105525. /**
  105526. * Does the sound loop after it finishes playing once.
  105527. */
  105528. loop: boolean;
  105529. /**
  105530. * Does the sound use a custom attenuation curve to simulate the falloff
  105531. * happening when the source gets further away from the camera.
  105532. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  105533. */
  105534. useCustomAttenuation: boolean;
  105535. /**
  105536. * The sound track id this sound belongs to.
  105537. */
  105538. soundTrackId: number;
  105539. /**
  105540. * Is this sound currently played.
  105541. */
  105542. isPlaying: boolean;
  105543. /**
  105544. * Is this sound currently paused.
  105545. */
  105546. isPaused: boolean;
  105547. /**
  105548. * Does this sound enables spatial sound.
  105549. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105550. */
  105551. spatialSound: boolean;
  105552. /**
  105553. * Define the reference distance the sound should be heard perfectly.
  105554. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105555. */
  105556. refDistance: number;
  105557. /**
  105558. * Define the roll off factor of spatial sounds.
  105559. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105560. */
  105561. rolloffFactor: number;
  105562. /**
  105563. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  105564. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105565. */
  105566. maxDistance: number;
  105567. /**
  105568. * Define the distance attenuation model the sound will follow.
  105569. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105570. */
  105571. distanceModel: string;
  105572. /**
  105573. * @hidden
  105574. * Back Compat
  105575. **/
  105576. onended: () => any;
  105577. /**
  105578. * Observable event when the current playing sound finishes.
  105579. */
  105580. onEndedObservable: Observable<Sound>;
  105581. private _panningModel;
  105582. private _playbackRate;
  105583. private _streaming;
  105584. private _startTime;
  105585. private _startOffset;
  105586. private _position;
  105587. /** @hidden */
  105588. _positionInEmitterSpace: boolean;
  105589. private _localDirection;
  105590. private _volume;
  105591. private _isReadyToPlay;
  105592. private _isDirectional;
  105593. private _readyToPlayCallback;
  105594. private _audioBuffer;
  105595. private _soundSource;
  105596. private _streamingSource;
  105597. private _soundPanner;
  105598. private _soundGain;
  105599. private _inputAudioNode;
  105600. private _outputAudioNode;
  105601. private _coneInnerAngle;
  105602. private _coneOuterAngle;
  105603. private _coneOuterGain;
  105604. private _scene;
  105605. private _connectedTransformNode;
  105606. private _customAttenuationFunction;
  105607. private _registerFunc;
  105608. private _isOutputConnected;
  105609. private _htmlAudioElement;
  105610. private _urlType;
  105611. private _length?;
  105612. private _offset?;
  105613. /** @hidden */
  105614. static _SceneComponentInitialization: (scene: Scene) => void;
  105615. /**
  105616. * Create a sound and attach it to a scene
  105617. * @param name Name of your sound
  105618. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  105619. * @param scene defines the scene the sound belongs to
  105620. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  105621. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  105622. */
  105623. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  105624. /**
  105625. * Release the sound and its associated resources
  105626. */
  105627. dispose(): void;
  105628. /**
  105629. * Gets if the sounds is ready to be played or not.
  105630. * @returns true if ready, otherwise false
  105631. */
  105632. isReady(): boolean;
  105633. private _soundLoaded;
  105634. /**
  105635. * Sets the data of the sound from an audiobuffer
  105636. * @param audioBuffer The audioBuffer containing the data
  105637. */
  105638. setAudioBuffer(audioBuffer: AudioBuffer): void;
  105639. /**
  105640. * Updates the current sounds options such as maxdistance, loop...
  105641. * @param options A JSON object containing values named as the object properties
  105642. */
  105643. updateOptions(options: ISoundOptions): void;
  105644. private _createSpatialParameters;
  105645. private _updateSpatialParameters;
  105646. /**
  105647. * Switch the panning model to HRTF:
  105648. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  105649. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105650. */
  105651. switchPanningModelToHRTF(): void;
  105652. /**
  105653. * Switch the panning model to Equal Power:
  105654. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  105655. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105656. */
  105657. switchPanningModelToEqualPower(): void;
  105658. private _switchPanningModel;
  105659. /**
  105660. * Connect this sound to a sound track audio node like gain...
  105661. * @param soundTrackAudioNode the sound track audio node to connect to
  105662. */
  105663. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  105664. /**
  105665. * Transform this sound into a directional source
  105666. * @param coneInnerAngle Size of the inner cone in degree
  105667. * @param coneOuterAngle Size of the outer cone in degree
  105668. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  105669. */
  105670. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  105671. /**
  105672. * Gets or sets the inner angle for the directional cone.
  105673. */
  105674. /**
  105675. * Gets or sets the inner angle for the directional cone.
  105676. */
  105677. directionalConeInnerAngle: number;
  105678. /**
  105679. * Gets or sets the outer angle for the directional cone.
  105680. */
  105681. /**
  105682. * Gets or sets the outer angle for the directional cone.
  105683. */
  105684. directionalConeOuterAngle: number;
  105685. /**
  105686. * Sets the position of the emitter if spatial sound is enabled
  105687. * @param newPosition Defines the new posisiton
  105688. */
  105689. setPosition(newPosition: Vector3): void;
  105690. /**
  105691. * Sets the local direction of the emitter if spatial sound is enabled
  105692. * @param newLocalDirection Defines the new local direction
  105693. */
  105694. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  105695. private _updateDirection;
  105696. /** @hidden */
  105697. updateDistanceFromListener(): void;
  105698. /**
  105699. * Sets a new custom attenuation function for the sound.
  105700. * @param callback Defines the function used for the attenuation
  105701. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  105702. */
  105703. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  105704. /**
  105705. * Play the sound
  105706. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  105707. * @param offset (optional) Start the sound at a specific time in seconds
  105708. * @param length (optional) Sound duration (in seconds)
  105709. */
  105710. play(time?: number, offset?: number, length?: number): void;
  105711. private _onended;
  105712. /**
  105713. * Stop the sound
  105714. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  105715. */
  105716. stop(time?: number): void;
  105717. /**
  105718. * Put the sound in pause
  105719. */
  105720. pause(): void;
  105721. /**
  105722. * Sets a dedicated volume for this sounds
  105723. * @param newVolume Define the new volume of the sound
  105724. * @param time Define time for gradual change to new volume
  105725. */
  105726. setVolume(newVolume: number, time?: number): void;
  105727. /**
  105728. * Set the sound play back rate
  105729. * @param newPlaybackRate Define the playback rate the sound should be played at
  105730. */
  105731. setPlaybackRate(newPlaybackRate: number): void;
  105732. /**
  105733. * Gets the volume of the sound.
  105734. * @returns the volume of the sound
  105735. */
  105736. getVolume(): number;
  105737. /**
  105738. * Attach the sound to a dedicated mesh
  105739. * @param transformNode The transform node to connect the sound with
  105740. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  105741. */
  105742. attachToMesh(transformNode: TransformNode): void;
  105743. /**
  105744. * Detach the sound from the previously attached mesh
  105745. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  105746. */
  105747. detachFromMesh(): void;
  105748. private _onRegisterAfterWorldMatrixUpdate;
  105749. /**
  105750. * Clone the current sound in the scene.
  105751. * @returns the new sound clone
  105752. */
  105753. clone(): Nullable<Sound>;
  105754. /**
  105755. * Gets the current underlying audio buffer containing the data
  105756. * @returns the audio buffer
  105757. */
  105758. getAudioBuffer(): Nullable<AudioBuffer>;
  105759. /**
  105760. * Serializes the Sound in a JSON representation
  105761. * @returns the JSON representation of the sound
  105762. */
  105763. serialize(): any;
  105764. /**
  105765. * Parse a JSON representation of a sound to innstantiate in a given scene
  105766. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  105767. * @param scene Define the scene the new parsed sound should be created in
  105768. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  105769. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  105770. * @returns the newly parsed sound
  105771. */
  105772. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  105773. }
  105774. }
  105775. declare module BABYLON {
  105776. /**
  105777. * This defines an action helpful to play a defined sound on a triggered action.
  105778. */
  105779. export class PlaySoundAction extends Action {
  105780. private _sound;
  105781. /**
  105782. * Instantiate the action
  105783. * @param triggerOptions defines the trigger options
  105784. * @param sound defines the sound to play
  105785. * @param condition defines the trigger related conditions
  105786. */
  105787. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  105788. /** @hidden */
  105789. _prepare(): void;
  105790. /**
  105791. * Execute the action and play the sound.
  105792. */
  105793. execute(): void;
  105794. /**
  105795. * Serializes the actions and its related information.
  105796. * @param parent defines the object to serialize in
  105797. * @returns the serialized object
  105798. */
  105799. serialize(parent: any): any;
  105800. }
  105801. /**
  105802. * This defines an action helpful to stop a defined sound on a triggered action.
  105803. */
  105804. export class StopSoundAction extends Action {
  105805. private _sound;
  105806. /**
  105807. * Instantiate the action
  105808. * @param triggerOptions defines the trigger options
  105809. * @param sound defines the sound to stop
  105810. * @param condition defines the trigger related conditions
  105811. */
  105812. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  105813. /** @hidden */
  105814. _prepare(): void;
  105815. /**
  105816. * Execute the action and stop the sound.
  105817. */
  105818. execute(): void;
  105819. /**
  105820. * Serializes the actions and its related information.
  105821. * @param parent defines the object to serialize in
  105822. * @returns the serialized object
  105823. */
  105824. serialize(parent: any): any;
  105825. }
  105826. }
  105827. declare module BABYLON {
  105828. /**
  105829. * This defines an action responsible to change the value of a property
  105830. * by interpolating between its current value and the newly set one once triggered.
  105831. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  105832. */
  105833. export class InterpolateValueAction extends Action {
  105834. /**
  105835. * Defines the path of the property where the value should be interpolated
  105836. */
  105837. propertyPath: string;
  105838. /**
  105839. * Defines the target value at the end of the interpolation.
  105840. */
  105841. value: any;
  105842. /**
  105843. * Defines the time it will take for the property to interpolate to the value.
  105844. */
  105845. duration: number;
  105846. /**
  105847. * Defines if the other scene animations should be stopped when the action has been triggered
  105848. */
  105849. stopOtherAnimations?: boolean;
  105850. /**
  105851. * Defines a callback raised once the interpolation animation has been done.
  105852. */
  105853. onInterpolationDone?: () => void;
  105854. /**
  105855. * Observable triggered once the interpolation animation has been done.
  105856. */
  105857. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  105858. private _target;
  105859. private _effectiveTarget;
  105860. private _property;
  105861. /**
  105862. * Instantiate the action
  105863. * @param triggerOptions defines the trigger options
  105864. * @param target defines the object containing the value to interpolate
  105865. * @param propertyPath defines the path to the property in the target object
  105866. * @param value defines the target value at the end of the interpolation
  105867. * @param duration deines the time it will take for the property to interpolate to the value.
  105868. * @param condition defines the trigger related conditions
  105869. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  105870. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  105871. */
  105872. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  105873. /** @hidden */
  105874. _prepare(): void;
  105875. /**
  105876. * Execute the action starts the value interpolation.
  105877. */
  105878. execute(): void;
  105879. /**
  105880. * Serializes the actions and its related information.
  105881. * @param parent defines the object to serialize in
  105882. * @returns the serialized object
  105883. */
  105884. serialize(parent: any): any;
  105885. }
  105886. }
  105887. declare module BABYLON {
  105888. /**
  105889. * Options allowed during the creation of a sound track.
  105890. */
  105891. export interface ISoundTrackOptions {
  105892. /**
  105893. * The volume the sound track should take during creation
  105894. */
  105895. volume?: number;
  105896. /**
  105897. * Define if the sound track is the main sound track of the scene
  105898. */
  105899. mainTrack?: boolean;
  105900. }
  105901. /**
  105902. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  105903. * It will be also used in a future release to apply effects on a specific track.
  105904. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  105905. */
  105906. export class SoundTrack {
  105907. /**
  105908. * The unique identifier of the sound track in the scene.
  105909. */
  105910. id: number;
  105911. /**
  105912. * The list of sounds included in the sound track.
  105913. */
  105914. soundCollection: Array<Sound>;
  105915. private _outputAudioNode;
  105916. private _scene;
  105917. private _connectedAnalyser;
  105918. private _options;
  105919. private _isInitialized;
  105920. /**
  105921. * Creates a new sound track.
  105922. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  105923. * @param scene Define the scene the sound track belongs to
  105924. * @param options
  105925. */
  105926. constructor(scene: Scene, options?: ISoundTrackOptions);
  105927. private _initializeSoundTrackAudioGraph;
  105928. /**
  105929. * Release the sound track and its associated resources
  105930. */
  105931. dispose(): void;
  105932. /**
  105933. * Adds a sound to this sound track
  105934. * @param sound define the cound to add
  105935. * @ignoreNaming
  105936. */
  105937. AddSound(sound: Sound): void;
  105938. /**
  105939. * Removes a sound to this sound track
  105940. * @param sound define the cound to remove
  105941. * @ignoreNaming
  105942. */
  105943. RemoveSound(sound: Sound): void;
  105944. /**
  105945. * Set a global volume for the full sound track.
  105946. * @param newVolume Define the new volume of the sound track
  105947. */
  105948. setVolume(newVolume: number): void;
  105949. /**
  105950. * Switch the panning model to HRTF:
  105951. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  105952. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105953. */
  105954. switchPanningModelToHRTF(): void;
  105955. /**
  105956. * Switch the panning model to Equal Power:
  105957. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  105958. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105959. */
  105960. switchPanningModelToEqualPower(): void;
  105961. /**
  105962. * Connect the sound track to an audio analyser allowing some amazing
  105963. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  105964. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  105965. * @param analyser The analyser to connect to the engine
  105966. */
  105967. connectToAnalyser(analyser: Analyser): void;
  105968. }
  105969. }
  105970. declare module BABYLON {
  105971. interface AbstractScene {
  105972. /**
  105973. * The list of sounds used in the scene.
  105974. */
  105975. sounds: Nullable<Array<Sound>>;
  105976. }
  105977. interface Scene {
  105978. /**
  105979. * @hidden
  105980. * Backing field
  105981. */
  105982. _mainSoundTrack: SoundTrack;
  105983. /**
  105984. * The main sound track played by the scene.
  105985. * It cotains your primary collection of sounds.
  105986. */
  105987. mainSoundTrack: SoundTrack;
  105988. /**
  105989. * The list of sound tracks added to the scene
  105990. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105991. */
  105992. soundTracks: Nullable<Array<SoundTrack>>;
  105993. /**
  105994. * Gets a sound using a given name
  105995. * @param name defines the name to search for
  105996. * @return the found sound or null if not found at all.
  105997. */
  105998. getSoundByName(name: string): Nullable<Sound>;
  105999. /**
  106000. * Gets or sets if audio support is enabled
  106001. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106002. */
  106003. audioEnabled: boolean;
  106004. /**
  106005. * Gets or sets if audio will be output to headphones
  106006. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106007. */
  106008. headphone: boolean;
  106009. /**
  106010. * Gets or sets custom audio listener position provider
  106011. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106012. */
  106013. audioListenerPositionProvider: Nullable<() => Vector3>;
  106014. /**
  106015. * Gets or sets a refresh rate when using 3D audio positioning
  106016. */
  106017. audioPositioningRefreshRate: number;
  106018. }
  106019. /**
  106020. * Defines the sound scene component responsible to manage any sounds
  106021. * in a given scene.
  106022. */
  106023. export class AudioSceneComponent implements ISceneSerializableComponent {
  106024. /**
  106025. * The component name helpfull to identify the component in the list of scene components.
  106026. */
  106027. readonly name: string;
  106028. /**
  106029. * The scene the component belongs to.
  106030. */
  106031. scene: Scene;
  106032. private _audioEnabled;
  106033. /**
  106034. * Gets whether audio is enabled or not.
  106035. * Please use related enable/disable method to switch state.
  106036. */
  106037. readonly audioEnabled: boolean;
  106038. private _headphone;
  106039. /**
  106040. * Gets whether audio is outputing to headphone or not.
  106041. * Please use the according Switch methods to change output.
  106042. */
  106043. readonly headphone: boolean;
  106044. /**
  106045. * Gets or sets a refresh rate when using 3D audio positioning
  106046. */
  106047. audioPositioningRefreshRate: number;
  106048. private _audioListenerPositionProvider;
  106049. /**
  106050. * Gets the current audio listener position provider
  106051. */
  106052. /**
  106053. * Sets a custom listener position for all sounds in the scene
  106054. * By default, this is the position of the first active camera
  106055. */
  106056. audioListenerPositionProvider: Nullable<() => Vector3>;
  106057. /**
  106058. * Creates a new instance of the component for the given scene
  106059. * @param scene Defines the scene to register the component in
  106060. */
  106061. constructor(scene: Scene);
  106062. /**
  106063. * Registers the component in a given scene
  106064. */
  106065. register(): void;
  106066. /**
  106067. * Rebuilds the elements related to this component in case of
  106068. * context lost for instance.
  106069. */
  106070. rebuild(): void;
  106071. /**
  106072. * Serializes the component data to the specified json object
  106073. * @param serializationObject The object to serialize to
  106074. */
  106075. serialize(serializationObject: any): void;
  106076. /**
  106077. * Adds all the elements from the container to the scene
  106078. * @param container the container holding the elements
  106079. */
  106080. addFromContainer(container: AbstractScene): void;
  106081. /**
  106082. * Removes all the elements in the container from the scene
  106083. * @param container contains the elements to remove
  106084. * @param dispose if the removed element should be disposed (default: false)
  106085. */
  106086. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  106087. /**
  106088. * Disposes the component and the associated ressources.
  106089. */
  106090. dispose(): void;
  106091. /**
  106092. * Disables audio in the associated scene.
  106093. */
  106094. disableAudio(): void;
  106095. /**
  106096. * Enables audio in the associated scene.
  106097. */
  106098. enableAudio(): void;
  106099. /**
  106100. * Switch audio to headphone output.
  106101. */
  106102. switchAudioModeForHeadphones(): void;
  106103. /**
  106104. * Switch audio to normal speakers.
  106105. */
  106106. switchAudioModeForNormalSpeakers(): void;
  106107. private _cachedCameraDirection;
  106108. private _cachedCameraPosition;
  106109. private _lastCheck;
  106110. private _afterRender;
  106111. }
  106112. }
  106113. declare module BABYLON {
  106114. /**
  106115. * Wraps one or more Sound objects and selects one with random weight for playback.
  106116. */
  106117. export class WeightedSound {
  106118. /** When true a Sound will be selected and played when the current playing Sound completes. */
  106119. loop: boolean;
  106120. private _coneInnerAngle;
  106121. private _coneOuterAngle;
  106122. private _volume;
  106123. /** A Sound is currently playing. */
  106124. isPlaying: boolean;
  106125. /** A Sound is currently paused. */
  106126. isPaused: boolean;
  106127. private _sounds;
  106128. private _weights;
  106129. private _currentIndex?;
  106130. /**
  106131. * Creates a new WeightedSound from the list of sounds given.
  106132. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  106133. * @param sounds Array of Sounds that will be selected from.
  106134. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  106135. */
  106136. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  106137. /**
  106138. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  106139. */
  106140. /**
  106141. * The size of cone in degress for a directional sound in which there will be no attenuation.
  106142. */
  106143. directionalConeInnerAngle: number;
  106144. /**
  106145. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  106146. * Listener angles between innerAngle and outerAngle will falloff linearly.
  106147. */
  106148. /**
  106149. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  106150. * Listener angles between innerAngle and outerAngle will falloff linearly.
  106151. */
  106152. directionalConeOuterAngle: number;
  106153. /**
  106154. * Playback volume.
  106155. */
  106156. /**
  106157. * Playback volume.
  106158. */
  106159. volume: number;
  106160. private _onended;
  106161. /**
  106162. * Suspend playback
  106163. */
  106164. pause(): void;
  106165. /**
  106166. * Stop playback
  106167. */
  106168. stop(): void;
  106169. /**
  106170. * Start playback.
  106171. * @param startOffset Position the clip head at a specific time in seconds.
  106172. */
  106173. play(startOffset?: number): void;
  106174. }
  106175. }
  106176. declare module BABYLON {
  106177. /**
  106178. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  106179. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  106180. */
  106181. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  106182. /**
  106183. * Gets the name of the behavior.
  106184. */
  106185. readonly name: string;
  106186. /**
  106187. * The easing function used by animations
  106188. */
  106189. static EasingFunction: BackEase;
  106190. /**
  106191. * The easing mode used by animations
  106192. */
  106193. static EasingMode: number;
  106194. /**
  106195. * The duration of the animation, in milliseconds
  106196. */
  106197. transitionDuration: number;
  106198. /**
  106199. * Length of the distance animated by the transition when lower radius is reached
  106200. */
  106201. lowerRadiusTransitionRange: number;
  106202. /**
  106203. * Length of the distance animated by the transition when upper radius is reached
  106204. */
  106205. upperRadiusTransitionRange: number;
  106206. private _autoTransitionRange;
  106207. /**
  106208. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  106209. */
  106210. /**
  106211. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  106212. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  106213. */
  106214. autoTransitionRange: boolean;
  106215. private _attachedCamera;
  106216. private _onAfterCheckInputsObserver;
  106217. private _onMeshTargetChangedObserver;
  106218. /**
  106219. * Initializes the behavior.
  106220. */
  106221. init(): void;
  106222. /**
  106223. * Attaches the behavior to its arc rotate camera.
  106224. * @param camera Defines the camera to attach the behavior to
  106225. */
  106226. attach(camera: ArcRotateCamera): void;
  106227. /**
  106228. * Detaches the behavior from its current arc rotate camera.
  106229. */
  106230. detach(): void;
  106231. private _radiusIsAnimating;
  106232. private _radiusBounceTransition;
  106233. private _animatables;
  106234. private _cachedWheelPrecision;
  106235. /**
  106236. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  106237. * @param radiusLimit The limit to check against.
  106238. * @return Bool to indicate if at limit.
  106239. */
  106240. private _isRadiusAtLimit;
  106241. /**
  106242. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  106243. * @param radiusDelta The delta by which to animate to. Can be negative.
  106244. */
  106245. private _applyBoundRadiusAnimation;
  106246. /**
  106247. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  106248. */
  106249. protected _clearAnimationLocks(): void;
  106250. /**
  106251. * Stops and removes all animations that have been applied to the camera
  106252. */
  106253. stopAllAnimations(): void;
  106254. }
  106255. }
  106256. declare module BABYLON {
  106257. /**
  106258. * 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.
  106259. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  106260. */
  106261. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  106262. /**
  106263. * Gets the name of the behavior.
  106264. */
  106265. readonly name: string;
  106266. private _mode;
  106267. private _radiusScale;
  106268. private _positionScale;
  106269. private _defaultElevation;
  106270. private _elevationReturnTime;
  106271. private _elevationReturnWaitTime;
  106272. private _zoomStopsAnimation;
  106273. private _framingTime;
  106274. /**
  106275. * The easing function used by animations
  106276. */
  106277. static EasingFunction: ExponentialEase;
  106278. /**
  106279. * The easing mode used by animations
  106280. */
  106281. static EasingMode: number;
  106282. /**
  106283. * Sets the current mode used by the behavior
  106284. */
  106285. /**
  106286. * Gets current mode used by the behavior.
  106287. */
  106288. mode: number;
  106289. /**
  106290. * Sets the scale applied to the radius (1 by default)
  106291. */
  106292. /**
  106293. * Gets the scale applied to the radius
  106294. */
  106295. radiusScale: number;
  106296. /**
  106297. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  106298. */
  106299. /**
  106300. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  106301. */
  106302. positionScale: number;
  106303. /**
  106304. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  106305. * behaviour is triggered, in radians.
  106306. */
  106307. /**
  106308. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  106309. * behaviour is triggered, in radians.
  106310. */
  106311. defaultElevation: number;
  106312. /**
  106313. * Sets the time (in milliseconds) taken to return to the default beta position.
  106314. * Negative value indicates camera should not return to default.
  106315. */
  106316. /**
  106317. * Gets the time (in milliseconds) taken to return to the default beta position.
  106318. * Negative value indicates camera should not return to default.
  106319. */
  106320. elevationReturnTime: number;
  106321. /**
  106322. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  106323. */
  106324. /**
  106325. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  106326. */
  106327. elevationReturnWaitTime: number;
  106328. /**
  106329. * Sets the flag that indicates if user zooming should stop animation.
  106330. */
  106331. /**
  106332. * Gets the flag that indicates if user zooming should stop animation.
  106333. */
  106334. zoomStopsAnimation: boolean;
  106335. /**
  106336. * Sets the transition time when framing the mesh, in milliseconds
  106337. */
  106338. /**
  106339. * Gets the transition time when framing the mesh, in milliseconds
  106340. */
  106341. framingTime: number;
  106342. /**
  106343. * Define if the behavior should automatically change the configured
  106344. * camera limits and sensibilities.
  106345. */
  106346. autoCorrectCameraLimitsAndSensibility: boolean;
  106347. private _onPrePointerObservableObserver;
  106348. private _onAfterCheckInputsObserver;
  106349. private _onMeshTargetChangedObserver;
  106350. private _attachedCamera;
  106351. private _isPointerDown;
  106352. private _lastInteractionTime;
  106353. /**
  106354. * Initializes the behavior.
  106355. */
  106356. init(): void;
  106357. /**
  106358. * Attaches the behavior to its arc rotate camera.
  106359. * @param camera Defines the camera to attach the behavior to
  106360. */
  106361. attach(camera: ArcRotateCamera): void;
  106362. /**
  106363. * Detaches the behavior from its current arc rotate camera.
  106364. */
  106365. detach(): void;
  106366. private _animatables;
  106367. private _betaIsAnimating;
  106368. private _betaTransition;
  106369. private _radiusTransition;
  106370. private _vectorTransition;
  106371. /**
  106372. * Targets the given mesh and updates zoom level accordingly.
  106373. * @param mesh The mesh to target.
  106374. * @param radius Optional. If a cached radius position already exists, overrides default.
  106375. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  106376. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  106377. * @param onAnimationEnd Callback triggered at the end of the framing animation
  106378. */
  106379. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  106380. /**
  106381. * Targets the given mesh with its children and updates zoom level accordingly.
  106382. * @param mesh The mesh to target.
  106383. * @param radius Optional. If a cached radius position already exists, overrides default.
  106384. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  106385. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  106386. * @param onAnimationEnd Callback triggered at the end of the framing animation
  106387. */
  106388. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  106389. /**
  106390. * Targets the given meshes with their children and updates zoom level accordingly.
  106391. * @param meshes The mesh to target.
  106392. * @param radius Optional. If a cached radius position already exists, overrides default.
  106393. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  106394. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  106395. * @param onAnimationEnd Callback triggered at the end of the framing animation
  106396. */
  106397. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  106398. /**
  106399. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  106400. * @param minimumWorld Determines the smaller position of the bounding box extend
  106401. * @param maximumWorld Determines the bigger position of the bounding box extend
  106402. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  106403. * @param onAnimationEnd Callback triggered at the end of the framing animation
  106404. */
  106405. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  106406. /**
  106407. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  106408. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  106409. * frustum width.
  106410. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  106411. * to fully enclose the mesh in the viewing frustum.
  106412. */
  106413. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  106414. /**
  106415. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  106416. * is automatically returned to its default position (expected to be above ground plane).
  106417. */
  106418. private _maintainCameraAboveGround;
  106419. /**
  106420. * Returns the frustum slope based on the canvas ratio and camera FOV
  106421. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  106422. */
  106423. private _getFrustumSlope;
  106424. /**
  106425. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  106426. */
  106427. private _clearAnimationLocks;
  106428. /**
  106429. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  106430. */
  106431. private _applyUserInteraction;
  106432. /**
  106433. * Stops and removes all animations that have been applied to the camera
  106434. */
  106435. stopAllAnimations(): void;
  106436. /**
  106437. * Gets a value indicating if the user is moving the camera
  106438. */
  106439. readonly isUserIsMoving: boolean;
  106440. /**
  106441. * The camera can move all the way towards the mesh.
  106442. */
  106443. static IgnoreBoundsSizeMode: number;
  106444. /**
  106445. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  106446. */
  106447. static FitFrustumSidesMode: number;
  106448. }
  106449. }
  106450. declare module BABYLON {
  106451. /**
  106452. * Base class for Camera Pointer Inputs.
  106453. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  106454. * for example usage.
  106455. */
  106456. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  106457. /**
  106458. * Defines the camera the input is attached to.
  106459. */
  106460. abstract camera: Camera;
  106461. /**
  106462. * Whether keyboard modifier keys are pressed at time of last mouse event.
  106463. */
  106464. protected _altKey: boolean;
  106465. protected _ctrlKey: boolean;
  106466. protected _metaKey: boolean;
  106467. protected _shiftKey: boolean;
  106468. /**
  106469. * Which mouse buttons were pressed at time of last mouse event.
  106470. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  106471. */
  106472. protected _buttonsPressed: number;
  106473. /**
  106474. * Defines the buttons associated with the input to handle camera move.
  106475. */
  106476. buttons: number[];
  106477. /**
  106478. * Attach the input controls to a specific dom element to get the input from.
  106479. * @param element Defines the element the controls should be listened from
  106480. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106481. */
  106482. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106483. /**
  106484. * Detach the current controls from the specified dom element.
  106485. * @param element Defines the element to stop listening the inputs from
  106486. */
  106487. detachControl(element: Nullable<HTMLElement>): void;
  106488. /**
  106489. * Gets the class name of the current input.
  106490. * @returns the class name
  106491. */
  106492. getClassName(): string;
  106493. /**
  106494. * Get the friendly name associated with the input class.
  106495. * @returns the input friendly name
  106496. */
  106497. getSimpleName(): string;
  106498. /**
  106499. * Called on pointer POINTERDOUBLETAP event.
  106500. * Override this method to provide functionality on POINTERDOUBLETAP event.
  106501. */
  106502. protected onDoubleTap(type: string): void;
  106503. /**
  106504. * Called on pointer POINTERMOVE event if only a single touch is active.
  106505. * Override this method to provide functionality.
  106506. */
  106507. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  106508. /**
  106509. * Called on pointer POINTERMOVE event if multiple touches are active.
  106510. * Override this method to provide functionality.
  106511. */
  106512. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  106513. /**
  106514. * Called on JS contextmenu event.
  106515. * Override this method to provide functionality.
  106516. */
  106517. protected onContextMenu(evt: PointerEvent): void;
  106518. /**
  106519. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  106520. * press.
  106521. * Override this method to provide functionality.
  106522. */
  106523. protected onButtonDown(evt: PointerEvent): void;
  106524. /**
  106525. * Called each time a new POINTERUP event occurs. Ie, for each button
  106526. * release.
  106527. * Override this method to provide functionality.
  106528. */
  106529. protected onButtonUp(evt: PointerEvent): void;
  106530. /**
  106531. * Called when window becomes inactive.
  106532. * Override this method to provide functionality.
  106533. */
  106534. protected onLostFocus(): void;
  106535. private _pointerInput;
  106536. private _observer;
  106537. private _onLostFocus;
  106538. private pointA;
  106539. private pointB;
  106540. }
  106541. }
  106542. declare module BABYLON {
  106543. /**
  106544. * Manage the pointers inputs to control an arc rotate camera.
  106545. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106546. */
  106547. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  106548. /**
  106549. * Defines the camera the input is attached to.
  106550. */
  106551. camera: ArcRotateCamera;
  106552. /**
  106553. * Gets the class name of the current input.
  106554. * @returns the class name
  106555. */
  106556. getClassName(): string;
  106557. /**
  106558. * Defines the buttons associated with the input to handle camera move.
  106559. */
  106560. buttons: number[];
  106561. /**
  106562. * Defines the pointer angular sensibility along the X axis or how fast is
  106563. * the camera rotating.
  106564. */
  106565. angularSensibilityX: number;
  106566. /**
  106567. * Defines the pointer angular sensibility along the Y axis or how fast is
  106568. * the camera rotating.
  106569. */
  106570. angularSensibilityY: number;
  106571. /**
  106572. * Defines the pointer pinch precision or how fast is the camera zooming.
  106573. */
  106574. pinchPrecision: number;
  106575. /**
  106576. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  106577. * from 0.
  106578. * It defines the percentage of current camera.radius to use as delta when
  106579. * pinch zoom is used.
  106580. */
  106581. pinchDeltaPercentage: number;
  106582. /**
  106583. * Defines the pointer panning sensibility or how fast is the camera moving.
  106584. */
  106585. panningSensibility: number;
  106586. /**
  106587. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  106588. */
  106589. multiTouchPanning: boolean;
  106590. /**
  106591. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  106592. * zoom (pinch) through multitouch.
  106593. */
  106594. multiTouchPanAndZoom: boolean;
  106595. /**
  106596. * Revers pinch action direction.
  106597. */
  106598. pinchInwards: boolean;
  106599. private _isPanClick;
  106600. private _twoFingerActivityCount;
  106601. private _isPinching;
  106602. /**
  106603. * Called on pointer POINTERMOVE event if only a single touch is active.
  106604. */
  106605. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  106606. /**
  106607. * Called on pointer POINTERDOUBLETAP event.
  106608. */
  106609. protected onDoubleTap(type: string): void;
  106610. /**
  106611. * Called on pointer POINTERMOVE event if multiple touches are active.
  106612. */
  106613. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  106614. /**
  106615. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  106616. * press.
  106617. */
  106618. protected onButtonDown(evt: PointerEvent): void;
  106619. /**
  106620. * Called each time a new POINTERUP event occurs. Ie, for each button
  106621. * release.
  106622. */
  106623. protected onButtonUp(evt: PointerEvent): void;
  106624. /**
  106625. * Called when window becomes inactive.
  106626. */
  106627. protected onLostFocus(): void;
  106628. }
  106629. }
  106630. declare module BABYLON {
  106631. /**
  106632. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  106633. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106634. */
  106635. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  106636. /**
  106637. * Defines the camera the input is attached to.
  106638. */
  106639. camera: ArcRotateCamera;
  106640. /**
  106641. * Defines the list of key codes associated with the up action (increase alpha)
  106642. */
  106643. keysUp: number[];
  106644. /**
  106645. * Defines the list of key codes associated with the down action (decrease alpha)
  106646. */
  106647. keysDown: number[];
  106648. /**
  106649. * Defines the list of key codes associated with the left action (increase beta)
  106650. */
  106651. keysLeft: number[];
  106652. /**
  106653. * Defines the list of key codes associated with the right action (decrease beta)
  106654. */
  106655. keysRight: number[];
  106656. /**
  106657. * Defines the list of key codes associated with the reset action.
  106658. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  106659. */
  106660. keysReset: number[];
  106661. /**
  106662. * Defines the panning sensibility of the inputs.
  106663. * (How fast is the camera paning)
  106664. */
  106665. panningSensibility: number;
  106666. /**
  106667. * Defines the zooming sensibility of the inputs.
  106668. * (How fast is the camera zooming)
  106669. */
  106670. zoomingSensibility: number;
  106671. /**
  106672. * Defines wether maintaining the alt key down switch the movement mode from
  106673. * orientation to zoom.
  106674. */
  106675. useAltToZoom: boolean;
  106676. /**
  106677. * Rotation speed of the camera
  106678. */
  106679. angularSpeed: number;
  106680. private _keys;
  106681. private _ctrlPressed;
  106682. private _altPressed;
  106683. private _onCanvasBlurObserver;
  106684. private _onKeyboardObserver;
  106685. private _engine;
  106686. private _scene;
  106687. /**
  106688. * Attach the input controls to a specific dom element to get the input from.
  106689. * @param element Defines the element the controls should be listened from
  106690. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106691. */
  106692. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106693. /**
  106694. * Detach the current controls from the specified dom element.
  106695. * @param element Defines the element to stop listening the inputs from
  106696. */
  106697. detachControl(element: Nullable<HTMLElement>): void;
  106698. /**
  106699. * Update the current camera state depending on the inputs that have been used this frame.
  106700. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106701. */
  106702. checkInputs(): void;
  106703. /**
  106704. * Gets the class name of the current intput.
  106705. * @returns the class name
  106706. */
  106707. getClassName(): string;
  106708. /**
  106709. * Get the friendly name associated with the input class.
  106710. * @returns the input friendly name
  106711. */
  106712. getSimpleName(): string;
  106713. }
  106714. }
  106715. declare module BABYLON {
  106716. /**
  106717. * Manage the mouse wheel inputs to control an arc rotate camera.
  106718. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106719. */
  106720. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  106721. /**
  106722. * Defines the camera the input is attached to.
  106723. */
  106724. camera: ArcRotateCamera;
  106725. /**
  106726. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  106727. */
  106728. wheelPrecision: number;
  106729. /**
  106730. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  106731. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  106732. */
  106733. wheelDeltaPercentage: number;
  106734. private _wheel;
  106735. private _observer;
  106736. private computeDeltaFromMouseWheelLegacyEvent;
  106737. /**
  106738. * Attach the input controls to a specific dom element to get the input from.
  106739. * @param element Defines the element the controls should be listened from
  106740. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106741. */
  106742. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106743. /**
  106744. * Detach the current controls from the specified dom element.
  106745. * @param element Defines the element to stop listening the inputs from
  106746. */
  106747. detachControl(element: Nullable<HTMLElement>): void;
  106748. /**
  106749. * Gets the class name of the current intput.
  106750. * @returns the class name
  106751. */
  106752. getClassName(): string;
  106753. /**
  106754. * Get the friendly name associated with the input class.
  106755. * @returns the input friendly name
  106756. */
  106757. getSimpleName(): string;
  106758. }
  106759. }
  106760. declare module BABYLON {
  106761. /**
  106762. * Default Inputs manager for the ArcRotateCamera.
  106763. * It groups all the default supported inputs for ease of use.
  106764. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106765. */
  106766. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  106767. /**
  106768. * Instantiates a new ArcRotateCameraInputsManager.
  106769. * @param camera Defines the camera the inputs belong to
  106770. */
  106771. constructor(camera: ArcRotateCamera);
  106772. /**
  106773. * Add mouse wheel input support to the input manager.
  106774. * @returns the current input manager
  106775. */
  106776. addMouseWheel(): ArcRotateCameraInputsManager;
  106777. /**
  106778. * Add pointers input support to the input manager.
  106779. * @returns the current input manager
  106780. */
  106781. addPointers(): ArcRotateCameraInputsManager;
  106782. /**
  106783. * Add keyboard input support to the input manager.
  106784. * @returns the current input manager
  106785. */
  106786. addKeyboard(): ArcRotateCameraInputsManager;
  106787. }
  106788. }
  106789. declare module BABYLON {
  106790. /**
  106791. * This represents an orbital type of camera.
  106792. *
  106793. * 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.
  106794. * 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.
  106795. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  106796. */
  106797. export class ArcRotateCamera extends TargetCamera {
  106798. /**
  106799. * Defines the rotation angle of the camera along the longitudinal axis.
  106800. */
  106801. alpha: number;
  106802. /**
  106803. * Defines the rotation angle of the camera along the latitudinal axis.
  106804. */
  106805. beta: number;
  106806. /**
  106807. * Defines the radius of the camera from it s target point.
  106808. */
  106809. radius: number;
  106810. protected _target: Vector3;
  106811. protected _targetHost: Nullable<AbstractMesh>;
  106812. /**
  106813. * Defines the target point of the camera.
  106814. * The camera looks towards it form the radius distance.
  106815. */
  106816. target: Vector3;
  106817. /**
  106818. * Define the current local position of the camera in the scene
  106819. */
  106820. position: Vector3;
  106821. protected _upVector: Vector3;
  106822. protected _upToYMatrix: Matrix;
  106823. protected _YToUpMatrix: Matrix;
  106824. /**
  106825. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  106826. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  106827. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  106828. */
  106829. upVector: Vector3;
  106830. /**
  106831. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  106832. */
  106833. setMatUp(): void;
  106834. /**
  106835. * Current inertia value on the longitudinal axis.
  106836. * The bigger this number the longer it will take for the camera to stop.
  106837. */
  106838. inertialAlphaOffset: number;
  106839. /**
  106840. * Current inertia value on the latitudinal axis.
  106841. * The bigger this number the longer it will take for the camera to stop.
  106842. */
  106843. inertialBetaOffset: number;
  106844. /**
  106845. * Current inertia value on the radius axis.
  106846. * The bigger this number the longer it will take for the camera to stop.
  106847. */
  106848. inertialRadiusOffset: number;
  106849. /**
  106850. * Minimum allowed angle on the longitudinal axis.
  106851. * This can help limiting how the Camera is able to move in the scene.
  106852. */
  106853. lowerAlphaLimit: Nullable<number>;
  106854. /**
  106855. * Maximum allowed angle on the longitudinal axis.
  106856. * This can help limiting how the Camera is able to move in the scene.
  106857. */
  106858. upperAlphaLimit: Nullable<number>;
  106859. /**
  106860. * Minimum allowed angle on the latitudinal axis.
  106861. * This can help limiting how the Camera is able to move in the scene.
  106862. */
  106863. lowerBetaLimit: number;
  106864. /**
  106865. * Maximum allowed angle on the latitudinal axis.
  106866. * This can help limiting how the Camera is able to move in the scene.
  106867. */
  106868. upperBetaLimit: number;
  106869. /**
  106870. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  106871. * This can help limiting how the Camera is able to move in the scene.
  106872. */
  106873. lowerRadiusLimit: Nullable<number>;
  106874. /**
  106875. * Maximum allowed distance of the camera to the target (The camera can not get further).
  106876. * This can help limiting how the Camera is able to move in the scene.
  106877. */
  106878. upperRadiusLimit: Nullable<number>;
  106879. /**
  106880. * Defines the current inertia value used during panning of the camera along the X axis.
  106881. */
  106882. inertialPanningX: number;
  106883. /**
  106884. * Defines the current inertia value used during panning of the camera along the Y axis.
  106885. */
  106886. inertialPanningY: number;
  106887. /**
  106888. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  106889. * Basically if your fingers moves away from more than this distance you will be considered
  106890. * in pinch mode.
  106891. */
  106892. pinchToPanMaxDistance: number;
  106893. /**
  106894. * Defines the maximum distance the camera can pan.
  106895. * This could help keeping the cammera always in your scene.
  106896. */
  106897. panningDistanceLimit: Nullable<number>;
  106898. /**
  106899. * Defines the target of the camera before paning.
  106900. */
  106901. panningOriginTarget: Vector3;
  106902. /**
  106903. * Defines the value of the inertia used during panning.
  106904. * 0 would mean stop inertia and one would mean no decelleration at all.
  106905. */
  106906. panningInertia: number;
  106907. /**
  106908. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  106909. */
  106910. angularSensibilityX: number;
  106911. /**
  106912. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  106913. */
  106914. angularSensibilityY: number;
  106915. /**
  106916. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  106917. */
  106918. pinchPrecision: number;
  106919. /**
  106920. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  106921. * It will be used instead of pinchDeltaPrecision if different from 0.
  106922. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  106923. */
  106924. pinchDeltaPercentage: number;
  106925. /**
  106926. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  106927. */
  106928. panningSensibility: number;
  106929. /**
  106930. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  106931. */
  106932. keysUp: number[];
  106933. /**
  106934. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  106935. */
  106936. keysDown: number[];
  106937. /**
  106938. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  106939. */
  106940. keysLeft: number[];
  106941. /**
  106942. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  106943. */
  106944. keysRight: number[];
  106945. /**
  106946. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  106947. */
  106948. wheelPrecision: number;
  106949. /**
  106950. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  106951. * It will be used instead of pinchDeltaPrecision if different from 0.
  106952. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  106953. */
  106954. wheelDeltaPercentage: number;
  106955. /**
  106956. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  106957. */
  106958. zoomOnFactor: number;
  106959. /**
  106960. * Defines a screen offset for the camera position.
  106961. */
  106962. targetScreenOffset: Vector2;
  106963. /**
  106964. * Allows the camera to be completely reversed.
  106965. * If false the camera can not arrive upside down.
  106966. */
  106967. allowUpsideDown: boolean;
  106968. /**
  106969. * Define if double tap/click is used to restore the previously saved state of the camera.
  106970. */
  106971. useInputToRestoreState: boolean;
  106972. /** @hidden */
  106973. _viewMatrix: Matrix;
  106974. /** @hidden */
  106975. _useCtrlForPanning: boolean;
  106976. /** @hidden */
  106977. _panningMouseButton: number;
  106978. /**
  106979. * Defines the input associated to the camera.
  106980. */
  106981. inputs: ArcRotateCameraInputsManager;
  106982. /** @hidden */
  106983. _reset: () => void;
  106984. /**
  106985. * Defines the allowed panning axis.
  106986. */
  106987. panningAxis: Vector3;
  106988. protected _localDirection: Vector3;
  106989. protected _transformedDirection: Vector3;
  106990. private _bouncingBehavior;
  106991. /**
  106992. * Gets the bouncing behavior of the camera if it has been enabled.
  106993. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  106994. */
  106995. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  106996. /**
  106997. * Defines if the bouncing behavior of the camera is enabled on the camera.
  106998. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  106999. */
  107000. useBouncingBehavior: boolean;
  107001. private _framingBehavior;
  107002. /**
  107003. * Gets the framing behavior of the camera if it has been enabled.
  107004. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  107005. */
  107006. readonly framingBehavior: Nullable<FramingBehavior>;
  107007. /**
  107008. * Defines if the framing behavior of the camera is enabled on the camera.
  107009. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  107010. */
  107011. useFramingBehavior: boolean;
  107012. private _autoRotationBehavior;
  107013. /**
  107014. * Gets the auto rotation behavior of the camera if it has been enabled.
  107015. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  107016. */
  107017. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  107018. /**
  107019. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  107020. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  107021. */
  107022. useAutoRotationBehavior: boolean;
  107023. /**
  107024. * Observable triggered when the mesh target has been changed on the camera.
  107025. */
  107026. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  107027. /**
  107028. * Event raised when the camera is colliding with a mesh.
  107029. */
  107030. onCollide: (collidedMesh: AbstractMesh) => void;
  107031. /**
  107032. * Defines whether the camera should check collision with the objects oh the scene.
  107033. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  107034. */
  107035. checkCollisions: boolean;
  107036. /**
  107037. * Defines the collision radius of the camera.
  107038. * This simulates a sphere around the camera.
  107039. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  107040. */
  107041. collisionRadius: Vector3;
  107042. protected _collider: Collider;
  107043. protected _previousPosition: Vector3;
  107044. protected _collisionVelocity: Vector3;
  107045. protected _newPosition: Vector3;
  107046. protected _previousAlpha: number;
  107047. protected _previousBeta: number;
  107048. protected _previousRadius: number;
  107049. protected _collisionTriggered: boolean;
  107050. protected _targetBoundingCenter: Nullable<Vector3>;
  107051. private _computationVector;
  107052. /**
  107053. * Instantiates a new ArcRotateCamera in a given scene
  107054. * @param name Defines the name of the camera
  107055. * @param alpha Defines the camera rotation along the logitudinal axis
  107056. * @param beta Defines the camera rotation along the latitudinal axis
  107057. * @param radius Defines the camera distance from its target
  107058. * @param target Defines the camera target
  107059. * @param scene Defines the scene the camera belongs to
  107060. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  107061. */
  107062. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  107063. /** @hidden */
  107064. _initCache(): void;
  107065. /** @hidden */
  107066. _updateCache(ignoreParentClass?: boolean): void;
  107067. protected _getTargetPosition(): Vector3;
  107068. private _storedAlpha;
  107069. private _storedBeta;
  107070. private _storedRadius;
  107071. private _storedTarget;
  107072. private _storedTargetScreenOffset;
  107073. /**
  107074. * Stores the current state of the camera (alpha, beta, radius and target)
  107075. * @returns the camera itself
  107076. */
  107077. storeState(): Camera;
  107078. /**
  107079. * @hidden
  107080. * Restored camera state. You must call storeState() first
  107081. */
  107082. _restoreStateValues(): boolean;
  107083. /** @hidden */
  107084. _isSynchronizedViewMatrix(): boolean;
  107085. /**
  107086. * Attached controls to the current camera.
  107087. * @param element Defines the element the controls should be listened from
  107088. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107089. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  107090. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  107091. */
  107092. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  107093. /**
  107094. * Detach the current controls from the camera.
  107095. * The camera will stop reacting to inputs.
  107096. * @param element Defines the element to stop listening the inputs from
  107097. */
  107098. detachControl(element: HTMLElement): void;
  107099. /** @hidden */
  107100. _checkInputs(): void;
  107101. protected _checkLimits(): void;
  107102. /**
  107103. * Rebuilds angles (alpha, beta) and radius from the give position and target
  107104. */
  107105. rebuildAnglesAndRadius(): void;
  107106. /**
  107107. * Use a position to define the current camera related information like alpha, beta and radius
  107108. * @param position Defines the position to set the camera at
  107109. */
  107110. setPosition(position: Vector3): void;
  107111. /**
  107112. * Defines the target the camera should look at.
  107113. * This will automatically adapt alpha beta and radius to fit within the new target.
  107114. * @param target Defines the new target as a Vector or a mesh
  107115. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  107116. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  107117. */
  107118. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  107119. /** @hidden */
  107120. _getViewMatrix(): Matrix;
  107121. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  107122. /**
  107123. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  107124. * @param meshes Defines the mesh to zoom on
  107125. * @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)
  107126. */
  107127. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  107128. /**
  107129. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  107130. * The target will be changed but the radius
  107131. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  107132. * @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)
  107133. */
  107134. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  107135. min: Vector3;
  107136. max: Vector3;
  107137. distance: number;
  107138. }, doNotUpdateMaxZ?: boolean): void;
  107139. /**
  107140. * @override
  107141. * Override Camera.createRigCamera
  107142. */
  107143. createRigCamera(name: string, cameraIndex: number): Camera;
  107144. /**
  107145. * @hidden
  107146. * @override
  107147. * Override Camera._updateRigCameras
  107148. */
  107149. _updateRigCameras(): void;
  107150. /**
  107151. * Destroy the camera and release the current resources hold by it.
  107152. */
  107153. dispose(): void;
  107154. /**
  107155. * Gets the current object class name.
  107156. * @return the class name
  107157. */
  107158. getClassName(): string;
  107159. }
  107160. }
  107161. declare module BABYLON {
  107162. /**
  107163. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  107164. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  107165. */
  107166. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  107167. /**
  107168. * Gets the name of the behavior.
  107169. */
  107170. readonly name: string;
  107171. private _zoomStopsAnimation;
  107172. private _idleRotationSpeed;
  107173. private _idleRotationWaitTime;
  107174. private _idleRotationSpinupTime;
  107175. /**
  107176. * Sets the flag that indicates if user zooming should stop animation.
  107177. */
  107178. /**
  107179. * Gets the flag that indicates if user zooming should stop animation.
  107180. */
  107181. zoomStopsAnimation: boolean;
  107182. /**
  107183. * Sets the default speed at which the camera rotates around the model.
  107184. */
  107185. /**
  107186. * Gets the default speed at which the camera rotates around the model.
  107187. */
  107188. idleRotationSpeed: number;
  107189. /**
  107190. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  107191. */
  107192. /**
  107193. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  107194. */
  107195. idleRotationWaitTime: number;
  107196. /**
  107197. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  107198. */
  107199. /**
  107200. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  107201. */
  107202. idleRotationSpinupTime: number;
  107203. /**
  107204. * Gets a value indicating if the camera is currently rotating because of this behavior
  107205. */
  107206. readonly rotationInProgress: boolean;
  107207. private _onPrePointerObservableObserver;
  107208. private _onAfterCheckInputsObserver;
  107209. private _attachedCamera;
  107210. private _isPointerDown;
  107211. private _lastFrameTime;
  107212. private _lastInteractionTime;
  107213. private _cameraRotationSpeed;
  107214. /**
  107215. * Initializes the behavior.
  107216. */
  107217. init(): void;
  107218. /**
  107219. * Attaches the behavior to its arc rotate camera.
  107220. * @param camera Defines the camera to attach the behavior to
  107221. */
  107222. attach(camera: ArcRotateCamera): void;
  107223. /**
  107224. * Detaches the behavior from its current arc rotate camera.
  107225. */
  107226. detach(): void;
  107227. /**
  107228. * Returns true if user is scrolling.
  107229. * @return true if user is scrolling.
  107230. */
  107231. private _userIsZooming;
  107232. private _lastFrameRadius;
  107233. private _shouldAnimationStopForInteraction;
  107234. /**
  107235. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  107236. */
  107237. private _applyUserInteraction;
  107238. private _userIsMoving;
  107239. }
  107240. }
  107241. declare module BABYLON {
  107242. /**
  107243. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  107244. */
  107245. export class AttachToBoxBehavior implements Behavior<Mesh> {
  107246. private ui;
  107247. /**
  107248. * The name of the behavior
  107249. */
  107250. name: string;
  107251. /**
  107252. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  107253. */
  107254. distanceAwayFromFace: number;
  107255. /**
  107256. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  107257. */
  107258. distanceAwayFromBottomOfFace: number;
  107259. private _faceVectors;
  107260. private _target;
  107261. private _scene;
  107262. private _onRenderObserver;
  107263. private _tmpMatrix;
  107264. private _tmpVector;
  107265. /**
  107266. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  107267. * @param ui The transform node that should be attched to the mesh
  107268. */
  107269. constructor(ui: TransformNode);
  107270. /**
  107271. * Initializes the behavior
  107272. */
  107273. init(): void;
  107274. private _closestFace;
  107275. private _zeroVector;
  107276. private _lookAtTmpMatrix;
  107277. private _lookAtToRef;
  107278. /**
  107279. * Attaches the AttachToBoxBehavior to the passed in mesh
  107280. * @param target The mesh that the specified node will be attached to
  107281. */
  107282. attach(target: Mesh): void;
  107283. /**
  107284. * Detaches the behavior from the mesh
  107285. */
  107286. detach(): void;
  107287. }
  107288. }
  107289. declare module BABYLON {
  107290. /**
  107291. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  107292. */
  107293. export class FadeInOutBehavior implements Behavior<Mesh> {
  107294. /**
  107295. * Time in milliseconds to delay before fading in (Default: 0)
  107296. */
  107297. delay: number;
  107298. /**
  107299. * Time in milliseconds for the mesh to fade in (Default: 300)
  107300. */
  107301. fadeInTime: number;
  107302. private _millisecondsPerFrame;
  107303. private _hovered;
  107304. private _hoverValue;
  107305. private _ownerNode;
  107306. /**
  107307. * Instatiates the FadeInOutBehavior
  107308. */
  107309. constructor();
  107310. /**
  107311. * The name of the behavior
  107312. */
  107313. readonly name: string;
  107314. /**
  107315. * Initializes the behavior
  107316. */
  107317. init(): void;
  107318. /**
  107319. * Attaches the fade behavior on the passed in mesh
  107320. * @param ownerNode The mesh that will be faded in/out once attached
  107321. */
  107322. attach(ownerNode: Mesh): void;
  107323. /**
  107324. * Detaches the behavior from the mesh
  107325. */
  107326. detach(): void;
  107327. /**
  107328. * Triggers the mesh to begin fading in or out
  107329. * @param value if the object should fade in or out (true to fade in)
  107330. */
  107331. fadeIn(value: boolean): void;
  107332. private _update;
  107333. private _setAllVisibility;
  107334. }
  107335. }
  107336. declare module BABYLON {
  107337. /**
  107338. * Class containing a set of static utilities functions for managing Pivots
  107339. * @hidden
  107340. */
  107341. export class PivotTools {
  107342. private static _PivotCached;
  107343. private static _OldPivotPoint;
  107344. private static _PivotTranslation;
  107345. private static _PivotTmpVector;
  107346. /** @hidden */
  107347. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  107348. /** @hidden */
  107349. static _RestorePivotPoint(mesh: AbstractMesh): void;
  107350. }
  107351. }
  107352. declare module BABYLON {
  107353. /**
  107354. * Class containing static functions to help procedurally build meshes
  107355. */
  107356. export class PlaneBuilder {
  107357. /**
  107358. * Creates a plane mesh
  107359. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  107360. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  107361. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  107362. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107363. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107364. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107365. * @param name defines the name of the mesh
  107366. * @param options defines the options used to create the mesh
  107367. * @param scene defines the hosting scene
  107368. * @returns the plane mesh
  107369. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  107370. */
  107371. static CreatePlane(name: string, options: {
  107372. size?: number;
  107373. width?: number;
  107374. height?: number;
  107375. sideOrientation?: number;
  107376. frontUVs?: Vector4;
  107377. backUVs?: Vector4;
  107378. updatable?: boolean;
  107379. sourcePlane?: Plane;
  107380. }, scene?: Nullable<Scene>): Mesh;
  107381. }
  107382. }
  107383. declare module BABYLON {
  107384. /**
  107385. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  107386. */
  107387. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  107388. private static _AnyMouseID;
  107389. /**
  107390. * Abstract mesh the behavior is set on
  107391. */
  107392. attachedNode: AbstractMesh;
  107393. private _dragPlane;
  107394. private _scene;
  107395. private _pointerObserver;
  107396. private _beforeRenderObserver;
  107397. private static _planeScene;
  107398. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  107399. /**
  107400. * 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)
  107401. */
  107402. maxDragAngle: number;
  107403. /**
  107404. * @hidden
  107405. */
  107406. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  107407. /**
  107408. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  107409. */
  107410. currentDraggingPointerID: number;
  107411. /**
  107412. * The last position where the pointer hit the drag plane in world space
  107413. */
  107414. lastDragPosition: Vector3;
  107415. /**
  107416. * If the behavior is currently in a dragging state
  107417. */
  107418. dragging: boolean;
  107419. /**
  107420. * 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)
  107421. */
  107422. dragDeltaRatio: number;
  107423. /**
  107424. * If the drag plane orientation should be updated during the dragging (Default: true)
  107425. */
  107426. updateDragPlane: boolean;
  107427. private _debugMode;
  107428. private _moving;
  107429. /**
  107430. * Fires each time the attached mesh is dragged with the pointer
  107431. * * delta between last drag position and current drag position in world space
  107432. * * dragDistance along the drag axis
  107433. * * dragPlaneNormal normal of the current drag plane used during the drag
  107434. * * dragPlanePoint in world space where the drag intersects the drag plane
  107435. */
  107436. onDragObservable: Observable<{
  107437. delta: Vector3;
  107438. dragPlanePoint: Vector3;
  107439. dragPlaneNormal: Vector3;
  107440. dragDistance: number;
  107441. pointerId: number;
  107442. }>;
  107443. /**
  107444. * Fires each time a drag begins (eg. mouse down on mesh)
  107445. */
  107446. onDragStartObservable: Observable<{
  107447. dragPlanePoint: Vector3;
  107448. pointerId: number;
  107449. }>;
  107450. /**
  107451. * Fires each time a drag ends (eg. mouse release after drag)
  107452. */
  107453. onDragEndObservable: Observable<{
  107454. dragPlanePoint: Vector3;
  107455. pointerId: number;
  107456. }>;
  107457. /**
  107458. * If the attached mesh should be moved when dragged
  107459. */
  107460. moveAttached: boolean;
  107461. /**
  107462. * If the drag behavior will react to drag events (Default: true)
  107463. */
  107464. enabled: boolean;
  107465. /**
  107466. * If pointer events should start and release the drag (Default: true)
  107467. */
  107468. startAndReleaseDragOnPointerEvents: boolean;
  107469. /**
  107470. * If camera controls should be detached during the drag
  107471. */
  107472. detachCameraControls: boolean;
  107473. /**
  107474. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  107475. */
  107476. useObjectOrienationForDragging: boolean;
  107477. private _options;
  107478. /**
  107479. * Gets the options used by the behavior
  107480. */
  107481. /**
  107482. * Sets the options used by the behavior
  107483. */
  107484. options: {
  107485. dragAxis?: Vector3;
  107486. dragPlaneNormal?: Vector3;
  107487. };
  107488. /**
  107489. * Creates a pointer drag behavior that can be attached to a mesh
  107490. * @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)
  107491. */
  107492. constructor(options?: {
  107493. dragAxis?: Vector3;
  107494. dragPlaneNormal?: Vector3;
  107495. });
  107496. /**
  107497. * Predicate to determine if it is valid to move the object to a new position when it is moved
  107498. */
  107499. validateDrag: (targetPosition: Vector3) => boolean;
  107500. /**
  107501. * The name of the behavior
  107502. */
  107503. readonly name: string;
  107504. /**
  107505. * Initializes the behavior
  107506. */
  107507. init(): void;
  107508. private _tmpVector;
  107509. private _alternatePickedPoint;
  107510. private _worldDragAxis;
  107511. private _targetPosition;
  107512. private _attachedElement;
  107513. /**
  107514. * Attaches the drag behavior the passed in mesh
  107515. * @param ownerNode The mesh that will be dragged around once attached
  107516. * @param predicate Predicate to use for pick filtering
  107517. */
  107518. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  107519. /**
  107520. * Force relase the drag action by code.
  107521. */
  107522. releaseDrag(): void;
  107523. private _startDragRay;
  107524. private _lastPointerRay;
  107525. /**
  107526. * Simulates the start of a pointer drag event on the behavior
  107527. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  107528. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  107529. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  107530. */
  107531. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  107532. private _startDrag;
  107533. private _dragDelta;
  107534. private _moveDrag;
  107535. private _pickWithRayOnDragPlane;
  107536. private _pointA;
  107537. private _pointB;
  107538. private _pointC;
  107539. private _lineA;
  107540. private _lineB;
  107541. private _localAxis;
  107542. private _lookAt;
  107543. private _updateDragPlanePosition;
  107544. /**
  107545. * Detaches the behavior from the mesh
  107546. */
  107547. detach(): void;
  107548. }
  107549. }
  107550. declare module BABYLON {
  107551. /**
  107552. * A behavior that when attached to a mesh will allow the mesh to be scaled
  107553. */
  107554. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  107555. private _dragBehaviorA;
  107556. private _dragBehaviorB;
  107557. private _startDistance;
  107558. private _initialScale;
  107559. private _targetScale;
  107560. private _ownerNode;
  107561. private _sceneRenderObserver;
  107562. /**
  107563. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  107564. */
  107565. constructor();
  107566. /**
  107567. * The name of the behavior
  107568. */
  107569. readonly name: string;
  107570. /**
  107571. * Initializes the behavior
  107572. */
  107573. init(): void;
  107574. private _getCurrentDistance;
  107575. /**
  107576. * Attaches the scale behavior the passed in mesh
  107577. * @param ownerNode The mesh that will be scaled around once attached
  107578. */
  107579. attach(ownerNode: Mesh): void;
  107580. /**
  107581. * Detaches the behavior from the mesh
  107582. */
  107583. detach(): void;
  107584. }
  107585. }
  107586. declare module BABYLON {
  107587. /**
  107588. * 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
  107589. */
  107590. export class SixDofDragBehavior implements Behavior<Mesh> {
  107591. private static _virtualScene;
  107592. private _ownerNode;
  107593. private _sceneRenderObserver;
  107594. private _scene;
  107595. private _targetPosition;
  107596. private _virtualOriginMesh;
  107597. private _virtualDragMesh;
  107598. private _pointerObserver;
  107599. private _moving;
  107600. private _startingOrientation;
  107601. /**
  107602. * 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)
  107603. */
  107604. private zDragFactor;
  107605. /**
  107606. * If the object should rotate to face the drag origin
  107607. */
  107608. rotateDraggedObject: boolean;
  107609. /**
  107610. * If the behavior is currently in a dragging state
  107611. */
  107612. dragging: boolean;
  107613. /**
  107614. * 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)
  107615. */
  107616. dragDeltaRatio: number;
  107617. /**
  107618. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  107619. */
  107620. currentDraggingPointerID: number;
  107621. /**
  107622. * If camera controls should be detached during the drag
  107623. */
  107624. detachCameraControls: boolean;
  107625. /**
  107626. * Fires each time a drag starts
  107627. */
  107628. onDragStartObservable: Observable<{}>;
  107629. /**
  107630. * Fires each time a drag ends (eg. mouse release after drag)
  107631. */
  107632. onDragEndObservable: Observable<{}>;
  107633. /**
  107634. * 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
  107635. */
  107636. constructor();
  107637. /**
  107638. * The name of the behavior
  107639. */
  107640. readonly name: string;
  107641. /**
  107642. * Initializes the behavior
  107643. */
  107644. init(): void;
  107645. /**
  107646. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  107647. */
  107648. private readonly _pointerCamera;
  107649. /**
  107650. * Attaches the scale behavior the passed in mesh
  107651. * @param ownerNode The mesh that will be scaled around once attached
  107652. */
  107653. attach(ownerNode: Mesh): void;
  107654. /**
  107655. * Detaches the behavior from the mesh
  107656. */
  107657. detach(): void;
  107658. }
  107659. }
  107660. declare module BABYLON {
  107661. /**
  107662. * Class used to apply inverse kinematics to bones
  107663. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  107664. */
  107665. export class BoneIKController {
  107666. private static _tmpVecs;
  107667. private static _tmpQuat;
  107668. private static _tmpMats;
  107669. /**
  107670. * Gets or sets the target mesh
  107671. */
  107672. targetMesh: AbstractMesh;
  107673. /** Gets or sets the mesh used as pole */
  107674. poleTargetMesh: AbstractMesh;
  107675. /**
  107676. * Gets or sets the bone used as pole
  107677. */
  107678. poleTargetBone: Nullable<Bone>;
  107679. /**
  107680. * Gets or sets the target position
  107681. */
  107682. targetPosition: Vector3;
  107683. /**
  107684. * Gets or sets the pole target position
  107685. */
  107686. poleTargetPosition: Vector3;
  107687. /**
  107688. * Gets or sets the pole target local offset
  107689. */
  107690. poleTargetLocalOffset: Vector3;
  107691. /**
  107692. * Gets or sets the pole angle
  107693. */
  107694. poleAngle: number;
  107695. /**
  107696. * Gets or sets the mesh associated with the controller
  107697. */
  107698. mesh: AbstractMesh;
  107699. /**
  107700. * 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)
  107701. */
  107702. slerpAmount: number;
  107703. private _bone1Quat;
  107704. private _bone1Mat;
  107705. private _bone2Ang;
  107706. private _bone1;
  107707. private _bone2;
  107708. private _bone1Length;
  107709. private _bone2Length;
  107710. private _maxAngle;
  107711. private _maxReach;
  107712. private _rightHandedSystem;
  107713. private _bendAxis;
  107714. private _slerping;
  107715. private _adjustRoll;
  107716. /**
  107717. * Gets or sets maximum allowed angle
  107718. */
  107719. maxAngle: number;
  107720. /**
  107721. * Creates a new BoneIKController
  107722. * @param mesh defines the mesh to control
  107723. * @param bone defines the bone to control
  107724. * @param options defines options to set up the controller
  107725. */
  107726. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  107727. targetMesh?: AbstractMesh;
  107728. poleTargetMesh?: AbstractMesh;
  107729. poleTargetBone?: Bone;
  107730. poleTargetLocalOffset?: Vector3;
  107731. poleAngle?: number;
  107732. bendAxis?: Vector3;
  107733. maxAngle?: number;
  107734. slerpAmount?: number;
  107735. });
  107736. private _setMaxAngle;
  107737. /**
  107738. * Force the controller to update the bones
  107739. */
  107740. update(): void;
  107741. }
  107742. }
  107743. declare module BABYLON {
  107744. /**
  107745. * Class used to make a bone look toward a point in space
  107746. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  107747. */
  107748. export class BoneLookController {
  107749. private static _tmpVecs;
  107750. private static _tmpQuat;
  107751. private static _tmpMats;
  107752. /**
  107753. * The target Vector3 that the bone will look at
  107754. */
  107755. target: Vector3;
  107756. /**
  107757. * The mesh that the bone is attached to
  107758. */
  107759. mesh: AbstractMesh;
  107760. /**
  107761. * The bone that will be looking to the target
  107762. */
  107763. bone: Bone;
  107764. /**
  107765. * The up axis of the coordinate system that is used when the bone is rotated
  107766. */
  107767. upAxis: Vector3;
  107768. /**
  107769. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  107770. */
  107771. upAxisSpace: Space;
  107772. /**
  107773. * Used to make an adjustment to the yaw of the bone
  107774. */
  107775. adjustYaw: number;
  107776. /**
  107777. * Used to make an adjustment to the pitch of the bone
  107778. */
  107779. adjustPitch: number;
  107780. /**
  107781. * Used to make an adjustment to the roll of the bone
  107782. */
  107783. adjustRoll: number;
  107784. /**
  107785. * 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)
  107786. */
  107787. slerpAmount: number;
  107788. private _minYaw;
  107789. private _maxYaw;
  107790. private _minPitch;
  107791. private _maxPitch;
  107792. private _minYawSin;
  107793. private _minYawCos;
  107794. private _maxYawSin;
  107795. private _maxYawCos;
  107796. private _midYawConstraint;
  107797. private _minPitchTan;
  107798. private _maxPitchTan;
  107799. private _boneQuat;
  107800. private _slerping;
  107801. private _transformYawPitch;
  107802. private _transformYawPitchInv;
  107803. private _firstFrameSkipped;
  107804. private _yawRange;
  107805. private _fowardAxis;
  107806. /**
  107807. * Gets or sets the minimum yaw angle that the bone can look to
  107808. */
  107809. minYaw: number;
  107810. /**
  107811. * Gets or sets the maximum yaw angle that the bone can look to
  107812. */
  107813. maxYaw: number;
  107814. /**
  107815. * Gets or sets the minimum pitch angle that the bone can look to
  107816. */
  107817. minPitch: number;
  107818. /**
  107819. * Gets or sets the maximum pitch angle that the bone can look to
  107820. */
  107821. maxPitch: number;
  107822. /**
  107823. * Create a BoneLookController
  107824. * @param mesh the mesh that the bone belongs to
  107825. * @param bone the bone that will be looking to the target
  107826. * @param target the target Vector3 to look at
  107827. * @param options optional settings:
  107828. * * maxYaw: the maximum angle the bone will yaw to
  107829. * * minYaw: the minimum angle the bone will yaw to
  107830. * * maxPitch: the maximum angle the bone will pitch to
  107831. * * minPitch: the minimum angle the bone will yaw to
  107832. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  107833. * * upAxis: the up axis of the coordinate system
  107834. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  107835. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  107836. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  107837. * * adjustYaw: used to make an adjustment to the yaw of the bone
  107838. * * adjustPitch: used to make an adjustment to the pitch of the bone
  107839. * * adjustRoll: used to make an adjustment to the roll of the bone
  107840. **/
  107841. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  107842. maxYaw?: number;
  107843. minYaw?: number;
  107844. maxPitch?: number;
  107845. minPitch?: number;
  107846. slerpAmount?: number;
  107847. upAxis?: Vector3;
  107848. upAxisSpace?: Space;
  107849. yawAxis?: Vector3;
  107850. pitchAxis?: Vector3;
  107851. adjustYaw?: number;
  107852. adjustPitch?: number;
  107853. adjustRoll?: number;
  107854. });
  107855. /**
  107856. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  107857. */
  107858. update(): void;
  107859. private _getAngleDiff;
  107860. private _getAngleBetween;
  107861. private _isAngleBetween;
  107862. }
  107863. }
  107864. declare module BABYLON {
  107865. /**
  107866. * Manage the gamepad inputs to control an arc rotate camera.
  107867. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107868. */
  107869. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  107870. /**
  107871. * Defines the camera the input is attached to.
  107872. */
  107873. camera: ArcRotateCamera;
  107874. /**
  107875. * Defines the gamepad the input is gathering event from.
  107876. */
  107877. gamepad: Nullable<Gamepad>;
  107878. /**
  107879. * Defines the gamepad rotation sensiblity.
  107880. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  107881. */
  107882. gamepadRotationSensibility: number;
  107883. /**
  107884. * Defines the gamepad move sensiblity.
  107885. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  107886. */
  107887. gamepadMoveSensibility: number;
  107888. private _yAxisScale;
  107889. /**
  107890. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  107891. */
  107892. invertYAxis: boolean;
  107893. private _onGamepadConnectedObserver;
  107894. private _onGamepadDisconnectedObserver;
  107895. /**
  107896. * Attach the input controls to a specific dom element to get the input from.
  107897. * @param element Defines the element the controls should be listened from
  107898. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107899. */
  107900. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107901. /**
  107902. * Detach the current controls from the specified dom element.
  107903. * @param element Defines the element to stop listening the inputs from
  107904. */
  107905. detachControl(element: Nullable<HTMLElement>): void;
  107906. /**
  107907. * Update the current camera state depending on the inputs that have been used this frame.
  107908. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  107909. */
  107910. checkInputs(): void;
  107911. /**
  107912. * Gets the class name of the current intput.
  107913. * @returns the class name
  107914. */
  107915. getClassName(): string;
  107916. /**
  107917. * Get the friendly name associated with the input class.
  107918. * @returns the input friendly name
  107919. */
  107920. getSimpleName(): string;
  107921. }
  107922. }
  107923. declare module BABYLON {
  107924. interface ArcRotateCameraInputsManager {
  107925. /**
  107926. * Add orientation input support to the input manager.
  107927. * @returns the current input manager
  107928. */
  107929. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  107930. }
  107931. /**
  107932. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  107933. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107934. */
  107935. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  107936. /**
  107937. * Defines the camera the input is attached to.
  107938. */
  107939. camera: ArcRotateCamera;
  107940. /**
  107941. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  107942. */
  107943. alphaCorrection: number;
  107944. /**
  107945. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  107946. */
  107947. gammaCorrection: number;
  107948. private _alpha;
  107949. private _gamma;
  107950. private _dirty;
  107951. private _deviceOrientationHandler;
  107952. /**
  107953. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  107954. */
  107955. constructor();
  107956. /**
  107957. * Attach the input controls to a specific dom element to get the input from.
  107958. * @param element Defines the element the controls should be listened from
  107959. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107960. */
  107961. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107962. /** @hidden */
  107963. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  107964. /**
  107965. * Update the current camera state depending on the inputs that have been used this frame.
  107966. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  107967. */
  107968. checkInputs(): void;
  107969. /**
  107970. * Detach the current controls from the specified dom element.
  107971. * @param element Defines the element to stop listening the inputs from
  107972. */
  107973. detachControl(element: Nullable<HTMLElement>): void;
  107974. /**
  107975. * Gets the class name of the current intput.
  107976. * @returns the class name
  107977. */
  107978. getClassName(): string;
  107979. /**
  107980. * Get the friendly name associated with the input class.
  107981. * @returns the input friendly name
  107982. */
  107983. getSimpleName(): string;
  107984. }
  107985. }
  107986. declare module BABYLON {
  107987. /**
  107988. * Listen to mouse events to control the camera.
  107989. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107990. */
  107991. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  107992. /**
  107993. * Defines the camera the input is attached to.
  107994. */
  107995. camera: FlyCamera;
  107996. /**
  107997. * Defines if touch is enabled. (Default is true.)
  107998. */
  107999. touchEnabled: boolean;
  108000. /**
  108001. * Defines the buttons associated with the input to handle camera rotation.
  108002. */
  108003. buttons: number[];
  108004. /**
  108005. * Assign buttons for Yaw control.
  108006. */
  108007. buttonsYaw: number[];
  108008. /**
  108009. * Assign buttons for Pitch control.
  108010. */
  108011. buttonsPitch: number[];
  108012. /**
  108013. * Assign buttons for Roll control.
  108014. */
  108015. buttonsRoll: number[];
  108016. /**
  108017. * Detect if any button is being pressed while mouse is moved.
  108018. * -1 = Mouse locked.
  108019. * 0 = Left button.
  108020. * 1 = Middle Button.
  108021. * 2 = Right Button.
  108022. */
  108023. activeButton: number;
  108024. /**
  108025. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  108026. * Higher values reduce its sensitivity.
  108027. */
  108028. angularSensibility: number;
  108029. private _mousemoveCallback;
  108030. private _observer;
  108031. private _rollObserver;
  108032. private previousPosition;
  108033. private noPreventDefault;
  108034. private element;
  108035. /**
  108036. * Listen to mouse events to control the camera.
  108037. * @param touchEnabled Define if touch is enabled. (Default is true.)
  108038. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108039. */
  108040. constructor(touchEnabled?: boolean);
  108041. /**
  108042. * Attach the mouse control to the HTML DOM element.
  108043. * @param element Defines the element that listens to the input events.
  108044. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  108045. */
  108046. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108047. /**
  108048. * Detach the current controls from the specified dom element.
  108049. * @param element Defines the element to stop listening the inputs from
  108050. */
  108051. detachControl(element: Nullable<HTMLElement>): void;
  108052. /**
  108053. * Gets the class name of the current input.
  108054. * @returns the class name.
  108055. */
  108056. getClassName(): string;
  108057. /**
  108058. * Get the friendly name associated with the input class.
  108059. * @returns the input's friendly name.
  108060. */
  108061. getSimpleName(): string;
  108062. private _pointerInput;
  108063. private _onMouseMove;
  108064. /**
  108065. * Rotate camera by mouse offset.
  108066. */
  108067. private rotateCamera;
  108068. }
  108069. }
  108070. declare module BABYLON {
  108071. /**
  108072. * Default Inputs manager for the FlyCamera.
  108073. * It groups all the default supported inputs for ease of use.
  108074. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108075. */
  108076. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  108077. /**
  108078. * Instantiates a new FlyCameraInputsManager.
  108079. * @param camera Defines the camera the inputs belong to.
  108080. */
  108081. constructor(camera: FlyCamera);
  108082. /**
  108083. * Add keyboard input support to the input manager.
  108084. * @returns the new FlyCameraKeyboardMoveInput().
  108085. */
  108086. addKeyboard(): FlyCameraInputsManager;
  108087. /**
  108088. * Add mouse input support to the input manager.
  108089. * @param touchEnabled Enable touch screen support.
  108090. * @returns the new FlyCameraMouseInput().
  108091. */
  108092. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  108093. }
  108094. }
  108095. declare module BABYLON {
  108096. /**
  108097. * This is a flying camera, designed for 3D movement and rotation in all directions,
  108098. * such as in a 3D Space Shooter or a Flight Simulator.
  108099. */
  108100. export class FlyCamera extends TargetCamera {
  108101. /**
  108102. * Define the collision ellipsoid of the camera.
  108103. * This is helpful for simulating a camera body, like a player's body.
  108104. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  108105. */
  108106. ellipsoid: Vector3;
  108107. /**
  108108. * Define an offset for the position of the ellipsoid around the camera.
  108109. * This can be helpful if the camera is attached away from the player's body center,
  108110. * such as at its head.
  108111. */
  108112. ellipsoidOffset: Vector3;
  108113. /**
  108114. * Enable or disable collisions of the camera with the rest of the scene objects.
  108115. */
  108116. checkCollisions: boolean;
  108117. /**
  108118. * Enable or disable gravity on the camera.
  108119. */
  108120. applyGravity: boolean;
  108121. /**
  108122. * Define the current direction the camera is moving to.
  108123. */
  108124. cameraDirection: Vector3;
  108125. /**
  108126. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  108127. * This overrides and empties cameraRotation.
  108128. */
  108129. rotationQuaternion: Quaternion;
  108130. /**
  108131. * Track Roll to maintain the wanted Rolling when looking around.
  108132. */
  108133. _trackRoll: number;
  108134. /**
  108135. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  108136. */
  108137. rollCorrect: number;
  108138. /**
  108139. * Mimic a banked turn, Rolling the camera when Yawing.
  108140. * It's recommended to use rollCorrect = 10 for faster banking correction.
  108141. */
  108142. bankedTurn: boolean;
  108143. /**
  108144. * Limit in radians for how much Roll banking will add. (Default: 90°)
  108145. */
  108146. bankedTurnLimit: number;
  108147. /**
  108148. * Value of 0 disables the banked Roll.
  108149. * Value of 1 is equal to the Yaw angle in radians.
  108150. */
  108151. bankedTurnMultiplier: number;
  108152. /**
  108153. * The inputs manager loads all the input sources, such as keyboard and mouse.
  108154. */
  108155. inputs: FlyCameraInputsManager;
  108156. /**
  108157. * Gets the input sensibility for mouse input.
  108158. * Higher values reduce sensitivity.
  108159. */
  108160. /**
  108161. * Sets the input sensibility for a mouse input.
  108162. * Higher values reduce sensitivity.
  108163. */
  108164. angularSensibility: number;
  108165. /**
  108166. * Get the keys for camera movement forward.
  108167. */
  108168. /**
  108169. * Set the keys for camera movement forward.
  108170. */
  108171. keysForward: number[];
  108172. /**
  108173. * Get the keys for camera movement backward.
  108174. */
  108175. keysBackward: number[];
  108176. /**
  108177. * Get the keys for camera movement up.
  108178. */
  108179. /**
  108180. * Set the keys for camera movement up.
  108181. */
  108182. keysUp: number[];
  108183. /**
  108184. * Get the keys for camera movement down.
  108185. */
  108186. /**
  108187. * Set the keys for camera movement down.
  108188. */
  108189. keysDown: number[];
  108190. /**
  108191. * Get the keys for camera movement left.
  108192. */
  108193. /**
  108194. * Set the keys for camera movement left.
  108195. */
  108196. keysLeft: number[];
  108197. /**
  108198. * Set the keys for camera movement right.
  108199. */
  108200. /**
  108201. * Set the keys for camera movement right.
  108202. */
  108203. keysRight: number[];
  108204. /**
  108205. * Event raised when the camera collides with a mesh in the scene.
  108206. */
  108207. onCollide: (collidedMesh: AbstractMesh) => void;
  108208. private _collider;
  108209. private _needMoveForGravity;
  108210. private _oldPosition;
  108211. private _diffPosition;
  108212. private _newPosition;
  108213. /** @hidden */
  108214. _localDirection: Vector3;
  108215. /** @hidden */
  108216. _transformedDirection: Vector3;
  108217. /**
  108218. * Instantiates a FlyCamera.
  108219. * This is a flying camera, designed for 3D movement and rotation in all directions,
  108220. * such as in a 3D Space Shooter or a Flight Simulator.
  108221. * @param name Define the name of the camera in the scene.
  108222. * @param position Define the starting position of the camera in the scene.
  108223. * @param scene Define the scene the camera belongs to.
  108224. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  108225. */
  108226. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  108227. /**
  108228. * Attach a control to the HTML DOM element.
  108229. * @param element Defines the element that listens to the input events.
  108230. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  108231. */
  108232. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108233. /**
  108234. * Detach a control from the HTML DOM element.
  108235. * The camera will stop reacting to that input.
  108236. * @param element Defines the element that listens to the input events.
  108237. */
  108238. detachControl(element: HTMLElement): void;
  108239. private _collisionMask;
  108240. /**
  108241. * Get the mask that the camera ignores in collision events.
  108242. */
  108243. /**
  108244. * Set the mask that the camera ignores in collision events.
  108245. */
  108246. collisionMask: number;
  108247. /** @hidden */
  108248. _collideWithWorld(displacement: Vector3): void;
  108249. /** @hidden */
  108250. private _onCollisionPositionChange;
  108251. /** @hidden */
  108252. _checkInputs(): void;
  108253. /** @hidden */
  108254. _decideIfNeedsToMove(): boolean;
  108255. /** @hidden */
  108256. _updatePosition(): void;
  108257. /**
  108258. * Restore the Roll to its target value at the rate specified.
  108259. * @param rate - Higher means slower restoring.
  108260. * @hidden
  108261. */
  108262. restoreRoll(rate: number): void;
  108263. /**
  108264. * Destroy the camera and release the current resources held by it.
  108265. */
  108266. dispose(): void;
  108267. /**
  108268. * Get the current object class name.
  108269. * @returns the class name.
  108270. */
  108271. getClassName(): string;
  108272. }
  108273. }
  108274. declare module BABYLON {
  108275. /**
  108276. * Listen to keyboard events to control the camera.
  108277. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108278. */
  108279. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  108280. /**
  108281. * Defines the camera the input is attached to.
  108282. */
  108283. camera: FlyCamera;
  108284. /**
  108285. * The list of keyboard keys used to control the forward move of the camera.
  108286. */
  108287. keysForward: number[];
  108288. /**
  108289. * The list of keyboard keys used to control the backward move of the camera.
  108290. */
  108291. keysBackward: number[];
  108292. /**
  108293. * The list of keyboard keys used to control the forward move of the camera.
  108294. */
  108295. keysUp: number[];
  108296. /**
  108297. * The list of keyboard keys used to control the backward move of the camera.
  108298. */
  108299. keysDown: number[];
  108300. /**
  108301. * The list of keyboard keys used to control the right strafe move of the camera.
  108302. */
  108303. keysRight: number[];
  108304. /**
  108305. * The list of keyboard keys used to control the left strafe move of the camera.
  108306. */
  108307. keysLeft: number[];
  108308. private _keys;
  108309. private _onCanvasBlurObserver;
  108310. private _onKeyboardObserver;
  108311. private _engine;
  108312. private _scene;
  108313. /**
  108314. * Attach the input controls to a specific dom element to get the input from.
  108315. * @param element Defines the element the controls should be listened from
  108316. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108317. */
  108318. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108319. /**
  108320. * Detach the current controls from the specified dom element.
  108321. * @param element Defines the element to stop listening the inputs from
  108322. */
  108323. detachControl(element: Nullable<HTMLElement>): void;
  108324. /**
  108325. * Gets the class name of the current intput.
  108326. * @returns the class name
  108327. */
  108328. getClassName(): string;
  108329. /** @hidden */
  108330. _onLostFocus(e: FocusEvent): void;
  108331. /**
  108332. * Get the friendly name associated with the input class.
  108333. * @returns the input friendly name
  108334. */
  108335. getSimpleName(): string;
  108336. /**
  108337. * Update the current camera state depending on the inputs that have been used this frame.
  108338. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  108339. */
  108340. checkInputs(): void;
  108341. }
  108342. }
  108343. declare module BABYLON {
  108344. /**
  108345. * Manage the mouse wheel inputs to control a follow camera.
  108346. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108347. */
  108348. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  108349. /**
  108350. * Defines the camera the input is attached to.
  108351. */
  108352. camera: FollowCamera;
  108353. /**
  108354. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  108355. */
  108356. axisControlRadius: boolean;
  108357. /**
  108358. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  108359. */
  108360. axisControlHeight: boolean;
  108361. /**
  108362. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  108363. */
  108364. axisControlRotation: boolean;
  108365. /**
  108366. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  108367. * relation to mouseWheel events.
  108368. */
  108369. wheelPrecision: number;
  108370. /**
  108371. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  108372. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  108373. */
  108374. wheelDeltaPercentage: number;
  108375. private _wheel;
  108376. private _observer;
  108377. /**
  108378. * Attach the input controls to a specific dom element to get the input from.
  108379. * @param element Defines the element the controls should be listened from
  108380. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108381. */
  108382. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108383. /**
  108384. * Detach the current controls from the specified dom element.
  108385. * @param element Defines the element to stop listening the inputs from
  108386. */
  108387. detachControl(element: Nullable<HTMLElement>): void;
  108388. /**
  108389. * Gets the class name of the current intput.
  108390. * @returns the class name
  108391. */
  108392. getClassName(): string;
  108393. /**
  108394. * Get the friendly name associated with the input class.
  108395. * @returns the input friendly name
  108396. */
  108397. getSimpleName(): string;
  108398. }
  108399. }
  108400. declare module BABYLON {
  108401. /**
  108402. * Manage the pointers inputs to control an follow camera.
  108403. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108404. */
  108405. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  108406. /**
  108407. * Defines the camera the input is attached to.
  108408. */
  108409. camera: FollowCamera;
  108410. /**
  108411. * Gets the class name of the current input.
  108412. * @returns the class name
  108413. */
  108414. getClassName(): string;
  108415. /**
  108416. * Defines the pointer angular sensibility along the X axis or how fast is
  108417. * the camera rotating.
  108418. * A negative number will reverse the axis direction.
  108419. */
  108420. angularSensibilityX: number;
  108421. /**
  108422. * Defines the pointer angular sensibility along the Y axis or how fast is
  108423. * the camera rotating.
  108424. * A negative number will reverse the axis direction.
  108425. */
  108426. angularSensibilityY: number;
  108427. /**
  108428. * Defines the pointer pinch precision or how fast is the camera zooming.
  108429. * A negative number will reverse the axis direction.
  108430. */
  108431. pinchPrecision: number;
  108432. /**
  108433. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  108434. * from 0.
  108435. * It defines the percentage of current camera.radius to use as delta when
  108436. * pinch zoom is used.
  108437. */
  108438. pinchDeltaPercentage: number;
  108439. /**
  108440. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  108441. */
  108442. axisXControlRadius: boolean;
  108443. /**
  108444. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  108445. */
  108446. axisXControlHeight: boolean;
  108447. /**
  108448. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  108449. */
  108450. axisXControlRotation: boolean;
  108451. /**
  108452. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  108453. */
  108454. axisYControlRadius: boolean;
  108455. /**
  108456. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  108457. */
  108458. axisYControlHeight: boolean;
  108459. /**
  108460. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  108461. */
  108462. axisYControlRotation: boolean;
  108463. /**
  108464. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  108465. */
  108466. axisPinchControlRadius: boolean;
  108467. /**
  108468. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  108469. */
  108470. axisPinchControlHeight: boolean;
  108471. /**
  108472. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  108473. */
  108474. axisPinchControlRotation: boolean;
  108475. /**
  108476. * Log error messages if basic misconfiguration has occurred.
  108477. */
  108478. warningEnable: boolean;
  108479. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  108480. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  108481. private _warningCounter;
  108482. private _warning;
  108483. }
  108484. }
  108485. declare module BABYLON {
  108486. /**
  108487. * Default Inputs manager for the FollowCamera.
  108488. * It groups all the default supported inputs for ease of use.
  108489. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108490. */
  108491. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  108492. /**
  108493. * Instantiates a new FollowCameraInputsManager.
  108494. * @param camera Defines the camera the inputs belong to
  108495. */
  108496. constructor(camera: FollowCamera);
  108497. /**
  108498. * Add keyboard input support to the input manager.
  108499. * @returns the current input manager
  108500. */
  108501. addKeyboard(): FollowCameraInputsManager;
  108502. /**
  108503. * Add mouse wheel input support to the input manager.
  108504. * @returns the current input manager
  108505. */
  108506. addMouseWheel(): FollowCameraInputsManager;
  108507. /**
  108508. * Add pointers input support to the input manager.
  108509. * @returns the current input manager
  108510. */
  108511. addPointers(): FollowCameraInputsManager;
  108512. /**
  108513. * Add orientation input support to the input manager.
  108514. * @returns the current input manager
  108515. */
  108516. addVRDeviceOrientation(): FollowCameraInputsManager;
  108517. }
  108518. }
  108519. declare module BABYLON {
  108520. /**
  108521. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  108522. * an arc rotate version arcFollowCamera are available.
  108523. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  108524. */
  108525. export class FollowCamera extends TargetCamera {
  108526. /**
  108527. * Distance the follow camera should follow an object at
  108528. */
  108529. radius: number;
  108530. /**
  108531. * Minimum allowed distance of the camera to the axis of rotation
  108532. * (The camera can not get closer).
  108533. * This can help limiting how the Camera is able to move in the scene.
  108534. */
  108535. lowerRadiusLimit: Nullable<number>;
  108536. /**
  108537. * Maximum allowed distance of the camera to the axis of rotation
  108538. * (The camera can not get further).
  108539. * This can help limiting how the Camera is able to move in the scene.
  108540. */
  108541. upperRadiusLimit: Nullable<number>;
  108542. /**
  108543. * Define a rotation offset between the camera and the object it follows
  108544. */
  108545. rotationOffset: number;
  108546. /**
  108547. * Minimum allowed angle to camera position relative to target object.
  108548. * This can help limiting how the Camera is able to move in the scene.
  108549. */
  108550. lowerRotationOffsetLimit: Nullable<number>;
  108551. /**
  108552. * Maximum allowed angle to camera position relative to target object.
  108553. * This can help limiting how the Camera is able to move in the scene.
  108554. */
  108555. upperRotationOffsetLimit: Nullable<number>;
  108556. /**
  108557. * Define a height offset between the camera and the object it follows.
  108558. * It can help following an object from the top (like a car chaing a plane)
  108559. */
  108560. heightOffset: number;
  108561. /**
  108562. * Minimum allowed height of camera position relative to target object.
  108563. * This can help limiting how the Camera is able to move in the scene.
  108564. */
  108565. lowerHeightOffsetLimit: Nullable<number>;
  108566. /**
  108567. * Maximum allowed height of camera position relative to target object.
  108568. * This can help limiting how the Camera is able to move in the scene.
  108569. */
  108570. upperHeightOffsetLimit: Nullable<number>;
  108571. /**
  108572. * Define how fast the camera can accelerate to follow it s target.
  108573. */
  108574. cameraAcceleration: number;
  108575. /**
  108576. * Define the speed limit of the camera following an object.
  108577. */
  108578. maxCameraSpeed: number;
  108579. /**
  108580. * Define the target of the camera.
  108581. */
  108582. lockedTarget: Nullable<AbstractMesh>;
  108583. /**
  108584. * Defines the input associated with the camera.
  108585. */
  108586. inputs: FollowCameraInputsManager;
  108587. /**
  108588. * Instantiates the follow camera.
  108589. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  108590. * @param name Define the name of the camera in the scene
  108591. * @param position Define the position of the camera
  108592. * @param scene Define the scene the camera belong to
  108593. * @param lockedTarget Define the target of the camera
  108594. */
  108595. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  108596. private _follow;
  108597. /**
  108598. * Attached controls to the current camera.
  108599. * @param element Defines the element the controls should be listened from
  108600. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108601. */
  108602. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108603. /**
  108604. * Detach the current controls from the camera.
  108605. * The camera will stop reacting to inputs.
  108606. * @param element Defines the element to stop listening the inputs from
  108607. */
  108608. detachControl(element: HTMLElement): void;
  108609. /** @hidden */
  108610. _checkInputs(): void;
  108611. private _checkLimits;
  108612. /**
  108613. * Gets the camera class name.
  108614. * @returns the class name
  108615. */
  108616. getClassName(): string;
  108617. }
  108618. /**
  108619. * Arc Rotate version of the follow camera.
  108620. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  108621. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  108622. */
  108623. export class ArcFollowCamera extends TargetCamera {
  108624. /** The longitudinal angle of the camera */
  108625. alpha: number;
  108626. /** The latitudinal angle of the camera */
  108627. beta: number;
  108628. /** The radius of the camera from its target */
  108629. radius: number;
  108630. /** Define the camera target (the messh it should follow) */
  108631. target: Nullable<AbstractMesh>;
  108632. private _cartesianCoordinates;
  108633. /**
  108634. * Instantiates a new ArcFollowCamera
  108635. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  108636. * @param name Define the name of the camera
  108637. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  108638. * @param beta Define the rotation angle of the camera around the elevation axis
  108639. * @param radius Define the radius of the camera from its target point
  108640. * @param target Define the target of the camera
  108641. * @param scene Define the scene the camera belongs to
  108642. */
  108643. constructor(name: string,
  108644. /** The longitudinal angle of the camera */
  108645. alpha: number,
  108646. /** The latitudinal angle of the camera */
  108647. beta: number,
  108648. /** The radius of the camera from its target */
  108649. radius: number,
  108650. /** Define the camera target (the messh it should follow) */
  108651. target: Nullable<AbstractMesh>, scene: Scene);
  108652. private _follow;
  108653. /** @hidden */
  108654. _checkInputs(): void;
  108655. /**
  108656. * Returns the class name of the object.
  108657. * It is mostly used internally for serialization purposes.
  108658. */
  108659. getClassName(): string;
  108660. }
  108661. }
  108662. declare module BABYLON {
  108663. /**
  108664. * Manage the keyboard inputs to control the movement of a follow camera.
  108665. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108666. */
  108667. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  108668. /**
  108669. * Defines the camera the input is attached to.
  108670. */
  108671. camera: FollowCamera;
  108672. /**
  108673. * Defines the list of key codes associated with the up action (increase heightOffset)
  108674. */
  108675. keysHeightOffsetIncr: number[];
  108676. /**
  108677. * Defines the list of key codes associated with the down action (decrease heightOffset)
  108678. */
  108679. keysHeightOffsetDecr: number[];
  108680. /**
  108681. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  108682. */
  108683. keysHeightOffsetModifierAlt: boolean;
  108684. /**
  108685. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  108686. */
  108687. keysHeightOffsetModifierCtrl: boolean;
  108688. /**
  108689. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  108690. */
  108691. keysHeightOffsetModifierShift: boolean;
  108692. /**
  108693. * Defines the list of key codes associated with the left action (increase rotationOffset)
  108694. */
  108695. keysRotationOffsetIncr: number[];
  108696. /**
  108697. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  108698. */
  108699. keysRotationOffsetDecr: number[];
  108700. /**
  108701. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  108702. */
  108703. keysRotationOffsetModifierAlt: boolean;
  108704. /**
  108705. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  108706. */
  108707. keysRotationOffsetModifierCtrl: boolean;
  108708. /**
  108709. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  108710. */
  108711. keysRotationOffsetModifierShift: boolean;
  108712. /**
  108713. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  108714. */
  108715. keysRadiusIncr: number[];
  108716. /**
  108717. * Defines the list of key codes associated with the zoom-out action (increase radius)
  108718. */
  108719. keysRadiusDecr: number[];
  108720. /**
  108721. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  108722. */
  108723. keysRadiusModifierAlt: boolean;
  108724. /**
  108725. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  108726. */
  108727. keysRadiusModifierCtrl: boolean;
  108728. /**
  108729. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  108730. */
  108731. keysRadiusModifierShift: boolean;
  108732. /**
  108733. * Defines the rate of change of heightOffset.
  108734. */
  108735. heightSensibility: number;
  108736. /**
  108737. * Defines the rate of change of rotationOffset.
  108738. */
  108739. rotationSensibility: number;
  108740. /**
  108741. * Defines the rate of change of radius.
  108742. */
  108743. radiusSensibility: number;
  108744. private _keys;
  108745. private _ctrlPressed;
  108746. private _altPressed;
  108747. private _shiftPressed;
  108748. private _onCanvasBlurObserver;
  108749. private _onKeyboardObserver;
  108750. private _engine;
  108751. private _scene;
  108752. /**
  108753. * Attach the input controls to a specific dom element to get the input from.
  108754. * @param element Defines the element the controls should be listened from
  108755. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108756. */
  108757. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108758. /**
  108759. * Detach the current controls from the specified dom element.
  108760. * @param element Defines the element to stop listening the inputs from
  108761. */
  108762. detachControl(element: Nullable<HTMLElement>): void;
  108763. /**
  108764. * Update the current camera state depending on the inputs that have been used this frame.
  108765. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  108766. */
  108767. checkInputs(): void;
  108768. /**
  108769. * Gets the class name of the current input.
  108770. * @returns the class name
  108771. */
  108772. getClassName(): string;
  108773. /**
  108774. * Get the friendly name associated with the input class.
  108775. * @returns the input friendly name
  108776. */
  108777. getSimpleName(): string;
  108778. /**
  108779. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  108780. * allow modification of the heightOffset value.
  108781. */
  108782. private _modifierHeightOffset;
  108783. /**
  108784. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  108785. * allow modification of the rotationOffset value.
  108786. */
  108787. private _modifierRotationOffset;
  108788. /**
  108789. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  108790. * allow modification of the radius value.
  108791. */
  108792. private _modifierRadius;
  108793. }
  108794. }
  108795. declare module BABYLON {
  108796. interface FreeCameraInputsManager {
  108797. /**
  108798. * @hidden
  108799. */
  108800. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  108801. /**
  108802. * Add orientation input support to the input manager.
  108803. * @returns the current input manager
  108804. */
  108805. addDeviceOrientation(): FreeCameraInputsManager;
  108806. }
  108807. /**
  108808. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  108809. * Screen rotation is taken into account.
  108810. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108811. */
  108812. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  108813. private _camera;
  108814. private _screenOrientationAngle;
  108815. private _constantTranform;
  108816. private _screenQuaternion;
  108817. private _alpha;
  108818. private _beta;
  108819. private _gamma;
  108820. /**
  108821. * Can be used to detect if a device orientation sensor is available on a device
  108822. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  108823. * @returns a promise that will resolve on orientation change
  108824. */
  108825. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  108826. /**
  108827. * @hidden
  108828. */
  108829. _onDeviceOrientationChangedObservable: Observable<void>;
  108830. /**
  108831. * Instantiates a new input
  108832. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108833. */
  108834. constructor();
  108835. /**
  108836. * Define the camera controlled by the input.
  108837. */
  108838. camera: FreeCamera;
  108839. /**
  108840. * Attach the input controls to a specific dom element to get the input from.
  108841. * @param element Defines the element the controls should be listened from
  108842. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108843. */
  108844. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108845. private _orientationChanged;
  108846. private _deviceOrientation;
  108847. /**
  108848. * Detach the current controls from the specified dom element.
  108849. * @param element Defines the element to stop listening the inputs from
  108850. */
  108851. detachControl(element: Nullable<HTMLElement>): void;
  108852. /**
  108853. * Update the current camera state depending on the inputs that have been used this frame.
  108854. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  108855. */
  108856. checkInputs(): void;
  108857. /**
  108858. * Gets the class name of the current intput.
  108859. * @returns the class name
  108860. */
  108861. getClassName(): string;
  108862. /**
  108863. * Get the friendly name associated with the input class.
  108864. * @returns the input friendly name
  108865. */
  108866. getSimpleName(): string;
  108867. }
  108868. }
  108869. declare module BABYLON {
  108870. /**
  108871. * Manage the gamepad inputs to control a free camera.
  108872. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108873. */
  108874. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  108875. /**
  108876. * Define the camera the input is attached to.
  108877. */
  108878. camera: FreeCamera;
  108879. /**
  108880. * Define the Gamepad controlling the input
  108881. */
  108882. gamepad: Nullable<Gamepad>;
  108883. /**
  108884. * Defines the gamepad rotation sensiblity.
  108885. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  108886. */
  108887. gamepadAngularSensibility: number;
  108888. /**
  108889. * Defines the gamepad move sensiblity.
  108890. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  108891. */
  108892. gamepadMoveSensibility: number;
  108893. private _yAxisScale;
  108894. /**
  108895. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  108896. */
  108897. invertYAxis: boolean;
  108898. private _onGamepadConnectedObserver;
  108899. private _onGamepadDisconnectedObserver;
  108900. private _cameraTransform;
  108901. private _deltaTransform;
  108902. private _vector3;
  108903. private _vector2;
  108904. /**
  108905. * Attach the input controls to a specific dom element to get the input from.
  108906. * @param element Defines the element the controls should be listened from
  108907. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108908. */
  108909. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108910. /**
  108911. * Detach the current controls from the specified dom element.
  108912. * @param element Defines the element to stop listening the inputs from
  108913. */
  108914. detachControl(element: Nullable<HTMLElement>): void;
  108915. /**
  108916. * Update the current camera state depending on the inputs that have been used this frame.
  108917. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  108918. */
  108919. checkInputs(): void;
  108920. /**
  108921. * Gets the class name of the current intput.
  108922. * @returns the class name
  108923. */
  108924. getClassName(): string;
  108925. /**
  108926. * Get the friendly name associated with the input class.
  108927. * @returns the input friendly name
  108928. */
  108929. getSimpleName(): string;
  108930. }
  108931. }
  108932. declare module BABYLON {
  108933. /**
  108934. * Defines the potential axis of a Joystick
  108935. */
  108936. export enum JoystickAxis {
  108937. /** X axis */
  108938. X = 0,
  108939. /** Y axis */
  108940. Y = 1,
  108941. /** Z axis */
  108942. Z = 2
  108943. }
  108944. /**
  108945. * Class used to define virtual joystick (used in touch mode)
  108946. */
  108947. export class VirtualJoystick {
  108948. /**
  108949. * Gets or sets a boolean indicating that left and right values must be inverted
  108950. */
  108951. reverseLeftRight: boolean;
  108952. /**
  108953. * Gets or sets a boolean indicating that up and down values must be inverted
  108954. */
  108955. reverseUpDown: boolean;
  108956. /**
  108957. * Gets the offset value for the position (ie. the change of the position value)
  108958. */
  108959. deltaPosition: Vector3;
  108960. /**
  108961. * Gets a boolean indicating if the virtual joystick was pressed
  108962. */
  108963. pressed: boolean;
  108964. /**
  108965. * Canvas the virtual joystick will render onto, default z-index of this is 5
  108966. */
  108967. static Canvas: Nullable<HTMLCanvasElement>;
  108968. private static _globalJoystickIndex;
  108969. private static vjCanvasContext;
  108970. private static vjCanvasWidth;
  108971. private static vjCanvasHeight;
  108972. private static halfWidth;
  108973. private _action;
  108974. private _axisTargetedByLeftAndRight;
  108975. private _axisTargetedByUpAndDown;
  108976. private _joystickSensibility;
  108977. private _inversedSensibility;
  108978. private _joystickPointerID;
  108979. private _joystickColor;
  108980. private _joystickPointerPos;
  108981. private _joystickPreviousPointerPos;
  108982. private _joystickPointerStartPos;
  108983. private _deltaJoystickVector;
  108984. private _leftJoystick;
  108985. private _touches;
  108986. private _onPointerDownHandlerRef;
  108987. private _onPointerMoveHandlerRef;
  108988. private _onPointerUpHandlerRef;
  108989. private _onResize;
  108990. /**
  108991. * Creates a new virtual joystick
  108992. * @param leftJoystick defines that the joystick is for left hand (false by default)
  108993. */
  108994. constructor(leftJoystick?: boolean);
  108995. /**
  108996. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  108997. * @param newJoystickSensibility defines the new sensibility
  108998. */
  108999. setJoystickSensibility(newJoystickSensibility: number): void;
  109000. private _onPointerDown;
  109001. private _onPointerMove;
  109002. private _onPointerUp;
  109003. /**
  109004. * Change the color of the virtual joystick
  109005. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  109006. */
  109007. setJoystickColor(newColor: string): void;
  109008. /**
  109009. * Defines a callback to call when the joystick is touched
  109010. * @param action defines the callback
  109011. */
  109012. setActionOnTouch(action: () => any): void;
  109013. /**
  109014. * Defines which axis you'd like to control for left & right
  109015. * @param axis defines the axis to use
  109016. */
  109017. setAxisForLeftRight(axis: JoystickAxis): void;
  109018. /**
  109019. * Defines which axis you'd like to control for up & down
  109020. * @param axis defines the axis to use
  109021. */
  109022. setAxisForUpDown(axis: JoystickAxis): void;
  109023. private _drawVirtualJoystick;
  109024. /**
  109025. * Release internal HTML canvas
  109026. */
  109027. releaseCanvas(): void;
  109028. }
  109029. }
  109030. declare module BABYLON {
  109031. interface FreeCameraInputsManager {
  109032. /**
  109033. * Add virtual joystick input support to the input manager.
  109034. * @returns the current input manager
  109035. */
  109036. addVirtualJoystick(): FreeCameraInputsManager;
  109037. }
  109038. /**
  109039. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  109040. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109041. */
  109042. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  109043. /**
  109044. * Defines the camera the input is attached to.
  109045. */
  109046. camera: FreeCamera;
  109047. private _leftjoystick;
  109048. private _rightjoystick;
  109049. /**
  109050. * Gets the left stick of the virtual joystick.
  109051. * @returns The virtual Joystick
  109052. */
  109053. getLeftJoystick(): VirtualJoystick;
  109054. /**
  109055. * Gets the right stick of the virtual joystick.
  109056. * @returns The virtual Joystick
  109057. */
  109058. getRightJoystick(): VirtualJoystick;
  109059. /**
  109060. * Update the current camera state depending on the inputs that have been used this frame.
  109061. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  109062. */
  109063. checkInputs(): void;
  109064. /**
  109065. * Attach the input controls to a specific dom element to get the input from.
  109066. * @param element Defines the element the controls should be listened from
  109067. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109068. */
  109069. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109070. /**
  109071. * Detach the current controls from the specified dom element.
  109072. * @param element Defines the element to stop listening the inputs from
  109073. */
  109074. detachControl(element: Nullable<HTMLElement>): void;
  109075. /**
  109076. * Gets the class name of the current intput.
  109077. * @returns the class name
  109078. */
  109079. getClassName(): string;
  109080. /**
  109081. * Get the friendly name associated with the input class.
  109082. * @returns the input friendly name
  109083. */
  109084. getSimpleName(): string;
  109085. }
  109086. }
  109087. declare module BABYLON {
  109088. /**
  109089. * This represents a FPS type of camera controlled by touch.
  109090. * This is like a universal camera minus the Gamepad controls.
  109091. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  109092. */
  109093. export class TouchCamera extends FreeCamera {
  109094. /**
  109095. * Defines the touch sensibility for rotation.
  109096. * The higher the faster.
  109097. */
  109098. touchAngularSensibility: number;
  109099. /**
  109100. * Defines the touch sensibility for move.
  109101. * The higher the faster.
  109102. */
  109103. touchMoveSensibility: number;
  109104. /**
  109105. * Instantiates a new touch camera.
  109106. * This represents a FPS type of camera controlled by touch.
  109107. * This is like a universal camera minus the Gamepad controls.
  109108. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  109109. * @param name Define the name of the camera in the scene
  109110. * @param position Define the start position of the camera in the scene
  109111. * @param scene Define the scene the camera belongs to
  109112. */
  109113. constructor(name: string, position: Vector3, scene: Scene);
  109114. /**
  109115. * Gets the current object class name.
  109116. * @return the class name
  109117. */
  109118. getClassName(): string;
  109119. /** @hidden */
  109120. _setupInputs(): void;
  109121. }
  109122. }
  109123. declare module BABYLON {
  109124. /**
  109125. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  109126. * being tilted forward or back and left or right.
  109127. */
  109128. export class DeviceOrientationCamera extends FreeCamera {
  109129. private _initialQuaternion;
  109130. private _quaternionCache;
  109131. private _tmpDragQuaternion;
  109132. private _disablePointerInputWhenUsingDeviceOrientation;
  109133. /**
  109134. * Creates a new device orientation camera
  109135. * @param name The name of the camera
  109136. * @param position The start position camera
  109137. * @param scene The scene the camera belongs to
  109138. */
  109139. constructor(name: string, position: Vector3, scene: Scene);
  109140. /**
  109141. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  109142. */
  109143. disablePointerInputWhenUsingDeviceOrientation: boolean;
  109144. private _dragFactor;
  109145. /**
  109146. * Enabled turning on the y axis when the orientation sensor is active
  109147. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  109148. */
  109149. enableHorizontalDragging(dragFactor?: number): void;
  109150. /**
  109151. * Gets the current instance class name ("DeviceOrientationCamera").
  109152. * This helps avoiding instanceof at run time.
  109153. * @returns the class name
  109154. */
  109155. getClassName(): string;
  109156. /**
  109157. * @hidden
  109158. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  109159. */
  109160. _checkInputs(): void;
  109161. /**
  109162. * Reset the camera to its default orientation on the specified axis only.
  109163. * @param axis The axis to reset
  109164. */
  109165. resetToCurrentRotation(axis?: Axis): void;
  109166. }
  109167. }
  109168. declare module BABYLON {
  109169. /**
  109170. * Defines supported buttons for XBox360 compatible gamepads
  109171. */
  109172. export enum Xbox360Button {
  109173. /** A */
  109174. A = 0,
  109175. /** B */
  109176. B = 1,
  109177. /** X */
  109178. X = 2,
  109179. /** Y */
  109180. Y = 3,
  109181. /** Start */
  109182. Start = 4,
  109183. /** Back */
  109184. Back = 5,
  109185. /** Left button */
  109186. LB = 6,
  109187. /** Right button */
  109188. RB = 7,
  109189. /** Left stick */
  109190. LeftStick = 8,
  109191. /** Right stick */
  109192. RightStick = 9
  109193. }
  109194. /** Defines values for XBox360 DPad */
  109195. export enum Xbox360Dpad {
  109196. /** Up */
  109197. Up = 0,
  109198. /** Down */
  109199. Down = 1,
  109200. /** Left */
  109201. Left = 2,
  109202. /** Right */
  109203. Right = 3
  109204. }
  109205. /**
  109206. * Defines a XBox360 gamepad
  109207. */
  109208. export class Xbox360Pad extends Gamepad {
  109209. private _leftTrigger;
  109210. private _rightTrigger;
  109211. private _onlefttriggerchanged;
  109212. private _onrighttriggerchanged;
  109213. private _onbuttondown;
  109214. private _onbuttonup;
  109215. private _ondpaddown;
  109216. private _ondpadup;
  109217. /** Observable raised when a button is pressed */
  109218. onButtonDownObservable: Observable<Xbox360Button>;
  109219. /** Observable raised when a button is released */
  109220. onButtonUpObservable: Observable<Xbox360Button>;
  109221. /** Observable raised when a pad is pressed */
  109222. onPadDownObservable: Observable<Xbox360Dpad>;
  109223. /** Observable raised when a pad is released */
  109224. onPadUpObservable: Observable<Xbox360Dpad>;
  109225. private _buttonA;
  109226. private _buttonB;
  109227. private _buttonX;
  109228. private _buttonY;
  109229. private _buttonBack;
  109230. private _buttonStart;
  109231. private _buttonLB;
  109232. private _buttonRB;
  109233. private _buttonLeftStick;
  109234. private _buttonRightStick;
  109235. private _dPadUp;
  109236. private _dPadDown;
  109237. private _dPadLeft;
  109238. private _dPadRight;
  109239. private _isXboxOnePad;
  109240. /**
  109241. * Creates a new XBox360 gamepad object
  109242. * @param id defines the id of this gamepad
  109243. * @param index defines its index
  109244. * @param gamepad defines the internal HTML gamepad object
  109245. * @param xboxOne defines if it is a XBox One gamepad
  109246. */
  109247. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  109248. /**
  109249. * Defines the callback to call when left trigger is pressed
  109250. * @param callback defines the callback to use
  109251. */
  109252. onlefttriggerchanged(callback: (value: number) => void): void;
  109253. /**
  109254. * Defines the callback to call when right trigger is pressed
  109255. * @param callback defines the callback to use
  109256. */
  109257. onrighttriggerchanged(callback: (value: number) => void): void;
  109258. /**
  109259. * Gets the left trigger value
  109260. */
  109261. /**
  109262. * Sets the left trigger value
  109263. */
  109264. leftTrigger: number;
  109265. /**
  109266. * Gets the right trigger value
  109267. */
  109268. /**
  109269. * Sets the right trigger value
  109270. */
  109271. rightTrigger: number;
  109272. /**
  109273. * Defines the callback to call when a button is pressed
  109274. * @param callback defines the callback to use
  109275. */
  109276. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  109277. /**
  109278. * Defines the callback to call when a button is released
  109279. * @param callback defines the callback to use
  109280. */
  109281. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  109282. /**
  109283. * Defines the callback to call when a pad is pressed
  109284. * @param callback defines the callback to use
  109285. */
  109286. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  109287. /**
  109288. * Defines the callback to call when a pad is released
  109289. * @param callback defines the callback to use
  109290. */
  109291. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  109292. private _setButtonValue;
  109293. private _setDPadValue;
  109294. /**
  109295. * Gets the value of the `A` button
  109296. */
  109297. /**
  109298. * Sets the value of the `A` button
  109299. */
  109300. buttonA: number;
  109301. /**
  109302. * Gets the value of the `B` button
  109303. */
  109304. /**
  109305. * Sets the value of the `B` button
  109306. */
  109307. buttonB: number;
  109308. /**
  109309. * Gets the value of the `X` button
  109310. */
  109311. /**
  109312. * Sets the value of the `X` button
  109313. */
  109314. buttonX: number;
  109315. /**
  109316. * Gets the value of the `Y` button
  109317. */
  109318. /**
  109319. * Sets the value of the `Y` button
  109320. */
  109321. buttonY: number;
  109322. /**
  109323. * Gets the value of the `Start` button
  109324. */
  109325. /**
  109326. * Sets the value of the `Start` button
  109327. */
  109328. buttonStart: number;
  109329. /**
  109330. * Gets the value of the `Back` button
  109331. */
  109332. /**
  109333. * Sets the value of the `Back` button
  109334. */
  109335. buttonBack: number;
  109336. /**
  109337. * Gets the value of the `Left` button
  109338. */
  109339. /**
  109340. * Sets the value of the `Left` button
  109341. */
  109342. buttonLB: number;
  109343. /**
  109344. * Gets the value of the `Right` button
  109345. */
  109346. /**
  109347. * Sets the value of the `Right` button
  109348. */
  109349. buttonRB: number;
  109350. /**
  109351. * Gets the value of the Left joystick
  109352. */
  109353. /**
  109354. * Sets the value of the Left joystick
  109355. */
  109356. buttonLeftStick: number;
  109357. /**
  109358. * Gets the value of the Right joystick
  109359. */
  109360. /**
  109361. * Sets the value of the Right joystick
  109362. */
  109363. buttonRightStick: number;
  109364. /**
  109365. * Gets the value of D-pad up
  109366. */
  109367. /**
  109368. * Sets the value of D-pad up
  109369. */
  109370. dPadUp: number;
  109371. /**
  109372. * Gets the value of D-pad down
  109373. */
  109374. /**
  109375. * Sets the value of D-pad down
  109376. */
  109377. dPadDown: number;
  109378. /**
  109379. * Gets the value of D-pad left
  109380. */
  109381. /**
  109382. * Sets the value of D-pad left
  109383. */
  109384. dPadLeft: number;
  109385. /**
  109386. * Gets the value of D-pad right
  109387. */
  109388. /**
  109389. * Sets the value of D-pad right
  109390. */
  109391. dPadRight: number;
  109392. /**
  109393. * Force the gamepad to synchronize with device values
  109394. */
  109395. update(): void;
  109396. /**
  109397. * Disposes the gamepad
  109398. */
  109399. dispose(): void;
  109400. }
  109401. }
  109402. declare module BABYLON {
  109403. /**
  109404. * Defines supported buttons for DualShock compatible gamepads
  109405. */
  109406. export enum DualShockButton {
  109407. /** Cross */
  109408. Cross = 0,
  109409. /** Circle */
  109410. Circle = 1,
  109411. /** Square */
  109412. Square = 2,
  109413. /** Triangle */
  109414. Triangle = 3,
  109415. /** Options */
  109416. Options = 4,
  109417. /** Share */
  109418. Share = 5,
  109419. /** L1 */
  109420. L1 = 6,
  109421. /** R1 */
  109422. R1 = 7,
  109423. /** Left stick */
  109424. LeftStick = 8,
  109425. /** Right stick */
  109426. RightStick = 9
  109427. }
  109428. /** Defines values for DualShock DPad */
  109429. export enum DualShockDpad {
  109430. /** Up */
  109431. Up = 0,
  109432. /** Down */
  109433. Down = 1,
  109434. /** Left */
  109435. Left = 2,
  109436. /** Right */
  109437. Right = 3
  109438. }
  109439. /**
  109440. * Defines a DualShock gamepad
  109441. */
  109442. export class DualShockPad extends Gamepad {
  109443. private _leftTrigger;
  109444. private _rightTrigger;
  109445. private _onlefttriggerchanged;
  109446. private _onrighttriggerchanged;
  109447. private _onbuttondown;
  109448. private _onbuttonup;
  109449. private _ondpaddown;
  109450. private _ondpadup;
  109451. /** Observable raised when a button is pressed */
  109452. onButtonDownObservable: Observable<DualShockButton>;
  109453. /** Observable raised when a button is released */
  109454. onButtonUpObservable: Observable<DualShockButton>;
  109455. /** Observable raised when a pad is pressed */
  109456. onPadDownObservable: Observable<DualShockDpad>;
  109457. /** Observable raised when a pad is released */
  109458. onPadUpObservable: Observable<DualShockDpad>;
  109459. private _buttonCross;
  109460. private _buttonCircle;
  109461. private _buttonSquare;
  109462. private _buttonTriangle;
  109463. private _buttonShare;
  109464. private _buttonOptions;
  109465. private _buttonL1;
  109466. private _buttonR1;
  109467. private _buttonLeftStick;
  109468. private _buttonRightStick;
  109469. private _dPadUp;
  109470. private _dPadDown;
  109471. private _dPadLeft;
  109472. private _dPadRight;
  109473. /**
  109474. * Creates a new DualShock gamepad object
  109475. * @param id defines the id of this gamepad
  109476. * @param index defines its index
  109477. * @param gamepad defines the internal HTML gamepad object
  109478. */
  109479. constructor(id: string, index: number, gamepad: any);
  109480. /**
  109481. * Defines the callback to call when left trigger is pressed
  109482. * @param callback defines the callback to use
  109483. */
  109484. onlefttriggerchanged(callback: (value: number) => void): void;
  109485. /**
  109486. * Defines the callback to call when right trigger is pressed
  109487. * @param callback defines the callback to use
  109488. */
  109489. onrighttriggerchanged(callback: (value: number) => void): void;
  109490. /**
  109491. * Gets the left trigger value
  109492. */
  109493. /**
  109494. * Sets the left trigger value
  109495. */
  109496. leftTrigger: number;
  109497. /**
  109498. * Gets the right trigger value
  109499. */
  109500. /**
  109501. * Sets the right trigger value
  109502. */
  109503. rightTrigger: number;
  109504. /**
  109505. * Defines the callback to call when a button is pressed
  109506. * @param callback defines the callback to use
  109507. */
  109508. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  109509. /**
  109510. * Defines the callback to call when a button is released
  109511. * @param callback defines the callback to use
  109512. */
  109513. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  109514. /**
  109515. * Defines the callback to call when a pad is pressed
  109516. * @param callback defines the callback to use
  109517. */
  109518. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  109519. /**
  109520. * Defines the callback to call when a pad is released
  109521. * @param callback defines the callback to use
  109522. */
  109523. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  109524. private _setButtonValue;
  109525. private _setDPadValue;
  109526. /**
  109527. * Gets the value of the `Cross` button
  109528. */
  109529. /**
  109530. * Sets the value of the `Cross` button
  109531. */
  109532. buttonCross: number;
  109533. /**
  109534. * Gets the value of the `Circle` button
  109535. */
  109536. /**
  109537. * Sets the value of the `Circle` button
  109538. */
  109539. buttonCircle: number;
  109540. /**
  109541. * Gets the value of the `Square` button
  109542. */
  109543. /**
  109544. * Sets the value of the `Square` button
  109545. */
  109546. buttonSquare: number;
  109547. /**
  109548. * Gets the value of the `Triangle` button
  109549. */
  109550. /**
  109551. * Sets the value of the `Triangle` button
  109552. */
  109553. buttonTriangle: number;
  109554. /**
  109555. * Gets the value of the `Options` button
  109556. */
  109557. /**
  109558. * Sets the value of the `Options` button
  109559. */
  109560. buttonOptions: number;
  109561. /**
  109562. * Gets the value of the `Share` button
  109563. */
  109564. /**
  109565. * Sets the value of the `Share` button
  109566. */
  109567. buttonShare: number;
  109568. /**
  109569. * Gets the value of the `L1` button
  109570. */
  109571. /**
  109572. * Sets the value of the `L1` button
  109573. */
  109574. buttonL1: number;
  109575. /**
  109576. * Gets the value of the `R1` button
  109577. */
  109578. /**
  109579. * Sets the value of the `R1` button
  109580. */
  109581. buttonR1: number;
  109582. /**
  109583. * Gets the value of the Left joystick
  109584. */
  109585. /**
  109586. * Sets the value of the Left joystick
  109587. */
  109588. buttonLeftStick: number;
  109589. /**
  109590. * Gets the value of the Right joystick
  109591. */
  109592. /**
  109593. * Sets the value of the Right joystick
  109594. */
  109595. buttonRightStick: number;
  109596. /**
  109597. * Gets the value of D-pad up
  109598. */
  109599. /**
  109600. * Sets the value of D-pad up
  109601. */
  109602. dPadUp: number;
  109603. /**
  109604. * Gets the value of D-pad down
  109605. */
  109606. /**
  109607. * Sets the value of D-pad down
  109608. */
  109609. dPadDown: number;
  109610. /**
  109611. * Gets the value of D-pad left
  109612. */
  109613. /**
  109614. * Sets the value of D-pad left
  109615. */
  109616. dPadLeft: number;
  109617. /**
  109618. * Gets the value of D-pad right
  109619. */
  109620. /**
  109621. * Sets the value of D-pad right
  109622. */
  109623. dPadRight: number;
  109624. /**
  109625. * Force the gamepad to synchronize with device values
  109626. */
  109627. update(): void;
  109628. /**
  109629. * Disposes the gamepad
  109630. */
  109631. dispose(): void;
  109632. }
  109633. }
  109634. declare module BABYLON {
  109635. /**
  109636. * Manager for handling gamepads
  109637. */
  109638. export class GamepadManager {
  109639. private _scene?;
  109640. private _babylonGamepads;
  109641. private _oneGamepadConnected;
  109642. /** @hidden */
  109643. _isMonitoring: boolean;
  109644. private _gamepadEventSupported;
  109645. private _gamepadSupport;
  109646. /**
  109647. * observable to be triggered when the gamepad controller has been connected
  109648. */
  109649. onGamepadConnectedObservable: Observable<Gamepad>;
  109650. /**
  109651. * observable to be triggered when the gamepad controller has been disconnected
  109652. */
  109653. onGamepadDisconnectedObservable: Observable<Gamepad>;
  109654. private _onGamepadConnectedEvent;
  109655. private _onGamepadDisconnectedEvent;
  109656. /**
  109657. * Initializes the gamepad manager
  109658. * @param _scene BabylonJS scene
  109659. */
  109660. constructor(_scene?: Scene | undefined);
  109661. /**
  109662. * The gamepads in the game pad manager
  109663. */
  109664. readonly gamepads: Gamepad[];
  109665. /**
  109666. * Get the gamepad controllers based on type
  109667. * @param type The type of gamepad controller
  109668. * @returns Nullable gamepad
  109669. */
  109670. getGamepadByType(type?: number): Nullable<Gamepad>;
  109671. /**
  109672. * Disposes the gamepad manager
  109673. */
  109674. dispose(): void;
  109675. private _addNewGamepad;
  109676. private _startMonitoringGamepads;
  109677. private _stopMonitoringGamepads;
  109678. /** @hidden */
  109679. _checkGamepadsStatus(): void;
  109680. private _updateGamepadObjects;
  109681. }
  109682. }
  109683. declare module BABYLON {
  109684. interface Scene {
  109685. /** @hidden */
  109686. _gamepadManager: Nullable<GamepadManager>;
  109687. /**
  109688. * Gets the gamepad manager associated with the scene
  109689. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  109690. */
  109691. gamepadManager: GamepadManager;
  109692. }
  109693. /**
  109694. * Interface representing a free camera inputs manager
  109695. */
  109696. interface FreeCameraInputsManager {
  109697. /**
  109698. * Adds gamepad input support to the FreeCameraInputsManager.
  109699. * @returns the FreeCameraInputsManager
  109700. */
  109701. addGamepad(): FreeCameraInputsManager;
  109702. }
  109703. /**
  109704. * Interface representing an arc rotate camera inputs manager
  109705. */
  109706. interface ArcRotateCameraInputsManager {
  109707. /**
  109708. * Adds gamepad input support to the ArcRotateCamera InputManager.
  109709. * @returns the camera inputs manager
  109710. */
  109711. addGamepad(): ArcRotateCameraInputsManager;
  109712. }
  109713. /**
  109714. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  109715. */
  109716. export class GamepadSystemSceneComponent implements ISceneComponent {
  109717. /**
  109718. * The component name helpfull to identify the component in the list of scene components.
  109719. */
  109720. readonly name: string;
  109721. /**
  109722. * The scene the component belongs to.
  109723. */
  109724. scene: Scene;
  109725. /**
  109726. * Creates a new instance of the component for the given scene
  109727. * @param scene Defines the scene to register the component in
  109728. */
  109729. constructor(scene: Scene);
  109730. /**
  109731. * Registers the component in a given scene
  109732. */
  109733. register(): void;
  109734. /**
  109735. * Rebuilds the elements related to this component in case of
  109736. * context lost for instance.
  109737. */
  109738. rebuild(): void;
  109739. /**
  109740. * Disposes the component and the associated ressources
  109741. */
  109742. dispose(): void;
  109743. private _beforeCameraUpdate;
  109744. }
  109745. }
  109746. declare module BABYLON {
  109747. /**
  109748. * 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,
  109749. * which still works and will still be found in many Playgrounds.
  109750. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  109751. */
  109752. export class UniversalCamera extends TouchCamera {
  109753. /**
  109754. * Defines the gamepad rotation sensiblity.
  109755. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  109756. */
  109757. gamepadAngularSensibility: number;
  109758. /**
  109759. * Defines the gamepad move sensiblity.
  109760. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  109761. */
  109762. gamepadMoveSensibility: number;
  109763. /**
  109764. * 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,
  109765. * which still works and will still be found in many Playgrounds.
  109766. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  109767. * @param name Define the name of the camera in the scene
  109768. * @param position Define the start position of the camera in the scene
  109769. * @param scene Define the scene the camera belongs to
  109770. */
  109771. constructor(name: string, position: Vector3, scene: Scene);
  109772. /**
  109773. * Gets the current object class name.
  109774. * @return the class name
  109775. */
  109776. getClassName(): string;
  109777. }
  109778. }
  109779. declare module BABYLON {
  109780. /**
  109781. * This represents a FPS type of camera. This is only here for back compat purpose.
  109782. * Please use the UniversalCamera instead as both are identical.
  109783. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  109784. */
  109785. export class GamepadCamera extends UniversalCamera {
  109786. /**
  109787. * Instantiates a new Gamepad Camera
  109788. * This represents a FPS type of camera. This is only here for back compat purpose.
  109789. * Please use the UniversalCamera instead as both are identical.
  109790. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  109791. * @param name Define the name of the camera in the scene
  109792. * @param position Define the start position of the camera in the scene
  109793. * @param scene Define the scene the camera belongs to
  109794. */
  109795. constructor(name: string, position: Vector3, scene: Scene);
  109796. /**
  109797. * Gets the current object class name.
  109798. * @return the class name
  109799. */
  109800. getClassName(): string;
  109801. }
  109802. }
  109803. declare module BABYLON {
  109804. /** @hidden */
  109805. export var passPixelShader: {
  109806. name: string;
  109807. shader: string;
  109808. };
  109809. }
  109810. declare module BABYLON {
  109811. /** @hidden */
  109812. export var passCubePixelShader: {
  109813. name: string;
  109814. shader: string;
  109815. };
  109816. }
  109817. declare module BABYLON {
  109818. /**
  109819. * PassPostProcess which produces an output the same as it's input
  109820. */
  109821. export class PassPostProcess extends PostProcess {
  109822. /**
  109823. * Creates the PassPostProcess
  109824. * @param name The name of the effect.
  109825. * @param options The required width/height ratio to downsize to before computing the render pass.
  109826. * @param camera The camera to apply the render pass to.
  109827. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109828. * @param engine The engine which the post process will be applied. (default: current engine)
  109829. * @param reusable If the post process can be reused on the same frame. (default: false)
  109830. * @param textureType The type of texture to be used when performing the post processing.
  109831. * @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)
  109832. */
  109833. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109834. }
  109835. /**
  109836. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  109837. */
  109838. export class PassCubePostProcess extends PostProcess {
  109839. private _face;
  109840. /**
  109841. * Gets or sets the cube face to display.
  109842. * * 0 is +X
  109843. * * 1 is -X
  109844. * * 2 is +Y
  109845. * * 3 is -Y
  109846. * * 4 is +Z
  109847. * * 5 is -Z
  109848. */
  109849. face: number;
  109850. /**
  109851. * Creates the PassCubePostProcess
  109852. * @param name The name of the effect.
  109853. * @param options The required width/height ratio to downsize to before computing the render pass.
  109854. * @param camera The camera to apply the render pass to.
  109855. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109856. * @param engine The engine which the post process will be applied. (default: current engine)
  109857. * @param reusable If the post process can be reused on the same frame. (default: false)
  109858. * @param textureType The type of texture to be used when performing the post processing.
  109859. * @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)
  109860. */
  109861. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109862. }
  109863. }
  109864. declare module BABYLON {
  109865. /** @hidden */
  109866. export var anaglyphPixelShader: {
  109867. name: string;
  109868. shader: string;
  109869. };
  109870. }
  109871. declare module BABYLON {
  109872. /**
  109873. * Postprocess used to generate anaglyphic rendering
  109874. */
  109875. export class AnaglyphPostProcess extends PostProcess {
  109876. private _passedProcess;
  109877. /**
  109878. * Creates a new AnaglyphPostProcess
  109879. * @param name defines postprocess name
  109880. * @param options defines creation options or target ratio scale
  109881. * @param rigCameras defines cameras using this postprocess
  109882. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  109883. * @param engine defines hosting engine
  109884. * @param reusable defines if the postprocess will be reused multiple times per frame
  109885. */
  109886. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  109887. }
  109888. }
  109889. declare module BABYLON {
  109890. /**
  109891. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  109892. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  109893. */
  109894. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  109895. /**
  109896. * Creates a new AnaglyphArcRotateCamera
  109897. * @param name defines camera name
  109898. * @param alpha defines alpha angle (in radians)
  109899. * @param beta defines beta angle (in radians)
  109900. * @param radius defines radius
  109901. * @param target defines camera target
  109902. * @param interaxialDistance defines distance between each color axis
  109903. * @param scene defines the hosting scene
  109904. */
  109905. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  109906. /**
  109907. * Gets camera class name
  109908. * @returns AnaglyphArcRotateCamera
  109909. */
  109910. getClassName(): string;
  109911. }
  109912. }
  109913. declare module BABYLON {
  109914. /**
  109915. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  109916. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  109917. */
  109918. export class AnaglyphFreeCamera extends FreeCamera {
  109919. /**
  109920. * Creates a new AnaglyphFreeCamera
  109921. * @param name defines camera name
  109922. * @param position defines initial position
  109923. * @param interaxialDistance defines distance between each color axis
  109924. * @param scene defines the hosting scene
  109925. */
  109926. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  109927. /**
  109928. * Gets camera class name
  109929. * @returns AnaglyphFreeCamera
  109930. */
  109931. getClassName(): string;
  109932. }
  109933. }
  109934. declare module BABYLON {
  109935. /**
  109936. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  109937. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  109938. */
  109939. export class AnaglyphGamepadCamera extends GamepadCamera {
  109940. /**
  109941. * Creates a new AnaglyphGamepadCamera
  109942. * @param name defines camera name
  109943. * @param position defines initial position
  109944. * @param interaxialDistance defines distance between each color axis
  109945. * @param scene defines the hosting scene
  109946. */
  109947. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  109948. /**
  109949. * Gets camera class name
  109950. * @returns AnaglyphGamepadCamera
  109951. */
  109952. getClassName(): string;
  109953. }
  109954. }
  109955. declare module BABYLON {
  109956. /**
  109957. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  109958. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  109959. */
  109960. export class AnaglyphUniversalCamera extends UniversalCamera {
  109961. /**
  109962. * Creates a new AnaglyphUniversalCamera
  109963. * @param name defines camera name
  109964. * @param position defines initial position
  109965. * @param interaxialDistance defines distance between each color axis
  109966. * @param scene defines the hosting scene
  109967. */
  109968. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  109969. /**
  109970. * Gets camera class name
  109971. * @returns AnaglyphUniversalCamera
  109972. */
  109973. getClassName(): string;
  109974. }
  109975. }
  109976. declare module BABYLON {
  109977. /** @hidden */
  109978. export var stereoscopicInterlacePixelShader: {
  109979. name: string;
  109980. shader: string;
  109981. };
  109982. }
  109983. declare module BABYLON {
  109984. /**
  109985. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  109986. */
  109987. export class StereoscopicInterlacePostProcess extends PostProcess {
  109988. private _stepSize;
  109989. private _passedProcess;
  109990. /**
  109991. * Initializes a StereoscopicInterlacePostProcess
  109992. * @param name The name of the effect.
  109993. * @param rigCameras The rig cameras to be appled to the post process
  109994. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  109995. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109996. * @param engine The engine which the post process will be applied. (default: current engine)
  109997. * @param reusable If the post process can be reused on the same frame. (default: false)
  109998. */
  109999. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  110000. }
  110001. }
  110002. declare module BABYLON {
  110003. /**
  110004. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  110005. * @see http://doc.babylonjs.com/features/cameras
  110006. */
  110007. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  110008. /**
  110009. * Creates a new StereoscopicArcRotateCamera
  110010. * @param name defines camera name
  110011. * @param alpha defines alpha angle (in radians)
  110012. * @param beta defines beta angle (in radians)
  110013. * @param radius defines radius
  110014. * @param target defines camera target
  110015. * @param interaxialDistance defines distance between each color axis
  110016. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  110017. * @param scene defines the hosting scene
  110018. */
  110019. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  110020. /**
  110021. * Gets camera class name
  110022. * @returns StereoscopicArcRotateCamera
  110023. */
  110024. getClassName(): string;
  110025. }
  110026. }
  110027. declare module BABYLON {
  110028. /**
  110029. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  110030. * @see http://doc.babylonjs.com/features/cameras
  110031. */
  110032. export class StereoscopicFreeCamera extends FreeCamera {
  110033. /**
  110034. * Creates a new StereoscopicFreeCamera
  110035. * @param name defines camera name
  110036. * @param position defines initial position
  110037. * @param interaxialDistance defines distance between each color axis
  110038. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  110039. * @param scene defines the hosting scene
  110040. */
  110041. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  110042. /**
  110043. * Gets camera class name
  110044. * @returns StereoscopicFreeCamera
  110045. */
  110046. getClassName(): string;
  110047. }
  110048. }
  110049. declare module BABYLON {
  110050. /**
  110051. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  110052. * @see http://doc.babylonjs.com/features/cameras
  110053. */
  110054. export class StereoscopicGamepadCamera extends GamepadCamera {
  110055. /**
  110056. * Creates a new StereoscopicGamepadCamera
  110057. * @param name defines camera name
  110058. * @param position defines initial position
  110059. * @param interaxialDistance defines distance between each color axis
  110060. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  110061. * @param scene defines the hosting scene
  110062. */
  110063. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  110064. /**
  110065. * Gets camera class name
  110066. * @returns StereoscopicGamepadCamera
  110067. */
  110068. getClassName(): string;
  110069. }
  110070. }
  110071. declare module BABYLON {
  110072. /**
  110073. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  110074. * @see http://doc.babylonjs.com/features/cameras
  110075. */
  110076. export class StereoscopicUniversalCamera extends UniversalCamera {
  110077. /**
  110078. * Creates a new StereoscopicUniversalCamera
  110079. * @param name defines camera name
  110080. * @param position defines initial position
  110081. * @param interaxialDistance defines distance between each color axis
  110082. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  110083. * @param scene defines the hosting scene
  110084. */
  110085. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  110086. /**
  110087. * Gets camera class name
  110088. * @returns StereoscopicUniversalCamera
  110089. */
  110090. getClassName(): string;
  110091. }
  110092. }
  110093. declare module BABYLON {
  110094. /**
  110095. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  110096. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  110097. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  110098. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  110099. */
  110100. export class VirtualJoysticksCamera extends FreeCamera {
  110101. /**
  110102. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  110103. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  110104. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  110105. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  110106. * @param name Define the name of the camera in the scene
  110107. * @param position Define the start position of the camera in the scene
  110108. * @param scene Define the scene the camera belongs to
  110109. */
  110110. constructor(name: string, position: Vector3, scene: Scene);
  110111. /**
  110112. * Gets the current object class name.
  110113. * @return the class name
  110114. */
  110115. getClassName(): string;
  110116. }
  110117. }
  110118. declare module BABYLON {
  110119. /**
  110120. * This represents all the required metrics to create a VR camera.
  110121. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  110122. */
  110123. export class VRCameraMetrics {
  110124. /**
  110125. * Define the horizontal resolution off the screen.
  110126. */
  110127. hResolution: number;
  110128. /**
  110129. * Define the vertical resolution off the screen.
  110130. */
  110131. vResolution: number;
  110132. /**
  110133. * Define the horizontal screen size.
  110134. */
  110135. hScreenSize: number;
  110136. /**
  110137. * Define the vertical screen size.
  110138. */
  110139. vScreenSize: number;
  110140. /**
  110141. * Define the vertical screen center position.
  110142. */
  110143. vScreenCenter: number;
  110144. /**
  110145. * Define the distance of the eyes to the screen.
  110146. */
  110147. eyeToScreenDistance: number;
  110148. /**
  110149. * Define the distance between both lenses
  110150. */
  110151. lensSeparationDistance: number;
  110152. /**
  110153. * Define the distance between both viewer's eyes.
  110154. */
  110155. interpupillaryDistance: number;
  110156. /**
  110157. * Define the distortion factor of the VR postprocess.
  110158. * Please, touch with care.
  110159. */
  110160. distortionK: number[];
  110161. /**
  110162. * Define the chromatic aberration correction factors for the VR post process.
  110163. */
  110164. chromaAbCorrection: number[];
  110165. /**
  110166. * Define the scale factor of the post process.
  110167. * The smaller the better but the slower.
  110168. */
  110169. postProcessScaleFactor: number;
  110170. /**
  110171. * Define an offset for the lens center.
  110172. */
  110173. lensCenterOffset: number;
  110174. /**
  110175. * Define if the current vr camera should compensate the distortion of the lense or not.
  110176. */
  110177. compensateDistortion: boolean;
  110178. /**
  110179. * Defines if multiview should be enabled when rendering (Default: false)
  110180. */
  110181. multiviewEnabled: boolean;
  110182. /**
  110183. * Gets the rendering aspect ratio based on the provided resolutions.
  110184. */
  110185. readonly aspectRatio: number;
  110186. /**
  110187. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  110188. */
  110189. readonly aspectRatioFov: number;
  110190. /**
  110191. * @hidden
  110192. */
  110193. readonly leftHMatrix: Matrix;
  110194. /**
  110195. * @hidden
  110196. */
  110197. readonly rightHMatrix: Matrix;
  110198. /**
  110199. * @hidden
  110200. */
  110201. readonly leftPreViewMatrix: Matrix;
  110202. /**
  110203. * @hidden
  110204. */
  110205. readonly rightPreViewMatrix: Matrix;
  110206. /**
  110207. * Get the default VRMetrics based on the most generic setup.
  110208. * @returns the default vr metrics
  110209. */
  110210. static GetDefault(): VRCameraMetrics;
  110211. }
  110212. }
  110213. declare module BABYLON {
  110214. /** @hidden */
  110215. export var vrDistortionCorrectionPixelShader: {
  110216. name: string;
  110217. shader: string;
  110218. };
  110219. }
  110220. declare module BABYLON {
  110221. /**
  110222. * VRDistortionCorrectionPostProcess used for mobile VR
  110223. */
  110224. export class VRDistortionCorrectionPostProcess extends PostProcess {
  110225. private _isRightEye;
  110226. private _distortionFactors;
  110227. private _postProcessScaleFactor;
  110228. private _lensCenterOffset;
  110229. private _scaleIn;
  110230. private _scaleFactor;
  110231. private _lensCenter;
  110232. /**
  110233. * Initializes the VRDistortionCorrectionPostProcess
  110234. * @param name The name of the effect.
  110235. * @param camera The camera to apply the render pass to.
  110236. * @param isRightEye If this is for the right eye distortion
  110237. * @param vrMetrics All the required metrics for the VR camera
  110238. */
  110239. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  110240. }
  110241. }
  110242. declare module BABYLON {
  110243. /**
  110244. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  110245. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  110246. */
  110247. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  110248. /**
  110249. * Creates a new VRDeviceOrientationArcRotateCamera
  110250. * @param name defines camera name
  110251. * @param alpha defines the camera rotation along the logitudinal axis
  110252. * @param beta defines the camera rotation along the latitudinal axis
  110253. * @param radius defines the camera distance from its target
  110254. * @param target defines the camera target
  110255. * @param scene defines the scene the camera belongs to
  110256. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  110257. * @param vrCameraMetrics defines the vr metrics associated to the camera
  110258. */
  110259. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  110260. /**
  110261. * Gets camera class name
  110262. * @returns VRDeviceOrientationArcRotateCamera
  110263. */
  110264. getClassName(): string;
  110265. }
  110266. }
  110267. declare module BABYLON {
  110268. /**
  110269. * Camera used to simulate VR rendering (based on FreeCamera)
  110270. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  110271. */
  110272. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  110273. /**
  110274. * Creates a new VRDeviceOrientationFreeCamera
  110275. * @param name defines camera name
  110276. * @param position defines the start position of the camera
  110277. * @param scene defines the scene the camera belongs to
  110278. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  110279. * @param vrCameraMetrics defines the vr metrics associated to the camera
  110280. */
  110281. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  110282. /**
  110283. * Gets camera class name
  110284. * @returns VRDeviceOrientationFreeCamera
  110285. */
  110286. getClassName(): string;
  110287. }
  110288. }
  110289. declare module BABYLON {
  110290. /**
  110291. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  110292. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  110293. */
  110294. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  110295. /**
  110296. * Creates a new VRDeviceOrientationGamepadCamera
  110297. * @param name defines camera name
  110298. * @param position defines the start position of the camera
  110299. * @param scene defines the scene the camera belongs to
  110300. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  110301. * @param vrCameraMetrics defines the vr metrics associated to the camera
  110302. */
  110303. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  110304. /**
  110305. * Gets camera class name
  110306. * @returns VRDeviceOrientationGamepadCamera
  110307. */
  110308. getClassName(): string;
  110309. }
  110310. }
  110311. declare module BABYLON {
  110312. /** @hidden */
  110313. export var imageProcessingPixelShader: {
  110314. name: string;
  110315. shader: string;
  110316. };
  110317. }
  110318. declare module BABYLON {
  110319. /**
  110320. * ImageProcessingPostProcess
  110321. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  110322. */
  110323. export class ImageProcessingPostProcess extends PostProcess {
  110324. /**
  110325. * Default configuration related to image processing available in the PBR Material.
  110326. */
  110327. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  110328. /**
  110329. * Gets the image processing configuration used either in this material.
  110330. */
  110331. /**
  110332. * Sets the Default image processing configuration used either in the this material.
  110333. *
  110334. * If sets to null, the scene one is in use.
  110335. */
  110336. imageProcessingConfiguration: ImageProcessingConfiguration;
  110337. /**
  110338. * Keep track of the image processing observer to allow dispose and replace.
  110339. */
  110340. private _imageProcessingObserver;
  110341. /**
  110342. * Attaches a new image processing configuration to the PBR Material.
  110343. * @param configuration
  110344. */
  110345. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  110346. /**
  110347. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  110348. */
  110349. /**
  110350. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  110351. */
  110352. colorCurves: Nullable<ColorCurves>;
  110353. /**
  110354. * Gets wether the color curves effect is enabled.
  110355. */
  110356. /**
  110357. * Sets wether the color curves effect is enabled.
  110358. */
  110359. colorCurvesEnabled: boolean;
  110360. /**
  110361. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  110362. */
  110363. /**
  110364. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  110365. */
  110366. colorGradingTexture: Nullable<BaseTexture>;
  110367. /**
  110368. * Gets wether the color grading effect is enabled.
  110369. */
  110370. /**
  110371. * Gets wether the color grading effect is enabled.
  110372. */
  110373. colorGradingEnabled: boolean;
  110374. /**
  110375. * Gets exposure used in the effect.
  110376. */
  110377. /**
  110378. * Sets exposure used in the effect.
  110379. */
  110380. exposure: number;
  110381. /**
  110382. * Gets wether tonemapping is enabled or not.
  110383. */
  110384. /**
  110385. * Sets wether tonemapping is enabled or not
  110386. */
  110387. toneMappingEnabled: boolean;
  110388. /**
  110389. * Gets the type of tone mapping effect.
  110390. */
  110391. /**
  110392. * Sets the type of tone mapping effect.
  110393. */
  110394. toneMappingType: number;
  110395. /**
  110396. * Gets contrast used in the effect.
  110397. */
  110398. /**
  110399. * Sets contrast used in the effect.
  110400. */
  110401. contrast: number;
  110402. /**
  110403. * Gets Vignette stretch size.
  110404. */
  110405. /**
  110406. * Sets Vignette stretch size.
  110407. */
  110408. vignetteStretch: number;
  110409. /**
  110410. * Gets Vignette centre X Offset.
  110411. */
  110412. /**
  110413. * Sets Vignette centre X Offset.
  110414. */
  110415. vignetteCentreX: number;
  110416. /**
  110417. * Gets Vignette centre Y Offset.
  110418. */
  110419. /**
  110420. * Sets Vignette centre Y Offset.
  110421. */
  110422. vignetteCentreY: number;
  110423. /**
  110424. * Gets Vignette weight or intensity of the vignette effect.
  110425. */
  110426. /**
  110427. * Sets Vignette weight or intensity of the vignette effect.
  110428. */
  110429. vignetteWeight: number;
  110430. /**
  110431. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  110432. * if vignetteEnabled is set to true.
  110433. */
  110434. /**
  110435. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  110436. * if vignetteEnabled is set to true.
  110437. */
  110438. vignetteColor: Color4;
  110439. /**
  110440. * Gets Camera field of view used by the Vignette effect.
  110441. */
  110442. /**
  110443. * Sets Camera field of view used by the Vignette effect.
  110444. */
  110445. vignetteCameraFov: number;
  110446. /**
  110447. * Gets the vignette blend mode allowing different kind of effect.
  110448. */
  110449. /**
  110450. * Sets the vignette blend mode allowing different kind of effect.
  110451. */
  110452. vignetteBlendMode: number;
  110453. /**
  110454. * Gets wether the vignette effect is enabled.
  110455. */
  110456. /**
  110457. * Sets wether the vignette effect is enabled.
  110458. */
  110459. vignetteEnabled: boolean;
  110460. private _fromLinearSpace;
  110461. /**
  110462. * Gets wether the input of the processing is in Gamma or Linear Space.
  110463. */
  110464. /**
  110465. * Sets wether the input of the processing is in Gamma or Linear Space.
  110466. */
  110467. fromLinearSpace: boolean;
  110468. /**
  110469. * Defines cache preventing GC.
  110470. */
  110471. private _defines;
  110472. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  110473. /**
  110474. * "ImageProcessingPostProcess"
  110475. * @returns "ImageProcessingPostProcess"
  110476. */
  110477. getClassName(): string;
  110478. protected _updateParameters(): void;
  110479. dispose(camera?: Camera): void;
  110480. }
  110481. }
  110482. declare module BABYLON {
  110483. /**
  110484. * Class containing static functions to help procedurally build meshes
  110485. */
  110486. export class GroundBuilder {
  110487. /**
  110488. * Creates a ground mesh
  110489. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  110490. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  110491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110492. * @param name defines the name of the mesh
  110493. * @param options defines the options used to create the mesh
  110494. * @param scene defines the hosting scene
  110495. * @returns the ground mesh
  110496. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  110497. */
  110498. static CreateGround(name: string, options: {
  110499. width?: number;
  110500. height?: number;
  110501. subdivisions?: number;
  110502. subdivisionsX?: number;
  110503. subdivisionsY?: number;
  110504. updatable?: boolean;
  110505. }, scene: any): Mesh;
  110506. /**
  110507. * Creates a tiled ground mesh
  110508. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  110509. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  110510. * * 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
  110511. * * 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
  110512. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110513. * @param name defines the name of the mesh
  110514. * @param options defines the options used to create the mesh
  110515. * @param scene defines the hosting scene
  110516. * @returns the tiled ground mesh
  110517. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  110518. */
  110519. static CreateTiledGround(name: string, options: {
  110520. xmin: number;
  110521. zmin: number;
  110522. xmax: number;
  110523. zmax: number;
  110524. subdivisions?: {
  110525. w: number;
  110526. h: number;
  110527. };
  110528. precision?: {
  110529. w: number;
  110530. h: number;
  110531. };
  110532. updatable?: boolean;
  110533. }, scene?: Nullable<Scene>): Mesh;
  110534. /**
  110535. * Creates a ground mesh from a height map
  110536. * * The parameter `url` sets the URL of the height map image resource.
  110537. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  110538. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  110539. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  110540. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  110541. * * 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.
  110542. * * 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).
  110543. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  110544. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110545. * @param name defines the name of the mesh
  110546. * @param url defines the url to the height map
  110547. * @param options defines the options used to create the mesh
  110548. * @param scene defines the hosting scene
  110549. * @returns the ground mesh
  110550. * @see https://doc.babylonjs.com/babylon101/height_map
  110551. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  110552. */
  110553. static CreateGroundFromHeightMap(name: string, url: string, options: {
  110554. width?: number;
  110555. height?: number;
  110556. subdivisions?: number;
  110557. minHeight?: number;
  110558. maxHeight?: number;
  110559. colorFilter?: Color3;
  110560. alphaFilter?: number;
  110561. updatable?: boolean;
  110562. onReady?: (mesh: GroundMesh) => void;
  110563. }, scene?: Nullable<Scene>): GroundMesh;
  110564. }
  110565. }
  110566. declare module BABYLON {
  110567. /**
  110568. * Class containing static functions to help procedurally build meshes
  110569. */
  110570. export class TorusBuilder {
  110571. /**
  110572. * Creates a torus mesh
  110573. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  110574. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  110575. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  110576. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110577. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110578. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110579. * @param name defines the name of the mesh
  110580. * @param options defines the options used to create the mesh
  110581. * @param scene defines the hosting scene
  110582. * @returns the torus mesh
  110583. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  110584. */
  110585. static CreateTorus(name: string, options: {
  110586. diameter?: number;
  110587. thickness?: number;
  110588. tessellation?: number;
  110589. updatable?: boolean;
  110590. sideOrientation?: number;
  110591. frontUVs?: Vector4;
  110592. backUVs?: Vector4;
  110593. }, scene: any): Mesh;
  110594. }
  110595. }
  110596. declare module BABYLON {
  110597. /**
  110598. * Class containing static functions to help procedurally build meshes
  110599. */
  110600. export class CylinderBuilder {
  110601. /**
  110602. * Creates a cylinder or a cone mesh
  110603. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  110604. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  110605. * * 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.
  110606. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  110607. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  110608. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  110609. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  110610. * * 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).
  110611. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  110612. * * 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).
  110613. * * 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
  110614. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  110615. * * 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
  110616. * * 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.
  110617. * * If `enclose` is false, a ring surface is one element.
  110618. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  110619. * * 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
  110620. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110621. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110622. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110623. * @param name defines the name of the mesh
  110624. * @param options defines the options used to create the mesh
  110625. * @param scene defines the hosting scene
  110626. * @returns the cylinder mesh
  110627. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  110628. */
  110629. static CreateCylinder(name: string, options: {
  110630. height?: number;
  110631. diameterTop?: number;
  110632. diameterBottom?: number;
  110633. diameter?: number;
  110634. tessellation?: number;
  110635. subdivisions?: number;
  110636. arc?: number;
  110637. faceColors?: Color4[];
  110638. faceUV?: Vector4[];
  110639. updatable?: boolean;
  110640. hasRings?: boolean;
  110641. enclose?: boolean;
  110642. cap?: number;
  110643. sideOrientation?: number;
  110644. frontUVs?: Vector4;
  110645. backUVs?: Vector4;
  110646. }, scene: any): Mesh;
  110647. }
  110648. }
  110649. declare module BABYLON {
  110650. /**
  110651. * States of the webXR experience
  110652. */
  110653. export enum WebXRState {
  110654. /**
  110655. * Transitioning to being in XR mode
  110656. */
  110657. ENTERING_XR = 0,
  110658. /**
  110659. * Transitioning to non XR mode
  110660. */
  110661. EXITING_XR = 1,
  110662. /**
  110663. * In XR mode and presenting
  110664. */
  110665. IN_XR = 2,
  110666. /**
  110667. * Not entered XR mode
  110668. */
  110669. NOT_IN_XR = 3
  110670. }
  110671. /**
  110672. * Abstraction of the XR render target
  110673. */
  110674. export interface WebXRRenderTarget extends IDisposable {
  110675. /**
  110676. * xrpresent context of the canvas which can be used to display/mirror xr content
  110677. */
  110678. canvasContext: WebGLRenderingContext;
  110679. /**
  110680. * xr layer for the canvas
  110681. */
  110682. xrLayer: Nullable<XRWebGLLayer>;
  110683. /**
  110684. * Initializes the xr layer for the session
  110685. * @param xrSession xr session
  110686. * @returns a promise that will resolve once the XR Layer has been created
  110687. */
  110688. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  110689. }
  110690. }
  110691. declare module BABYLON {
  110692. /**
  110693. * COnfiguration object for WebXR output canvas
  110694. */
  110695. export class WebXRManagedOutputCanvasOptions {
  110696. /**
  110697. * Options for this XR Layer output
  110698. */
  110699. canvasOptions: XRWebGLLayerOptions;
  110700. /**
  110701. * CSS styling for a newly created canvas (if not provided)
  110702. */
  110703. newCanvasCssStyle?: string;
  110704. /**
  110705. * Get the default values of the configuration object
  110706. * @returns default values of this configuration object
  110707. */
  110708. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  110709. }
  110710. /**
  110711. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  110712. */
  110713. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  110714. private configuration;
  110715. private _engine;
  110716. private _canvas;
  110717. /**
  110718. * xrpresent context of the canvas which can be used to display/mirror xr content
  110719. */
  110720. canvasContext: WebGLRenderingContext;
  110721. /**
  110722. * xr layer for the canvas
  110723. */
  110724. xrLayer: Nullable<XRWebGLLayer>;
  110725. /**
  110726. * Initializes the xr layer for the session
  110727. * @param xrSession xr session
  110728. * @returns a promise that will resolve once the XR Layer has been created
  110729. */
  110730. initializeXRLayerAsync(xrSession: any): any;
  110731. /**
  110732. * Initializes the canvas to be added/removed upon entering/exiting xr
  110733. * @param engine the Babylon engine
  110734. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  110735. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  110736. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  110737. */
  110738. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  110739. /**
  110740. * Disposes of the object
  110741. */
  110742. dispose(): void;
  110743. private _setManagedOutputCanvas;
  110744. private _addCanvas;
  110745. private _removeCanvas;
  110746. }
  110747. }
  110748. declare module BABYLON {
  110749. /**
  110750. * Manages an XRSession to work with Babylon's engine
  110751. * @see https://doc.babylonjs.com/how_to/webxr
  110752. */
  110753. export class WebXRSessionManager implements IDisposable {
  110754. private scene;
  110755. /**
  110756. * Fires every time a new xrFrame arrives which can be used to update the camera
  110757. */
  110758. onXRFrameObservable: Observable<any>;
  110759. /**
  110760. * Fires when the xr session is ended either by the device or manually done
  110761. */
  110762. onXRSessionEnded: Observable<any>;
  110763. /**
  110764. * Underlying xr session
  110765. */
  110766. session: XRSession;
  110767. /**
  110768. * Type of reference space used when creating the session
  110769. */
  110770. referenceSpace: XRReferenceSpace;
  110771. /**
  110772. * Current XR frame
  110773. */
  110774. currentFrame: Nullable<XRFrame>;
  110775. private _xrNavigator;
  110776. private baseLayer;
  110777. private _rttProvider;
  110778. private _sessionEnded;
  110779. /**
  110780. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  110781. * @param scene The scene which the session should be created for
  110782. */
  110783. constructor(scene: Scene);
  110784. /**
  110785. * Initializes the manager
  110786. * After initialization enterXR can be called to start an XR session
  110787. * @returns Promise which resolves after it is initialized
  110788. */
  110789. initializeAsync(): Promise<void>;
  110790. /**
  110791. * Initializes an xr session
  110792. * @param xrSessionMode mode to initialize
  110793. * @param optionalFeatures defines optional values to pass to the session builder
  110794. * @returns a promise which will resolve once the session has been initialized
  110795. */
  110796. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  110797. /**
  110798. * Sets the reference space on the xr session
  110799. * @param referenceSpace space to set
  110800. * @returns a promise that will resolve once the reference space has been set
  110801. */
  110802. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  110803. /**
  110804. * Updates the render state of the session
  110805. * @param state state to set
  110806. * @returns a promise that resolves once the render state has been updated
  110807. */
  110808. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  110809. /**
  110810. * Starts rendering to the xr layer
  110811. * @returns a promise that will resolve once rendering has started
  110812. */
  110813. startRenderingToXRAsync(): Promise<void>;
  110814. /**
  110815. * Gets the correct render target texture to be rendered this frame for this eye
  110816. * @param eye the eye for which to get the render target
  110817. * @returns the render target for the specified eye
  110818. */
  110819. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  110820. /**
  110821. * Stops the xrSession and restores the renderloop
  110822. * @returns Promise which resolves after it exits XR
  110823. */
  110824. exitXRAsync(): Promise<void>;
  110825. /**
  110826. * Checks if a session would be supported for the creation options specified
  110827. * @param sessionMode session mode to check if supported eg. immersive-vr
  110828. * @returns true if supported
  110829. */
  110830. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  110831. /**
  110832. * Creates a WebXRRenderTarget object for the XR session
  110833. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  110834. * @param options optional options to provide when creating a new render target
  110835. * @returns a WebXR render target to which the session can render
  110836. */
  110837. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  110838. /**
  110839. * @hidden
  110840. * Converts the render layer of xrSession to a render target
  110841. * @param session session to create render target for
  110842. * @param scene scene the new render target should be created for
  110843. */
  110844. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  110845. /**
  110846. * Disposes of the session manager
  110847. */
  110848. dispose(): void;
  110849. /**
  110850. * Gets a promise returning true when fullfiled if the given session mode is supported
  110851. * @param sessionMode defines the session to test
  110852. * @returns a promise
  110853. */
  110854. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  110855. }
  110856. }
  110857. declare module BABYLON {
  110858. /**
  110859. * WebXR Camera which holds the views for the xrSession
  110860. * @see https://doc.babylonjs.com/how_to/webxr
  110861. */
  110862. export class WebXRCamera extends FreeCamera {
  110863. /**
  110864. * Is the camera in debug mode. Used when using an emulator
  110865. */
  110866. debugMode: boolean;
  110867. /**
  110868. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  110869. * @param name the name of the camera
  110870. * @param scene the scene to add the camera to
  110871. */
  110872. constructor(name: string, scene: Scene);
  110873. private _updateNumberOfRigCameras;
  110874. /** @hidden */
  110875. _updateForDualEyeDebugging(): void;
  110876. /**
  110877. * Updates the cameras position from the current pose information of the XR session
  110878. * @param xrSessionManager the session containing pose information
  110879. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  110880. */
  110881. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  110882. }
  110883. }
  110884. declare module BABYLON {
  110885. /**
  110886. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  110887. * @see https://doc.babylonjs.com/how_to/webxr
  110888. */
  110889. export class WebXRExperienceHelper implements IDisposable {
  110890. private scene;
  110891. /**
  110892. * 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
  110893. */
  110894. container: AbstractMesh;
  110895. /**
  110896. * Camera used to render xr content
  110897. */
  110898. camera: WebXRCamera;
  110899. /**
  110900. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  110901. */
  110902. state: WebXRState;
  110903. private _setState;
  110904. private static _TmpVector;
  110905. /**
  110906. * Fires when the state of the experience helper has changed
  110907. */
  110908. onStateChangedObservable: Observable<WebXRState>;
  110909. /** Session manager used to keep track of xr session */
  110910. sessionManager: WebXRSessionManager;
  110911. private _nonVRCamera;
  110912. private _originalSceneAutoClear;
  110913. private _supported;
  110914. /**
  110915. * Creates the experience helper
  110916. * @param scene the scene to attach the experience helper to
  110917. * @returns a promise for the experience helper
  110918. */
  110919. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  110920. /**
  110921. * Creates a WebXRExperienceHelper
  110922. * @param scene The scene the helper should be created in
  110923. */
  110924. private constructor();
  110925. /**
  110926. * Exits XR mode and returns the scene to its original state
  110927. * @returns promise that resolves after xr mode has exited
  110928. */
  110929. exitXRAsync(): Promise<void>;
  110930. /**
  110931. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  110932. * @param sessionMode options for the XR session
  110933. * @param referenceSpaceType frame of reference of the XR session
  110934. * @param renderTarget the output canvas that will be used to enter XR mode
  110935. * @returns promise that resolves after xr mode has entered
  110936. */
  110937. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  110938. /**
  110939. * Updates the global position of the camera by moving the camera's container
  110940. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  110941. * @param position The desired global position of the camera
  110942. */
  110943. setPositionOfCameraUsingContainer(position: Vector3): void;
  110944. /**
  110945. * Rotates the xr camera by rotating the camera's container around the camera's position
  110946. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  110947. * @param rotation the desired quaternion rotation to apply to the camera
  110948. */
  110949. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  110950. /**
  110951. * Disposes of the experience helper
  110952. */
  110953. dispose(): void;
  110954. }
  110955. }
  110956. declare module BABYLON {
  110957. /**
  110958. * Represents an XR input
  110959. */
  110960. export class WebXRController {
  110961. private scene;
  110962. /** The underlying input source for the controller */
  110963. inputSource: XRInputSource;
  110964. private parentContainer;
  110965. /**
  110966. * 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
  110967. */
  110968. grip?: AbstractMesh;
  110969. /**
  110970. * Pointer which can be used to select objects or attach a visible laser to
  110971. */
  110972. pointer: AbstractMesh;
  110973. private _gamepadMode;
  110974. /**
  110975. * If available, this is the gamepad object related to this controller.
  110976. * Using this object it is possible to get click events and trackpad changes of the
  110977. * webxr controller that is currently being used.
  110978. */
  110979. gamepadController?: WebVRController;
  110980. /**
  110981. * Event that fires when the controller is removed/disposed
  110982. */
  110983. onDisposeObservable: Observable<{}>;
  110984. private _tmpQuaternion;
  110985. private _tmpVector;
  110986. /**
  110987. * Creates the controller
  110988. * @see https://doc.babylonjs.com/how_to/webxr
  110989. * @param scene the scene which the controller should be associated to
  110990. * @param inputSource the underlying input source for the controller
  110991. * @param parentContainer parent that the controller meshes should be children of
  110992. */
  110993. constructor(scene: Scene,
  110994. /** The underlying input source for the controller */
  110995. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  110996. /**
  110997. * Updates the controller pose based on the given XRFrame
  110998. * @param xrFrame xr frame to update the pose with
  110999. * @param referenceSpace reference space to use
  111000. */
  111001. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  111002. /**
  111003. * Gets a world space ray coming from the controller
  111004. * @param result the resulting ray
  111005. */
  111006. getWorldPointerRayToRef(result: Ray): void;
  111007. /**
  111008. * Get the scene associated with this controller
  111009. * @returns the scene object
  111010. */
  111011. getScene(): Scene;
  111012. /**
  111013. * Disposes of the object
  111014. */
  111015. dispose(): void;
  111016. }
  111017. }
  111018. declare module BABYLON {
  111019. /**
  111020. * XR input used to track XR inputs such as controllers/rays
  111021. */
  111022. export class WebXRInput implements IDisposable {
  111023. /**
  111024. * Base experience the input listens to
  111025. */
  111026. baseExperience: WebXRExperienceHelper;
  111027. /**
  111028. * XR controllers being tracked
  111029. */
  111030. controllers: Array<WebXRController>;
  111031. private _frameObserver;
  111032. private _stateObserver;
  111033. /**
  111034. * Event when a controller has been connected/added
  111035. */
  111036. onControllerAddedObservable: Observable<WebXRController>;
  111037. /**
  111038. * Event when a controller has been removed/disconnected
  111039. */
  111040. onControllerRemovedObservable: Observable<WebXRController>;
  111041. /**
  111042. * Initializes the WebXRInput
  111043. * @param baseExperience experience helper which the input should be created for
  111044. */
  111045. constructor(
  111046. /**
  111047. * Base experience the input listens to
  111048. */
  111049. baseExperience: WebXRExperienceHelper);
  111050. private _onInputSourcesChange;
  111051. private _addAndRemoveControllers;
  111052. /**
  111053. * Disposes of the object
  111054. */
  111055. dispose(): void;
  111056. }
  111057. }
  111058. declare module BABYLON {
  111059. /**
  111060. * Class used to represent data loading progression
  111061. */
  111062. export class SceneLoaderProgressEvent {
  111063. /** defines if data length to load can be evaluated */
  111064. readonly lengthComputable: boolean;
  111065. /** defines the loaded data length */
  111066. readonly loaded: number;
  111067. /** defines the data length to load */
  111068. readonly total: number;
  111069. /**
  111070. * Create a new progress event
  111071. * @param lengthComputable defines if data length to load can be evaluated
  111072. * @param loaded defines the loaded data length
  111073. * @param total defines the data length to load
  111074. */
  111075. constructor(
  111076. /** defines if data length to load can be evaluated */
  111077. lengthComputable: boolean,
  111078. /** defines the loaded data length */
  111079. loaded: number,
  111080. /** defines the data length to load */
  111081. total: number);
  111082. /**
  111083. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  111084. * @param event defines the source event
  111085. * @returns a new SceneLoaderProgressEvent
  111086. */
  111087. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  111088. }
  111089. /**
  111090. * Interface used by SceneLoader plugins to define supported file extensions
  111091. */
  111092. export interface ISceneLoaderPluginExtensions {
  111093. /**
  111094. * Defines the list of supported extensions
  111095. */
  111096. [extension: string]: {
  111097. isBinary: boolean;
  111098. };
  111099. }
  111100. /**
  111101. * Interface used by SceneLoader plugin factory
  111102. */
  111103. export interface ISceneLoaderPluginFactory {
  111104. /**
  111105. * Defines the name of the factory
  111106. */
  111107. name: string;
  111108. /**
  111109. * Function called to create a new plugin
  111110. * @return the new plugin
  111111. */
  111112. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  111113. /**
  111114. * The callback that returns true if the data can be directly loaded.
  111115. * @param data string containing the file data
  111116. * @returns if the data can be loaded directly
  111117. */
  111118. canDirectLoad?(data: string): boolean;
  111119. }
  111120. /**
  111121. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  111122. */
  111123. export interface ISceneLoaderPluginBase {
  111124. /**
  111125. * The friendly name of this plugin.
  111126. */
  111127. name: string;
  111128. /**
  111129. * The file extensions supported by this plugin.
  111130. */
  111131. extensions: string | ISceneLoaderPluginExtensions;
  111132. /**
  111133. * The callback called when loading from a url.
  111134. * @param scene scene loading this url
  111135. * @param url url to load
  111136. * @param onSuccess callback called when the file successfully loads
  111137. * @param onProgress callback called while file is loading (if the server supports this mode)
  111138. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  111139. * @param onError callback called when the file fails to load
  111140. * @returns a file request object
  111141. */
  111142. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  111143. /**
  111144. * The callback called when loading from a file object.
  111145. * @param scene scene loading this file
  111146. * @param file defines the file to load
  111147. * @param onSuccess defines the callback to call when data is loaded
  111148. * @param onProgress defines the callback to call during loading process
  111149. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  111150. * @param onError defines the callback to call when an error occurs
  111151. * @returns a file request object
  111152. */
  111153. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  111154. /**
  111155. * The callback that returns true if the data can be directly loaded.
  111156. * @param data string containing the file data
  111157. * @returns if the data can be loaded directly
  111158. */
  111159. canDirectLoad?(data: string): boolean;
  111160. /**
  111161. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  111162. * @param scene scene loading this data
  111163. * @param data string containing the data
  111164. * @returns data to pass to the plugin
  111165. */
  111166. directLoad?(scene: Scene, data: string): any;
  111167. /**
  111168. * The callback that allows custom handling of the root url based on the response url.
  111169. * @param rootUrl the original root url
  111170. * @param responseURL the response url if available
  111171. * @returns the new root url
  111172. */
  111173. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  111174. }
  111175. /**
  111176. * Interface used to define a SceneLoader plugin
  111177. */
  111178. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  111179. /**
  111180. * Import meshes into a scene.
  111181. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  111182. * @param scene The scene to import into
  111183. * @param data The data to import
  111184. * @param rootUrl The root url for scene and resources
  111185. * @param meshes The meshes array to import into
  111186. * @param particleSystems The particle systems array to import into
  111187. * @param skeletons The skeletons array to import into
  111188. * @param onError The callback when import fails
  111189. * @returns True if successful or false otherwise
  111190. */
  111191. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  111192. /**
  111193. * Load into a scene.
  111194. * @param scene The scene to load into
  111195. * @param data The data to import
  111196. * @param rootUrl The root url for scene and resources
  111197. * @param onError The callback when import fails
  111198. * @returns True if successful or false otherwise
  111199. */
  111200. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  111201. /**
  111202. * Load into an asset container.
  111203. * @param scene The scene to load into
  111204. * @param data The data to import
  111205. * @param rootUrl The root url for scene and resources
  111206. * @param onError The callback when import fails
  111207. * @returns The loaded asset container
  111208. */
  111209. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  111210. }
  111211. /**
  111212. * Interface used to define an async SceneLoader plugin
  111213. */
  111214. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  111215. /**
  111216. * Import meshes into a scene.
  111217. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  111218. * @param scene The scene to import into
  111219. * @param data The data to import
  111220. * @param rootUrl The root url for scene and resources
  111221. * @param onProgress The callback when the load progresses
  111222. * @param fileName Defines the name of the file to load
  111223. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  111224. */
  111225. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  111226. meshes: AbstractMesh[];
  111227. particleSystems: IParticleSystem[];
  111228. skeletons: Skeleton[];
  111229. animationGroups: AnimationGroup[];
  111230. }>;
  111231. /**
  111232. * Load into a scene.
  111233. * @param scene The scene to load into
  111234. * @param data The data to import
  111235. * @param rootUrl The root url for scene and resources
  111236. * @param onProgress The callback when the load progresses
  111237. * @param fileName Defines the name of the file to load
  111238. * @returns Nothing
  111239. */
  111240. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  111241. /**
  111242. * Load into an asset container.
  111243. * @param scene The scene to load into
  111244. * @param data The data to import
  111245. * @param rootUrl The root url for scene and resources
  111246. * @param onProgress The callback when the load progresses
  111247. * @param fileName Defines the name of the file to load
  111248. * @returns The loaded asset container
  111249. */
  111250. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  111251. }
  111252. /**
  111253. * Class used to load scene from various file formats using registered plugins
  111254. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  111255. */
  111256. export class SceneLoader {
  111257. /**
  111258. * No logging while loading
  111259. */
  111260. static readonly NO_LOGGING: number;
  111261. /**
  111262. * Minimal logging while loading
  111263. */
  111264. static readonly MINIMAL_LOGGING: number;
  111265. /**
  111266. * Summary logging while loading
  111267. */
  111268. static readonly SUMMARY_LOGGING: number;
  111269. /**
  111270. * Detailled logging while loading
  111271. */
  111272. static readonly DETAILED_LOGGING: number;
  111273. /**
  111274. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  111275. */
  111276. static ForceFullSceneLoadingForIncremental: boolean;
  111277. /**
  111278. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  111279. */
  111280. static ShowLoadingScreen: boolean;
  111281. /**
  111282. * Defines the current logging level (while loading the scene)
  111283. * @ignorenaming
  111284. */
  111285. static loggingLevel: number;
  111286. /**
  111287. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  111288. */
  111289. static CleanBoneMatrixWeights: boolean;
  111290. /**
  111291. * Event raised when a plugin is used to load a scene
  111292. */
  111293. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  111294. private static _registeredPlugins;
  111295. private static _getDefaultPlugin;
  111296. private static _getPluginForExtension;
  111297. private static _getPluginForDirectLoad;
  111298. private static _getPluginForFilename;
  111299. private static _getDirectLoad;
  111300. private static _loadData;
  111301. private static _getFileInfo;
  111302. /**
  111303. * Gets a plugin that can load the given extension
  111304. * @param extension defines the extension to load
  111305. * @returns a plugin or null if none works
  111306. */
  111307. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  111308. /**
  111309. * Gets a boolean indicating that the given extension can be loaded
  111310. * @param extension defines the extension to load
  111311. * @returns true if the extension is supported
  111312. */
  111313. static IsPluginForExtensionAvailable(extension: string): boolean;
  111314. /**
  111315. * Adds a new plugin to the list of registered plugins
  111316. * @param plugin defines the plugin to add
  111317. */
  111318. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  111319. /**
  111320. * Import meshes into a scene
  111321. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  111322. * @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)
  111323. * @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)
  111324. * @param scene the instance of BABYLON.Scene to append to
  111325. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  111326. * @param onProgress a callback with a progress event for each file being loaded
  111327. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  111328. * @param pluginExtension the extension used to determine the plugin
  111329. * @returns The loaded plugin
  111330. */
  111331. 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>;
  111332. /**
  111333. * Import meshes into a scene
  111334. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  111335. * @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)
  111336. * @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)
  111337. * @param scene the instance of BABYLON.Scene to append to
  111338. * @param onProgress a callback with a progress event for each file being loaded
  111339. * @param pluginExtension the extension used to determine the plugin
  111340. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  111341. */
  111342. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  111343. meshes: AbstractMesh[];
  111344. particleSystems: IParticleSystem[];
  111345. skeletons: Skeleton[];
  111346. animationGroups: AnimationGroup[];
  111347. }>;
  111348. /**
  111349. * Load a scene
  111350. * @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)
  111351. * @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)
  111352. * @param engine is the instance of BABYLON.Engine to use to create the scene
  111353. * @param onSuccess a callback with the scene when import succeeds
  111354. * @param onProgress a callback with a progress event for each file being loaded
  111355. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  111356. * @param pluginExtension the extension used to determine the plugin
  111357. * @returns The loaded plugin
  111358. */
  111359. 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>;
  111360. /**
  111361. * Load a scene
  111362. * @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)
  111363. * @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)
  111364. * @param engine is the instance of BABYLON.Engine to use to create the scene
  111365. * @param onProgress a callback with a progress event for each file being loaded
  111366. * @param pluginExtension the extension used to determine the plugin
  111367. * @returns The loaded scene
  111368. */
  111369. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  111370. /**
  111371. * Append a scene
  111372. * @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)
  111373. * @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)
  111374. * @param scene is the instance of BABYLON.Scene to append to
  111375. * @param onSuccess a callback with the scene when import succeeds
  111376. * @param onProgress a callback with a progress event for each file being loaded
  111377. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  111378. * @param pluginExtension the extension used to determine the plugin
  111379. * @returns The loaded plugin
  111380. */
  111381. 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>;
  111382. /**
  111383. * Append a scene
  111384. * @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)
  111385. * @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)
  111386. * @param scene is the instance of BABYLON.Scene to append to
  111387. * @param onProgress a callback with a progress event for each file being loaded
  111388. * @param pluginExtension the extension used to determine the plugin
  111389. * @returns The given scene
  111390. */
  111391. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  111392. /**
  111393. * Load a scene into an asset container
  111394. * @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)
  111395. * @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)
  111396. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  111397. * @param onSuccess a callback with the scene when import succeeds
  111398. * @param onProgress a callback with a progress event for each file being loaded
  111399. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  111400. * @param pluginExtension the extension used to determine the plugin
  111401. * @returns The loaded plugin
  111402. */
  111403. 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>;
  111404. /**
  111405. * Load a scene into an asset container
  111406. * @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)
  111407. * @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)
  111408. * @param scene is the instance of Scene to append to
  111409. * @param onProgress a callback with a progress event for each file being loaded
  111410. * @param pluginExtension the extension used to determine the plugin
  111411. * @returns The loaded asset container
  111412. */
  111413. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  111414. }
  111415. }
  111416. declare module BABYLON {
  111417. /**
  111418. * Generic Controller
  111419. */
  111420. export class GenericController extends WebVRController {
  111421. /**
  111422. * Base Url for the controller model.
  111423. */
  111424. static readonly MODEL_BASE_URL: string;
  111425. /**
  111426. * File name for the controller model.
  111427. */
  111428. static readonly MODEL_FILENAME: string;
  111429. /**
  111430. * Creates a new GenericController from a gamepad
  111431. * @param vrGamepad the gamepad that the controller should be created from
  111432. */
  111433. constructor(vrGamepad: any);
  111434. /**
  111435. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111436. * @param scene scene in which to add meshes
  111437. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111438. */
  111439. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111440. /**
  111441. * Called once for each button that changed state since the last frame
  111442. * @param buttonIdx Which button index changed
  111443. * @param state New state of the button
  111444. * @param changes Which properties on the state changed since last frame
  111445. */
  111446. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111447. }
  111448. }
  111449. declare module BABYLON {
  111450. /**
  111451. * Defines the WindowsMotionController object that the state of the windows motion controller
  111452. */
  111453. export class WindowsMotionController extends WebVRController {
  111454. /**
  111455. * The base url used to load the left and right controller models
  111456. */
  111457. static MODEL_BASE_URL: string;
  111458. /**
  111459. * The name of the left controller model file
  111460. */
  111461. static MODEL_LEFT_FILENAME: string;
  111462. /**
  111463. * The name of the right controller model file
  111464. */
  111465. static MODEL_RIGHT_FILENAME: string;
  111466. /**
  111467. * The controller name prefix for this controller type
  111468. */
  111469. static readonly GAMEPAD_ID_PREFIX: string;
  111470. /**
  111471. * The controller id pattern for this controller type
  111472. */
  111473. private static readonly GAMEPAD_ID_PATTERN;
  111474. private _loadedMeshInfo;
  111475. protected readonly _mapping: {
  111476. buttons: string[];
  111477. buttonMeshNames: {
  111478. 'trigger': string;
  111479. 'menu': string;
  111480. 'grip': string;
  111481. 'thumbstick': string;
  111482. 'trackpad': string;
  111483. };
  111484. buttonObservableNames: {
  111485. 'trigger': string;
  111486. 'menu': string;
  111487. 'grip': string;
  111488. 'thumbstick': string;
  111489. 'trackpad': string;
  111490. };
  111491. axisMeshNames: string[];
  111492. pointingPoseMeshName: string;
  111493. };
  111494. /**
  111495. * Fired when the trackpad on this controller is clicked
  111496. */
  111497. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  111498. /**
  111499. * Fired when the trackpad on this controller is modified
  111500. */
  111501. onTrackpadValuesChangedObservable: Observable<StickValues>;
  111502. /**
  111503. * The current x and y values of this controller's trackpad
  111504. */
  111505. trackpad: StickValues;
  111506. /**
  111507. * Creates a new WindowsMotionController from a gamepad
  111508. * @param vrGamepad the gamepad that the controller should be created from
  111509. */
  111510. constructor(vrGamepad: any);
  111511. /**
  111512. * Fired when the trigger on this controller is modified
  111513. */
  111514. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111515. /**
  111516. * Fired when the menu button on this controller is modified
  111517. */
  111518. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111519. /**
  111520. * Fired when the grip button on this controller is modified
  111521. */
  111522. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111523. /**
  111524. * Fired when the thumbstick button on this controller is modified
  111525. */
  111526. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111527. /**
  111528. * Fired when the touchpad button on this controller is modified
  111529. */
  111530. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111531. /**
  111532. * Fired when the touchpad values on this controller are modified
  111533. */
  111534. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  111535. protected _updateTrackpad(): void;
  111536. /**
  111537. * Called once per frame by the engine.
  111538. */
  111539. update(): void;
  111540. /**
  111541. * Called once for each button that changed state since the last frame
  111542. * @param buttonIdx Which button index changed
  111543. * @param state New state of the button
  111544. * @param changes Which properties on the state changed since last frame
  111545. */
  111546. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111547. /**
  111548. * Moves the buttons on the controller mesh based on their current state
  111549. * @param buttonName the name of the button to move
  111550. * @param buttonValue the value of the button which determines the buttons new position
  111551. */
  111552. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  111553. /**
  111554. * Moves the axis on the controller mesh based on its current state
  111555. * @param axis the index of the axis
  111556. * @param axisValue the value of the axis which determines the meshes new position
  111557. * @hidden
  111558. */
  111559. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  111560. /**
  111561. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111562. * @param scene scene in which to add meshes
  111563. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111564. */
  111565. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  111566. /**
  111567. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  111568. * can be transformed by button presses and axes values, based on this._mapping.
  111569. *
  111570. * @param scene scene in which the meshes exist
  111571. * @param meshes list of meshes that make up the controller model to process
  111572. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  111573. */
  111574. private processModel;
  111575. private createMeshInfo;
  111576. /**
  111577. * Gets the ray of the controller in the direction the controller is pointing
  111578. * @param length the length the resulting ray should be
  111579. * @returns a ray in the direction the controller is pointing
  111580. */
  111581. getForwardRay(length?: number): Ray;
  111582. /**
  111583. * Disposes of the controller
  111584. */
  111585. dispose(): void;
  111586. }
  111587. /**
  111588. * This class represents a new windows motion controller in XR.
  111589. */
  111590. export class XRWindowsMotionController extends WindowsMotionController {
  111591. /**
  111592. * Changing the original WIndowsMotionController mapping to fir the new mapping
  111593. */
  111594. protected readonly _mapping: {
  111595. buttons: string[];
  111596. buttonMeshNames: {
  111597. 'trigger': string;
  111598. 'menu': string;
  111599. 'grip': string;
  111600. 'thumbstick': string;
  111601. 'trackpad': string;
  111602. };
  111603. buttonObservableNames: {
  111604. 'trigger': string;
  111605. 'menu': string;
  111606. 'grip': string;
  111607. 'thumbstick': string;
  111608. 'trackpad': string;
  111609. };
  111610. axisMeshNames: string[];
  111611. pointingPoseMeshName: string;
  111612. };
  111613. /**
  111614. * Construct a new XR-Based windows motion controller
  111615. *
  111616. * @param gamepadInfo the gamepad object from the browser
  111617. */
  111618. constructor(gamepadInfo: any);
  111619. /**
  111620. * holds the thumbstick values (X,Y)
  111621. */
  111622. thumbstickValues: StickValues;
  111623. /**
  111624. * Fired when the thumbstick on this controller is clicked
  111625. */
  111626. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  111627. /**
  111628. * Fired when the thumbstick on this controller is modified
  111629. */
  111630. onThumbstickValuesChangedObservable: Observable<StickValues>;
  111631. /**
  111632. * Fired when the touchpad button on this controller is modified
  111633. */
  111634. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  111635. /**
  111636. * Fired when the touchpad values on this controller are modified
  111637. */
  111638. onTrackpadValuesChangedObservable: Observable<StickValues>;
  111639. /**
  111640. * Fired when the thumbstick button on this controller is modified
  111641. * here to prevent breaking changes
  111642. */
  111643. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111644. /**
  111645. * updating the thumbstick(!) and not the trackpad.
  111646. * This is named this way due to the difference between WebVR and XR and to avoid
  111647. * changing the parent class.
  111648. */
  111649. protected _updateTrackpad(): void;
  111650. /**
  111651. * Disposes the class with joy
  111652. */
  111653. dispose(): void;
  111654. }
  111655. }
  111656. declare module BABYLON {
  111657. /**
  111658. * Oculus Touch Controller
  111659. */
  111660. export class OculusTouchController extends WebVRController {
  111661. /**
  111662. * Base Url for the controller model.
  111663. */
  111664. static MODEL_BASE_URL: string;
  111665. /**
  111666. * File name for the left controller model.
  111667. */
  111668. static MODEL_LEFT_FILENAME: string;
  111669. /**
  111670. * File name for the right controller model.
  111671. */
  111672. static MODEL_RIGHT_FILENAME: string;
  111673. /**
  111674. * Base Url for the Quest controller model.
  111675. */
  111676. static QUEST_MODEL_BASE_URL: string;
  111677. /**
  111678. * @hidden
  111679. * If the controllers are running on a device that needs the updated Quest controller models
  111680. */
  111681. static _IsQuest: boolean;
  111682. /**
  111683. * Fired when the secondary trigger on this controller is modified
  111684. */
  111685. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  111686. /**
  111687. * Fired when the thumb rest on this controller is modified
  111688. */
  111689. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  111690. /**
  111691. * Creates a new OculusTouchController from a gamepad
  111692. * @param vrGamepad the gamepad that the controller should be created from
  111693. */
  111694. constructor(vrGamepad: any);
  111695. /**
  111696. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111697. * @param scene scene in which to add meshes
  111698. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111699. */
  111700. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111701. /**
  111702. * Fired when the A button on this controller is modified
  111703. */
  111704. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111705. /**
  111706. * Fired when the B button on this controller is modified
  111707. */
  111708. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111709. /**
  111710. * Fired when the X button on this controller is modified
  111711. */
  111712. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111713. /**
  111714. * Fired when the Y button on this controller is modified
  111715. */
  111716. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111717. /**
  111718. * Called once for each button that changed state since the last frame
  111719. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  111720. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  111721. * 2) secondary trigger (same)
  111722. * 3) A (right) X (left), touch, pressed = value
  111723. * 4) B / Y
  111724. * 5) thumb rest
  111725. * @param buttonIdx Which button index changed
  111726. * @param state New state of the button
  111727. * @param changes Which properties on the state changed since last frame
  111728. */
  111729. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111730. }
  111731. }
  111732. declare module BABYLON {
  111733. /**
  111734. * Vive Controller
  111735. */
  111736. export class ViveController extends WebVRController {
  111737. /**
  111738. * Base Url for the controller model.
  111739. */
  111740. static MODEL_BASE_URL: string;
  111741. /**
  111742. * File name for the controller model.
  111743. */
  111744. static MODEL_FILENAME: string;
  111745. /**
  111746. * Creates a new ViveController from a gamepad
  111747. * @param vrGamepad the gamepad that the controller should be created from
  111748. */
  111749. constructor(vrGamepad: any);
  111750. /**
  111751. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111752. * @param scene scene in which to add meshes
  111753. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111754. */
  111755. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111756. /**
  111757. * Fired when the left button on this controller is modified
  111758. */
  111759. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111760. /**
  111761. * Fired when the right button on this controller is modified
  111762. */
  111763. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111764. /**
  111765. * Fired when the menu button on this controller is modified
  111766. */
  111767. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111768. /**
  111769. * Called once for each button that changed state since the last frame
  111770. * Vive mapping:
  111771. * 0: touchpad
  111772. * 1: trigger
  111773. * 2: left AND right buttons
  111774. * 3: menu button
  111775. * @param buttonIdx Which button index changed
  111776. * @param state New state of the button
  111777. * @param changes Which properties on the state changed since last frame
  111778. */
  111779. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111780. }
  111781. }
  111782. declare module BABYLON {
  111783. /**
  111784. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  111785. */
  111786. export class WebXRControllerModelLoader {
  111787. /**
  111788. * an observable that triggers when a new model (the mesh itself) was initialized.
  111789. * To know when the mesh was loaded use the controller's own modelLoaded() method
  111790. */
  111791. onControllerModelLoaded: Observable<WebXRController>;
  111792. /**
  111793. * Creates the WebXRControllerModelLoader
  111794. * @param input xr input that creates the controllers
  111795. */
  111796. constructor(input: WebXRInput);
  111797. }
  111798. }
  111799. declare module BABYLON {
  111800. /**
  111801. * Handles pointer input automatically for the pointer of XR controllers
  111802. */
  111803. export class WebXRControllerPointerSelection {
  111804. private static _idCounter;
  111805. private _tmpRay;
  111806. /**
  111807. * Creates a WebXRControllerPointerSelection
  111808. * @param input input manager to setup pointer selection
  111809. */
  111810. constructor(input: WebXRInput);
  111811. private _convertNormalToDirectionOfRay;
  111812. private _updatePointerDistance;
  111813. }
  111814. }
  111815. declare module BABYLON {
  111816. /**
  111817. * Enables teleportation
  111818. */
  111819. export class WebXRControllerTeleportation {
  111820. private _teleportationFillColor;
  111821. private _teleportationBorderColor;
  111822. private _tmpRay;
  111823. private _tmpVector;
  111824. /**
  111825. * Creates a WebXRControllerTeleportation
  111826. * @param input input manager to add teleportation to
  111827. * @param floorMeshes floormeshes which can be teleported to
  111828. */
  111829. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  111830. }
  111831. }
  111832. declare module BABYLON {
  111833. /**
  111834. * Button which can be used to enter a different mode of XR
  111835. */
  111836. export class WebXREnterExitUIButton {
  111837. /** button element */
  111838. element: HTMLElement;
  111839. /** XR initialization options for the button */
  111840. sessionMode: XRSessionMode;
  111841. /** Reference space type */
  111842. referenceSpaceType: XRReferenceSpaceType;
  111843. /**
  111844. * Creates a WebXREnterExitUIButton
  111845. * @param element button element
  111846. * @param sessionMode XR initialization session mode
  111847. * @param referenceSpaceType the type of reference space to be used
  111848. */
  111849. constructor(
  111850. /** button element */
  111851. element: HTMLElement,
  111852. /** XR initialization options for the button */
  111853. sessionMode: XRSessionMode,
  111854. /** Reference space type */
  111855. referenceSpaceType: XRReferenceSpaceType);
  111856. /**
  111857. * Overwritable function which can be used to update the button's visuals when the state changes
  111858. * @param activeButton the current active button in the UI
  111859. */
  111860. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  111861. }
  111862. /**
  111863. * Options to create the webXR UI
  111864. */
  111865. export class WebXREnterExitUIOptions {
  111866. /**
  111867. * Context to enter xr with
  111868. */
  111869. renderTarget?: Nullable<WebXRRenderTarget>;
  111870. /**
  111871. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  111872. */
  111873. customButtons?: Array<WebXREnterExitUIButton>;
  111874. /**
  111875. * A session mode to use when creating the default button.
  111876. * Default is immersive-vr
  111877. */
  111878. sessionMode?: XRSessionMode;
  111879. /**
  111880. * A reference space type to use when creating the default button.
  111881. * Default is local-floor
  111882. */
  111883. referenceSpaceType?: XRReferenceSpaceType;
  111884. }
  111885. /**
  111886. * UI to allow the user to enter/exit XR mode
  111887. */
  111888. export class WebXREnterExitUI implements IDisposable {
  111889. private scene;
  111890. private _overlay;
  111891. private _buttons;
  111892. private _activeButton;
  111893. /**
  111894. * Fired every time the active button is changed.
  111895. *
  111896. * When xr is entered via a button that launches xr that button will be the callback parameter
  111897. *
  111898. * When exiting xr the callback parameter will be null)
  111899. */
  111900. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  111901. /**
  111902. * Creates UI to allow the user to enter/exit XR mode
  111903. * @param scene the scene to add the ui to
  111904. * @param helper the xr experience helper to enter/exit xr with
  111905. * @param options options to configure the UI
  111906. * @returns the created ui
  111907. */
  111908. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  111909. private constructor();
  111910. private _updateButtons;
  111911. /**
  111912. * Disposes of the object
  111913. */
  111914. dispose(): void;
  111915. }
  111916. }
  111917. declare module BABYLON {
  111918. /**
  111919. * Options for the default xr helper
  111920. */
  111921. export class WebXRDefaultExperienceOptions {
  111922. /**
  111923. * Floor meshes that should be used for teleporting
  111924. */
  111925. floorMeshes: Array<AbstractMesh>;
  111926. /**
  111927. * Enable or disable default UI to enter XR
  111928. */
  111929. disableDefaultUI?: boolean;
  111930. /**
  111931. * optional configuration for the output canvas
  111932. */
  111933. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  111934. }
  111935. /**
  111936. * Default experience which provides a similar setup to the previous webVRExperience
  111937. */
  111938. export class WebXRDefaultExperience {
  111939. /**
  111940. * Base experience
  111941. */
  111942. baseExperience: WebXRExperienceHelper;
  111943. /**
  111944. * Input experience extension
  111945. */
  111946. input: WebXRInput;
  111947. /**
  111948. * Loads the controller models
  111949. */
  111950. controllerModelLoader: WebXRControllerModelLoader;
  111951. /**
  111952. * Enables laser pointer and selection
  111953. */
  111954. pointerSelection: WebXRControllerPointerSelection;
  111955. /**
  111956. * Enables teleportation
  111957. */
  111958. teleportation: WebXRControllerTeleportation;
  111959. /**
  111960. * Enables ui for enetering/exiting xr
  111961. */
  111962. enterExitUI: WebXREnterExitUI;
  111963. /**
  111964. * Default target xr should render to
  111965. */
  111966. renderTarget: WebXRRenderTarget;
  111967. /**
  111968. * Creates the default xr experience
  111969. * @param scene scene
  111970. * @param options options for basic configuration
  111971. * @returns resulting WebXRDefaultExperience
  111972. */
  111973. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  111974. private constructor();
  111975. /**
  111976. * DIsposes of the experience helper
  111977. */
  111978. dispose(): void;
  111979. }
  111980. }
  111981. declare module BABYLON {
  111982. /**
  111983. * Options to modify the vr teleportation behavior.
  111984. */
  111985. export interface VRTeleportationOptions {
  111986. /**
  111987. * The name of the mesh which should be used as the teleportation floor. (default: null)
  111988. */
  111989. floorMeshName?: string;
  111990. /**
  111991. * A list of meshes to be used as the teleportation floor. (default: empty)
  111992. */
  111993. floorMeshes?: Mesh[];
  111994. /**
  111995. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  111996. */
  111997. teleportationMode?: number;
  111998. /**
  111999. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  112000. */
  112001. teleportationTime?: number;
  112002. /**
  112003. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  112004. */
  112005. teleportationSpeed?: number;
  112006. /**
  112007. * The easing function used in the animation or null for Linear. (default CircleEase)
  112008. */
  112009. easingFunction?: EasingFunction;
  112010. }
  112011. /**
  112012. * Options to modify the vr experience helper's behavior.
  112013. */
  112014. export interface VRExperienceHelperOptions extends WebVROptions {
  112015. /**
  112016. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  112017. */
  112018. createDeviceOrientationCamera?: boolean;
  112019. /**
  112020. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  112021. */
  112022. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  112023. /**
  112024. * Uses the main button on the controller to toggle the laser casted. (default: true)
  112025. */
  112026. laserToggle?: boolean;
  112027. /**
  112028. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  112029. */
  112030. floorMeshes?: Mesh[];
  112031. /**
  112032. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  112033. */
  112034. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  112035. /**
  112036. * Defines if WebXR should be used instead of WebVR (if available)
  112037. */
  112038. useXR?: boolean;
  112039. }
  112040. /**
  112041. * Event containing information after VR has been entered
  112042. */
  112043. export class OnAfterEnteringVRObservableEvent {
  112044. /**
  112045. * If entering vr was successful
  112046. */
  112047. success: boolean;
  112048. }
  112049. /**
  112050. * Helps to quickly add VR support to an existing scene.
  112051. * See http://doc.babylonjs.com/how_to/webvr_helper
  112052. */
  112053. export class VRExperienceHelper {
  112054. /** Options to modify the vr experience helper's behavior. */
  112055. webVROptions: VRExperienceHelperOptions;
  112056. private _scene;
  112057. private _position;
  112058. private _btnVR;
  112059. private _btnVRDisplayed;
  112060. private _webVRsupported;
  112061. private _webVRready;
  112062. private _webVRrequesting;
  112063. private _webVRpresenting;
  112064. private _hasEnteredVR;
  112065. private _fullscreenVRpresenting;
  112066. private _inputElement;
  112067. private _webVRCamera;
  112068. private _vrDeviceOrientationCamera;
  112069. private _deviceOrientationCamera;
  112070. private _existingCamera;
  112071. private _onKeyDown;
  112072. private _onVrDisplayPresentChange;
  112073. private _onVRDisplayChanged;
  112074. private _onVRRequestPresentStart;
  112075. private _onVRRequestPresentComplete;
  112076. /**
  112077. * 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)
  112078. */
  112079. enableGazeEvenWhenNoPointerLock: boolean;
  112080. /**
  112081. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  112082. */
  112083. exitVROnDoubleTap: boolean;
  112084. /**
  112085. * Observable raised right before entering VR.
  112086. */
  112087. onEnteringVRObservable: Observable<VRExperienceHelper>;
  112088. /**
  112089. * Observable raised when entering VR has completed.
  112090. */
  112091. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  112092. /**
  112093. * Observable raised when exiting VR.
  112094. */
  112095. onExitingVRObservable: Observable<VRExperienceHelper>;
  112096. /**
  112097. * Observable raised when controller mesh is loaded.
  112098. */
  112099. onControllerMeshLoadedObservable: Observable<WebVRController>;
  112100. /** Return this.onEnteringVRObservable
  112101. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  112102. */
  112103. readonly onEnteringVR: Observable<VRExperienceHelper>;
  112104. /** Return this.onExitingVRObservable
  112105. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  112106. */
  112107. readonly onExitingVR: Observable<VRExperienceHelper>;
  112108. /** Return this.onControllerMeshLoadedObservable
  112109. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  112110. */
  112111. readonly onControllerMeshLoaded: Observable<WebVRController>;
  112112. private _rayLength;
  112113. private _useCustomVRButton;
  112114. private _teleportationRequested;
  112115. private _teleportActive;
  112116. private _floorMeshName;
  112117. private _floorMeshesCollection;
  112118. private _teleportationMode;
  112119. private _teleportationTime;
  112120. private _teleportationSpeed;
  112121. private _teleportationEasing;
  112122. private _rotationAllowed;
  112123. private _teleportBackwardsVector;
  112124. private _teleportationTarget;
  112125. private _isDefaultTeleportationTarget;
  112126. private _postProcessMove;
  112127. private _teleportationFillColor;
  112128. private _teleportationBorderColor;
  112129. private _rotationAngle;
  112130. private _haloCenter;
  112131. private _cameraGazer;
  112132. private _padSensibilityUp;
  112133. private _padSensibilityDown;
  112134. private _leftController;
  112135. private _rightController;
  112136. /**
  112137. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  112138. */
  112139. onNewMeshSelected: Observable<AbstractMesh>;
  112140. /**
  112141. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  112142. * This observable will provide the mesh and the controller used to select the mesh
  112143. */
  112144. onMeshSelectedWithController: Observable<{
  112145. mesh: AbstractMesh;
  112146. controller: WebVRController;
  112147. }>;
  112148. /**
  112149. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  112150. */
  112151. onNewMeshPicked: Observable<PickingInfo>;
  112152. private _circleEase;
  112153. /**
  112154. * Observable raised before camera teleportation
  112155. */
  112156. onBeforeCameraTeleport: Observable<Vector3>;
  112157. /**
  112158. * Observable raised after camera teleportation
  112159. */
  112160. onAfterCameraTeleport: Observable<Vector3>;
  112161. /**
  112162. * Observable raised when current selected mesh gets unselected
  112163. */
  112164. onSelectedMeshUnselected: Observable<AbstractMesh>;
  112165. private _raySelectionPredicate;
  112166. /**
  112167. * To be optionaly changed by user to define custom ray selection
  112168. */
  112169. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  112170. /**
  112171. * To be optionaly changed by user to define custom selection logic (after ray selection)
  112172. */
  112173. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  112174. /**
  112175. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  112176. */
  112177. teleportationEnabled: boolean;
  112178. private _defaultHeight;
  112179. private _teleportationInitialized;
  112180. private _interactionsEnabled;
  112181. private _interactionsRequested;
  112182. private _displayGaze;
  112183. private _displayLaserPointer;
  112184. /**
  112185. * The mesh used to display where the user is going to teleport.
  112186. */
  112187. /**
  112188. * Sets the mesh to be used to display where the user is going to teleport.
  112189. */
  112190. teleportationTarget: Mesh;
  112191. /**
  112192. * 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
  112193. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  112194. * See http://doc.babylonjs.com/resources/baking_transformations
  112195. */
  112196. gazeTrackerMesh: Mesh;
  112197. /**
  112198. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  112199. */
  112200. updateGazeTrackerScale: boolean;
  112201. /**
  112202. * If the gaze trackers color should be updated when selecting meshes
  112203. */
  112204. updateGazeTrackerColor: boolean;
  112205. /**
  112206. * If the controller laser color should be updated when selecting meshes
  112207. */
  112208. updateControllerLaserColor: boolean;
  112209. /**
  112210. * The gaze tracking mesh corresponding to the left controller
  112211. */
  112212. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  112213. /**
  112214. * The gaze tracking mesh corresponding to the right controller
  112215. */
  112216. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  112217. /**
  112218. * If the ray of the gaze should be displayed.
  112219. */
  112220. /**
  112221. * Sets if the ray of the gaze should be displayed.
  112222. */
  112223. displayGaze: boolean;
  112224. /**
  112225. * If the ray of the LaserPointer should be displayed.
  112226. */
  112227. /**
  112228. * Sets if the ray of the LaserPointer should be displayed.
  112229. */
  112230. displayLaserPointer: boolean;
  112231. /**
  112232. * The deviceOrientationCamera used as the camera when not in VR.
  112233. */
  112234. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  112235. /**
  112236. * Based on the current WebVR support, returns the current VR camera used.
  112237. */
  112238. readonly currentVRCamera: Nullable<Camera>;
  112239. /**
  112240. * The webVRCamera which is used when in VR.
  112241. */
  112242. readonly webVRCamera: WebVRFreeCamera;
  112243. /**
  112244. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  112245. */
  112246. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  112247. /**
  112248. * The html button that is used to trigger entering into VR.
  112249. */
  112250. readonly vrButton: Nullable<HTMLButtonElement>;
  112251. private readonly _teleportationRequestInitiated;
  112252. /**
  112253. * Defines wether or not Pointer lock should be requested when switching to
  112254. * full screen.
  112255. */
  112256. requestPointerLockOnFullScreen: boolean;
  112257. /**
  112258. * If asking to force XR, this will be populated with the default xr experience
  112259. */
  112260. xr: WebXRDefaultExperience;
  112261. /**
  112262. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  112263. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  112264. */
  112265. xrTestDone: boolean;
  112266. /**
  112267. * Instantiates a VRExperienceHelper.
  112268. * Helps to quickly add VR support to an existing scene.
  112269. * @param scene The scene the VRExperienceHelper belongs to.
  112270. * @param webVROptions Options to modify the vr experience helper's behavior.
  112271. */
  112272. constructor(scene: Scene,
  112273. /** Options to modify the vr experience helper's behavior. */
  112274. webVROptions?: VRExperienceHelperOptions);
  112275. private completeVRInit;
  112276. private _onDefaultMeshLoaded;
  112277. private _onResize;
  112278. private _onFullscreenChange;
  112279. /**
  112280. * Gets a value indicating if we are currently in VR mode.
  112281. */
  112282. readonly isInVRMode: boolean;
  112283. private onVrDisplayPresentChange;
  112284. private onVRDisplayChanged;
  112285. private moveButtonToBottomRight;
  112286. private displayVRButton;
  112287. private updateButtonVisibility;
  112288. private _cachedAngularSensibility;
  112289. /**
  112290. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  112291. * Otherwise, will use the fullscreen API.
  112292. */
  112293. enterVR(): void;
  112294. /**
  112295. * Attempt to exit VR, or fullscreen.
  112296. */
  112297. exitVR(): void;
  112298. /**
  112299. * The position of the vr experience helper.
  112300. */
  112301. /**
  112302. * Sets the position of the vr experience helper.
  112303. */
  112304. position: Vector3;
  112305. /**
  112306. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  112307. */
  112308. enableInteractions(): void;
  112309. private readonly _noControllerIsActive;
  112310. private beforeRender;
  112311. private _isTeleportationFloor;
  112312. /**
  112313. * Adds a floor mesh to be used for teleportation.
  112314. * @param floorMesh the mesh to be used for teleportation.
  112315. */
  112316. addFloorMesh(floorMesh: Mesh): void;
  112317. /**
  112318. * Removes a floor mesh from being used for teleportation.
  112319. * @param floorMesh the mesh to be removed.
  112320. */
  112321. removeFloorMesh(floorMesh: Mesh): void;
  112322. /**
  112323. * Enables interactions and teleportation using the VR controllers and gaze.
  112324. * @param vrTeleportationOptions options to modify teleportation behavior.
  112325. */
  112326. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  112327. private _onNewGamepadConnected;
  112328. private _tryEnableInteractionOnController;
  112329. private _onNewGamepadDisconnected;
  112330. private _enableInteractionOnController;
  112331. private _checkTeleportWithRay;
  112332. private _checkRotate;
  112333. private _checkTeleportBackwards;
  112334. private _enableTeleportationOnController;
  112335. private _createTeleportationCircles;
  112336. private _displayTeleportationTarget;
  112337. private _hideTeleportationTarget;
  112338. private _rotateCamera;
  112339. private _moveTeleportationSelectorTo;
  112340. private _workingVector;
  112341. private _workingQuaternion;
  112342. private _workingMatrix;
  112343. /**
  112344. * Time Constant Teleportation Mode
  112345. */
  112346. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  112347. /**
  112348. * Speed Constant Teleportation Mode
  112349. */
  112350. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  112351. /**
  112352. * Teleports the users feet to the desired location
  112353. * @param location The location where the user's feet should be placed
  112354. */
  112355. teleportCamera(location: Vector3): void;
  112356. private _convertNormalToDirectionOfRay;
  112357. private _castRayAndSelectObject;
  112358. private _notifySelectedMeshUnselected;
  112359. /**
  112360. * Sets the color of the laser ray from the vr controllers.
  112361. * @param color new color for the ray.
  112362. */
  112363. changeLaserColor(color: Color3): void;
  112364. /**
  112365. * Sets the color of the ray from the vr headsets gaze.
  112366. * @param color new color for the ray.
  112367. */
  112368. changeGazeColor(color: Color3): void;
  112369. /**
  112370. * Exits VR and disposes of the vr experience helper
  112371. */
  112372. dispose(): void;
  112373. /**
  112374. * Gets the name of the VRExperienceHelper class
  112375. * @returns "VRExperienceHelper"
  112376. */
  112377. getClassName(): string;
  112378. }
  112379. }
  112380. declare module BABYLON {
  112381. /**
  112382. * Contains an array of blocks representing the octree
  112383. */
  112384. export interface IOctreeContainer<T> {
  112385. /**
  112386. * Blocks within the octree
  112387. */
  112388. blocks: Array<OctreeBlock<T>>;
  112389. }
  112390. /**
  112391. * Class used to store a cell in an octree
  112392. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  112393. */
  112394. export class OctreeBlock<T> {
  112395. /**
  112396. * Gets the content of the current block
  112397. */
  112398. entries: T[];
  112399. /**
  112400. * Gets the list of block children
  112401. */
  112402. blocks: Array<OctreeBlock<T>>;
  112403. private _depth;
  112404. private _maxDepth;
  112405. private _capacity;
  112406. private _minPoint;
  112407. private _maxPoint;
  112408. private _boundingVectors;
  112409. private _creationFunc;
  112410. /**
  112411. * Creates a new block
  112412. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  112413. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  112414. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  112415. * @param depth defines the current depth of this block in the octree
  112416. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  112417. * @param creationFunc defines a callback to call when an element is added to the block
  112418. */
  112419. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  112420. /**
  112421. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  112422. */
  112423. readonly capacity: number;
  112424. /**
  112425. * Gets the minimum vector (in world space) of the block's bounding box
  112426. */
  112427. readonly minPoint: Vector3;
  112428. /**
  112429. * Gets the maximum vector (in world space) of the block's bounding box
  112430. */
  112431. readonly maxPoint: Vector3;
  112432. /**
  112433. * Add a new element to this block
  112434. * @param entry defines the element to add
  112435. */
  112436. addEntry(entry: T): void;
  112437. /**
  112438. * Remove an element from this block
  112439. * @param entry defines the element to remove
  112440. */
  112441. removeEntry(entry: T): void;
  112442. /**
  112443. * Add an array of elements to this block
  112444. * @param entries defines the array of elements to add
  112445. */
  112446. addEntries(entries: T[]): void;
  112447. /**
  112448. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  112449. * @param frustumPlanes defines the frustum planes to test
  112450. * @param selection defines the array to store current content if selection is positive
  112451. * @param allowDuplicate defines if the selection array can contains duplicated entries
  112452. */
  112453. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  112454. /**
  112455. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  112456. * @param sphereCenter defines the bounding sphere center
  112457. * @param sphereRadius defines the bounding sphere radius
  112458. * @param selection defines the array to store current content if selection is positive
  112459. * @param allowDuplicate defines if the selection array can contains duplicated entries
  112460. */
  112461. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  112462. /**
  112463. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  112464. * @param ray defines the ray to test with
  112465. * @param selection defines the array to store current content if selection is positive
  112466. */
  112467. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  112468. /**
  112469. * Subdivide the content into child blocks (this block will then be empty)
  112470. */
  112471. createInnerBlocks(): void;
  112472. /**
  112473. * @hidden
  112474. */
  112475. 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;
  112476. }
  112477. }
  112478. declare module BABYLON {
  112479. /**
  112480. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  112481. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  112482. */
  112483. export class Octree<T> {
  112484. /** 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.) */
  112485. maxDepth: number;
  112486. /**
  112487. * Blocks within the octree containing objects
  112488. */
  112489. blocks: Array<OctreeBlock<T>>;
  112490. /**
  112491. * Content stored in the octree
  112492. */
  112493. dynamicContent: T[];
  112494. private _maxBlockCapacity;
  112495. private _selectionContent;
  112496. private _creationFunc;
  112497. /**
  112498. * Creates a octree
  112499. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  112500. * @param creationFunc function to be used to instatiate the octree
  112501. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  112502. * @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.)
  112503. */
  112504. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  112505. /** 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.) */
  112506. maxDepth?: number);
  112507. /**
  112508. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  112509. * @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);
  112510. * @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);
  112511. * @param entries meshes to be added to the octree blocks
  112512. */
  112513. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  112514. /**
  112515. * Adds a mesh to the octree
  112516. * @param entry Mesh to add to the octree
  112517. */
  112518. addMesh(entry: T): void;
  112519. /**
  112520. * Remove an element from the octree
  112521. * @param entry defines the element to remove
  112522. */
  112523. removeMesh(entry: T): void;
  112524. /**
  112525. * Selects an array of meshes within the frustum
  112526. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  112527. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  112528. * @returns array of meshes within the frustum
  112529. */
  112530. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  112531. /**
  112532. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  112533. * @param sphereCenter defines the bounding sphere center
  112534. * @param sphereRadius defines the bounding sphere radius
  112535. * @param allowDuplicate defines if the selection array can contains duplicated entries
  112536. * @returns an array of objects that intersect the sphere
  112537. */
  112538. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  112539. /**
  112540. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  112541. * @param ray defines the ray to test with
  112542. * @returns array of intersected objects
  112543. */
  112544. intersectsRay(ray: Ray): SmartArray<T>;
  112545. /**
  112546. * Adds a mesh into the octree block if it intersects the block
  112547. */
  112548. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  112549. /**
  112550. * Adds a submesh into the octree block if it intersects the block
  112551. */
  112552. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  112553. }
  112554. }
  112555. declare module BABYLON {
  112556. interface Scene {
  112557. /**
  112558. * @hidden
  112559. * Backing Filed
  112560. */
  112561. _selectionOctree: Octree<AbstractMesh>;
  112562. /**
  112563. * Gets the octree used to boost mesh selection (picking)
  112564. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  112565. */
  112566. selectionOctree: Octree<AbstractMesh>;
  112567. /**
  112568. * Creates or updates the octree used to boost selection (picking)
  112569. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  112570. * @param maxCapacity defines the maximum capacity per leaf
  112571. * @param maxDepth defines the maximum depth of the octree
  112572. * @returns an octree of AbstractMesh
  112573. */
  112574. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  112575. }
  112576. interface AbstractMesh {
  112577. /**
  112578. * @hidden
  112579. * Backing Field
  112580. */
  112581. _submeshesOctree: Octree<SubMesh>;
  112582. /**
  112583. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  112584. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  112585. * @param maxCapacity defines the maximum size of each block (64 by default)
  112586. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  112587. * @returns the new octree
  112588. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  112589. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  112590. */
  112591. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  112592. }
  112593. /**
  112594. * Defines the octree scene component responsible to manage any octrees
  112595. * in a given scene.
  112596. */
  112597. export class OctreeSceneComponent {
  112598. /**
  112599. * The component name help to identify the component in the list of scene components.
  112600. */
  112601. readonly name: string;
  112602. /**
  112603. * The scene the component belongs to.
  112604. */
  112605. scene: Scene;
  112606. /**
  112607. * Indicates if the meshes have been checked to make sure they are isEnabled()
  112608. */
  112609. readonly checksIsEnabled: boolean;
  112610. /**
  112611. * Creates a new instance of the component for the given scene
  112612. * @param scene Defines the scene to register the component in
  112613. */
  112614. constructor(scene: Scene);
  112615. /**
  112616. * Registers the component in a given scene
  112617. */
  112618. register(): void;
  112619. /**
  112620. * Return the list of active meshes
  112621. * @returns the list of active meshes
  112622. */
  112623. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  112624. /**
  112625. * Return the list of active sub meshes
  112626. * @param mesh The mesh to get the candidates sub meshes from
  112627. * @returns the list of active sub meshes
  112628. */
  112629. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  112630. private _tempRay;
  112631. /**
  112632. * Return the list of sub meshes intersecting with a given local ray
  112633. * @param mesh defines the mesh to find the submesh for
  112634. * @param localRay defines the ray in local space
  112635. * @returns the list of intersecting sub meshes
  112636. */
  112637. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  112638. /**
  112639. * Return the list of sub meshes colliding with a collider
  112640. * @param mesh defines the mesh to find the submesh for
  112641. * @param collider defines the collider to evaluate the collision against
  112642. * @returns the list of colliding sub meshes
  112643. */
  112644. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  112645. /**
  112646. * Rebuilds the elements related to this component in case of
  112647. * context lost for instance.
  112648. */
  112649. rebuild(): void;
  112650. /**
  112651. * Disposes the component and the associated ressources.
  112652. */
  112653. dispose(): void;
  112654. }
  112655. }
  112656. declare module BABYLON {
  112657. /**
  112658. * Renders a layer on top of an existing scene
  112659. */
  112660. export class UtilityLayerRenderer implements IDisposable {
  112661. /** the original scene that will be rendered on top of */
  112662. originalScene: Scene;
  112663. private _pointerCaptures;
  112664. private _lastPointerEvents;
  112665. private static _DefaultUtilityLayer;
  112666. private static _DefaultKeepDepthUtilityLayer;
  112667. private _sharedGizmoLight;
  112668. private _renderCamera;
  112669. /**
  112670. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  112671. * @returns the camera that is used when rendering the utility layer
  112672. */
  112673. getRenderCamera(): Nullable<Camera>;
  112674. /**
  112675. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  112676. * @param cam the camera that should be used when rendering the utility layer
  112677. */
  112678. setRenderCamera(cam: Nullable<Camera>): void;
  112679. /**
  112680. * @hidden
  112681. * Light which used by gizmos to get light shading
  112682. */
  112683. _getSharedGizmoLight(): HemisphericLight;
  112684. /**
  112685. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  112686. */
  112687. pickUtilitySceneFirst: boolean;
  112688. /**
  112689. * 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)
  112690. */
  112691. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  112692. /**
  112693. * 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)
  112694. */
  112695. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  112696. /**
  112697. * The scene that is rendered on top of the original scene
  112698. */
  112699. utilityLayerScene: Scene;
  112700. /**
  112701. * If the utility layer should automatically be rendered on top of existing scene
  112702. */
  112703. shouldRender: boolean;
  112704. /**
  112705. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  112706. */
  112707. onlyCheckPointerDownEvents: boolean;
  112708. /**
  112709. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  112710. */
  112711. processAllEvents: boolean;
  112712. /**
  112713. * Observable raised when the pointer move from the utility layer scene to the main scene
  112714. */
  112715. onPointerOutObservable: Observable<number>;
  112716. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  112717. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  112718. private _afterRenderObserver;
  112719. private _sceneDisposeObserver;
  112720. private _originalPointerObserver;
  112721. /**
  112722. * Instantiates a UtilityLayerRenderer
  112723. * @param originalScene the original scene that will be rendered on top of
  112724. * @param handleEvents boolean indicating if the utility layer should handle events
  112725. */
  112726. constructor(
  112727. /** the original scene that will be rendered on top of */
  112728. originalScene: Scene, handleEvents?: boolean);
  112729. private _notifyObservers;
  112730. /**
  112731. * Renders the utility layers scene on top of the original scene
  112732. */
  112733. render(): void;
  112734. /**
  112735. * Disposes of the renderer
  112736. */
  112737. dispose(): void;
  112738. private _updateCamera;
  112739. }
  112740. }
  112741. declare module BABYLON {
  112742. /**
  112743. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  112744. */
  112745. export class Gizmo implements IDisposable {
  112746. /** The utility layer the gizmo will be added to */
  112747. gizmoLayer: UtilityLayerRenderer;
  112748. /**
  112749. * The root mesh of the gizmo
  112750. */
  112751. _rootMesh: Mesh;
  112752. private _attachedMesh;
  112753. /**
  112754. * Ratio for the scale of the gizmo (Default: 1)
  112755. */
  112756. scaleRatio: number;
  112757. /**
  112758. * If a custom mesh has been set (Default: false)
  112759. */
  112760. protected _customMeshSet: boolean;
  112761. /**
  112762. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  112763. * * When set, interactions will be enabled
  112764. */
  112765. attachedMesh: Nullable<AbstractMesh>;
  112766. /**
  112767. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  112768. * @param mesh The mesh to replace the default mesh of the gizmo
  112769. */
  112770. setCustomMesh(mesh: Mesh): void;
  112771. /**
  112772. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  112773. */
  112774. updateGizmoRotationToMatchAttachedMesh: boolean;
  112775. /**
  112776. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  112777. */
  112778. updateGizmoPositionToMatchAttachedMesh: boolean;
  112779. /**
  112780. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  112781. */
  112782. updateScale: boolean;
  112783. protected _interactionsEnabled: boolean;
  112784. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112785. private _beforeRenderObserver;
  112786. private _tempVector;
  112787. /**
  112788. * Creates a gizmo
  112789. * @param gizmoLayer The utility layer the gizmo will be added to
  112790. */
  112791. constructor(
  112792. /** The utility layer the gizmo will be added to */
  112793. gizmoLayer?: UtilityLayerRenderer);
  112794. /**
  112795. * Updates the gizmo to match the attached mesh's position/rotation
  112796. */
  112797. protected _update(): void;
  112798. /**
  112799. * Disposes of the gizmo
  112800. */
  112801. dispose(): void;
  112802. }
  112803. }
  112804. declare module BABYLON {
  112805. /**
  112806. * Single plane drag gizmo
  112807. */
  112808. export class PlaneDragGizmo extends Gizmo {
  112809. /**
  112810. * Drag behavior responsible for the gizmos dragging interactions
  112811. */
  112812. dragBehavior: PointerDragBehavior;
  112813. private _pointerObserver;
  112814. /**
  112815. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112816. */
  112817. snapDistance: number;
  112818. /**
  112819. * Event that fires each time the gizmo snaps to a new location.
  112820. * * snapDistance is the the change in distance
  112821. */
  112822. onSnapObservable: Observable<{
  112823. snapDistance: number;
  112824. }>;
  112825. private _plane;
  112826. private _coloredMaterial;
  112827. private _hoverMaterial;
  112828. private _isEnabled;
  112829. private _parent;
  112830. /** @hidden */
  112831. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  112832. /** @hidden */
  112833. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  112834. /**
  112835. * Creates a PlaneDragGizmo
  112836. * @param gizmoLayer The utility layer the gizmo will be added to
  112837. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  112838. * @param color The color of the gizmo
  112839. */
  112840. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  112841. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112842. /**
  112843. * If the gizmo is enabled
  112844. */
  112845. isEnabled: boolean;
  112846. /**
  112847. * Disposes of the gizmo
  112848. */
  112849. dispose(): void;
  112850. }
  112851. }
  112852. declare module BABYLON {
  112853. /**
  112854. * Gizmo that enables dragging a mesh along 3 axis
  112855. */
  112856. export class PositionGizmo extends Gizmo {
  112857. /**
  112858. * Internal gizmo used for interactions on the x axis
  112859. */
  112860. xGizmo: AxisDragGizmo;
  112861. /**
  112862. * Internal gizmo used for interactions on the y axis
  112863. */
  112864. yGizmo: AxisDragGizmo;
  112865. /**
  112866. * Internal gizmo used for interactions on the z axis
  112867. */
  112868. zGizmo: AxisDragGizmo;
  112869. /**
  112870. * Internal gizmo used for interactions on the yz plane
  112871. */
  112872. xPlaneGizmo: PlaneDragGizmo;
  112873. /**
  112874. * Internal gizmo used for interactions on the xz plane
  112875. */
  112876. yPlaneGizmo: PlaneDragGizmo;
  112877. /**
  112878. * Internal gizmo used for interactions on the xy plane
  112879. */
  112880. zPlaneGizmo: PlaneDragGizmo;
  112881. /**
  112882. * private variables
  112883. */
  112884. private _meshAttached;
  112885. private _updateGizmoRotationToMatchAttachedMesh;
  112886. private _snapDistance;
  112887. private _scaleRatio;
  112888. /** Fires an event when any of it's sub gizmos are dragged */
  112889. onDragStartObservable: Observable<unknown>;
  112890. /** Fires an event when any of it's sub gizmos are released from dragging */
  112891. onDragEndObservable: Observable<unknown>;
  112892. /**
  112893. * If set to true, planar drag is enabled
  112894. */
  112895. private _planarGizmoEnabled;
  112896. attachedMesh: Nullable<AbstractMesh>;
  112897. /**
  112898. * Creates a PositionGizmo
  112899. * @param gizmoLayer The utility layer the gizmo will be added to
  112900. */
  112901. constructor(gizmoLayer?: UtilityLayerRenderer);
  112902. /**
  112903. * If the planar drag gizmo is enabled
  112904. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  112905. */
  112906. planarGizmoEnabled: boolean;
  112907. updateGizmoRotationToMatchAttachedMesh: boolean;
  112908. /**
  112909. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112910. */
  112911. snapDistance: number;
  112912. /**
  112913. * Ratio for the scale of the gizmo (Default: 1)
  112914. */
  112915. scaleRatio: number;
  112916. /**
  112917. * Disposes of the gizmo
  112918. */
  112919. dispose(): void;
  112920. /**
  112921. * CustomMeshes are not supported by this gizmo
  112922. * @param mesh The mesh to replace the default mesh of the gizmo
  112923. */
  112924. setCustomMesh(mesh: Mesh): void;
  112925. }
  112926. }
  112927. declare module BABYLON {
  112928. /**
  112929. * Single axis drag gizmo
  112930. */
  112931. export class AxisDragGizmo extends Gizmo {
  112932. /**
  112933. * Drag behavior responsible for the gizmos dragging interactions
  112934. */
  112935. dragBehavior: PointerDragBehavior;
  112936. private _pointerObserver;
  112937. /**
  112938. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112939. */
  112940. snapDistance: number;
  112941. /**
  112942. * Event that fires each time the gizmo snaps to a new location.
  112943. * * snapDistance is the the change in distance
  112944. */
  112945. onSnapObservable: Observable<{
  112946. snapDistance: number;
  112947. }>;
  112948. private _isEnabled;
  112949. private _parent;
  112950. private _arrow;
  112951. private _coloredMaterial;
  112952. private _hoverMaterial;
  112953. /** @hidden */
  112954. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  112955. /** @hidden */
  112956. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  112957. /**
  112958. * Creates an AxisDragGizmo
  112959. * @param gizmoLayer The utility layer the gizmo will be added to
  112960. * @param dragAxis The axis which the gizmo will be able to drag on
  112961. * @param color The color of the gizmo
  112962. */
  112963. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  112964. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112965. /**
  112966. * If the gizmo is enabled
  112967. */
  112968. isEnabled: boolean;
  112969. /**
  112970. * Disposes of the gizmo
  112971. */
  112972. dispose(): void;
  112973. }
  112974. }
  112975. declare module BABYLON.Debug {
  112976. /**
  112977. * The Axes viewer will show 3 axes in a specific point in space
  112978. */
  112979. export class AxesViewer {
  112980. private _xAxis;
  112981. private _yAxis;
  112982. private _zAxis;
  112983. private _scaleLinesFactor;
  112984. private _instanced;
  112985. /**
  112986. * Gets the hosting scene
  112987. */
  112988. scene: Scene;
  112989. /**
  112990. * Gets or sets a number used to scale line length
  112991. */
  112992. scaleLines: number;
  112993. /** Gets the node hierarchy used to render x-axis */
  112994. readonly xAxis: TransformNode;
  112995. /** Gets the node hierarchy used to render y-axis */
  112996. readonly yAxis: TransformNode;
  112997. /** Gets the node hierarchy used to render z-axis */
  112998. readonly zAxis: TransformNode;
  112999. /**
  113000. * Creates a new AxesViewer
  113001. * @param scene defines the hosting scene
  113002. * @param scaleLines defines a number used to scale line length (1 by default)
  113003. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  113004. * @param xAxis defines the node hierarchy used to render the x-axis
  113005. * @param yAxis defines the node hierarchy used to render the y-axis
  113006. * @param zAxis defines the node hierarchy used to render the z-axis
  113007. */
  113008. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  113009. /**
  113010. * Force the viewer to update
  113011. * @param position defines the position of the viewer
  113012. * @param xaxis defines the x axis of the viewer
  113013. * @param yaxis defines the y axis of the viewer
  113014. * @param zaxis defines the z axis of the viewer
  113015. */
  113016. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  113017. /**
  113018. * Creates an instance of this axes viewer.
  113019. * @returns a new axes viewer with instanced meshes
  113020. */
  113021. createInstance(): AxesViewer;
  113022. /** Releases resources */
  113023. dispose(): void;
  113024. private static _SetRenderingGroupId;
  113025. }
  113026. }
  113027. declare module BABYLON.Debug {
  113028. /**
  113029. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  113030. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  113031. */
  113032. export class BoneAxesViewer extends AxesViewer {
  113033. /**
  113034. * Gets or sets the target mesh where to display the axes viewer
  113035. */
  113036. mesh: Nullable<Mesh>;
  113037. /**
  113038. * Gets or sets the target bone where to display the axes viewer
  113039. */
  113040. bone: Nullable<Bone>;
  113041. /** Gets current position */
  113042. pos: Vector3;
  113043. /** Gets direction of X axis */
  113044. xaxis: Vector3;
  113045. /** Gets direction of Y axis */
  113046. yaxis: Vector3;
  113047. /** Gets direction of Z axis */
  113048. zaxis: Vector3;
  113049. /**
  113050. * Creates a new BoneAxesViewer
  113051. * @param scene defines the hosting scene
  113052. * @param bone defines the target bone
  113053. * @param mesh defines the target mesh
  113054. * @param scaleLines defines a scaling factor for line length (1 by default)
  113055. */
  113056. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  113057. /**
  113058. * Force the viewer to update
  113059. */
  113060. update(): void;
  113061. /** Releases resources */
  113062. dispose(): void;
  113063. }
  113064. }
  113065. declare module BABYLON {
  113066. /**
  113067. * Interface used to define scene explorer extensibility option
  113068. */
  113069. export interface IExplorerExtensibilityOption {
  113070. /**
  113071. * Define the option label
  113072. */
  113073. label: string;
  113074. /**
  113075. * Defines the action to execute on click
  113076. */
  113077. action: (entity: any) => void;
  113078. }
  113079. /**
  113080. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  113081. */
  113082. export interface IExplorerExtensibilityGroup {
  113083. /**
  113084. * Defines a predicate to test if a given type mut be extended
  113085. */
  113086. predicate: (entity: any) => boolean;
  113087. /**
  113088. * Gets the list of options added to a type
  113089. */
  113090. entries: IExplorerExtensibilityOption[];
  113091. }
  113092. /**
  113093. * Interface used to define the options to use to create the Inspector
  113094. */
  113095. export interface IInspectorOptions {
  113096. /**
  113097. * Display in overlay mode (default: false)
  113098. */
  113099. overlay?: boolean;
  113100. /**
  113101. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  113102. */
  113103. globalRoot?: HTMLElement;
  113104. /**
  113105. * Display the Scene explorer
  113106. */
  113107. showExplorer?: boolean;
  113108. /**
  113109. * Display the property inspector
  113110. */
  113111. showInspector?: boolean;
  113112. /**
  113113. * Display in embed mode (both panes on the right)
  113114. */
  113115. embedMode?: boolean;
  113116. /**
  113117. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  113118. */
  113119. handleResize?: boolean;
  113120. /**
  113121. * Allow the panes to popup (default: true)
  113122. */
  113123. enablePopup?: boolean;
  113124. /**
  113125. * Allow the panes to be closed by users (default: true)
  113126. */
  113127. enableClose?: boolean;
  113128. /**
  113129. * Optional list of extensibility entries
  113130. */
  113131. explorerExtensibility?: IExplorerExtensibilityGroup[];
  113132. /**
  113133. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  113134. */
  113135. inspectorURL?: string;
  113136. /**
  113137. * Optional initial tab (default to DebugLayerTab.Properties)
  113138. */
  113139. initialTab?: DebugLayerTab;
  113140. }
  113141. interface Scene {
  113142. /**
  113143. * @hidden
  113144. * Backing field
  113145. */
  113146. _debugLayer: DebugLayer;
  113147. /**
  113148. * Gets the debug layer (aka Inspector) associated with the scene
  113149. * @see http://doc.babylonjs.com/features/playground_debuglayer
  113150. */
  113151. debugLayer: DebugLayer;
  113152. }
  113153. /**
  113154. * Enum of inspector action tab
  113155. */
  113156. export enum DebugLayerTab {
  113157. /**
  113158. * Properties tag (default)
  113159. */
  113160. Properties = 0,
  113161. /**
  113162. * Debug tab
  113163. */
  113164. Debug = 1,
  113165. /**
  113166. * Statistics tab
  113167. */
  113168. Statistics = 2,
  113169. /**
  113170. * Tools tab
  113171. */
  113172. Tools = 3,
  113173. /**
  113174. * Settings tab
  113175. */
  113176. Settings = 4
  113177. }
  113178. /**
  113179. * The debug layer (aka Inspector) is the go to tool in order to better understand
  113180. * what is happening in your scene
  113181. * @see http://doc.babylonjs.com/features/playground_debuglayer
  113182. */
  113183. export class DebugLayer {
  113184. /**
  113185. * Define the url to get the inspector script from.
  113186. * By default it uses the babylonjs CDN.
  113187. * @ignoreNaming
  113188. */
  113189. static InspectorURL: string;
  113190. private _scene;
  113191. private BJSINSPECTOR;
  113192. private _onPropertyChangedObservable?;
  113193. /**
  113194. * Observable triggered when a property is changed through the inspector.
  113195. */
  113196. readonly onPropertyChangedObservable: any;
  113197. /**
  113198. * Instantiates a new debug layer.
  113199. * The debug layer (aka Inspector) is the go to tool in order to better understand
  113200. * what is happening in your scene
  113201. * @see http://doc.babylonjs.com/features/playground_debuglayer
  113202. * @param scene Defines the scene to inspect
  113203. */
  113204. constructor(scene: Scene);
  113205. /** Creates the inspector window. */
  113206. private _createInspector;
  113207. /**
  113208. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  113209. * @param entity defines the entity to select
  113210. * @param lineContainerTitle defines the specific block to highlight
  113211. */
  113212. select(entity: any, lineContainerTitle?: string): void;
  113213. /** Get the inspector from bundle or global */
  113214. private _getGlobalInspector;
  113215. /**
  113216. * Get if the inspector is visible or not.
  113217. * @returns true if visible otherwise, false
  113218. */
  113219. isVisible(): boolean;
  113220. /**
  113221. * Hide the inspector and close its window.
  113222. */
  113223. hide(): void;
  113224. /**
  113225. * Launch the debugLayer.
  113226. * @param config Define the configuration of the inspector
  113227. * @return a promise fulfilled when the debug layer is visible
  113228. */
  113229. show(config?: IInspectorOptions): Promise<DebugLayer>;
  113230. }
  113231. }
  113232. declare module BABYLON {
  113233. /**
  113234. * Class containing static functions to help procedurally build meshes
  113235. */
  113236. export class BoxBuilder {
  113237. /**
  113238. * Creates a box mesh
  113239. * * The parameter `size` sets the size (float) of each box side (default 1)
  113240. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  113241. * * 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)
  113242. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  113243. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113244. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113245. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113246. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  113247. * @param name defines the name of the mesh
  113248. * @param options defines the options used to create the mesh
  113249. * @param scene defines the hosting scene
  113250. * @returns the box mesh
  113251. */
  113252. static CreateBox(name: string, options: {
  113253. size?: number;
  113254. width?: number;
  113255. height?: number;
  113256. depth?: number;
  113257. faceUV?: Vector4[];
  113258. faceColors?: Color4[];
  113259. sideOrientation?: number;
  113260. frontUVs?: Vector4;
  113261. backUVs?: Vector4;
  113262. wrap?: boolean;
  113263. topBaseAt?: number;
  113264. bottomBaseAt?: number;
  113265. updatable?: boolean;
  113266. }, scene?: Nullable<Scene>): Mesh;
  113267. }
  113268. }
  113269. declare module BABYLON {
  113270. /**
  113271. * Class containing static functions to help procedurally build meshes
  113272. */
  113273. export class SphereBuilder {
  113274. /**
  113275. * Creates a sphere mesh
  113276. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  113277. * * 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`)
  113278. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  113279. * * 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
  113280. * * 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)
  113281. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113282. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113283. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113284. * @param name defines the name of the mesh
  113285. * @param options defines the options used to create the mesh
  113286. * @param scene defines the hosting scene
  113287. * @returns the sphere mesh
  113288. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  113289. */
  113290. static CreateSphere(name: string, options: {
  113291. segments?: number;
  113292. diameter?: number;
  113293. diameterX?: number;
  113294. diameterY?: number;
  113295. diameterZ?: number;
  113296. arc?: number;
  113297. slice?: number;
  113298. sideOrientation?: number;
  113299. frontUVs?: Vector4;
  113300. backUVs?: Vector4;
  113301. updatable?: boolean;
  113302. }, scene?: Nullable<Scene>): Mesh;
  113303. }
  113304. }
  113305. declare module BABYLON.Debug {
  113306. /**
  113307. * Used to show the physics impostor around the specific mesh
  113308. */
  113309. export class PhysicsViewer {
  113310. /** @hidden */
  113311. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  113312. /** @hidden */
  113313. protected _meshes: Array<Nullable<AbstractMesh>>;
  113314. /** @hidden */
  113315. protected _scene: Nullable<Scene>;
  113316. /** @hidden */
  113317. protected _numMeshes: number;
  113318. /** @hidden */
  113319. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  113320. private _renderFunction;
  113321. private _utilityLayer;
  113322. private _debugBoxMesh;
  113323. private _debugSphereMesh;
  113324. private _debugCylinderMesh;
  113325. private _debugMaterial;
  113326. private _debugMeshMeshes;
  113327. /**
  113328. * Creates a new PhysicsViewer
  113329. * @param scene defines the hosting scene
  113330. */
  113331. constructor(scene: Scene);
  113332. /** @hidden */
  113333. protected _updateDebugMeshes(): void;
  113334. /**
  113335. * Renders a specified physic impostor
  113336. * @param impostor defines the impostor to render
  113337. * @param targetMesh defines the mesh represented by the impostor
  113338. * @returns the new debug mesh used to render the impostor
  113339. */
  113340. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  113341. /**
  113342. * Hides a specified physic impostor
  113343. * @param impostor defines the impostor to hide
  113344. */
  113345. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  113346. private _getDebugMaterial;
  113347. private _getDebugBoxMesh;
  113348. private _getDebugSphereMesh;
  113349. private _getDebugCylinderMesh;
  113350. private _getDebugMeshMesh;
  113351. private _getDebugMesh;
  113352. /** Releases all resources */
  113353. dispose(): void;
  113354. }
  113355. }
  113356. declare module BABYLON {
  113357. /**
  113358. * Class containing static functions to help procedurally build meshes
  113359. */
  113360. export class LinesBuilder {
  113361. /**
  113362. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  113363. * * 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
  113364. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  113365. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  113366. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  113367. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  113368. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  113369. * * 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
  113370. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  113371. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113372. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  113373. * @param name defines the name of the new line system
  113374. * @param options defines the options used to create the line system
  113375. * @param scene defines the hosting scene
  113376. * @returns a new line system mesh
  113377. */
  113378. static CreateLineSystem(name: string, options: {
  113379. lines: Vector3[][];
  113380. updatable?: boolean;
  113381. instance?: Nullable<LinesMesh>;
  113382. colors?: Nullable<Color4[][]>;
  113383. useVertexAlpha?: boolean;
  113384. }, scene: Nullable<Scene>): LinesMesh;
  113385. /**
  113386. * Creates a line mesh
  113387. * 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
  113388. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  113389. * * The parameter `points` is an array successive Vector3
  113390. * * 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
  113391. * * The optional parameter `colors` is an array of successive Color4, one per line point
  113392. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  113393. * * When updating an instance, remember that only point positions can change, not the number of points
  113394. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113395. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  113396. * @param name defines the name of the new line system
  113397. * @param options defines the options used to create the line system
  113398. * @param scene defines the hosting scene
  113399. * @returns a new line mesh
  113400. */
  113401. static CreateLines(name: string, options: {
  113402. points: Vector3[];
  113403. updatable?: boolean;
  113404. instance?: Nullable<LinesMesh>;
  113405. colors?: Color4[];
  113406. useVertexAlpha?: boolean;
  113407. }, scene?: Nullable<Scene>): LinesMesh;
  113408. /**
  113409. * Creates a dashed line mesh
  113410. * * 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
  113411. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  113412. * * The parameter `points` is an array successive Vector3
  113413. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  113414. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  113415. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  113416. * * 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
  113417. * * When updating an instance, remember that only point positions can change, not the number of points
  113418. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113419. * @param name defines the name of the mesh
  113420. * @param options defines the options used to create the mesh
  113421. * @param scene defines the hosting scene
  113422. * @returns the dashed line mesh
  113423. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  113424. */
  113425. static CreateDashedLines(name: string, options: {
  113426. points: Vector3[];
  113427. dashSize?: number;
  113428. gapSize?: number;
  113429. dashNb?: number;
  113430. updatable?: boolean;
  113431. instance?: LinesMesh;
  113432. }, scene?: Nullable<Scene>): LinesMesh;
  113433. }
  113434. }
  113435. declare module BABYLON {
  113436. /**
  113437. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  113438. * in order to better appreciate the issue one might have.
  113439. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  113440. */
  113441. export class RayHelper {
  113442. /**
  113443. * Defines the ray we are currently tryin to visualize.
  113444. */
  113445. ray: Nullable<Ray>;
  113446. private _renderPoints;
  113447. private _renderLine;
  113448. private _renderFunction;
  113449. private _scene;
  113450. private _updateToMeshFunction;
  113451. private _attachedToMesh;
  113452. private _meshSpaceDirection;
  113453. private _meshSpaceOrigin;
  113454. /**
  113455. * Helper function to create a colored helper in a scene in one line.
  113456. * @param ray Defines the ray we are currently tryin to visualize
  113457. * @param scene Defines the scene the ray is used in
  113458. * @param color Defines the color we want to see the ray in
  113459. * @returns The newly created ray helper.
  113460. */
  113461. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  113462. /**
  113463. * Instantiate a new ray helper.
  113464. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  113465. * in order to better appreciate the issue one might have.
  113466. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  113467. * @param ray Defines the ray we are currently tryin to visualize
  113468. */
  113469. constructor(ray: Ray);
  113470. /**
  113471. * Shows the ray we are willing to debug.
  113472. * @param scene Defines the scene the ray needs to be rendered in
  113473. * @param color Defines the color the ray needs to be rendered in
  113474. */
  113475. show(scene: Scene, color?: Color3): void;
  113476. /**
  113477. * Hides the ray we are debugging.
  113478. */
  113479. hide(): void;
  113480. private _render;
  113481. /**
  113482. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  113483. * @param mesh Defines the mesh we want the helper attached to
  113484. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  113485. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  113486. * @param length Defines the length of the ray
  113487. */
  113488. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  113489. /**
  113490. * Detach the ray helper from the mesh it has previously been attached to.
  113491. */
  113492. detachFromMesh(): void;
  113493. private _updateToMesh;
  113494. /**
  113495. * Dispose the helper and release its associated resources.
  113496. */
  113497. dispose(): void;
  113498. }
  113499. }
  113500. declare module BABYLON.Debug {
  113501. /**
  113502. * Class used to render a debug view of a given skeleton
  113503. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  113504. */
  113505. export class SkeletonViewer {
  113506. /** defines the skeleton to render */
  113507. skeleton: Skeleton;
  113508. /** defines the mesh attached to the skeleton */
  113509. mesh: AbstractMesh;
  113510. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  113511. autoUpdateBonesMatrices: boolean;
  113512. /** defines the rendering group id to use with the viewer */
  113513. renderingGroupId: number;
  113514. /** Gets or sets the color used to render the skeleton */
  113515. color: Color3;
  113516. private _scene;
  113517. private _debugLines;
  113518. private _debugMesh;
  113519. private _isEnabled;
  113520. private _renderFunction;
  113521. private _utilityLayer;
  113522. /**
  113523. * Returns the mesh used to render the bones
  113524. */
  113525. readonly debugMesh: Nullable<LinesMesh>;
  113526. /**
  113527. * Creates a new SkeletonViewer
  113528. * @param skeleton defines the skeleton to render
  113529. * @param mesh defines the mesh attached to the skeleton
  113530. * @param scene defines the hosting scene
  113531. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  113532. * @param renderingGroupId defines the rendering group id to use with the viewer
  113533. */
  113534. constructor(
  113535. /** defines the skeleton to render */
  113536. skeleton: Skeleton,
  113537. /** defines the mesh attached to the skeleton */
  113538. mesh: AbstractMesh, scene: Scene,
  113539. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  113540. autoUpdateBonesMatrices?: boolean,
  113541. /** defines the rendering group id to use with the viewer */
  113542. renderingGroupId?: number);
  113543. /** Gets or sets a boolean indicating if the viewer is enabled */
  113544. isEnabled: boolean;
  113545. private _getBonePosition;
  113546. private _getLinesForBonesWithLength;
  113547. private _getLinesForBonesNoLength;
  113548. /** Update the viewer to sync with current skeleton state */
  113549. update(): void;
  113550. /** Release associated resources */
  113551. dispose(): void;
  113552. }
  113553. }
  113554. declare module BABYLON {
  113555. /**
  113556. * Options to create the null engine
  113557. */
  113558. export class NullEngineOptions {
  113559. /**
  113560. * Render width (Default: 512)
  113561. */
  113562. renderWidth: number;
  113563. /**
  113564. * Render height (Default: 256)
  113565. */
  113566. renderHeight: number;
  113567. /**
  113568. * Texture size (Default: 512)
  113569. */
  113570. textureSize: number;
  113571. /**
  113572. * If delta time between frames should be constant
  113573. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  113574. */
  113575. deterministicLockstep: boolean;
  113576. /**
  113577. * Maximum about of steps between frames (Default: 4)
  113578. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  113579. */
  113580. lockstepMaxSteps: number;
  113581. }
  113582. /**
  113583. * The null engine class provides support for headless version of babylon.js.
  113584. * This can be used in server side scenario or for testing purposes
  113585. */
  113586. export class NullEngine extends Engine {
  113587. private _options;
  113588. /**
  113589. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  113590. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  113591. * @returns true if engine is in deterministic lock step mode
  113592. */
  113593. isDeterministicLockStep(): boolean;
  113594. /**
  113595. * Gets the max steps when engine is running in deterministic lock step
  113596. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  113597. * @returns the max steps
  113598. */
  113599. getLockstepMaxSteps(): number;
  113600. /**
  113601. * Gets the current hardware scaling level.
  113602. * By default the hardware scaling level is computed from the window device ratio.
  113603. * 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.
  113604. * @returns a number indicating the current hardware scaling level
  113605. */
  113606. getHardwareScalingLevel(): number;
  113607. constructor(options?: NullEngineOptions);
  113608. /**
  113609. * Creates a vertex buffer
  113610. * @param vertices the data for the vertex buffer
  113611. * @returns the new WebGL static buffer
  113612. */
  113613. createVertexBuffer(vertices: FloatArray): DataBuffer;
  113614. /**
  113615. * Creates a new index buffer
  113616. * @param indices defines the content of the index buffer
  113617. * @param updatable defines if the index buffer must be updatable
  113618. * @returns a new webGL buffer
  113619. */
  113620. createIndexBuffer(indices: IndicesArray): DataBuffer;
  113621. /**
  113622. * Clear the current render buffer or the current render target (if any is set up)
  113623. * @param color defines the color to use
  113624. * @param backBuffer defines if the back buffer must be cleared
  113625. * @param depth defines if the depth buffer must be cleared
  113626. * @param stencil defines if the stencil buffer must be cleared
  113627. */
  113628. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  113629. /**
  113630. * Gets the current render width
  113631. * @param useScreen defines if screen size must be used (or the current render target if any)
  113632. * @returns a number defining the current render width
  113633. */
  113634. getRenderWidth(useScreen?: boolean): number;
  113635. /**
  113636. * Gets the current render height
  113637. * @param useScreen defines if screen size must be used (or the current render target if any)
  113638. * @returns a number defining the current render height
  113639. */
  113640. getRenderHeight(useScreen?: boolean): number;
  113641. /**
  113642. * Set the WebGL's viewport
  113643. * @param viewport defines the viewport element to be used
  113644. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  113645. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  113646. */
  113647. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  113648. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  113649. /**
  113650. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  113651. * @param pipelineContext defines the pipeline context to use
  113652. * @param uniformsNames defines the list of uniform names
  113653. * @returns an array of webGL uniform locations
  113654. */
  113655. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  113656. /**
  113657. * Gets the lsit of active attributes for a given webGL program
  113658. * @param pipelineContext defines the pipeline context to use
  113659. * @param attributesNames defines the list of attribute names to get
  113660. * @returns an array of indices indicating the offset of each attribute
  113661. */
  113662. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  113663. /**
  113664. * Binds an effect to the webGL context
  113665. * @param effect defines the effect to bind
  113666. */
  113667. bindSamplers(effect: Effect): void;
  113668. /**
  113669. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  113670. * @param effect defines the effect to activate
  113671. */
  113672. enableEffect(effect: Effect): void;
  113673. /**
  113674. * Set various states to the webGL context
  113675. * @param culling defines backface culling state
  113676. * @param zOffset defines the value to apply to zOffset (0 by default)
  113677. * @param force defines if states must be applied even if cache is up to date
  113678. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  113679. */
  113680. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  113681. /**
  113682. * Set the value of an uniform to an array of int32
  113683. * @param uniform defines the webGL uniform location where to store the value
  113684. * @param array defines the array of int32 to store
  113685. */
  113686. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  113687. /**
  113688. * Set the value of an uniform to an array of int32 (stored as vec2)
  113689. * @param uniform defines the webGL uniform location where to store the value
  113690. * @param array defines the array of int32 to store
  113691. */
  113692. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  113693. /**
  113694. * Set the value of an uniform to an array of int32 (stored as vec3)
  113695. * @param uniform defines the webGL uniform location where to store the value
  113696. * @param array defines the array of int32 to store
  113697. */
  113698. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  113699. /**
  113700. * Set the value of an uniform to an array of int32 (stored as vec4)
  113701. * @param uniform defines the webGL uniform location where to store the value
  113702. * @param array defines the array of int32 to store
  113703. */
  113704. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  113705. /**
  113706. * Set the value of an uniform to an array of float32
  113707. * @param uniform defines the webGL uniform location where to store the value
  113708. * @param array defines the array of float32 to store
  113709. */
  113710. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  113711. /**
  113712. * Set the value of an uniform to an array of float32 (stored as vec2)
  113713. * @param uniform defines the webGL uniform location where to store the value
  113714. * @param array defines the array of float32 to store
  113715. */
  113716. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  113717. /**
  113718. * Set the value of an uniform to an array of float32 (stored as vec3)
  113719. * @param uniform defines the webGL uniform location where to store the value
  113720. * @param array defines the array of float32 to store
  113721. */
  113722. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  113723. /**
  113724. * Set the value of an uniform to an array of float32 (stored as vec4)
  113725. * @param uniform defines the webGL uniform location where to store the value
  113726. * @param array defines the array of float32 to store
  113727. */
  113728. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  113729. /**
  113730. * Set the value of an uniform to an array of number
  113731. * @param uniform defines the webGL uniform location where to store the value
  113732. * @param array defines the array of number to store
  113733. */
  113734. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  113735. /**
  113736. * Set the value of an uniform to an array of number (stored as vec2)
  113737. * @param uniform defines the webGL uniform location where to store the value
  113738. * @param array defines the array of number to store
  113739. */
  113740. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  113741. /**
  113742. * Set the value of an uniform to an array of number (stored as vec3)
  113743. * @param uniform defines the webGL uniform location where to store the value
  113744. * @param array defines the array of number to store
  113745. */
  113746. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  113747. /**
  113748. * Set the value of an uniform to an array of number (stored as vec4)
  113749. * @param uniform defines the webGL uniform location where to store the value
  113750. * @param array defines the array of number to store
  113751. */
  113752. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  113753. /**
  113754. * Set the value of an uniform to an array of float32 (stored as matrices)
  113755. * @param uniform defines the webGL uniform location where to store the value
  113756. * @param matrices defines the array of float32 to store
  113757. */
  113758. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  113759. /**
  113760. * Set the value of an uniform to a matrix (3x3)
  113761. * @param uniform defines the webGL uniform location where to store the value
  113762. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  113763. */
  113764. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  113765. /**
  113766. * Set the value of an uniform to a matrix (2x2)
  113767. * @param uniform defines the webGL uniform location where to store the value
  113768. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  113769. */
  113770. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  113771. /**
  113772. * Set the value of an uniform to a number (float)
  113773. * @param uniform defines the webGL uniform location where to store the value
  113774. * @param value defines the float number to store
  113775. */
  113776. setFloat(uniform: WebGLUniformLocation, value: number): void;
  113777. /**
  113778. * Set the value of an uniform to a vec2
  113779. * @param uniform defines the webGL uniform location where to store the value
  113780. * @param x defines the 1st component of the value
  113781. * @param y defines the 2nd component of the value
  113782. */
  113783. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  113784. /**
  113785. * Set the value of an uniform to a vec3
  113786. * @param uniform defines the webGL uniform location where to store the value
  113787. * @param x defines the 1st component of the value
  113788. * @param y defines the 2nd component of the value
  113789. * @param z defines the 3rd component of the value
  113790. */
  113791. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  113792. /**
  113793. * Set the value of an uniform to a boolean
  113794. * @param uniform defines the webGL uniform location where to store the value
  113795. * @param bool defines the boolean to store
  113796. */
  113797. setBool(uniform: WebGLUniformLocation, bool: number): void;
  113798. /**
  113799. * Set the value of an uniform to a vec4
  113800. * @param uniform defines the webGL uniform location where to store the value
  113801. * @param x defines the 1st component of the value
  113802. * @param y defines the 2nd component of the value
  113803. * @param z defines the 3rd component of the value
  113804. * @param w defines the 4th component of the value
  113805. */
  113806. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  113807. /**
  113808. * Sets the current alpha mode
  113809. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  113810. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  113811. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  113812. */
  113813. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  113814. /**
  113815. * Bind webGl buffers directly to the webGL context
  113816. * @param vertexBuffers defines the vertex buffer to bind
  113817. * @param indexBuffer defines the index buffer to bind
  113818. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  113819. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  113820. * @param effect defines the effect associated with the vertex buffer
  113821. */
  113822. bindBuffers(vertexBuffers: {
  113823. [key: string]: VertexBuffer;
  113824. }, indexBuffer: DataBuffer, effect: Effect): void;
  113825. /**
  113826. * Force the entire cache to be cleared
  113827. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  113828. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  113829. */
  113830. wipeCaches(bruteForce?: boolean): void;
  113831. /**
  113832. * Send a draw order
  113833. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  113834. * @param indexStart defines the starting index
  113835. * @param indexCount defines the number of index to draw
  113836. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113837. */
  113838. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  113839. /**
  113840. * Draw a list of indexed primitives
  113841. * @param fillMode defines the primitive to use
  113842. * @param indexStart defines the starting index
  113843. * @param indexCount defines the number of index to draw
  113844. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113845. */
  113846. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  113847. /**
  113848. * Draw a list of unindexed primitives
  113849. * @param fillMode defines the primitive to use
  113850. * @param verticesStart defines the index of first vertex to draw
  113851. * @param verticesCount defines the count of vertices to draw
  113852. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113853. */
  113854. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  113855. /** @hidden */
  113856. _createTexture(): WebGLTexture;
  113857. /** @hidden */
  113858. _releaseTexture(texture: InternalTexture): void;
  113859. /**
  113860. * Usually called from Texture.ts.
  113861. * Passed information to create a WebGLTexture
  113862. * @param urlArg defines a value which contains one of the following:
  113863. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  113864. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  113865. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  113866. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  113867. * @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)
  113868. * @param scene needed for loading to the correct scene
  113869. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  113870. * @param onLoad optional callback to be called upon successful completion
  113871. * @param onError optional callback to be called upon failure
  113872. * @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
  113873. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  113874. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  113875. * @param forcedExtension defines the extension to use to pick the right loader
  113876. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  113877. * @returns a InternalTexture for assignment back into BABYLON.Texture
  113878. */
  113879. 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;
  113880. /**
  113881. * Creates a new render target texture
  113882. * @param size defines the size of the texture
  113883. * @param options defines the options used to create the texture
  113884. * @returns a new render target texture stored in an InternalTexture
  113885. */
  113886. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  113887. /**
  113888. * Update the sampling mode of a given texture
  113889. * @param samplingMode defines the required sampling mode
  113890. * @param texture defines the texture to update
  113891. */
  113892. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  113893. /**
  113894. * Binds the frame buffer to the specified texture.
  113895. * @param texture The texture to render to or null for the default canvas
  113896. * @param faceIndex The face of the texture to render to in case of cube texture
  113897. * @param requiredWidth The width of the target to render to
  113898. * @param requiredHeight The height of the target to render to
  113899. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  113900. * @param depthStencilTexture The depth stencil texture to use to render
  113901. * @param lodLevel defines le lod level to bind to the frame buffer
  113902. */
  113903. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  113904. /**
  113905. * Unbind the current render target texture from the webGL context
  113906. * @param texture defines the render target texture to unbind
  113907. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  113908. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  113909. */
  113910. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  113911. /**
  113912. * Creates a dynamic vertex buffer
  113913. * @param vertices the data for the dynamic vertex buffer
  113914. * @returns the new WebGL dynamic buffer
  113915. */
  113916. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  113917. /**
  113918. * Update the content of a dynamic texture
  113919. * @param texture defines the texture to update
  113920. * @param canvas defines the canvas containing the source
  113921. * @param invertY defines if data must be stored with Y axis inverted
  113922. * @param premulAlpha defines if alpha is stored as premultiplied
  113923. * @param format defines the format of the data
  113924. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  113925. */
  113926. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  113927. /**
  113928. * Gets a boolean indicating if all created effects are ready
  113929. * @returns true if all effects are ready
  113930. */
  113931. areAllEffectsReady(): boolean;
  113932. /**
  113933. * @hidden
  113934. * Get the current error code of the webGL context
  113935. * @returns the error code
  113936. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  113937. */
  113938. getError(): number;
  113939. /** @hidden */
  113940. _getUnpackAlignement(): number;
  113941. /** @hidden */
  113942. _unpackFlipY(value: boolean): void;
  113943. /**
  113944. * Update a dynamic index buffer
  113945. * @param indexBuffer defines the target index buffer
  113946. * @param indices defines the data to update
  113947. * @param offset defines the offset in the target index buffer where update should start
  113948. */
  113949. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  113950. /**
  113951. * Updates a dynamic vertex buffer.
  113952. * @param vertexBuffer the vertex buffer to update
  113953. * @param vertices the data used to update the vertex buffer
  113954. * @param byteOffset the byte offset of the data (optional)
  113955. * @param byteLength the byte length of the data (optional)
  113956. */
  113957. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  113958. /** @hidden */
  113959. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  113960. /** @hidden */
  113961. _bindTexture(channel: number, texture: InternalTexture): void;
  113962. protected _deleteBuffer(buffer: WebGLBuffer): void;
  113963. /**
  113964. * 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
  113965. */
  113966. releaseEffects(): void;
  113967. displayLoadingUI(): void;
  113968. hideLoadingUI(): void;
  113969. /** @hidden */
  113970. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113971. /** @hidden */
  113972. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113973. /** @hidden */
  113974. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113975. /** @hidden */
  113976. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  113977. }
  113978. }
  113979. declare module BABYLON {
  113980. /** @hidden */
  113981. export class _OcclusionDataStorage {
  113982. /** @hidden */
  113983. occlusionInternalRetryCounter: number;
  113984. /** @hidden */
  113985. isOcclusionQueryInProgress: boolean;
  113986. /** @hidden */
  113987. isOccluded: boolean;
  113988. /** @hidden */
  113989. occlusionRetryCount: number;
  113990. /** @hidden */
  113991. occlusionType: number;
  113992. /** @hidden */
  113993. occlusionQueryAlgorithmType: number;
  113994. }
  113995. interface Engine {
  113996. /**
  113997. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  113998. * @return the new query
  113999. */
  114000. createQuery(): WebGLQuery;
  114001. /**
  114002. * Delete and release a webGL query
  114003. * @param query defines the query to delete
  114004. * @return the current engine
  114005. */
  114006. deleteQuery(query: WebGLQuery): Engine;
  114007. /**
  114008. * Check if a given query has resolved and got its value
  114009. * @param query defines the query to check
  114010. * @returns true if the query got its value
  114011. */
  114012. isQueryResultAvailable(query: WebGLQuery): boolean;
  114013. /**
  114014. * Gets the value of a given query
  114015. * @param query defines the query to check
  114016. * @returns the value of the query
  114017. */
  114018. getQueryResult(query: WebGLQuery): number;
  114019. /**
  114020. * Initiates an occlusion query
  114021. * @param algorithmType defines the algorithm to use
  114022. * @param query defines the query to use
  114023. * @returns the current engine
  114024. * @see http://doc.babylonjs.com/features/occlusionquery
  114025. */
  114026. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  114027. /**
  114028. * Ends an occlusion query
  114029. * @see http://doc.babylonjs.com/features/occlusionquery
  114030. * @param algorithmType defines the algorithm to use
  114031. * @returns the current engine
  114032. */
  114033. endOcclusionQuery(algorithmType: number): Engine;
  114034. /**
  114035. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  114036. * Please note that only one query can be issued at a time
  114037. * @returns a time token used to track the time span
  114038. */
  114039. startTimeQuery(): Nullable<_TimeToken>;
  114040. /**
  114041. * Ends a time query
  114042. * @param token defines the token used to measure the time span
  114043. * @returns the time spent (in ns)
  114044. */
  114045. endTimeQuery(token: _TimeToken): int;
  114046. /** @hidden */
  114047. _currentNonTimestampToken: Nullable<_TimeToken>;
  114048. /** @hidden */
  114049. _createTimeQuery(): WebGLQuery;
  114050. /** @hidden */
  114051. _deleteTimeQuery(query: WebGLQuery): void;
  114052. /** @hidden */
  114053. _getGlAlgorithmType(algorithmType: number): number;
  114054. /** @hidden */
  114055. _getTimeQueryResult(query: WebGLQuery): any;
  114056. /** @hidden */
  114057. _getTimeQueryAvailability(query: WebGLQuery): any;
  114058. }
  114059. interface AbstractMesh {
  114060. /**
  114061. * Backing filed
  114062. * @hidden
  114063. */
  114064. __occlusionDataStorage: _OcclusionDataStorage;
  114065. /**
  114066. * Access property
  114067. * @hidden
  114068. */
  114069. _occlusionDataStorage: _OcclusionDataStorage;
  114070. /**
  114071. * 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.
  114072. * The default value is -1 which means don't break the query and wait till the result
  114073. * @see http://doc.babylonjs.com/features/occlusionquery
  114074. */
  114075. occlusionRetryCount: number;
  114076. /**
  114077. * 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:
  114078. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  114079. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  114080. * * 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.
  114081. * @see http://doc.babylonjs.com/features/occlusionquery
  114082. */
  114083. occlusionType: number;
  114084. /**
  114085. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  114086. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  114087. * * 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.
  114088. * @see http://doc.babylonjs.com/features/occlusionquery
  114089. */
  114090. occlusionQueryAlgorithmType: number;
  114091. /**
  114092. * 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
  114093. * @see http://doc.babylonjs.com/features/occlusionquery
  114094. */
  114095. isOccluded: boolean;
  114096. /**
  114097. * Flag to check the progress status of the query
  114098. * @see http://doc.babylonjs.com/features/occlusionquery
  114099. */
  114100. isOcclusionQueryInProgress: boolean;
  114101. }
  114102. }
  114103. declare module BABYLON {
  114104. /** @hidden */
  114105. export var _forceTransformFeedbackToBundle: boolean;
  114106. interface Engine {
  114107. /**
  114108. * Creates a webGL transform feedback object
  114109. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  114110. * @returns the webGL transform feedback object
  114111. */
  114112. createTransformFeedback(): WebGLTransformFeedback;
  114113. /**
  114114. * Delete a webGL transform feedback object
  114115. * @param value defines the webGL transform feedback object to delete
  114116. */
  114117. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  114118. /**
  114119. * Bind a webGL transform feedback object to the webgl context
  114120. * @param value defines the webGL transform feedback object to bind
  114121. */
  114122. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  114123. /**
  114124. * Begins a transform feedback operation
  114125. * @param usePoints defines if points or triangles must be used
  114126. */
  114127. beginTransformFeedback(usePoints: boolean): void;
  114128. /**
  114129. * Ends a transform feedback operation
  114130. */
  114131. endTransformFeedback(): void;
  114132. /**
  114133. * Specify the varyings to use with transform feedback
  114134. * @param program defines the associated webGL program
  114135. * @param value defines the list of strings representing the varying names
  114136. */
  114137. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  114138. /**
  114139. * Bind a webGL buffer for a transform feedback operation
  114140. * @param value defines the webGL buffer to bind
  114141. */
  114142. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  114143. }
  114144. }
  114145. declare module BABYLON {
  114146. /**
  114147. * Creation options of the multi render target texture.
  114148. */
  114149. export interface IMultiRenderTargetOptions {
  114150. /**
  114151. * Define if the texture needs to create mip maps after render.
  114152. */
  114153. generateMipMaps?: boolean;
  114154. /**
  114155. * Define the types of all the draw buffers we want to create
  114156. */
  114157. types?: number[];
  114158. /**
  114159. * Define the sampling modes of all the draw buffers we want to create
  114160. */
  114161. samplingModes?: number[];
  114162. /**
  114163. * Define if a depth buffer is required
  114164. */
  114165. generateDepthBuffer?: boolean;
  114166. /**
  114167. * Define if a stencil buffer is required
  114168. */
  114169. generateStencilBuffer?: boolean;
  114170. /**
  114171. * Define if a depth texture is required instead of a depth buffer
  114172. */
  114173. generateDepthTexture?: boolean;
  114174. /**
  114175. * Define the number of desired draw buffers
  114176. */
  114177. textureCount?: number;
  114178. /**
  114179. * Define if aspect ratio should be adapted to the texture or stay the scene one
  114180. */
  114181. doNotChangeAspectRatio?: boolean;
  114182. /**
  114183. * Define the default type of the buffers we are creating
  114184. */
  114185. defaultType?: number;
  114186. }
  114187. /**
  114188. * A multi render target, like a render target provides the ability to render to a texture.
  114189. * Unlike the render target, it can render to several draw buffers in one draw.
  114190. * This is specially interesting in deferred rendering or for any effects requiring more than
  114191. * just one color from a single pass.
  114192. */
  114193. export class MultiRenderTarget extends RenderTargetTexture {
  114194. private _internalTextures;
  114195. private _textures;
  114196. private _multiRenderTargetOptions;
  114197. /**
  114198. * Get if draw buffers are currently supported by the used hardware and browser.
  114199. */
  114200. readonly isSupported: boolean;
  114201. /**
  114202. * Get the list of textures generated by the multi render target.
  114203. */
  114204. readonly textures: Texture[];
  114205. /**
  114206. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  114207. */
  114208. readonly depthTexture: Texture;
  114209. /**
  114210. * Set the wrapping mode on U of all the textures we are rendering to.
  114211. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  114212. */
  114213. wrapU: number;
  114214. /**
  114215. * Set the wrapping mode on V of all the textures we are rendering to.
  114216. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  114217. */
  114218. wrapV: number;
  114219. /**
  114220. * Instantiate a new multi render target texture.
  114221. * A multi render target, like a render target provides the ability to render to a texture.
  114222. * Unlike the render target, it can render to several draw buffers in one draw.
  114223. * This is specially interesting in deferred rendering or for any effects requiring more than
  114224. * just one color from a single pass.
  114225. * @param name Define the name of the texture
  114226. * @param size Define the size of the buffers to render to
  114227. * @param count Define the number of target we are rendering into
  114228. * @param scene Define the scene the texture belongs to
  114229. * @param options Define the options used to create the multi render target
  114230. */
  114231. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  114232. /** @hidden */
  114233. _rebuild(): void;
  114234. private _createInternalTextures;
  114235. private _createTextures;
  114236. /**
  114237. * Define the number of samples used if MSAA is enabled.
  114238. */
  114239. samples: number;
  114240. /**
  114241. * Resize all the textures in the multi render target.
  114242. * Be carrefull as it will recreate all the data in the new texture.
  114243. * @param size Define the new size
  114244. */
  114245. resize(size: any): void;
  114246. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  114247. /**
  114248. * Dispose the render targets and their associated resources
  114249. */
  114250. dispose(): void;
  114251. /**
  114252. * Release all the underlying texture used as draw buffers.
  114253. */
  114254. releaseInternalTextures(): void;
  114255. }
  114256. }
  114257. declare module BABYLON {
  114258. interface ThinEngine {
  114259. /**
  114260. * Unbind a list of render target textures from the webGL context
  114261. * This is used only when drawBuffer extension or webGL2 are active
  114262. * @param textures defines the render target textures to unbind
  114263. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  114264. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  114265. */
  114266. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  114267. /**
  114268. * Create a multi render target texture
  114269. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  114270. * @param size defines the size of the texture
  114271. * @param options defines the creation options
  114272. * @returns the cube texture as an InternalTexture
  114273. */
  114274. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  114275. /**
  114276. * Update the sample count for a given multiple render target texture
  114277. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  114278. * @param textures defines the textures to update
  114279. * @param samples defines the sample count to set
  114280. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  114281. */
  114282. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  114283. }
  114284. }
  114285. declare module BABYLON {
  114286. /**
  114287. * Class used to define an additional view for the engine
  114288. * @see https://doc.babylonjs.com/how_to/multi_canvases
  114289. */
  114290. export class EngineView {
  114291. /** Defines the canvas where to render the view */
  114292. target: HTMLCanvasElement;
  114293. /** Defines an optional camera used to render the view (will use active camera else) */
  114294. camera?: Camera;
  114295. }
  114296. interface Engine {
  114297. /**
  114298. * Gets or sets the HTML element to use for attaching events
  114299. */
  114300. inputElement: Nullable<HTMLElement>;
  114301. /**
  114302. * Gets the current engine view
  114303. * @see https://doc.babylonjs.com/how_to/multi_canvases
  114304. */
  114305. activeView: Nullable<EngineView>;
  114306. /** Gets or sets the list of views */
  114307. views: EngineView[];
  114308. /**
  114309. * Register a new child canvas
  114310. * @param canvas defines the canvas to register
  114311. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  114312. * @returns the associated view
  114313. */
  114314. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  114315. /**
  114316. * Remove a registered child canvas
  114317. * @param canvas defines the canvas to remove
  114318. * @returns the current engine
  114319. */
  114320. unRegisterView(canvas: HTMLCanvasElement): Engine;
  114321. }
  114322. }
  114323. declare module BABYLON {
  114324. /**
  114325. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  114326. */
  114327. export interface CubeMapInfo {
  114328. /**
  114329. * The pixel array for the front face.
  114330. * This is stored in format, left to right, up to down format.
  114331. */
  114332. front: Nullable<ArrayBufferView>;
  114333. /**
  114334. * The pixel array for the back face.
  114335. * This is stored in format, left to right, up to down format.
  114336. */
  114337. back: Nullable<ArrayBufferView>;
  114338. /**
  114339. * The pixel array for the left face.
  114340. * This is stored in format, left to right, up to down format.
  114341. */
  114342. left: Nullable<ArrayBufferView>;
  114343. /**
  114344. * The pixel array for the right face.
  114345. * This is stored in format, left to right, up to down format.
  114346. */
  114347. right: Nullable<ArrayBufferView>;
  114348. /**
  114349. * The pixel array for the up face.
  114350. * This is stored in format, left to right, up to down format.
  114351. */
  114352. up: Nullable<ArrayBufferView>;
  114353. /**
  114354. * The pixel array for the down face.
  114355. * This is stored in format, left to right, up to down format.
  114356. */
  114357. down: Nullable<ArrayBufferView>;
  114358. /**
  114359. * The size of the cubemap stored.
  114360. *
  114361. * Each faces will be size * size pixels.
  114362. */
  114363. size: number;
  114364. /**
  114365. * The format of the texture.
  114366. *
  114367. * RGBA, RGB.
  114368. */
  114369. format: number;
  114370. /**
  114371. * The type of the texture data.
  114372. *
  114373. * UNSIGNED_INT, FLOAT.
  114374. */
  114375. type: number;
  114376. /**
  114377. * Specifies whether the texture is in gamma space.
  114378. */
  114379. gammaSpace: boolean;
  114380. }
  114381. /**
  114382. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  114383. */
  114384. export class PanoramaToCubeMapTools {
  114385. private static FACE_FRONT;
  114386. private static FACE_BACK;
  114387. private static FACE_RIGHT;
  114388. private static FACE_LEFT;
  114389. private static FACE_DOWN;
  114390. private static FACE_UP;
  114391. /**
  114392. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  114393. *
  114394. * @param float32Array The source data.
  114395. * @param inputWidth The width of the input panorama.
  114396. * @param inputHeight The height of the input panorama.
  114397. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  114398. * @return The cubemap data
  114399. */
  114400. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  114401. private static CreateCubemapTexture;
  114402. private static CalcProjectionSpherical;
  114403. }
  114404. }
  114405. declare module BABYLON {
  114406. /**
  114407. * Helper class dealing with the extraction of spherical polynomial dataArray
  114408. * from a cube map.
  114409. */
  114410. export class CubeMapToSphericalPolynomialTools {
  114411. private static FileFaces;
  114412. /**
  114413. * Converts a texture to the according Spherical Polynomial data.
  114414. * This extracts the first 3 orders only as they are the only one used in the lighting.
  114415. *
  114416. * @param texture The texture to extract the information from.
  114417. * @return The Spherical Polynomial data.
  114418. */
  114419. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  114420. /**
  114421. * Converts a cubemap to the according Spherical Polynomial data.
  114422. * This extracts the first 3 orders only as they are the only one used in the lighting.
  114423. *
  114424. * @param cubeInfo The Cube map to extract the information from.
  114425. * @return The Spherical Polynomial data.
  114426. */
  114427. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  114428. }
  114429. }
  114430. declare module BABYLON {
  114431. interface BaseTexture {
  114432. /**
  114433. * Get the polynomial representation of the texture data.
  114434. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  114435. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  114436. */
  114437. sphericalPolynomial: Nullable<SphericalPolynomial>;
  114438. }
  114439. }
  114440. declare module BABYLON {
  114441. /** @hidden */
  114442. export var rgbdEncodePixelShader: {
  114443. name: string;
  114444. shader: string;
  114445. };
  114446. }
  114447. declare module BABYLON {
  114448. /** @hidden */
  114449. export var rgbdDecodePixelShader: {
  114450. name: string;
  114451. shader: string;
  114452. };
  114453. }
  114454. declare module BABYLON {
  114455. /**
  114456. * Raw texture data and descriptor sufficient for WebGL texture upload
  114457. */
  114458. export interface EnvironmentTextureInfo {
  114459. /**
  114460. * Version of the environment map
  114461. */
  114462. version: number;
  114463. /**
  114464. * Width of image
  114465. */
  114466. width: number;
  114467. /**
  114468. * Irradiance information stored in the file.
  114469. */
  114470. irradiance: any;
  114471. /**
  114472. * Specular information stored in the file.
  114473. */
  114474. specular: any;
  114475. }
  114476. /**
  114477. * Defines One Image in the file. It requires only the position in the file
  114478. * as well as the length.
  114479. */
  114480. interface BufferImageData {
  114481. /**
  114482. * Length of the image data.
  114483. */
  114484. length: number;
  114485. /**
  114486. * Position of the data from the null terminator delimiting the end of the JSON.
  114487. */
  114488. position: number;
  114489. }
  114490. /**
  114491. * Defines the specular data enclosed in the file.
  114492. * This corresponds to the version 1 of the data.
  114493. */
  114494. export interface EnvironmentTextureSpecularInfoV1 {
  114495. /**
  114496. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  114497. */
  114498. specularDataPosition?: number;
  114499. /**
  114500. * This contains all the images data needed to reconstruct the cubemap.
  114501. */
  114502. mipmaps: Array<BufferImageData>;
  114503. /**
  114504. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  114505. */
  114506. lodGenerationScale: number;
  114507. }
  114508. /**
  114509. * Sets of helpers addressing the serialization and deserialization of environment texture
  114510. * stored in a BabylonJS env file.
  114511. * Those files are usually stored as .env files.
  114512. */
  114513. export class EnvironmentTextureTools {
  114514. /**
  114515. * Magic number identifying the env file.
  114516. */
  114517. private static _MagicBytes;
  114518. /**
  114519. * Gets the environment info from an env file.
  114520. * @param data The array buffer containing the .env bytes.
  114521. * @returns the environment file info (the json header) if successfully parsed.
  114522. */
  114523. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  114524. /**
  114525. * Creates an environment texture from a loaded cube texture.
  114526. * @param texture defines the cube texture to convert in env file
  114527. * @return a promise containing the environment data if succesfull.
  114528. */
  114529. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  114530. /**
  114531. * Creates a JSON representation of the spherical data.
  114532. * @param texture defines the texture containing the polynomials
  114533. * @return the JSON representation of the spherical info
  114534. */
  114535. private static _CreateEnvTextureIrradiance;
  114536. /**
  114537. * Creates the ArrayBufferViews used for initializing environment texture image data.
  114538. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  114539. * @param info parameters that determine what views will be created for accessing the underlying buffer
  114540. * @return the views described by info providing access to the underlying buffer
  114541. */
  114542. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  114543. /**
  114544. * Uploads the texture info contained in the env file to the GPU.
  114545. * @param texture defines the internal texture to upload to
  114546. * @param arrayBuffer defines the buffer cotaining the data to load
  114547. * @param info defines the texture info retrieved through the GetEnvInfo method
  114548. * @returns a promise
  114549. */
  114550. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  114551. private static _OnImageReadyAsync;
  114552. /**
  114553. * Uploads the levels of image data to the GPU.
  114554. * @param texture defines the internal texture to upload to
  114555. * @param imageData defines the array buffer views of image data [mipmap][face]
  114556. * @returns a promise
  114557. */
  114558. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  114559. /**
  114560. * Uploads spherical polynomials information to the texture.
  114561. * @param texture defines the texture we are trying to upload the information to
  114562. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  114563. */
  114564. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  114565. /** @hidden */
  114566. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  114567. }
  114568. }
  114569. declare module BABYLON {
  114570. /**
  114571. * Contains position and normal vectors for a vertex
  114572. */
  114573. export class PositionNormalVertex {
  114574. /** the position of the vertex (defaut: 0,0,0) */
  114575. position: Vector3;
  114576. /** the normal of the vertex (defaut: 0,1,0) */
  114577. normal: Vector3;
  114578. /**
  114579. * Creates a PositionNormalVertex
  114580. * @param position the position of the vertex (defaut: 0,0,0)
  114581. * @param normal the normal of the vertex (defaut: 0,1,0)
  114582. */
  114583. constructor(
  114584. /** the position of the vertex (defaut: 0,0,0) */
  114585. position?: Vector3,
  114586. /** the normal of the vertex (defaut: 0,1,0) */
  114587. normal?: Vector3);
  114588. /**
  114589. * Clones the PositionNormalVertex
  114590. * @returns the cloned PositionNormalVertex
  114591. */
  114592. clone(): PositionNormalVertex;
  114593. }
  114594. /**
  114595. * Contains position, normal and uv vectors for a vertex
  114596. */
  114597. export class PositionNormalTextureVertex {
  114598. /** the position of the vertex (defaut: 0,0,0) */
  114599. position: Vector3;
  114600. /** the normal of the vertex (defaut: 0,1,0) */
  114601. normal: Vector3;
  114602. /** the uv of the vertex (default: 0,0) */
  114603. uv: Vector2;
  114604. /**
  114605. * Creates a PositionNormalTextureVertex
  114606. * @param position the position of the vertex (defaut: 0,0,0)
  114607. * @param normal the normal of the vertex (defaut: 0,1,0)
  114608. * @param uv the uv of the vertex (default: 0,0)
  114609. */
  114610. constructor(
  114611. /** the position of the vertex (defaut: 0,0,0) */
  114612. position?: Vector3,
  114613. /** the normal of the vertex (defaut: 0,1,0) */
  114614. normal?: Vector3,
  114615. /** the uv of the vertex (default: 0,0) */
  114616. uv?: Vector2);
  114617. /**
  114618. * Clones the PositionNormalTextureVertex
  114619. * @returns the cloned PositionNormalTextureVertex
  114620. */
  114621. clone(): PositionNormalTextureVertex;
  114622. }
  114623. }
  114624. declare module BABYLON {
  114625. /** @hidden */
  114626. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  114627. private _genericAttributeLocation;
  114628. private _varyingLocationCount;
  114629. private _varyingLocationMap;
  114630. private _replacements;
  114631. private _textureCount;
  114632. private _uniforms;
  114633. lineProcessor(line: string): string;
  114634. attributeProcessor(attribute: string): string;
  114635. varyingProcessor(varying: string, isFragment: boolean): string;
  114636. uniformProcessor(uniform: string): string;
  114637. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  114638. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  114639. }
  114640. }
  114641. declare module BABYLON {
  114642. /**
  114643. * Container for accessors for natively-stored mesh data buffers.
  114644. */
  114645. class NativeDataBuffer extends DataBuffer {
  114646. /**
  114647. * Accessor value used to identify/retrieve a natively-stored index buffer.
  114648. */
  114649. nativeIndexBuffer?: any;
  114650. /**
  114651. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  114652. */
  114653. nativeVertexBuffer?: any;
  114654. }
  114655. /** @hidden */
  114656. class NativeTexture extends InternalTexture {
  114657. getInternalTexture(): InternalTexture;
  114658. getViewCount(): number;
  114659. }
  114660. /** @hidden */
  114661. export class NativeEngine extends Engine {
  114662. private readonly _native;
  114663. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  114664. private readonly INVALID_HANDLE;
  114665. getHardwareScalingLevel(): number;
  114666. constructor();
  114667. /**
  114668. * Can be used to override the current requestAnimationFrame requester.
  114669. * @hidden
  114670. */
  114671. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  114672. /**
  114673. * Override default engine behavior.
  114674. * @param color
  114675. * @param backBuffer
  114676. * @param depth
  114677. * @param stencil
  114678. */
  114679. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  114680. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  114681. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  114682. createVertexBuffer(data: DataArray): NativeDataBuffer;
  114683. recordVertexArrayObject(vertexBuffers: {
  114684. [key: string]: VertexBuffer;
  114685. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  114686. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  114687. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  114688. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  114689. /**
  114690. * Draw a list of indexed primitives
  114691. * @param fillMode defines the primitive to use
  114692. * @param indexStart defines the starting index
  114693. * @param indexCount defines the number of index to draw
  114694. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114695. */
  114696. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  114697. /**
  114698. * Draw a list of unindexed primitives
  114699. * @param fillMode defines the primitive to use
  114700. * @param verticesStart defines the index of first vertex to draw
  114701. * @param verticesCount defines the count of vertices to draw
  114702. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114703. */
  114704. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  114705. createPipelineContext(): IPipelineContext;
  114706. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  114707. /** @hidden */
  114708. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  114709. /** @hidden */
  114710. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  114711. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  114712. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  114713. protected _setProgram(program: WebGLProgram): void;
  114714. _releaseEffect(effect: Effect): void;
  114715. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  114716. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  114717. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  114718. bindSamplers(effect: Effect): void;
  114719. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  114720. getRenderWidth(useScreen?: boolean): number;
  114721. getRenderHeight(useScreen?: boolean): number;
  114722. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  114723. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  114724. /**
  114725. * Set the z offset to apply to current rendering
  114726. * @param value defines the offset to apply
  114727. */
  114728. setZOffset(value: number): void;
  114729. /**
  114730. * Gets the current value of the zOffset
  114731. * @returns the current zOffset state
  114732. */
  114733. getZOffset(): number;
  114734. /**
  114735. * Enable or disable depth buffering
  114736. * @param enable defines the state to set
  114737. */
  114738. setDepthBuffer(enable: boolean): void;
  114739. /**
  114740. * Gets a boolean indicating if depth writing is enabled
  114741. * @returns the current depth writing state
  114742. */
  114743. getDepthWrite(): boolean;
  114744. /**
  114745. * Enable or disable depth writing
  114746. * @param enable defines the state to set
  114747. */
  114748. setDepthWrite(enable: boolean): void;
  114749. /**
  114750. * Enable or disable color writing
  114751. * @param enable defines the state to set
  114752. */
  114753. setColorWrite(enable: boolean): void;
  114754. /**
  114755. * Gets a boolean indicating if color writing is enabled
  114756. * @returns the current color writing state
  114757. */
  114758. getColorWrite(): boolean;
  114759. /**
  114760. * Sets alpha constants used by some alpha blending modes
  114761. * @param r defines the red component
  114762. * @param g defines the green component
  114763. * @param b defines the blue component
  114764. * @param a defines the alpha component
  114765. */
  114766. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  114767. /**
  114768. * Sets the current alpha mode
  114769. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  114770. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  114771. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  114772. */
  114773. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  114774. /**
  114775. * Gets the current alpha mode
  114776. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  114777. * @returns the current alpha mode
  114778. */
  114779. getAlphaMode(): number;
  114780. setInt(uniform: WebGLUniformLocation, int: number): void;
  114781. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  114782. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  114783. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  114784. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  114785. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  114786. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  114787. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  114788. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  114789. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  114790. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  114791. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  114792. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  114793. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  114794. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  114795. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  114796. setFloat(uniform: WebGLUniformLocation, value: number): void;
  114797. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  114798. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  114799. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  114800. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  114801. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  114802. wipeCaches(bruteForce?: boolean): void;
  114803. _createTexture(): WebGLTexture;
  114804. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  114805. /**
  114806. * Usually called from BABYLON.Texture.ts.
  114807. * Passed information to create a WebGLTexture
  114808. * @param urlArg defines a value which contains one of the following:
  114809. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  114810. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  114811. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  114812. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  114813. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  114814. * @param scene needed for loading to the correct scene
  114815. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  114816. * @param onLoad optional callback to be called upon successful completion
  114817. * @param onError optional callback to be called upon failure
  114818. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  114819. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  114820. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  114821. * @param forcedExtension defines the extension to use to pick the right loader
  114822. * @returns a InternalTexture for assignment back into BABYLON.Texture
  114823. */
  114824. 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;
  114825. /**
  114826. * Creates a cube texture
  114827. * @param rootUrl defines the url where the files to load is located
  114828. * @param scene defines the current scene
  114829. * @param files defines the list of files to load (1 per face)
  114830. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  114831. * @param onLoad defines an optional callback raised when the texture is loaded
  114832. * @param onError defines an optional callback raised if there is an issue to load the texture
  114833. * @param format defines the format of the data
  114834. * @param forcedExtension defines the extension to use to pick the right loader
  114835. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  114836. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  114837. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  114838. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  114839. * @returns the cube texture as an InternalTexture
  114840. */
  114841. 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;
  114842. private _getSamplingFilter;
  114843. private static _GetNativeTextureFormat;
  114844. createRenderTargetTexture(size: number | {
  114845. width: number;
  114846. height: number;
  114847. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  114848. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  114849. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  114850. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  114851. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  114852. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  114853. /**
  114854. * Updates a dynamic vertex buffer.
  114855. * @param vertexBuffer the vertex buffer to update
  114856. * @param data the data used to update the vertex buffer
  114857. * @param byteOffset the byte offset of the data (optional)
  114858. * @param byteLength the byte length of the data (optional)
  114859. */
  114860. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  114861. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  114862. private _updateAnisotropicLevel;
  114863. private _getAddressMode;
  114864. /** @hidden */
  114865. _bindTexture(channel: number, texture: InternalTexture): void;
  114866. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  114867. releaseEffects(): void;
  114868. /** @hidden */
  114869. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  114870. /** @hidden */
  114871. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  114872. /** @hidden */
  114873. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  114874. /** @hidden */
  114875. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  114876. }
  114877. }
  114878. declare module BABYLON {
  114879. /**
  114880. * Gather the list of clipboard event types as constants.
  114881. */
  114882. export class ClipboardEventTypes {
  114883. /**
  114884. * The clipboard event is fired when a copy command is active (pressed).
  114885. */
  114886. static readonly COPY: number;
  114887. /**
  114888. * The clipboard event is fired when a cut command is active (pressed).
  114889. */
  114890. static readonly CUT: number;
  114891. /**
  114892. * The clipboard event is fired when a paste command is active (pressed).
  114893. */
  114894. static readonly PASTE: number;
  114895. }
  114896. /**
  114897. * This class is used to store clipboard related info for the onClipboardObservable event.
  114898. */
  114899. export class ClipboardInfo {
  114900. /**
  114901. * Defines the type of event (BABYLON.ClipboardEventTypes)
  114902. */
  114903. type: number;
  114904. /**
  114905. * Defines the related dom event
  114906. */
  114907. event: ClipboardEvent;
  114908. /**
  114909. *Creates an instance of ClipboardInfo.
  114910. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  114911. * @param event Defines the related dom event
  114912. */
  114913. constructor(
  114914. /**
  114915. * Defines the type of event (BABYLON.ClipboardEventTypes)
  114916. */
  114917. type: number,
  114918. /**
  114919. * Defines the related dom event
  114920. */
  114921. event: ClipboardEvent);
  114922. /**
  114923. * Get the clipboard event's type from the keycode.
  114924. * @param keyCode Defines the keyCode for the current keyboard event.
  114925. * @return {number}
  114926. */
  114927. static GetTypeFromCharacter(keyCode: number): number;
  114928. }
  114929. }
  114930. declare module BABYLON {
  114931. /**
  114932. * Google Daydream controller
  114933. */
  114934. export class DaydreamController extends WebVRController {
  114935. /**
  114936. * Base Url for the controller model.
  114937. */
  114938. static MODEL_BASE_URL: string;
  114939. /**
  114940. * File name for the controller model.
  114941. */
  114942. static MODEL_FILENAME: string;
  114943. /**
  114944. * Gamepad Id prefix used to identify Daydream Controller.
  114945. */
  114946. static readonly GAMEPAD_ID_PREFIX: string;
  114947. /**
  114948. * Creates a new DaydreamController from a gamepad
  114949. * @param vrGamepad the gamepad that the controller should be created from
  114950. */
  114951. constructor(vrGamepad: any);
  114952. /**
  114953. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  114954. * @param scene scene in which to add meshes
  114955. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  114956. */
  114957. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  114958. /**
  114959. * Called once for each button that changed state since the last frame
  114960. * @param buttonIdx Which button index changed
  114961. * @param state New state of the button
  114962. * @param changes Which properties on the state changed since last frame
  114963. */
  114964. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  114965. }
  114966. }
  114967. declare module BABYLON {
  114968. /**
  114969. * Gear VR Controller
  114970. */
  114971. export class GearVRController extends WebVRController {
  114972. /**
  114973. * Base Url for the controller model.
  114974. */
  114975. static MODEL_BASE_URL: string;
  114976. /**
  114977. * File name for the controller model.
  114978. */
  114979. static MODEL_FILENAME: string;
  114980. /**
  114981. * Gamepad Id prefix used to identify this controller.
  114982. */
  114983. static readonly GAMEPAD_ID_PREFIX: string;
  114984. private readonly _buttonIndexToObservableNameMap;
  114985. /**
  114986. * Creates a new GearVRController from a gamepad
  114987. * @param vrGamepad the gamepad that the controller should be created from
  114988. */
  114989. constructor(vrGamepad: any);
  114990. /**
  114991. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  114992. * @param scene scene in which to add meshes
  114993. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  114994. */
  114995. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  114996. /**
  114997. * Called once for each button that changed state since the last frame
  114998. * @param buttonIdx Which button index changed
  114999. * @param state New state of the button
  115000. * @param changes Which properties on the state changed since last frame
  115001. */
  115002. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  115003. }
  115004. }
  115005. declare module BABYLON {
  115006. /**
  115007. * Class containing static functions to help procedurally build meshes
  115008. */
  115009. export class PolyhedronBuilder {
  115010. /**
  115011. * Creates a polyhedron mesh
  115012. * * 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
  115013. * * The parameter `size` (positive float, default 1) sets the polygon size
  115014. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  115015. * * 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`
  115016. * * 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
  115017. * * 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)`)
  115018. * * 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
  115019. * * 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
  115020. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115021. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115022. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115023. * @param name defines the name of the mesh
  115024. * @param options defines the options used to create the mesh
  115025. * @param scene defines the hosting scene
  115026. * @returns the polyhedron mesh
  115027. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  115028. */
  115029. static CreatePolyhedron(name: string, options: {
  115030. type?: number;
  115031. size?: number;
  115032. sizeX?: number;
  115033. sizeY?: number;
  115034. sizeZ?: number;
  115035. custom?: any;
  115036. faceUV?: Vector4[];
  115037. faceColors?: Color4[];
  115038. flat?: boolean;
  115039. updatable?: boolean;
  115040. sideOrientation?: number;
  115041. frontUVs?: Vector4;
  115042. backUVs?: Vector4;
  115043. }, scene?: Nullable<Scene>): Mesh;
  115044. }
  115045. }
  115046. declare module BABYLON {
  115047. /**
  115048. * Gizmo that enables scaling a mesh along 3 axis
  115049. */
  115050. export class ScaleGizmo extends Gizmo {
  115051. /**
  115052. * Internal gizmo used for interactions on the x axis
  115053. */
  115054. xGizmo: AxisScaleGizmo;
  115055. /**
  115056. * Internal gizmo used for interactions on the y axis
  115057. */
  115058. yGizmo: AxisScaleGizmo;
  115059. /**
  115060. * Internal gizmo used for interactions on the z axis
  115061. */
  115062. zGizmo: AxisScaleGizmo;
  115063. /**
  115064. * Internal gizmo used to scale all axis equally
  115065. */
  115066. uniformScaleGizmo: AxisScaleGizmo;
  115067. private _meshAttached;
  115068. private _updateGizmoRotationToMatchAttachedMesh;
  115069. private _snapDistance;
  115070. private _scaleRatio;
  115071. private _uniformScalingMesh;
  115072. private _octahedron;
  115073. private _sensitivity;
  115074. /** Fires an event when any of it's sub gizmos are dragged */
  115075. onDragStartObservable: Observable<unknown>;
  115076. /** Fires an event when any of it's sub gizmos are released from dragging */
  115077. onDragEndObservable: Observable<unknown>;
  115078. attachedMesh: Nullable<AbstractMesh>;
  115079. /**
  115080. * Creates a ScaleGizmo
  115081. * @param gizmoLayer The utility layer the gizmo will be added to
  115082. */
  115083. constructor(gizmoLayer?: UtilityLayerRenderer);
  115084. updateGizmoRotationToMatchAttachedMesh: boolean;
  115085. /**
  115086. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  115087. */
  115088. snapDistance: number;
  115089. /**
  115090. * Ratio for the scale of the gizmo (Default: 1)
  115091. */
  115092. scaleRatio: number;
  115093. /**
  115094. * Sensitivity factor for dragging (Default: 1)
  115095. */
  115096. sensitivity: number;
  115097. /**
  115098. * Disposes of the gizmo
  115099. */
  115100. dispose(): void;
  115101. }
  115102. }
  115103. declare module BABYLON {
  115104. /**
  115105. * Single axis scale gizmo
  115106. */
  115107. export class AxisScaleGizmo extends Gizmo {
  115108. /**
  115109. * Drag behavior responsible for the gizmos dragging interactions
  115110. */
  115111. dragBehavior: PointerDragBehavior;
  115112. private _pointerObserver;
  115113. /**
  115114. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  115115. */
  115116. snapDistance: number;
  115117. /**
  115118. * Event that fires each time the gizmo snaps to a new location.
  115119. * * snapDistance is the the change in distance
  115120. */
  115121. onSnapObservable: Observable<{
  115122. snapDistance: number;
  115123. }>;
  115124. /**
  115125. * If the scaling operation should be done on all axis (default: false)
  115126. */
  115127. uniformScaling: boolean;
  115128. /**
  115129. * Custom sensitivity value for the drag strength
  115130. */
  115131. sensitivity: number;
  115132. private _isEnabled;
  115133. private _parent;
  115134. private _arrow;
  115135. private _coloredMaterial;
  115136. private _hoverMaterial;
  115137. /**
  115138. * Creates an AxisScaleGizmo
  115139. * @param gizmoLayer The utility layer the gizmo will be added to
  115140. * @param dragAxis The axis which the gizmo will be able to scale on
  115141. * @param color The color of the gizmo
  115142. */
  115143. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  115144. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  115145. /**
  115146. * If the gizmo is enabled
  115147. */
  115148. isEnabled: boolean;
  115149. /**
  115150. * Disposes of the gizmo
  115151. */
  115152. dispose(): void;
  115153. /**
  115154. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  115155. * @param mesh The mesh to replace the default mesh of the gizmo
  115156. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  115157. */
  115158. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  115159. }
  115160. }
  115161. declare module BABYLON {
  115162. /**
  115163. * Bounding box gizmo
  115164. */
  115165. export class BoundingBoxGizmo extends Gizmo {
  115166. private _lineBoundingBox;
  115167. private _rotateSpheresParent;
  115168. private _scaleBoxesParent;
  115169. private _boundingDimensions;
  115170. private _renderObserver;
  115171. private _pointerObserver;
  115172. private _scaleDragSpeed;
  115173. private _tmpQuaternion;
  115174. private _tmpVector;
  115175. private _tmpRotationMatrix;
  115176. /**
  115177. * 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)
  115178. */
  115179. ignoreChildren: boolean;
  115180. /**
  115181. * 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)
  115182. */
  115183. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  115184. /**
  115185. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  115186. */
  115187. rotationSphereSize: number;
  115188. /**
  115189. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  115190. */
  115191. scaleBoxSize: number;
  115192. /**
  115193. * 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)
  115194. */
  115195. fixedDragMeshScreenSize: boolean;
  115196. /**
  115197. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  115198. */
  115199. fixedDragMeshScreenSizeDistanceFactor: number;
  115200. /**
  115201. * Fired when a rotation sphere or scale box is dragged
  115202. */
  115203. onDragStartObservable: Observable<{}>;
  115204. /**
  115205. * Fired when a scale box is dragged
  115206. */
  115207. onScaleBoxDragObservable: Observable<{}>;
  115208. /**
  115209. * Fired when a scale box drag is ended
  115210. */
  115211. onScaleBoxDragEndObservable: Observable<{}>;
  115212. /**
  115213. * Fired when a rotation sphere is dragged
  115214. */
  115215. onRotationSphereDragObservable: Observable<{}>;
  115216. /**
  115217. * Fired when a rotation sphere drag is ended
  115218. */
  115219. onRotationSphereDragEndObservable: Observable<{}>;
  115220. /**
  115221. * 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)
  115222. */
  115223. scalePivot: Nullable<Vector3>;
  115224. /**
  115225. * Mesh used as a pivot to rotate the attached mesh
  115226. */
  115227. private _anchorMesh;
  115228. private _existingMeshScale;
  115229. private _dragMesh;
  115230. private pointerDragBehavior;
  115231. private coloredMaterial;
  115232. private hoverColoredMaterial;
  115233. /**
  115234. * Sets the color of the bounding box gizmo
  115235. * @param color the color to set
  115236. */
  115237. setColor(color: Color3): void;
  115238. /**
  115239. * Creates an BoundingBoxGizmo
  115240. * @param gizmoLayer The utility layer the gizmo will be added to
  115241. * @param color The color of the gizmo
  115242. */
  115243. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  115244. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  115245. private _selectNode;
  115246. /**
  115247. * Updates the bounding box information for the Gizmo
  115248. */
  115249. updateBoundingBox(): void;
  115250. private _updateRotationSpheres;
  115251. private _updateScaleBoxes;
  115252. /**
  115253. * Enables rotation on the specified axis and disables rotation on the others
  115254. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  115255. */
  115256. setEnabledRotationAxis(axis: string): void;
  115257. /**
  115258. * Enables/disables scaling
  115259. * @param enable if scaling should be enabled
  115260. */
  115261. setEnabledScaling(enable: boolean): void;
  115262. private _updateDummy;
  115263. /**
  115264. * Enables a pointer drag behavior on the bounding box of the gizmo
  115265. */
  115266. enableDragBehavior(): void;
  115267. /**
  115268. * Disposes of the gizmo
  115269. */
  115270. dispose(): void;
  115271. /**
  115272. * 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)
  115273. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  115274. * @returns the bounding box mesh with the passed in mesh as a child
  115275. */
  115276. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  115277. /**
  115278. * CustomMeshes are not supported by this gizmo
  115279. * @param mesh The mesh to replace the default mesh of the gizmo
  115280. */
  115281. setCustomMesh(mesh: Mesh): void;
  115282. }
  115283. }
  115284. declare module BABYLON {
  115285. /**
  115286. * Single plane rotation gizmo
  115287. */
  115288. export class PlaneRotationGizmo extends Gizmo {
  115289. /**
  115290. * Drag behavior responsible for the gizmos dragging interactions
  115291. */
  115292. dragBehavior: PointerDragBehavior;
  115293. private _pointerObserver;
  115294. /**
  115295. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  115296. */
  115297. snapDistance: number;
  115298. /**
  115299. * Event that fires each time the gizmo snaps to a new location.
  115300. * * snapDistance is the the change in distance
  115301. */
  115302. onSnapObservable: Observable<{
  115303. snapDistance: number;
  115304. }>;
  115305. private _isEnabled;
  115306. private _parent;
  115307. /**
  115308. * Creates a PlaneRotationGizmo
  115309. * @param gizmoLayer The utility layer the gizmo will be added to
  115310. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  115311. * @param color The color of the gizmo
  115312. * @param tessellation Amount of tessellation to be used when creating rotation circles
  115313. * @param useEulerRotation Use and update Euler angle instead of quaternion
  115314. */
  115315. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  115316. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  115317. /**
  115318. * If the gizmo is enabled
  115319. */
  115320. isEnabled: boolean;
  115321. /**
  115322. * Disposes of the gizmo
  115323. */
  115324. dispose(): void;
  115325. }
  115326. }
  115327. declare module BABYLON {
  115328. /**
  115329. * Gizmo that enables rotating a mesh along 3 axis
  115330. */
  115331. export class RotationGizmo extends Gizmo {
  115332. /**
  115333. * Internal gizmo used for interactions on the x axis
  115334. */
  115335. xGizmo: PlaneRotationGizmo;
  115336. /**
  115337. * Internal gizmo used for interactions on the y axis
  115338. */
  115339. yGizmo: PlaneRotationGizmo;
  115340. /**
  115341. * Internal gizmo used for interactions on the z axis
  115342. */
  115343. zGizmo: PlaneRotationGizmo;
  115344. /** Fires an event when any of it's sub gizmos are dragged */
  115345. onDragStartObservable: Observable<unknown>;
  115346. /** Fires an event when any of it's sub gizmos are released from dragging */
  115347. onDragEndObservable: Observable<unknown>;
  115348. private _meshAttached;
  115349. attachedMesh: Nullable<AbstractMesh>;
  115350. /**
  115351. * Creates a RotationGizmo
  115352. * @param gizmoLayer The utility layer the gizmo will be added to
  115353. * @param tessellation Amount of tessellation to be used when creating rotation circles
  115354. * @param useEulerRotation Use and update Euler angle instead of quaternion
  115355. */
  115356. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  115357. updateGizmoRotationToMatchAttachedMesh: boolean;
  115358. /**
  115359. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  115360. */
  115361. snapDistance: number;
  115362. /**
  115363. * Ratio for the scale of the gizmo (Default: 1)
  115364. */
  115365. scaleRatio: number;
  115366. /**
  115367. * Disposes of the gizmo
  115368. */
  115369. dispose(): void;
  115370. /**
  115371. * CustomMeshes are not supported by this gizmo
  115372. * @param mesh The mesh to replace the default mesh of the gizmo
  115373. */
  115374. setCustomMesh(mesh: Mesh): void;
  115375. }
  115376. }
  115377. declare module BABYLON {
  115378. /**
  115379. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  115380. */
  115381. export class GizmoManager implements IDisposable {
  115382. private scene;
  115383. /**
  115384. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  115385. */
  115386. gizmos: {
  115387. positionGizmo: Nullable<PositionGizmo>;
  115388. rotationGizmo: Nullable<RotationGizmo>;
  115389. scaleGizmo: Nullable<ScaleGizmo>;
  115390. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  115391. };
  115392. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  115393. clearGizmoOnEmptyPointerEvent: boolean;
  115394. /** Fires an event when the manager is attached to a mesh */
  115395. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  115396. private _gizmosEnabled;
  115397. private _pointerObserver;
  115398. private _attachedMesh;
  115399. private _boundingBoxColor;
  115400. private _defaultUtilityLayer;
  115401. private _defaultKeepDepthUtilityLayer;
  115402. /**
  115403. * When bounding box gizmo is enabled, this can be used to track drag/end events
  115404. */
  115405. boundingBoxDragBehavior: SixDofDragBehavior;
  115406. /**
  115407. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  115408. */
  115409. attachableMeshes: Nullable<Array<AbstractMesh>>;
  115410. /**
  115411. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  115412. */
  115413. usePointerToAttachGizmos: boolean;
  115414. /**
  115415. * Utility layer that the bounding box gizmo belongs to
  115416. */
  115417. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  115418. /**
  115419. * Utility layer that all gizmos besides bounding box belong to
  115420. */
  115421. readonly utilityLayer: UtilityLayerRenderer;
  115422. /**
  115423. * Instatiates a gizmo manager
  115424. * @param scene the scene to overlay the gizmos on top of
  115425. */
  115426. constructor(scene: Scene);
  115427. /**
  115428. * Attaches a set of gizmos to the specified mesh
  115429. * @param mesh The mesh the gizmo's should be attached to
  115430. */
  115431. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  115432. /**
  115433. * If the position gizmo is enabled
  115434. */
  115435. positionGizmoEnabled: boolean;
  115436. /**
  115437. * If the rotation gizmo is enabled
  115438. */
  115439. rotationGizmoEnabled: boolean;
  115440. /**
  115441. * If the scale gizmo is enabled
  115442. */
  115443. scaleGizmoEnabled: boolean;
  115444. /**
  115445. * If the boundingBox gizmo is enabled
  115446. */
  115447. boundingBoxGizmoEnabled: boolean;
  115448. /**
  115449. * Disposes of the gizmo manager
  115450. */
  115451. dispose(): void;
  115452. }
  115453. }
  115454. declare module BABYLON {
  115455. /**
  115456. * A directional light is defined by a direction (what a surprise!).
  115457. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  115458. * 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.
  115459. * Documentation: https://doc.babylonjs.com/babylon101/lights
  115460. */
  115461. export class DirectionalLight extends ShadowLight {
  115462. private _shadowFrustumSize;
  115463. /**
  115464. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  115465. */
  115466. /**
  115467. * Specifies a fix frustum size for the shadow generation.
  115468. */
  115469. shadowFrustumSize: number;
  115470. private _shadowOrthoScale;
  115471. /**
  115472. * Gets the shadow projection scale against the optimal computed one.
  115473. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  115474. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  115475. */
  115476. /**
  115477. * Sets the shadow projection scale against the optimal computed one.
  115478. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  115479. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  115480. */
  115481. shadowOrthoScale: number;
  115482. /**
  115483. * Automatically compute the projection matrix to best fit (including all the casters)
  115484. * on each frame.
  115485. */
  115486. autoUpdateExtends: boolean;
  115487. private _orthoLeft;
  115488. private _orthoRight;
  115489. private _orthoTop;
  115490. private _orthoBottom;
  115491. /**
  115492. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  115493. * The directional light is emitted from everywhere in the given direction.
  115494. * It can cast shadows.
  115495. * Documentation : https://doc.babylonjs.com/babylon101/lights
  115496. * @param name The friendly name of the light
  115497. * @param direction The direction of the light
  115498. * @param scene The scene the light belongs to
  115499. */
  115500. constructor(name: string, direction: Vector3, scene: Scene);
  115501. /**
  115502. * Returns the string "DirectionalLight".
  115503. * @return The class name
  115504. */
  115505. getClassName(): string;
  115506. /**
  115507. * Returns the integer 1.
  115508. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  115509. */
  115510. getTypeID(): number;
  115511. /**
  115512. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  115513. * Returns the DirectionalLight Shadow projection matrix.
  115514. */
  115515. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  115516. /**
  115517. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  115518. * Returns the DirectionalLight Shadow projection matrix.
  115519. */
  115520. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  115521. /**
  115522. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  115523. * Returns the DirectionalLight Shadow projection matrix.
  115524. */
  115525. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  115526. protected _buildUniformLayout(): void;
  115527. /**
  115528. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  115529. * @param effect The effect to update
  115530. * @param lightIndex The index of the light in the effect to update
  115531. * @returns The directional light
  115532. */
  115533. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  115534. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  115535. /**
  115536. * Gets the minZ used for shadow according to both the scene and the light.
  115537. *
  115538. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  115539. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  115540. * @param activeCamera The camera we are returning the min for
  115541. * @returns the depth min z
  115542. */
  115543. getDepthMinZ(activeCamera: Camera): number;
  115544. /**
  115545. * Gets the maxZ used for shadow according to both the scene and the light.
  115546. *
  115547. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  115548. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  115549. * @param activeCamera The camera we are returning the max for
  115550. * @returns the depth max z
  115551. */
  115552. getDepthMaxZ(activeCamera: Camera): number;
  115553. /**
  115554. * Prepares the list of defines specific to the light type.
  115555. * @param defines the list of defines
  115556. * @param lightIndex defines the index of the light for the effect
  115557. */
  115558. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  115559. }
  115560. }
  115561. declare module BABYLON {
  115562. /**
  115563. * Class containing static functions to help procedurally build meshes
  115564. */
  115565. export class HemisphereBuilder {
  115566. /**
  115567. * Creates a hemisphere mesh
  115568. * @param name defines the name of the mesh
  115569. * @param options defines the options used to create the mesh
  115570. * @param scene defines the hosting scene
  115571. * @returns the hemisphere mesh
  115572. */
  115573. static CreateHemisphere(name: string, options: {
  115574. segments?: number;
  115575. diameter?: number;
  115576. sideOrientation?: number;
  115577. }, scene: any): Mesh;
  115578. }
  115579. }
  115580. declare module BABYLON {
  115581. /**
  115582. * A spot light is defined by a position, a direction, an angle, and an exponent.
  115583. * These values define a cone of light starting from the position, emitting toward the direction.
  115584. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  115585. * and the exponent defines the speed of the decay of the light with distance (reach).
  115586. * Documentation: https://doc.babylonjs.com/babylon101/lights
  115587. */
  115588. export class SpotLight extends ShadowLight {
  115589. private _angle;
  115590. private _innerAngle;
  115591. private _cosHalfAngle;
  115592. private _lightAngleScale;
  115593. private _lightAngleOffset;
  115594. /**
  115595. * Gets the cone angle of the spot light in Radians.
  115596. */
  115597. /**
  115598. * Sets the cone angle of the spot light in Radians.
  115599. */
  115600. angle: number;
  115601. /**
  115602. * Only used in gltf falloff mode, this defines the angle where
  115603. * the directional falloff will start before cutting at angle which could be seen
  115604. * as outer angle.
  115605. */
  115606. /**
  115607. * Only used in gltf falloff mode, this defines the angle where
  115608. * the directional falloff will start before cutting at angle which could be seen
  115609. * as outer angle.
  115610. */
  115611. innerAngle: number;
  115612. private _shadowAngleScale;
  115613. /**
  115614. * Allows scaling the angle of the light for shadow generation only.
  115615. */
  115616. /**
  115617. * Allows scaling the angle of the light for shadow generation only.
  115618. */
  115619. shadowAngleScale: number;
  115620. /**
  115621. * The light decay speed with the distance from the emission spot.
  115622. */
  115623. exponent: number;
  115624. private _projectionTextureMatrix;
  115625. /**
  115626. * Allows reading the projecton texture
  115627. */
  115628. readonly projectionTextureMatrix: Matrix;
  115629. protected _projectionTextureLightNear: number;
  115630. /**
  115631. * Gets the near clip of the Spotlight for texture projection.
  115632. */
  115633. /**
  115634. * Sets the near clip of the Spotlight for texture projection.
  115635. */
  115636. projectionTextureLightNear: number;
  115637. protected _projectionTextureLightFar: number;
  115638. /**
  115639. * Gets the far clip of the Spotlight for texture projection.
  115640. */
  115641. /**
  115642. * Sets the far clip of the Spotlight for texture projection.
  115643. */
  115644. projectionTextureLightFar: number;
  115645. protected _projectionTextureUpDirection: Vector3;
  115646. /**
  115647. * Gets the Up vector of the Spotlight for texture projection.
  115648. */
  115649. /**
  115650. * Sets the Up vector of the Spotlight for texture projection.
  115651. */
  115652. projectionTextureUpDirection: Vector3;
  115653. private _projectionTexture;
  115654. /**
  115655. * Gets the projection texture of the light.
  115656. */
  115657. /**
  115658. * Sets the projection texture of the light.
  115659. */
  115660. projectionTexture: Nullable<BaseTexture>;
  115661. private _projectionTextureViewLightDirty;
  115662. private _projectionTextureProjectionLightDirty;
  115663. private _projectionTextureDirty;
  115664. private _projectionTextureViewTargetVector;
  115665. private _projectionTextureViewLightMatrix;
  115666. private _projectionTextureProjectionLightMatrix;
  115667. private _projectionTextureScalingMatrix;
  115668. /**
  115669. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  115670. * It can cast shadows.
  115671. * Documentation : https://doc.babylonjs.com/babylon101/lights
  115672. * @param name The light friendly name
  115673. * @param position The position of the spot light in the scene
  115674. * @param direction The direction of the light in the scene
  115675. * @param angle The cone angle of the light in Radians
  115676. * @param exponent The light decay speed with the distance from the emission spot
  115677. * @param scene The scene the lights belongs to
  115678. */
  115679. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  115680. /**
  115681. * Returns the string "SpotLight".
  115682. * @returns the class name
  115683. */
  115684. getClassName(): string;
  115685. /**
  115686. * Returns the integer 2.
  115687. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  115688. */
  115689. getTypeID(): number;
  115690. /**
  115691. * Overrides the direction setter to recompute the projection texture view light Matrix.
  115692. */
  115693. protected _setDirection(value: Vector3): void;
  115694. /**
  115695. * Overrides the position setter to recompute the projection texture view light Matrix.
  115696. */
  115697. protected _setPosition(value: Vector3): void;
  115698. /**
  115699. * 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.
  115700. * Returns the SpotLight.
  115701. */
  115702. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  115703. protected _computeProjectionTextureViewLightMatrix(): void;
  115704. protected _computeProjectionTextureProjectionLightMatrix(): void;
  115705. /**
  115706. * Main function for light texture projection matrix computing.
  115707. */
  115708. protected _computeProjectionTextureMatrix(): void;
  115709. protected _buildUniformLayout(): void;
  115710. private _computeAngleValues;
  115711. /**
  115712. * Sets the passed Effect "effect" with the Light textures.
  115713. * @param effect The effect to update
  115714. * @param lightIndex The index of the light in the effect to update
  115715. * @returns The light
  115716. */
  115717. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  115718. /**
  115719. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  115720. * @param effect The effect to update
  115721. * @param lightIndex The index of the light in the effect to update
  115722. * @returns The spot light
  115723. */
  115724. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  115725. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  115726. /**
  115727. * Disposes the light and the associated resources.
  115728. */
  115729. dispose(): void;
  115730. /**
  115731. * Prepares the list of defines specific to the light type.
  115732. * @param defines the list of defines
  115733. * @param lightIndex defines the index of the light for the effect
  115734. */
  115735. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  115736. }
  115737. }
  115738. declare module BABYLON {
  115739. /**
  115740. * Gizmo that enables viewing a light
  115741. */
  115742. export class LightGizmo extends Gizmo {
  115743. private _lightMesh;
  115744. private _material;
  115745. private _cachedPosition;
  115746. private _cachedForward;
  115747. private _attachedMeshParent;
  115748. /**
  115749. * Creates a LightGizmo
  115750. * @param gizmoLayer The utility layer the gizmo will be added to
  115751. */
  115752. constructor(gizmoLayer?: UtilityLayerRenderer);
  115753. private _light;
  115754. /**
  115755. * The light that the gizmo is attached to
  115756. */
  115757. light: Nullable<Light>;
  115758. /**
  115759. * Gets the material used to render the light gizmo
  115760. */
  115761. readonly material: StandardMaterial;
  115762. /**
  115763. * @hidden
  115764. * Updates the gizmo to match the attached mesh's position/rotation
  115765. */
  115766. protected _update(): void;
  115767. private static _Scale;
  115768. /**
  115769. * Creates the lines for a light mesh
  115770. */
  115771. private static _CreateLightLines;
  115772. /**
  115773. * Disposes of the light gizmo
  115774. */
  115775. dispose(): void;
  115776. private static _CreateHemisphericLightMesh;
  115777. private static _CreatePointLightMesh;
  115778. private static _CreateSpotLightMesh;
  115779. private static _CreateDirectionalLightMesh;
  115780. }
  115781. }
  115782. declare module BABYLON {
  115783. /** @hidden */
  115784. export var backgroundFragmentDeclaration: {
  115785. name: string;
  115786. shader: string;
  115787. };
  115788. }
  115789. declare module BABYLON {
  115790. /** @hidden */
  115791. export var backgroundUboDeclaration: {
  115792. name: string;
  115793. shader: string;
  115794. };
  115795. }
  115796. declare module BABYLON {
  115797. /** @hidden */
  115798. export var backgroundPixelShader: {
  115799. name: string;
  115800. shader: string;
  115801. };
  115802. }
  115803. declare module BABYLON {
  115804. /** @hidden */
  115805. export var backgroundVertexDeclaration: {
  115806. name: string;
  115807. shader: string;
  115808. };
  115809. }
  115810. declare module BABYLON {
  115811. /** @hidden */
  115812. export var backgroundVertexShader: {
  115813. name: string;
  115814. shader: string;
  115815. };
  115816. }
  115817. declare module BABYLON {
  115818. /**
  115819. * Background material used to create an efficient environement around your scene.
  115820. */
  115821. export class BackgroundMaterial extends PushMaterial {
  115822. /**
  115823. * Standard reflectance value at parallel view angle.
  115824. */
  115825. static StandardReflectance0: number;
  115826. /**
  115827. * Standard reflectance value at grazing angle.
  115828. */
  115829. static StandardReflectance90: number;
  115830. protected _primaryColor: Color3;
  115831. /**
  115832. * Key light Color (multiply against the environement texture)
  115833. */
  115834. primaryColor: Color3;
  115835. protected __perceptualColor: Nullable<Color3>;
  115836. /**
  115837. * Experimental Internal Use Only.
  115838. *
  115839. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  115840. * This acts as a helper to set the primary color to a more "human friendly" value.
  115841. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  115842. * output color as close as possible from the chosen value.
  115843. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  115844. * part of lighting setup.)
  115845. */
  115846. _perceptualColor: Nullable<Color3>;
  115847. protected _primaryColorShadowLevel: float;
  115848. /**
  115849. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  115850. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  115851. */
  115852. primaryColorShadowLevel: float;
  115853. protected _primaryColorHighlightLevel: float;
  115854. /**
  115855. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  115856. * The primary color is used at the level chosen to define what the white area would look.
  115857. */
  115858. primaryColorHighlightLevel: float;
  115859. protected _reflectionTexture: Nullable<BaseTexture>;
  115860. /**
  115861. * Reflection Texture used in the material.
  115862. * Should be author in a specific way for the best result (refer to the documentation).
  115863. */
  115864. reflectionTexture: Nullable<BaseTexture>;
  115865. protected _reflectionBlur: float;
  115866. /**
  115867. * Reflection Texture level of blur.
  115868. *
  115869. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  115870. * texture twice.
  115871. */
  115872. reflectionBlur: float;
  115873. protected _diffuseTexture: Nullable<BaseTexture>;
  115874. /**
  115875. * Diffuse Texture used in the material.
  115876. * Should be author in a specific way for the best result (refer to the documentation).
  115877. */
  115878. diffuseTexture: Nullable<BaseTexture>;
  115879. protected _shadowLights: Nullable<IShadowLight[]>;
  115880. /**
  115881. * Specify the list of lights casting shadow on the material.
  115882. * All scene shadow lights will be included if null.
  115883. */
  115884. shadowLights: Nullable<IShadowLight[]>;
  115885. protected _shadowLevel: float;
  115886. /**
  115887. * Helps adjusting the shadow to a softer level if required.
  115888. * 0 means black shadows and 1 means no shadows.
  115889. */
  115890. shadowLevel: float;
  115891. protected _sceneCenter: Vector3;
  115892. /**
  115893. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  115894. * It is usually zero but might be interesting to modify according to your setup.
  115895. */
  115896. sceneCenter: Vector3;
  115897. protected _opacityFresnel: boolean;
  115898. /**
  115899. * This helps specifying that the material is falling off to the sky box at grazing angle.
  115900. * This helps ensuring a nice transition when the camera goes under the ground.
  115901. */
  115902. opacityFresnel: boolean;
  115903. protected _reflectionFresnel: boolean;
  115904. /**
  115905. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  115906. * This helps adding a mirror texture on the ground.
  115907. */
  115908. reflectionFresnel: boolean;
  115909. protected _reflectionFalloffDistance: number;
  115910. /**
  115911. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  115912. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  115913. */
  115914. reflectionFalloffDistance: number;
  115915. protected _reflectionAmount: number;
  115916. /**
  115917. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  115918. */
  115919. reflectionAmount: number;
  115920. protected _reflectionReflectance0: number;
  115921. /**
  115922. * This specifies the weight of the reflection at grazing angle.
  115923. */
  115924. reflectionReflectance0: number;
  115925. protected _reflectionReflectance90: number;
  115926. /**
  115927. * This specifies the weight of the reflection at a perpendicular point of view.
  115928. */
  115929. reflectionReflectance90: number;
  115930. /**
  115931. * Sets the reflection reflectance fresnel values according to the default standard
  115932. * empirically know to work well :-)
  115933. */
  115934. reflectionStandardFresnelWeight: number;
  115935. protected _useRGBColor: boolean;
  115936. /**
  115937. * Helps to directly use the maps channels instead of their level.
  115938. */
  115939. useRGBColor: boolean;
  115940. protected _enableNoise: boolean;
  115941. /**
  115942. * This helps reducing the banding effect that could occur on the background.
  115943. */
  115944. enableNoise: boolean;
  115945. /**
  115946. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  115947. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  115948. * Recommended to be keep at 1.0 except for special cases.
  115949. */
  115950. fovMultiplier: number;
  115951. private _fovMultiplier;
  115952. /**
  115953. * Enable the FOV adjustment feature controlled by fovMultiplier.
  115954. */
  115955. useEquirectangularFOV: boolean;
  115956. private _maxSimultaneousLights;
  115957. /**
  115958. * Number of Simultaneous lights allowed on the material.
  115959. */
  115960. maxSimultaneousLights: int;
  115961. /**
  115962. * Default configuration related to image processing available in the Background Material.
  115963. */
  115964. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115965. /**
  115966. * Keep track of the image processing observer to allow dispose and replace.
  115967. */
  115968. private _imageProcessingObserver;
  115969. /**
  115970. * Attaches a new image processing configuration to the PBR Material.
  115971. * @param configuration (if null the scene configuration will be use)
  115972. */
  115973. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  115974. /**
  115975. * Gets the image processing configuration used either in this material.
  115976. */
  115977. /**
  115978. * Sets the Default image processing configuration used either in the this material.
  115979. *
  115980. * If sets to null, the scene one is in use.
  115981. */
  115982. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  115983. /**
  115984. * Gets wether the color curves effect is enabled.
  115985. */
  115986. /**
  115987. * Sets wether the color curves effect is enabled.
  115988. */
  115989. cameraColorCurvesEnabled: boolean;
  115990. /**
  115991. * Gets wether the color grading effect is enabled.
  115992. */
  115993. /**
  115994. * Gets wether the color grading effect is enabled.
  115995. */
  115996. cameraColorGradingEnabled: boolean;
  115997. /**
  115998. * Gets wether tonemapping is enabled or not.
  115999. */
  116000. /**
  116001. * Sets wether tonemapping is enabled or not
  116002. */
  116003. cameraToneMappingEnabled: boolean;
  116004. /**
  116005. * The camera exposure used on this material.
  116006. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  116007. * This corresponds to a photographic exposure.
  116008. */
  116009. /**
  116010. * The camera exposure used on this material.
  116011. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  116012. * This corresponds to a photographic exposure.
  116013. */
  116014. cameraExposure: float;
  116015. /**
  116016. * Gets The camera contrast used on this material.
  116017. */
  116018. /**
  116019. * Sets The camera contrast used on this material.
  116020. */
  116021. cameraContrast: float;
  116022. /**
  116023. * Gets the Color Grading 2D Lookup Texture.
  116024. */
  116025. /**
  116026. * Sets the Color Grading 2D Lookup Texture.
  116027. */
  116028. cameraColorGradingTexture: Nullable<BaseTexture>;
  116029. /**
  116030. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  116031. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  116032. * 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;
  116033. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  116034. */
  116035. /**
  116036. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  116037. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  116038. * 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;
  116039. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  116040. */
  116041. cameraColorCurves: Nullable<ColorCurves>;
  116042. /**
  116043. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  116044. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  116045. */
  116046. switchToBGR: boolean;
  116047. private _renderTargets;
  116048. private _reflectionControls;
  116049. private _white;
  116050. private _primaryShadowColor;
  116051. private _primaryHighlightColor;
  116052. /**
  116053. * Instantiates a Background Material in the given scene
  116054. * @param name The friendly name of the material
  116055. * @param scene The scene to add the material to
  116056. */
  116057. constructor(name: string, scene: Scene);
  116058. /**
  116059. * Gets a boolean indicating that current material needs to register RTT
  116060. */
  116061. readonly hasRenderTargetTextures: boolean;
  116062. /**
  116063. * The entire material has been created in order to prevent overdraw.
  116064. * @returns false
  116065. */
  116066. needAlphaTesting(): boolean;
  116067. /**
  116068. * The entire material has been created in order to prevent overdraw.
  116069. * @returns true if blending is enable
  116070. */
  116071. needAlphaBlending(): boolean;
  116072. /**
  116073. * Checks wether the material is ready to be rendered for a given mesh.
  116074. * @param mesh The mesh to render
  116075. * @param subMesh The submesh to check against
  116076. * @param useInstances Specify wether or not the material is used with instances
  116077. * @returns true if all the dependencies are ready (Textures, Effects...)
  116078. */
  116079. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  116080. /**
  116081. * Compute the primary color according to the chosen perceptual color.
  116082. */
  116083. private _computePrimaryColorFromPerceptualColor;
  116084. /**
  116085. * Compute the highlights and shadow colors according to their chosen levels.
  116086. */
  116087. private _computePrimaryColors;
  116088. /**
  116089. * Build the uniform buffer used in the material.
  116090. */
  116091. buildUniformLayout(): void;
  116092. /**
  116093. * Unbind the material.
  116094. */
  116095. unbind(): void;
  116096. /**
  116097. * Bind only the world matrix to the material.
  116098. * @param world The world matrix to bind.
  116099. */
  116100. bindOnlyWorldMatrix(world: Matrix): void;
  116101. /**
  116102. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  116103. * @param world The world matrix to bind.
  116104. * @param subMesh The submesh to bind for.
  116105. */
  116106. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  116107. /**
  116108. * Checks to see if a texture is used in the material.
  116109. * @param texture - Base texture to use.
  116110. * @returns - Boolean specifying if a texture is used in the material.
  116111. */
  116112. hasTexture(texture: BaseTexture): boolean;
  116113. /**
  116114. * Dispose the material.
  116115. * @param forceDisposeEffect Force disposal of the associated effect.
  116116. * @param forceDisposeTextures Force disposal of the associated textures.
  116117. */
  116118. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  116119. /**
  116120. * Clones the material.
  116121. * @param name The cloned name.
  116122. * @returns The cloned material.
  116123. */
  116124. clone(name: string): BackgroundMaterial;
  116125. /**
  116126. * Serializes the current material to its JSON representation.
  116127. * @returns The JSON representation.
  116128. */
  116129. serialize(): any;
  116130. /**
  116131. * Gets the class name of the material
  116132. * @returns "BackgroundMaterial"
  116133. */
  116134. getClassName(): string;
  116135. /**
  116136. * Parse a JSON input to create back a background material.
  116137. * @param source The JSON data to parse
  116138. * @param scene The scene to create the parsed material in
  116139. * @param rootUrl The root url of the assets the material depends upon
  116140. * @returns the instantiated BackgroundMaterial.
  116141. */
  116142. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  116143. }
  116144. }
  116145. declare module BABYLON {
  116146. /**
  116147. * Represents the different options available during the creation of
  116148. * a Environment helper.
  116149. *
  116150. * This can control the default ground, skybox and image processing setup of your scene.
  116151. */
  116152. export interface IEnvironmentHelperOptions {
  116153. /**
  116154. * Specifies wether or not to create a ground.
  116155. * True by default.
  116156. */
  116157. createGround: boolean;
  116158. /**
  116159. * Specifies the ground size.
  116160. * 15 by default.
  116161. */
  116162. groundSize: number;
  116163. /**
  116164. * The texture used on the ground for the main color.
  116165. * Comes from the BabylonJS CDN by default.
  116166. *
  116167. * Remarks: Can be either a texture or a url.
  116168. */
  116169. groundTexture: string | BaseTexture;
  116170. /**
  116171. * The color mixed in the ground texture by default.
  116172. * BabylonJS clearColor by default.
  116173. */
  116174. groundColor: Color3;
  116175. /**
  116176. * Specifies the ground opacity.
  116177. * 1 by default.
  116178. */
  116179. groundOpacity: number;
  116180. /**
  116181. * Enables the ground to receive shadows.
  116182. * True by default.
  116183. */
  116184. enableGroundShadow: boolean;
  116185. /**
  116186. * Helps preventing the shadow to be fully black on the ground.
  116187. * 0.5 by default.
  116188. */
  116189. groundShadowLevel: number;
  116190. /**
  116191. * Creates a mirror texture attach to the ground.
  116192. * false by default.
  116193. */
  116194. enableGroundMirror: boolean;
  116195. /**
  116196. * Specifies the ground mirror size ratio.
  116197. * 0.3 by default as the default kernel is 64.
  116198. */
  116199. groundMirrorSizeRatio: number;
  116200. /**
  116201. * Specifies the ground mirror blur kernel size.
  116202. * 64 by default.
  116203. */
  116204. groundMirrorBlurKernel: number;
  116205. /**
  116206. * Specifies the ground mirror visibility amount.
  116207. * 1 by default
  116208. */
  116209. groundMirrorAmount: number;
  116210. /**
  116211. * Specifies the ground mirror reflectance weight.
  116212. * This uses the standard weight of the background material to setup the fresnel effect
  116213. * of the mirror.
  116214. * 1 by default.
  116215. */
  116216. groundMirrorFresnelWeight: number;
  116217. /**
  116218. * Specifies the ground mirror Falloff distance.
  116219. * This can helps reducing the size of the reflection.
  116220. * 0 by Default.
  116221. */
  116222. groundMirrorFallOffDistance: number;
  116223. /**
  116224. * Specifies the ground mirror texture type.
  116225. * Unsigned Int by Default.
  116226. */
  116227. groundMirrorTextureType: number;
  116228. /**
  116229. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  116230. * the shown objects.
  116231. */
  116232. groundYBias: number;
  116233. /**
  116234. * Specifies wether or not to create a skybox.
  116235. * True by default.
  116236. */
  116237. createSkybox: boolean;
  116238. /**
  116239. * Specifies the skybox size.
  116240. * 20 by default.
  116241. */
  116242. skyboxSize: number;
  116243. /**
  116244. * The texture used on the skybox for the main color.
  116245. * Comes from the BabylonJS CDN by default.
  116246. *
  116247. * Remarks: Can be either a texture or a url.
  116248. */
  116249. skyboxTexture: string | BaseTexture;
  116250. /**
  116251. * The color mixed in the skybox texture by default.
  116252. * BabylonJS clearColor by default.
  116253. */
  116254. skyboxColor: Color3;
  116255. /**
  116256. * The background rotation around the Y axis of the scene.
  116257. * This helps aligning the key lights of your scene with the background.
  116258. * 0 by default.
  116259. */
  116260. backgroundYRotation: number;
  116261. /**
  116262. * Compute automatically the size of the elements to best fit with the scene.
  116263. */
  116264. sizeAuto: boolean;
  116265. /**
  116266. * Default position of the rootMesh if autoSize is not true.
  116267. */
  116268. rootPosition: Vector3;
  116269. /**
  116270. * Sets up the image processing in the scene.
  116271. * true by default.
  116272. */
  116273. setupImageProcessing: boolean;
  116274. /**
  116275. * The texture used as your environment texture in the scene.
  116276. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  116277. *
  116278. * Remarks: Can be either a texture or a url.
  116279. */
  116280. environmentTexture: string | BaseTexture;
  116281. /**
  116282. * The value of the exposure to apply to the scene.
  116283. * 0.6 by default if setupImageProcessing is true.
  116284. */
  116285. cameraExposure: number;
  116286. /**
  116287. * The value of the contrast to apply to the scene.
  116288. * 1.6 by default if setupImageProcessing is true.
  116289. */
  116290. cameraContrast: number;
  116291. /**
  116292. * Specifies wether or not tonemapping should be enabled in the scene.
  116293. * true by default if setupImageProcessing is true.
  116294. */
  116295. toneMappingEnabled: boolean;
  116296. }
  116297. /**
  116298. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  116299. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  116300. * It also helps with the default setup of your imageProcessing configuration.
  116301. */
  116302. export class EnvironmentHelper {
  116303. /**
  116304. * Default ground texture URL.
  116305. */
  116306. private static _groundTextureCDNUrl;
  116307. /**
  116308. * Default skybox texture URL.
  116309. */
  116310. private static _skyboxTextureCDNUrl;
  116311. /**
  116312. * Default environment texture URL.
  116313. */
  116314. private static _environmentTextureCDNUrl;
  116315. /**
  116316. * Creates the default options for the helper.
  116317. */
  116318. private static _getDefaultOptions;
  116319. private _rootMesh;
  116320. /**
  116321. * Gets the root mesh created by the helper.
  116322. */
  116323. readonly rootMesh: Mesh;
  116324. private _skybox;
  116325. /**
  116326. * Gets the skybox created by the helper.
  116327. */
  116328. readonly skybox: Nullable<Mesh>;
  116329. private _skyboxTexture;
  116330. /**
  116331. * Gets the skybox texture created by the helper.
  116332. */
  116333. readonly skyboxTexture: Nullable<BaseTexture>;
  116334. private _skyboxMaterial;
  116335. /**
  116336. * Gets the skybox material created by the helper.
  116337. */
  116338. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  116339. private _ground;
  116340. /**
  116341. * Gets the ground mesh created by the helper.
  116342. */
  116343. readonly ground: Nullable<Mesh>;
  116344. private _groundTexture;
  116345. /**
  116346. * Gets the ground texture created by the helper.
  116347. */
  116348. readonly groundTexture: Nullable<BaseTexture>;
  116349. private _groundMirror;
  116350. /**
  116351. * Gets the ground mirror created by the helper.
  116352. */
  116353. readonly groundMirror: Nullable<MirrorTexture>;
  116354. /**
  116355. * Gets the ground mirror render list to helps pushing the meshes
  116356. * you wish in the ground reflection.
  116357. */
  116358. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  116359. private _groundMaterial;
  116360. /**
  116361. * Gets the ground material created by the helper.
  116362. */
  116363. readonly groundMaterial: Nullable<BackgroundMaterial>;
  116364. /**
  116365. * Stores the creation options.
  116366. */
  116367. private readonly _scene;
  116368. private _options;
  116369. /**
  116370. * This observable will be notified with any error during the creation of the environment,
  116371. * mainly texture creation errors.
  116372. */
  116373. onErrorObservable: Observable<{
  116374. message?: string;
  116375. exception?: any;
  116376. }>;
  116377. /**
  116378. * constructor
  116379. * @param options Defines the options we want to customize the helper
  116380. * @param scene The scene to add the material to
  116381. */
  116382. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  116383. /**
  116384. * Updates the background according to the new options
  116385. * @param options
  116386. */
  116387. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  116388. /**
  116389. * Sets the primary color of all the available elements.
  116390. * @param color the main color to affect to the ground and the background
  116391. */
  116392. setMainColor(color: Color3): void;
  116393. /**
  116394. * Setup the image processing according to the specified options.
  116395. */
  116396. private _setupImageProcessing;
  116397. /**
  116398. * Setup the environment texture according to the specified options.
  116399. */
  116400. private _setupEnvironmentTexture;
  116401. /**
  116402. * Setup the background according to the specified options.
  116403. */
  116404. private _setupBackground;
  116405. /**
  116406. * Get the scene sizes according to the setup.
  116407. */
  116408. private _getSceneSize;
  116409. /**
  116410. * Setup the ground according to the specified options.
  116411. */
  116412. private _setupGround;
  116413. /**
  116414. * Setup the ground material according to the specified options.
  116415. */
  116416. private _setupGroundMaterial;
  116417. /**
  116418. * Setup the ground diffuse texture according to the specified options.
  116419. */
  116420. private _setupGroundDiffuseTexture;
  116421. /**
  116422. * Setup the ground mirror texture according to the specified options.
  116423. */
  116424. private _setupGroundMirrorTexture;
  116425. /**
  116426. * Setup the ground to receive the mirror texture.
  116427. */
  116428. private _setupMirrorInGroundMaterial;
  116429. /**
  116430. * Setup the skybox according to the specified options.
  116431. */
  116432. private _setupSkybox;
  116433. /**
  116434. * Setup the skybox material according to the specified options.
  116435. */
  116436. private _setupSkyboxMaterial;
  116437. /**
  116438. * Setup the skybox reflection texture according to the specified options.
  116439. */
  116440. private _setupSkyboxReflectionTexture;
  116441. private _errorHandler;
  116442. /**
  116443. * Dispose all the elements created by the Helper.
  116444. */
  116445. dispose(): void;
  116446. }
  116447. }
  116448. declare module BABYLON {
  116449. /**
  116450. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  116451. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  116452. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  116453. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  116454. */
  116455. export class PhotoDome extends TransformNode {
  116456. /**
  116457. * Define the image as a Monoscopic panoramic 360 image.
  116458. */
  116459. static readonly MODE_MONOSCOPIC: number;
  116460. /**
  116461. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  116462. */
  116463. static readonly MODE_TOPBOTTOM: number;
  116464. /**
  116465. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  116466. */
  116467. static readonly MODE_SIDEBYSIDE: number;
  116468. private _useDirectMapping;
  116469. /**
  116470. * The texture being displayed on the sphere
  116471. */
  116472. protected _photoTexture: Texture;
  116473. /**
  116474. * Gets or sets the texture being displayed on the sphere
  116475. */
  116476. photoTexture: Texture;
  116477. /**
  116478. * Observable raised when an error occured while loading the 360 image
  116479. */
  116480. onLoadErrorObservable: Observable<string>;
  116481. /**
  116482. * The skybox material
  116483. */
  116484. protected _material: BackgroundMaterial;
  116485. /**
  116486. * The surface used for the skybox
  116487. */
  116488. protected _mesh: Mesh;
  116489. /**
  116490. * Gets the mesh used for the skybox.
  116491. */
  116492. readonly mesh: Mesh;
  116493. /**
  116494. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  116495. * Also see the options.resolution property.
  116496. */
  116497. fovMultiplier: number;
  116498. private _imageMode;
  116499. /**
  116500. * Gets or set the current video mode for the video. It can be:
  116501. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  116502. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  116503. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  116504. */
  116505. imageMode: number;
  116506. /**
  116507. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  116508. * @param name Element's name, child elements will append suffixes for their own names.
  116509. * @param urlsOfPhoto defines the url of the photo to display
  116510. * @param options defines an object containing optional or exposed sub element properties
  116511. * @param onError defines a callback called when an error occured while loading the texture
  116512. */
  116513. constructor(name: string, urlOfPhoto: string, options: {
  116514. resolution?: number;
  116515. size?: number;
  116516. useDirectMapping?: boolean;
  116517. faceForward?: boolean;
  116518. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  116519. private _onBeforeCameraRenderObserver;
  116520. private _changeImageMode;
  116521. /**
  116522. * Releases resources associated with this node.
  116523. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  116524. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  116525. */
  116526. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  116527. }
  116528. }
  116529. declare module BABYLON {
  116530. /**
  116531. * Class used to host RGBD texture specific utilities
  116532. */
  116533. export class RGBDTextureTools {
  116534. /**
  116535. * Expand the RGBD Texture from RGBD to Half Float if possible.
  116536. * @param texture the texture to expand.
  116537. */
  116538. static ExpandRGBDTexture(texture: Texture): void;
  116539. }
  116540. }
  116541. declare module BABYLON {
  116542. /**
  116543. * Class used to host texture specific utilities
  116544. */
  116545. export class BRDFTextureTools {
  116546. /**
  116547. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  116548. * @param scene defines the hosting scene
  116549. * @returns the environment BRDF texture
  116550. */
  116551. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  116552. private static _environmentBRDFBase64Texture;
  116553. }
  116554. }
  116555. declare module BABYLON {
  116556. /**
  116557. * @hidden
  116558. */
  116559. export interface IMaterialClearCoatDefines {
  116560. CLEARCOAT: boolean;
  116561. CLEARCOAT_DEFAULTIOR: boolean;
  116562. CLEARCOAT_TEXTURE: boolean;
  116563. CLEARCOAT_TEXTUREDIRECTUV: number;
  116564. CLEARCOAT_BUMP: boolean;
  116565. CLEARCOAT_BUMPDIRECTUV: number;
  116566. CLEARCOAT_TINT: boolean;
  116567. CLEARCOAT_TINT_TEXTURE: boolean;
  116568. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  116569. /** @hidden */
  116570. _areTexturesDirty: boolean;
  116571. }
  116572. /**
  116573. * Define the code related to the clear coat parameters of the pbr material.
  116574. */
  116575. export class PBRClearCoatConfiguration {
  116576. /**
  116577. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  116578. * The default fits with a polyurethane material.
  116579. */
  116580. private static readonly _DefaultIndexOfRefraction;
  116581. private _isEnabled;
  116582. /**
  116583. * Defines if the clear coat is enabled in the material.
  116584. */
  116585. isEnabled: boolean;
  116586. /**
  116587. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  116588. */
  116589. intensity: number;
  116590. /**
  116591. * Defines the clear coat layer roughness.
  116592. */
  116593. roughness: number;
  116594. private _indexOfRefraction;
  116595. /**
  116596. * Defines the index of refraction of the clear coat.
  116597. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  116598. * The default fits with a polyurethane material.
  116599. * Changing the default value is more performance intensive.
  116600. */
  116601. indexOfRefraction: number;
  116602. private _texture;
  116603. /**
  116604. * Stores the clear coat values in a texture.
  116605. */
  116606. texture: Nullable<BaseTexture>;
  116607. private _bumpTexture;
  116608. /**
  116609. * Define the clear coat specific bump texture.
  116610. */
  116611. bumpTexture: Nullable<BaseTexture>;
  116612. private _isTintEnabled;
  116613. /**
  116614. * Defines if the clear coat tint is enabled in the material.
  116615. */
  116616. isTintEnabled: boolean;
  116617. /**
  116618. * Defines the clear coat tint of the material.
  116619. * This is only use if tint is enabled
  116620. */
  116621. tintColor: Color3;
  116622. /**
  116623. * Defines the distance at which the tint color should be found in the
  116624. * clear coat media.
  116625. * This is only use if tint is enabled
  116626. */
  116627. tintColorAtDistance: number;
  116628. /**
  116629. * Defines the clear coat layer thickness.
  116630. * This is only use if tint is enabled
  116631. */
  116632. tintThickness: number;
  116633. private _tintTexture;
  116634. /**
  116635. * Stores the clear tint values in a texture.
  116636. * rgb is tint
  116637. * a is a thickness factor
  116638. */
  116639. tintTexture: Nullable<BaseTexture>;
  116640. /** @hidden */
  116641. private _internalMarkAllSubMeshesAsTexturesDirty;
  116642. /** @hidden */
  116643. _markAllSubMeshesAsTexturesDirty(): void;
  116644. /**
  116645. * Instantiate a new istance of clear coat configuration.
  116646. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  116647. */
  116648. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  116649. /**
  116650. * Gets wehter the submesh is ready to be used or not.
  116651. * @param defines the list of "defines" to update.
  116652. * @param scene defines the scene the material belongs to.
  116653. * @param engine defines the engine the material belongs to.
  116654. * @param disableBumpMap defines wether the material disables bump or not.
  116655. * @returns - boolean indicating that the submesh is ready or not.
  116656. */
  116657. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  116658. /**
  116659. * Checks to see if a texture is used in the material.
  116660. * @param defines the list of "defines" to update.
  116661. * @param scene defines the scene to the material belongs to.
  116662. */
  116663. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  116664. /**
  116665. * Binds the material data.
  116666. * @param uniformBuffer defines the Uniform buffer to fill in.
  116667. * @param scene defines the scene the material belongs to.
  116668. * @param engine defines the engine the material belongs to.
  116669. * @param disableBumpMap defines wether the material disables bump or not.
  116670. * @param isFrozen defines wether the material is frozen or not.
  116671. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  116672. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  116673. */
  116674. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  116675. /**
  116676. * Checks to see if a texture is used in the material.
  116677. * @param texture - Base texture to use.
  116678. * @returns - Boolean specifying if a texture is used in the material.
  116679. */
  116680. hasTexture(texture: BaseTexture): boolean;
  116681. /**
  116682. * Returns an array of the actively used textures.
  116683. * @param activeTextures Array of BaseTextures
  116684. */
  116685. getActiveTextures(activeTextures: BaseTexture[]): void;
  116686. /**
  116687. * Returns the animatable textures.
  116688. * @param animatables Array of animatable textures.
  116689. */
  116690. getAnimatables(animatables: IAnimatable[]): void;
  116691. /**
  116692. * Disposes the resources of the material.
  116693. * @param forceDisposeTextures - Forces the disposal of all textures.
  116694. */
  116695. dispose(forceDisposeTextures?: boolean): void;
  116696. /**
  116697. * Get the current class name of the texture useful for serialization or dynamic coding.
  116698. * @returns "PBRClearCoatConfiguration"
  116699. */
  116700. getClassName(): string;
  116701. /**
  116702. * Add fallbacks to the effect fallbacks list.
  116703. * @param defines defines the Base texture to use.
  116704. * @param fallbacks defines the current fallback list.
  116705. * @param currentRank defines the current fallback rank.
  116706. * @returns the new fallback rank.
  116707. */
  116708. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  116709. /**
  116710. * Add the required uniforms to the current list.
  116711. * @param uniforms defines the current uniform list.
  116712. */
  116713. static AddUniforms(uniforms: string[]): void;
  116714. /**
  116715. * Add the required samplers to the current list.
  116716. * @param samplers defines the current sampler list.
  116717. */
  116718. static AddSamplers(samplers: string[]): void;
  116719. /**
  116720. * Add the required uniforms to the current buffer.
  116721. * @param uniformBuffer defines the current uniform buffer.
  116722. */
  116723. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  116724. /**
  116725. * Makes a duplicate of the current configuration into another one.
  116726. * @param clearCoatConfiguration define the config where to copy the info
  116727. */
  116728. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  116729. /**
  116730. * Serializes this clear coat configuration.
  116731. * @returns - An object with the serialized config.
  116732. */
  116733. serialize(): any;
  116734. /**
  116735. * Parses a anisotropy Configuration from a serialized object.
  116736. * @param source - Serialized object.
  116737. * @param scene Defines the scene we are parsing for
  116738. * @param rootUrl Defines the rootUrl to load from
  116739. */
  116740. parse(source: any, scene: Scene, rootUrl: string): void;
  116741. }
  116742. }
  116743. declare module BABYLON {
  116744. /**
  116745. * @hidden
  116746. */
  116747. export interface IMaterialAnisotropicDefines {
  116748. ANISOTROPIC: boolean;
  116749. ANISOTROPIC_TEXTURE: boolean;
  116750. ANISOTROPIC_TEXTUREDIRECTUV: number;
  116751. MAINUV1: boolean;
  116752. _areTexturesDirty: boolean;
  116753. _needUVs: boolean;
  116754. }
  116755. /**
  116756. * Define the code related to the anisotropic parameters of the pbr material.
  116757. */
  116758. export class PBRAnisotropicConfiguration {
  116759. private _isEnabled;
  116760. /**
  116761. * Defines if the anisotropy is enabled in the material.
  116762. */
  116763. isEnabled: boolean;
  116764. /**
  116765. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  116766. */
  116767. intensity: number;
  116768. /**
  116769. * Defines if the effect is along the tangents, bitangents or in between.
  116770. * By default, the effect is "strectching" the highlights along the tangents.
  116771. */
  116772. direction: Vector2;
  116773. private _texture;
  116774. /**
  116775. * Stores the anisotropy values in a texture.
  116776. * rg is direction (like normal from -1 to 1)
  116777. * b is a intensity
  116778. */
  116779. texture: Nullable<BaseTexture>;
  116780. /** @hidden */
  116781. private _internalMarkAllSubMeshesAsTexturesDirty;
  116782. /** @hidden */
  116783. _markAllSubMeshesAsTexturesDirty(): void;
  116784. /**
  116785. * Instantiate a new istance of anisotropy configuration.
  116786. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  116787. */
  116788. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  116789. /**
  116790. * Specifies that the submesh is ready to be used.
  116791. * @param defines the list of "defines" to update.
  116792. * @param scene defines the scene the material belongs to.
  116793. * @returns - boolean indicating that the submesh is ready or not.
  116794. */
  116795. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  116796. /**
  116797. * Checks to see if a texture is used in the material.
  116798. * @param defines the list of "defines" to update.
  116799. * @param mesh the mesh we are preparing the defines for.
  116800. * @param scene defines the scene the material belongs to.
  116801. */
  116802. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  116803. /**
  116804. * Binds the material data.
  116805. * @param uniformBuffer defines the Uniform buffer to fill in.
  116806. * @param scene defines the scene the material belongs to.
  116807. * @param isFrozen defines wether the material is frozen or not.
  116808. */
  116809. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  116810. /**
  116811. * Checks to see if a texture is used in the material.
  116812. * @param texture - Base texture to use.
  116813. * @returns - Boolean specifying if a texture is used in the material.
  116814. */
  116815. hasTexture(texture: BaseTexture): boolean;
  116816. /**
  116817. * Returns an array of the actively used textures.
  116818. * @param activeTextures Array of BaseTextures
  116819. */
  116820. getActiveTextures(activeTextures: BaseTexture[]): void;
  116821. /**
  116822. * Returns the animatable textures.
  116823. * @param animatables Array of animatable textures.
  116824. */
  116825. getAnimatables(animatables: IAnimatable[]): void;
  116826. /**
  116827. * Disposes the resources of the material.
  116828. * @param forceDisposeTextures - Forces the disposal of all textures.
  116829. */
  116830. dispose(forceDisposeTextures?: boolean): void;
  116831. /**
  116832. * Get the current class name of the texture useful for serialization or dynamic coding.
  116833. * @returns "PBRAnisotropicConfiguration"
  116834. */
  116835. getClassName(): string;
  116836. /**
  116837. * Add fallbacks to the effect fallbacks list.
  116838. * @param defines defines the Base texture to use.
  116839. * @param fallbacks defines the current fallback list.
  116840. * @param currentRank defines the current fallback rank.
  116841. * @returns the new fallback rank.
  116842. */
  116843. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  116844. /**
  116845. * Add the required uniforms to the current list.
  116846. * @param uniforms defines the current uniform list.
  116847. */
  116848. static AddUniforms(uniforms: string[]): void;
  116849. /**
  116850. * Add the required uniforms to the current buffer.
  116851. * @param uniformBuffer defines the current uniform buffer.
  116852. */
  116853. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  116854. /**
  116855. * Add the required samplers to the current list.
  116856. * @param samplers defines the current sampler list.
  116857. */
  116858. static AddSamplers(samplers: string[]): void;
  116859. /**
  116860. * Makes a duplicate of the current configuration into another one.
  116861. * @param anisotropicConfiguration define the config where to copy the info
  116862. */
  116863. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  116864. /**
  116865. * Serializes this anisotropy configuration.
  116866. * @returns - An object with the serialized config.
  116867. */
  116868. serialize(): any;
  116869. /**
  116870. * Parses a anisotropy Configuration from a serialized object.
  116871. * @param source - Serialized object.
  116872. * @param scene Defines the scene we are parsing for
  116873. * @param rootUrl Defines the rootUrl to load from
  116874. */
  116875. parse(source: any, scene: Scene, rootUrl: string): void;
  116876. }
  116877. }
  116878. declare module BABYLON {
  116879. /**
  116880. * @hidden
  116881. */
  116882. export interface IMaterialBRDFDefines {
  116883. BRDF_V_HEIGHT_CORRELATED: boolean;
  116884. MS_BRDF_ENERGY_CONSERVATION: boolean;
  116885. SPHERICAL_HARMONICS: boolean;
  116886. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  116887. /** @hidden */
  116888. _areMiscDirty: boolean;
  116889. }
  116890. /**
  116891. * Define the code related to the BRDF parameters of the pbr material.
  116892. */
  116893. export class PBRBRDFConfiguration {
  116894. /**
  116895. * Default value used for the energy conservation.
  116896. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  116897. */
  116898. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  116899. /**
  116900. * Default value used for the Smith Visibility Height Correlated mode.
  116901. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  116902. */
  116903. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  116904. /**
  116905. * Default value used for the IBL diffuse part.
  116906. * This can help switching back to the polynomials mode globally which is a tiny bit
  116907. * less GPU intensive at the drawback of a lower quality.
  116908. */
  116909. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  116910. /**
  116911. * Default value used for activating energy conservation for the specular workflow.
  116912. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  116913. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  116914. */
  116915. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  116916. private _useEnergyConservation;
  116917. /**
  116918. * Defines if the material uses energy conservation.
  116919. */
  116920. useEnergyConservation: boolean;
  116921. private _useSmithVisibilityHeightCorrelated;
  116922. /**
  116923. * LEGACY Mode set to false
  116924. * Defines if the material uses height smith correlated visibility term.
  116925. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  116926. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  116927. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  116928. * Not relying on height correlated will also disable energy conservation.
  116929. */
  116930. useSmithVisibilityHeightCorrelated: boolean;
  116931. private _useSphericalHarmonics;
  116932. /**
  116933. * LEGACY Mode set to false
  116934. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  116935. * diffuse part of the IBL.
  116936. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  116937. * to the ground truth.
  116938. */
  116939. useSphericalHarmonics: boolean;
  116940. private _useSpecularGlossinessInputEnergyConservation;
  116941. /**
  116942. * Defines if the material uses energy conservation, when the specular workflow is active.
  116943. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  116944. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  116945. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  116946. */
  116947. useSpecularGlossinessInputEnergyConservation: boolean;
  116948. /** @hidden */
  116949. private _internalMarkAllSubMeshesAsMiscDirty;
  116950. /** @hidden */
  116951. _markAllSubMeshesAsMiscDirty(): void;
  116952. /**
  116953. * Instantiate a new istance of clear coat configuration.
  116954. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  116955. */
  116956. constructor(markAllSubMeshesAsMiscDirty: () => void);
  116957. /**
  116958. * Checks to see if a texture is used in the material.
  116959. * @param defines the list of "defines" to update.
  116960. */
  116961. prepareDefines(defines: IMaterialBRDFDefines): void;
  116962. /**
  116963. * Get the current class name of the texture useful for serialization or dynamic coding.
  116964. * @returns "PBRClearCoatConfiguration"
  116965. */
  116966. getClassName(): string;
  116967. /**
  116968. * Makes a duplicate of the current configuration into another one.
  116969. * @param brdfConfiguration define the config where to copy the info
  116970. */
  116971. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  116972. /**
  116973. * Serializes this BRDF configuration.
  116974. * @returns - An object with the serialized config.
  116975. */
  116976. serialize(): any;
  116977. /**
  116978. * Parses a anisotropy Configuration from a serialized object.
  116979. * @param source - Serialized object.
  116980. * @param scene Defines the scene we are parsing for
  116981. * @param rootUrl Defines the rootUrl to load from
  116982. */
  116983. parse(source: any, scene: Scene, rootUrl: string): void;
  116984. }
  116985. }
  116986. declare module BABYLON {
  116987. /**
  116988. * @hidden
  116989. */
  116990. export interface IMaterialSheenDefines {
  116991. SHEEN: boolean;
  116992. SHEEN_TEXTURE: boolean;
  116993. SHEEN_TEXTUREDIRECTUV: number;
  116994. SHEEN_LINKWITHALBEDO: boolean;
  116995. /** @hidden */
  116996. _areTexturesDirty: boolean;
  116997. }
  116998. /**
  116999. * Define the code related to the Sheen parameters of the pbr material.
  117000. */
  117001. export class PBRSheenConfiguration {
  117002. private _isEnabled;
  117003. /**
  117004. * Defines if the material uses sheen.
  117005. */
  117006. isEnabled: boolean;
  117007. private _linkSheenWithAlbedo;
  117008. /**
  117009. * Defines if the sheen is linked to the sheen color.
  117010. */
  117011. linkSheenWithAlbedo: boolean;
  117012. /**
  117013. * Defines the sheen intensity.
  117014. */
  117015. intensity: number;
  117016. /**
  117017. * Defines the sheen color.
  117018. */
  117019. color: Color3;
  117020. private _texture;
  117021. /**
  117022. * Stores the sheen tint values in a texture.
  117023. * rgb is tint
  117024. * a is a intensity
  117025. */
  117026. texture: Nullable<BaseTexture>;
  117027. /** @hidden */
  117028. private _internalMarkAllSubMeshesAsTexturesDirty;
  117029. /** @hidden */
  117030. _markAllSubMeshesAsTexturesDirty(): void;
  117031. /**
  117032. * Instantiate a new istance of clear coat configuration.
  117033. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  117034. */
  117035. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  117036. /**
  117037. * Specifies that the submesh is ready to be used.
  117038. * @param defines the list of "defines" to update.
  117039. * @param scene defines the scene the material belongs to.
  117040. * @returns - boolean indicating that the submesh is ready or not.
  117041. */
  117042. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  117043. /**
  117044. * Checks to see if a texture is used in the material.
  117045. * @param defines the list of "defines" to update.
  117046. * @param scene defines the scene the material belongs to.
  117047. */
  117048. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  117049. /**
  117050. * Binds the material data.
  117051. * @param uniformBuffer defines the Uniform buffer to fill in.
  117052. * @param scene defines the scene the material belongs to.
  117053. * @param isFrozen defines wether the material is frozen or not.
  117054. */
  117055. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  117056. /**
  117057. * Checks to see if a texture is used in the material.
  117058. * @param texture - Base texture to use.
  117059. * @returns - Boolean specifying if a texture is used in the material.
  117060. */
  117061. hasTexture(texture: BaseTexture): boolean;
  117062. /**
  117063. * Returns an array of the actively used textures.
  117064. * @param activeTextures Array of BaseTextures
  117065. */
  117066. getActiveTextures(activeTextures: BaseTexture[]): void;
  117067. /**
  117068. * Returns the animatable textures.
  117069. * @param animatables Array of animatable textures.
  117070. */
  117071. getAnimatables(animatables: IAnimatable[]): void;
  117072. /**
  117073. * Disposes the resources of the material.
  117074. * @param forceDisposeTextures - Forces the disposal of all textures.
  117075. */
  117076. dispose(forceDisposeTextures?: boolean): void;
  117077. /**
  117078. * Get the current class name of the texture useful for serialization or dynamic coding.
  117079. * @returns "PBRSheenConfiguration"
  117080. */
  117081. getClassName(): string;
  117082. /**
  117083. * Add fallbacks to the effect fallbacks list.
  117084. * @param defines defines the Base texture to use.
  117085. * @param fallbacks defines the current fallback list.
  117086. * @param currentRank defines the current fallback rank.
  117087. * @returns the new fallback rank.
  117088. */
  117089. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  117090. /**
  117091. * Add the required uniforms to the current list.
  117092. * @param uniforms defines the current uniform list.
  117093. */
  117094. static AddUniforms(uniforms: string[]): void;
  117095. /**
  117096. * Add the required uniforms to the current buffer.
  117097. * @param uniformBuffer defines the current uniform buffer.
  117098. */
  117099. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  117100. /**
  117101. * Add the required samplers to the current list.
  117102. * @param samplers defines the current sampler list.
  117103. */
  117104. static AddSamplers(samplers: string[]): void;
  117105. /**
  117106. * Makes a duplicate of the current configuration into another one.
  117107. * @param sheenConfiguration define the config where to copy the info
  117108. */
  117109. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  117110. /**
  117111. * Serializes this BRDF configuration.
  117112. * @returns - An object with the serialized config.
  117113. */
  117114. serialize(): any;
  117115. /**
  117116. * Parses a anisotropy Configuration from a serialized object.
  117117. * @param source - Serialized object.
  117118. * @param scene Defines the scene we are parsing for
  117119. * @param rootUrl Defines the rootUrl to load from
  117120. */
  117121. parse(source: any, scene: Scene, rootUrl: string): void;
  117122. }
  117123. }
  117124. declare module BABYLON {
  117125. /**
  117126. * @hidden
  117127. */
  117128. export interface IMaterialSubSurfaceDefines {
  117129. SUBSURFACE: boolean;
  117130. SS_REFRACTION: boolean;
  117131. SS_TRANSLUCENCY: boolean;
  117132. SS_SCATERRING: boolean;
  117133. SS_THICKNESSANDMASK_TEXTURE: boolean;
  117134. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  117135. SS_REFRACTIONMAP_3D: boolean;
  117136. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  117137. SS_LODINREFRACTIONALPHA: boolean;
  117138. SS_GAMMAREFRACTION: boolean;
  117139. SS_RGBDREFRACTION: boolean;
  117140. SS_LINEARSPECULARREFRACTION: boolean;
  117141. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  117142. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  117143. /** @hidden */
  117144. _areTexturesDirty: boolean;
  117145. }
  117146. /**
  117147. * Define the code related to the sub surface parameters of the pbr material.
  117148. */
  117149. export class PBRSubSurfaceConfiguration {
  117150. private _isRefractionEnabled;
  117151. /**
  117152. * Defines if the refraction is enabled in the material.
  117153. */
  117154. isRefractionEnabled: boolean;
  117155. private _isTranslucencyEnabled;
  117156. /**
  117157. * Defines if the translucency is enabled in the material.
  117158. */
  117159. isTranslucencyEnabled: boolean;
  117160. private _isScatteringEnabled;
  117161. /**
  117162. * Defines the refraction intensity of the material.
  117163. * The refraction when enabled replaces the Diffuse part of the material.
  117164. * The intensity helps transitionning between diffuse and refraction.
  117165. */
  117166. refractionIntensity: number;
  117167. /**
  117168. * Defines the translucency intensity of the material.
  117169. * When translucency has been enabled, this defines how much of the "translucency"
  117170. * is addded to the diffuse part of the material.
  117171. */
  117172. translucencyIntensity: number;
  117173. /**
  117174. * Defines the scattering intensity of the material.
  117175. * When scattering has been enabled, this defines how much of the "scattered light"
  117176. * is addded to the diffuse part of the material.
  117177. */
  117178. scatteringIntensity: number;
  117179. private _thicknessTexture;
  117180. /**
  117181. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  117182. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  117183. * 0 would mean minimumThickness
  117184. * 1 would mean maximumThickness
  117185. * The other channels might be use as a mask to vary the different effects intensity.
  117186. */
  117187. thicknessTexture: Nullable<BaseTexture>;
  117188. private _refractionTexture;
  117189. /**
  117190. * Defines the texture to use for refraction.
  117191. */
  117192. refractionTexture: Nullable<BaseTexture>;
  117193. private _indexOfRefraction;
  117194. /**
  117195. * Defines the index of refraction used in the material.
  117196. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  117197. */
  117198. indexOfRefraction: number;
  117199. private _invertRefractionY;
  117200. /**
  117201. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  117202. */
  117203. invertRefractionY: boolean;
  117204. private _linkRefractionWithTransparency;
  117205. /**
  117206. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  117207. * Materials half opaque for instance using refraction could benefit from this control.
  117208. */
  117209. linkRefractionWithTransparency: boolean;
  117210. /**
  117211. * Defines the minimum thickness stored in the thickness map.
  117212. * If no thickness map is defined, this value will be used to simulate thickness.
  117213. */
  117214. minimumThickness: number;
  117215. /**
  117216. * Defines the maximum thickness stored in the thickness map.
  117217. */
  117218. maximumThickness: number;
  117219. /**
  117220. * Defines the volume tint of the material.
  117221. * This is used for both translucency and scattering.
  117222. */
  117223. tintColor: Color3;
  117224. /**
  117225. * Defines the distance at which the tint color should be found in the media.
  117226. * This is used for refraction only.
  117227. */
  117228. tintColorAtDistance: number;
  117229. /**
  117230. * Defines how far each channel transmit through the media.
  117231. * It is defined as a color to simplify it selection.
  117232. */
  117233. diffusionDistance: Color3;
  117234. private _useMaskFromThicknessTexture;
  117235. /**
  117236. * Stores the intensity of the different subsurface effects in the thickness texture.
  117237. * * the green channel is the translucency intensity.
  117238. * * the blue channel is the scattering intensity.
  117239. * * the alpha channel is the refraction intensity.
  117240. */
  117241. useMaskFromThicknessTexture: boolean;
  117242. /** @hidden */
  117243. private _internalMarkAllSubMeshesAsTexturesDirty;
  117244. /** @hidden */
  117245. _markAllSubMeshesAsTexturesDirty(): void;
  117246. /**
  117247. * Instantiate a new istance of sub surface configuration.
  117248. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  117249. */
  117250. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  117251. /**
  117252. * Gets wehter the submesh is ready to be used or not.
  117253. * @param defines the list of "defines" to update.
  117254. * @param scene defines the scene the material belongs to.
  117255. * @returns - boolean indicating that the submesh is ready or not.
  117256. */
  117257. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  117258. /**
  117259. * Checks to see if a texture is used in the material.
  117260. * @param defines the list of "defines" to update.
  117261. * @param scene defines the scene to the material belongs to.
  117262. */
  117263. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  117264. /**
  117265. * Binds the material data.
  117266. * @param uniformBuffer defines the Uniform buffer to fill in.
  117267. * @param scene defines the scene the material belongs to.
  117268. * @param engine defines the engine the material belongs to.
  117269. * @param isFrozen defines wether the material is frozen or not.
  117270. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  117271. */
  117272. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  117273. /**
  117274. * Unbinds the material from the mesh.
  117275. * @param activeEffect defines the effect that should be unbound from.
  117276. * @returns true if unbound, otherwise false
  117277. */
  117278. unbind(activeEffect: Effect): boolean;
  117279. /**
  117280. * Returns the texture used for refraction or null if none is used.
  117281. * @param scene defines the scene the material belongs to.
  117282. * @returns - Refraction texture if present. If no refraction texture and refraction
  117283. * is linked with transparency, returns environment texture. Otherwise, returns null.
  117284. */
  117285. private _getRefractionTexture;
  117286. /**
  117287. * Returns true if alpha blending should be disabled.
  117288. */
  117289. readonly disableAlphaBlending: boolean;
  117290. /**
  117291. * Fills the list of render target textures.
  117292. * @param renderTargets the list of render targets to update
  117293. */
  117294. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  117295. /**
  117296. * Checks to see if a texture is used in the material.
  117297. * @param texture - Base texture to use.
  117298. * @returns - Boolean specifying if a texture is used in the material.
  117299. */
  117300. hasTexture(texture: BaseTexture): boolean;
  117301. /**
  117302. * Gets a boolean indicating that current material needs to register RTT
  117303. * @returns true if this uses a render target otherwise false.
  117304. */
  117305. hasRenderTargetTextures(): boolean;
  117306. /**
  117307. * Returns an array of the actively used textures.
  117308. * @param activeTextures Array of BaseTextures
  117309. */
  117310. getActiveTextures(activeTextures: BaseTexture[]): void;
  117311. /**
  117312. * Returns the animatable textures.
  117313. * @param animatables Array of animatable textures.
  117314. */
  117315. getAnimatables(animatables: IAnimatable[]): void;
  117316. /**
  117317. * Disposes the resources of the material.
  117318. * @param forceDisposeTextures - Forces the disposal of all textures.
  117319. */
  117320. dispose(forceDisposeTextures?: boolean): void;
  117321. /**
  117322. * Get the current class name of the texture useful for serialization or dynamic coding.
  117323. * @returns "PBRSubSurfaceConfiguration"
  117324. */
  117325. getClassName(): string;
  117326. /**
  117327. * Add fallbacks to the effect fallbacks list.
  117328. * @param defines defines the Base texture to use.
  117329. * @param fallbacks defines the current fallback list.
  117330. * @param currentRank defines the current fallback rank.
  117331. * @returns the new fallback rank.
  117332. */
  117333. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  117334. /**
  117335. * Add the required uniforms to the current list.
  117336. * @param uniforms defines the current uniform list.
  117337. */
  117338. static AddUniforms(uniforms: string[]): void;
  117339. /**
  117340. * Add the required samplers to the current list.
  117341. * @param samplers defines the current sampler list.
  117342. */
  117343. static AddSamplers(samplers: string[]): void;
  117344. /**
  117345. * Add the required uniforms to the current buffer.
  117346. * @param uniformBuffer defines the current uniform buffer.
  117347. */
  117348. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  117349. /**
  117350. * Makes a duplicate of the current configuration into another one.
  117351. * @param configuration define the config where to copy the info
  117352. */
  117353. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  117354. /**
  117355. * Serializes this Sub Surface configuration.
  117356. * @returns - An object with the serialized config.
  117357. */
  117358. serialize(): any;
  117359. /**
  117360. * Parses a anisotropy Configuration from a serialized object.
  117361. * @param source - Serialized object.
  117362. * @param scene Defines the scene we are parsing for
  117363. * @param rootUrl Defines the rootUrl to load from
  117364. */
  117365. parse(source: any, scene: Scene, rootUrl: string): void;
  117366. }
  117367. }
  117368. declare module BABYLON {
  117369. /** @hidden */
  117370. export var pbrFragmentDeclaration: {
  117371. name: string;
  117372. shader: string;
  117373. };
  117374. }
  117375. declare module BABYLON {
  117376. /** @hidden */
  117377. export var pbrUboDeclaration: {
  117378. name: string;
  117379. shader: string;
  117380. };
  117381. }
  117382. declare module BABYLON {
  117383. /** @hidden */
  117384. export var pbrFragmentExtraDeclaration: {
  117385. name: string;
  117386. shader: string;
  117387. };
  117388. }
  117389. declare module BABYLON {
  117390. /** @hidden */
  117391. export var pbrFragmentSamplersDeclaration: {
  117392. name: string;
  117393. shader: string;
  117394. };
  117395. }
  117396. declare module BABYLON {
  117397. /** @hidden */
  117398. export var pbrHelperFunctions: {
  117399. name: string;
  117400. shader: string;
  117401. };
  117402. }
  117403. declare module BABYLON {
  117404. /** @hidden */
  117405. export var harmonicsFunctions: {
  117406. name: string;
  117407. shader: string;
  117408. };
  117409. }
  117410. declare module BABYLON {
  117411. /** @hidden */
  117412. export var pbrDirectLightingSetupFunctions: {
  117413. name: string;
  117414. shader: string;
  117415. };
  117416. }
  117417. declare module BABYLON {
  117418. /** @hidden */
  117419. export var pbrDirectLightingFalloffFunctions: {
  117420. name: string;
  117421. shader: string;
  117422. };
  117423. }
  117424. declare module BABYLON {
  117425. /** @hidden */
  117426. export var pbrBRDFFunctions: {
  117427. name: string;
  117428. shader: string;
  117429. };
  117430. }
  117431. declare module BABYLON {
  117432. /** @hidden */
  117433. export var pbrDirectLightingFunctions: {
  117434. name: string;
  117435. shader: string;
  117436. };
  117437. }
  117438. declare module BABYLON {
  117439. /** @hidden */
  117440. export var pbrIBLFunctions: {
  117441. name: string;
  117442. shader: string;
  117443. };
  117444. }
  117445. declare module BABYLON {
  117446. /** @hidden */
  117447. export var pbrDebug: {
  117448. name: string;
  117449. shader: string;
  117450. };
  117451. }
  117452. declare module BABYLON {
  117453. /** @hidden */
  117454. export var pbrPixelShader: {
  117455. name: string;
  117456. shader: string;
  117457. };
  117458. }
  117459. declare module BABYLON {
  117460. /** @hidden */
  117461. export var pbrVertexDeclaration: {
  117462. name: string;
  117463. shader: string;
  117464. };
  117465. }
  117466. declare module BABYLON {
  117467. /** @hidden */
  117468. export var pbrVertexShader: {
  117469. name: string;
  117470. shader: string;
  117471. };
  117472. }
  117473. declare module BABYLON {
  117474. /**
  117475. * Manages the defines for the PBR Material.
  117476. * @hidden
  117477. */
  117478. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  117479. PBR: boolean;
  117480. MAINUV1: boolean;
  117481. MAINUV2: boolean;
  117482. UV1: boolean;
  117483. UV2: boolean;
  117484. ALBEDO: boolean;
  117485. ALBEDODIRECTUV: number;
  117486. VERTEXCOLOR: boolean;
  117487. AMBIENT: boolean;
  117488. AMBIENTDIRECTUV: number;
  117489. AMBIENTINGRAYSCALE: boolean;
  117490. OPACITY: boolean;
  117491. VERTEXALPHA: boolean;
  117492. OPACITYDIRECTUV: number;
  117493. OPACITYRGB: boolean;
  117494. ALPHATEST: boolean;
  117495. DEPTHPREPASS: boolean;
  117496. ALPHABLEND: boolean;
  117497. ALPHAFROMALBEDO: boolean;
  117498. ALPHATESTVALUE: string;
  117499. SPECULAROVERALPHA: boolean;
  117500. RADIANCEOVERALPHA: boolean;
  117501. ALPHAFRESNEL: boolean;
  117502. LINEARALPHAFRESNEL: boolean;
  117503. PREMULTIPLYALPHA: boolean;
  117504. EMISSIVE: boolean;
  117505. EMISSIVEDIRECTUV: number;
  117506. REFLECTIVITY: boolean;
  117507. REFLECTIVITYDIRECTUV: number;
  117508. SPECULARTERM: boolean;
  117509. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  117510. MICROSURFACEAUTOMATIC: boolean;
  117511. LODBASEDMICROSFURACE: boolean;
  117512. MICROSURFACEMAP: boolean;
  117513. MICROSURFACEMAPDIRECTUV: number;
  117514. METALLICWORKFLOW: boolean;
  117515. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  117516. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  117517. METALLNESSSTOREINMETALMAPBLUE: boolean;
  117518. AOSTOREINMETALMAPRED: boolean;
  117519. METALLICF0FACTORFROMMETALLICMAP: boolean;
  117520. ENVIRONMENTBRDF: boolean;
  117521. ENVIRONMENTBRDF_RGBD: boolean;
  117522. NORMAL: boolean;
  117523. TANGENT: boolean;
  117524. BUMP: boolean;
  117525. BUMPDIRECTUV: number;
  117526. OBJECTSPACE_NORMALMAP: boolean;
  117527. PARALLAX: boolean;
  117528. PARALLAXOCCLUSION: boolean;
  117529. NORMALXYSCALE: boolean;
  117530. LIGHTMAP: boolean;
  117531. LIGHTMAPDIRECTUV: number;
  117532. USELIGHTMAPASSHADOWMAP: boolean;
  117533. GAMMALIGHTMAP: boolean;
  117534. RGBDLIGHTMAP: boolean;
  117535. REFLECTION: boolean;
  117536. REFLECTIONMAP_3D: boolean;
  117537. REFLECTIONMAP_SPHERICAL: boolean;
  117538. REFLECTIONMAP_PLANAR: boolean;
  117539. REFLECTIONMAP_CUBIC: boolean;
  117540. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  117541. REFLECTIONMAP_PROJECTION: boolean;
  117542. REFLECTIONMAP_SKYBOX: boolean;
  117543. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  117544. REFLECTIONMAP_EXPLICIT: boolean;
  117545. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  117546. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  117547. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  117548. INVERTCUBICMAP: boolean;
  117549. USESPHERICALFROMREFLECTIONMAP: boolean;
  117550. USEIRRADIANCEMAP: boolean;
  117551. SPHERICAL_HARMONICS: boolean;
  117552. USESPHERICALINVERTEX: boolean;
  117553. REFLECTIONMAP_OPPOSITEZ: boolean;
  117554. LODINREFLECTIONALPHA: boolean;
  117555. GAMMAREFLECTION: boolean;
  117556. RGBDREFLECTION: boolean;
  117557. LINEARSPECULARREFLECTION: boolean;
  117558. RADIANCEOCCLUSION: boolean;
  117559. HORIZONOCCLUSION: boolean;
  117560. INSTANCES: boolean;
  117561. NUM_BONE_INFLUENCERS: number;
  117562. BonesPerMesh: number;
  117563. BONETEXTURE: boolean;
  117564. NONUNIFORMSCALING: boolean;
  117565. MORPHTARGETS: boolean;
  117566. MORPHTARGETS_NORMAL: boolean;
  117567. MORPHTARGETS_TANGENT: boolean;
  117568. MORPHTARGETS_UV: boolean;
  117569. NUM_MORPH_INFLUENCERS: number;
  117570. IMAGEPROCESSING: boolean;
  117571. VIGNETTE: boolean;
  117572. VIGNETTEBLENDMODEMULTIPLY: boolean;
  117573. VIGNETTEBLENDMODEOPAQUE: boolean;
  117574. TONEMAPPING: boolean;
  117575. TONEMAPPING_ACES: boolean;
  117576. CONTRAST: boolean;
  117577. COLORCURVES: boolean;
  117578. COLORGRADING: boolean;
  117579. COLORGRADING3D: boolean;
  117580. SAMPLER3DGREENDEPTH: boolean;
  117581. SAMPLER3DBGRMAP: boolean;
  117582. IMAGEPROCESSINGPOSTPROCESS: boolean;
  117583. EXPOSURE: boolean;
  117584. MULTIVIEW: boolean;
  117585. USEPHYSICALLIGHTFALLOFF: boolean;
  117586. USEGLTFLIGHTFALLOFF: boolean;
  117587. TWOSIDEDLIGHTING: boolean;
  117588. SHADOWFLOAT: boolean;
  117589. CLIPPLANE: boolean;
  117590. CLIPPLANE2: boolean;
  117591. CLIPPLANE3: boolean;
  117592. CLIPPLANE4: boolean;
  117593. POINTSIZE: boolean;
  117594. FOG: boolean;
  117595. LOGARITHMICDEPTH: boolean;
  117596. FORCENORMALFORWARD: boolean;
  117597. SPECULARAA: boolean;
  117598. CLEARCOAT: boolean;
  117599. CLEARCOAT_DEFAULTIOR: boolean;
  117600. CLEARCOAT_TEXTURE: boolean;
  117601. CLEARCOAT_TEXTUREDIRECTUV: number;
  117602. CLEARCOAT_BUMP: boolean;
  117603. CLEARCOAT_BUMPDIRECTUV: number;
  117604. CLEARCOAT_TINT: boolean;
  117605. CLEARCOAT_TINT_TEXTURE: boolean;
  117606. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  117607. ANISOTROPIC: boolean;
  117608. ANISOTROPIC_TEXTURE: boolean;
  117609. ANISOTROPIC_TEXTUREDIRECTUV: number;
  117610. BRDF_V_HEIGHT_CORRELATED: boolean;
  117611. MS_BRDF_ENERGY_CONSERVATION: boolean;
  117612. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  117613. SHEEN: boolean;
  117614. SHEEN_TEXTURE: boolean;
  117615. SHEEN_TEXTUREDIRECTUV: number;
  117616. SHEEN_LINKWITHALBEDO: boolean;
  117617. SUBSURFACE: boolean;
  117618. SS_REFRACTION: boolean;
  117619. SS_TRANSLUCENCY: boolean;
  117620. SS_SCATERRING: boolean;
  117621. SS_THICKNESSANDMASK_TEXTURE: boolean;
  117622. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  117623. SS_REFRACTIONMAP_3D: boolean;
  117624. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  117625. SS_LODINREFRACTIONALPHA: boolean;
  117626. SS_GAMMAREFRACTION: boolean;
  117627. SS_RGBDREFRACTION: boolean;
  117628. SS_LINEARSPECULARREFRACTION: boolean;
  117629. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  117630. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  117631. UNLIT: boolean;
  117632. DEBUGMODE: number;
  117633. /**
  117634. * Initializes the PBR Material defines.
  117635. */
  117636. constructor();
  117637. /**
  117638. * Resets the PBR Material defines.
  117639. */
  117640. reset(): void;
  117641. }
  117642. /**
  117643. * The Physically based material base class of BJS.
  117644. *
  117645. * This offers the main features of a standard PBR material.
  117646. * For more information, please refer to the documentation :
  117647. * https://doc.babylonjs.com/how_to/physically_based_rendering
  117648. */
  117649. export abstract class PBRBaseMaterial extends PushMaterial {
  117650. /**
  117651. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  117652. */
  117653. static readonly PBRMATERIAL_OPAQUE: number;
  117654. /**
  117655. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  117656. */
  117657. static readonly PBRMATERIAL_ALPHATEST: number;
  117658. /**
  117659. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  117660. */
  117661. static readonly PBRMATERIAL_ALPHABLEND: number;
  117662. /**
  117663. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  117664. * They are also discarded below the alpha cutoff threshold to improve performances.
  117665. */
  117666. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  117667. /**
  117668. * Defines the default value of how much AO map is occluding the analytical lights
  117669. * (point spot...).
  117670. */
  117671. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  117672. /**
  117673. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  117674. */
  117675. static readonly LIGHTFALLOFF_PHYSICAL: number;
  117676. /**
  117677. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  117678. * to enhance interoperability with other engines.
  117679. */
  117680. static readonly LIGHTFALLOFF_GLTF: number;
  117681. /**
  117682. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  117683. * to enhance interoperability with other materials.
  117684. */
  117685. static readonly LIGHTFALLOFF_STANDARD: number;
  117686. /**
  117687. * Intensity of the direct lights e.g. the four lights available in your scene.
  117688. * This impacts both the direct diffuse and specular highlights.
  117689. */
  117690. protected _directIntensity: number;
  117691. /**
  117692. * Intensity of the emissive part of the material.
  117693. * This helps controlling the emissive effect without modifying the emissive color.
  117694. */
  117695. protected _emissiveIntensity: number;
  117696. /**
  117697. * Intensity of the environment e.g. how much the environment will light the object
  117698. * either through harmonics for rough material or through the refelction for shiny ones.
  117699. */
  117700. protected _environmentIntensity: number;
  117701. /**
  117702. * This is a special control allowing the reduction of the specular highlights coming from the
  117703. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  117704. */
  117705. protected _specularIntensity: number;
  117706. /**
  117707. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  117708. */
  117709. private _lightingInfos;
  117710. /**
  117711. * Debug Control allowing disabling the bump map on this material.
  117712. */
  117713. protected _disableBumpMap: boolean;
  117714. /**
  117715. * AKA Diffuse Texture in standard nomenclature.
  117716. */
  117717. protected _albedoTexture: Nullable<BaseTexture>;
  117718. /**
  117719. * AKA Occlusion Texture in other nomenclature.
  117720. */
  117721. protected _ambientTexture: Nullable<BaseTexture>;
  117722. /**
  117723. * AKA Occlusion Texture Intensity in other nomenclature.
  117724. */
  117725. protected _ambientTextureStrength: number;
  117726. /**
  117727. * Defines how much the AO map is occluding the analytical lights (point spot...).
  117728. * 1 means it completely occludes it
  117729. * 0 mean it has no impact
  117730. */
  117731. protected _ambientTextureImpactOnAnalyticalLights: number;
  117732. /**
  117733. * Stores the alpha values in a texture.
  117734. */
  117735. protected _opacityTexture: Nullable<BaseTexture>;
  117736. /**
  117737. * Stores the reflection values in a texture.
  117738. */
  117739. protected _reflectionTexture: Nullable<BaseTexture>;
  117740. /**
  117741. * Stores the emissive values in a texture.
  117742. */
  117743. protected _emissiveTexture: Nullable<BaseTexture>;
  117744. /**
  117745. * AKA Specular texture in other nomenclature.
  117746. */
  117747. protected _reflectivityTexture: Nullable<BaseTexture>;
  117748. /**
  117749. * Used to switch from specular/glossiness to metallic/roughness workflow.
  117750. */
  117751. protected _metallicTexture: Nullable<BaseTexture>;
  117752. /**
  117753. * Specifies the metallic scalar of the metallic/roughness workflow.
  117754. * Can also be used to scale the metalness values of the metallic texture.
  117755. */
  117756. protected _metallic: Nullable<number>;
  117757. /**
  117758. * Specifies the roughness scalar of the metallic/roughness workflow.
  117759. * Can also be used to scale the roughness values of the metallic texture.
  117760. */
  117761. protected _roughness: Nullable<number>;
  117762. /**
  117763. * Specifies the an F0 factor to help configuring the material F0.
  117764. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  117765. * to 0.5 the previously hard coded value stays the same.
  117766. * Can also be used to scale the F0 values of the metallic texture.
  117767. */
  117768. protected _metallicF0Factor: number;
  117769. /**
  117770. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  117771. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  117772. * your expectation as it multiplies with the texture data.
  117773. */
  117774. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  117775. /**
  117776. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  117777. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  117778. */
  117779. protected _microSurfaceTexture: Nullable<BaseTexture>;
  117780. /**
  117781. * Stores surface normal data used to displace a mesh in a texture.
  117782. */
  117783. protected _bumpTexture: Nullable<BaseTexture>;
  117784. /**
  117785. * Stores the pre-calculated light information of a mesh in a texture.
  117786. */
  117787. protected _lightmapTexture: Nullable<BaseTexture>;
  117788. /**
  117789. * The color of a material in ambient lighting.
  117790. */
  117791. protected _ambientColor: Color3;
  117792. /**
  117793. * AKA Diffuse Color in other nomenclature.
  117794. */
  117795. protected _albedoColor: Color3;
  117796. /**
  117797. * AKA Specular Color in other nomenclature.
  117798. */
  117799. protected _reflectivityColor: Color3;
  117800. /**
  117801. * The color applied when light is reflected from a material.
  117802. */
  117803. protected _reflectionColor: Color3;
  117804. /**
  117805. * The color applied when light is emitted from a material.
  117806. */
  117807. protected _emissiveColor: Color3;
  117808. /**
  117809. * AKA Glossiness in other nomenclature.
  117810. */
  117811. protected _microSurface: number;
  117812. /**
  117813. * Specifies that the material will use the light map as a show map.
  117814. */
  117815. protected _useLightmapAsShadowmap: boolean;
  117816. /**
  117817. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  117818. * makes the reflect vector face the model (under horizon).
  117819. */
  117820. protected _useHorizonOcclusion: boolean;
  117821. /**
  117822. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  117823. * too much the area relying on ambient texture to define their ambient occlusion.
  117824. */
  117825. protected _useRadianceOcclusion: boolean;
  117826. /**
  117827. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  117828. */
  117829. protected _useAlphaFromAlbedoTexture: boolean;
  117830. /**
  117831. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  117832. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  117833. */
  117834. protected _useSpecularOverAlpha: boolean;
  117835. /**
  117836. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  117837. */
  117838. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  117839. /**
  117840. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  117841. */
  117842. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  117843. /**
  117844. * Specifies if the metallic texture contains the roughness information in its green channel.
  117845. */
  117846. protected _useRoughnessFromMetallicTextureGreen: boolean;
  117847. /**
  117848. * Specifies if the metallic texture contains the metallness information in its blue channel.
  117849. */
  117850. protected _useMetallnessFromMetallicTextureBlue: boolean;
  117851. /**
  117852. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  117853. */
  117854. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  117855. /**
  117856. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  117857. */
  117858. protected _useAmbientInGrayScale: boolean;
  117859. /**
  117860. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  117861. * The material will try to infer what glossiness each pixel should be.
  117862. */
  117863. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  117864. /**
  117865. * Defines the falloff type used in this material.
  117866. * It by default is Physical.
  117867. */
  117868. protected _lightFalloff: number;
  117869. /**
  117870. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  117871. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  117872. */
  117873. protected _useRadianceOverAlpha: boolean;
  117874. /**
  117875. * Allows using an object space normal map (instead of tangent space).
  117876. */
  117877. protected _useObjectSpaceNormalMap: boolean;
  117878. /**
  117879. * Allows using the bump map in parallax mode.
  117880. */
  117881. protected _useParallax: boolean;
  117882. /**
  117883. * Allows using the bump map in parallax occlusion mode.
  117884. */
  117885. protected _useParallaxOcclusion: boolean;
  117886. /**
  117887. * Controls the scale bias of the parallax mode.
  117888. */
  117889. protected _parallaxScaleBias: number;
  117890. /**
  117891. * If sets to true, disables all the lights affecting the material.
  117892. */
  117893. protected _disableLighting: boolean;
  117894. /**
  117895. * Number of Simultaneous lights allowed on the material.
  117896. */
  117897. protected _maxSimultaneousLights: number;
  117898. /**
  117899. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  117900. */
  117901. protected _invertNormalMapX: boolean;
  117902. /**
  117903. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  117904. */
  117905. protected _invertNormalMapY: boolean;
  117906. /**
  117907. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  117908. */
  117909. protected _twoSidedLighting: boolean;
  117910. /**
  117911. * Defines the alpha limits in alpha test mode.
  117912. */
  117913. protected _alphaCutOff: number;
  117914. /**
  117915. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  117916. */
  117917. protected _forceAlphaTest: boolean;
  117918. /**
  117919. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  117920. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  117921. */
  117922. protected _useAlphaFresnel: boolean;
  117923. /**
  117924. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  117925. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  117926. */
  117927. protected _useLinearAlphaFresnel: boolean;
  117928. /**
  117929. * The transparency mode of the material.
  117930. */
  117931. protected _transparencyMode: Nullable<number>;
  117932. /**
  117933. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  117934. * from cos thetav and roughness:
  117935. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  117936. */
  117937. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  117938. /**
  117939. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  117940. */
  117941. protected _forceIrradianceInFragment: boolean;
  117942. /**
  117943. * Force normal to face away from face.
  117944. */
  117945. protected _forceNormalForward: boolean;
  117946. /**
  117947. * Enables specular anti aliasing in the PBR shader.
  117948. * It will both interacts on the Geometry for analytical and IBL lighting.
  117949. * It also prefilter the roughness map based on the bump values.
  117950. */
  117951. protected _enableSpecularAntiAliasing: boolean;
  117952. /**
  117953. * Default configuration related to image processing available in the PBR Material.
  117954. */
  117955. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  117956. /**
  117957. * Keep track of the image processing observer to allow dispose and replace.
  117958. */
  117959. private _imageProcessingObserver;
  117960. /**
  117961. * Attaches a new image processing configuration to the PBR Material.
  117962. * @param configuration
  117963. */
  117964. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  117965. /**
  117966. * Stores the available render targets.
  117967. */
  117968. private _renderTargets;
  117969. /**
  117970. * Sets the global ambient color for the material used in lighting calculations.
  117971. */
  117972. private _globalAmbientColor;
  117973. /**
  117974. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  117975. */
  117976. private _useLogarithmicDepth;
  117977. /**
  117978. * If set to true, no lighting calculations will be applied.
  117979. */
  117980. private _unlit;
  117981. private _debugMode;
  117982. /**
  117983. * @hidden
  117984. * This is reserved for the inspector.
  117985. * Defines the material debug mode.
  117986. * It helps seeing only some components of the material while troubleshooting.
  117987. */
  117988. debugMode: number;
  117989. /**
  117990. * @hidden
  117991. * This is reserved for the inspector.
  117992. * Specify from where on screen the debug mode should start.
  117993. * The value goes from -1 (full screen) to 1 (not visible)
  117994. * It helps with side by side comparison against the final render
  117995. * This defaults to -1
  117996. */
  117997. private debugLimit;
  117998. /**
  117999. * @hidden
  118000. * This is reserved for the inspector.
  118001. * As the default viewing range might not be enough (if the ambient is really small for instance)
  118002. * You can use the factor to better multiply the final value.
  118003. */
  118004. private debugFactor;
  118005. /**
  118006. * Defines the clear coat layer parameters for the material.
  118007. */
  118008. readonly clearCoat: PBRClearCoatConfiguration;
  118009. /**
  118010. * Defines the anisotropic parameters for the material.
  118011. */
  118012. readonly anisotropy: PBRAnisotropicConfiguration;
  118013. /**
  118014. * Defines the BRDF parameters for the material.
  118015. */
  118016. readonly brdf: PBRBRDFConfiguration;
  118017. /**
  118018. * Defines the Sheen parameters for the material.
  118019. */
  118020. readonly sheen: PBRSheenConfiguration;
  118021. /**
  118022. * Defines the SubSurface parameters for the material.
  118023. */
  118024. readonly subSurface: PBRSubSurfaceConfiguration;
  118025. /**
  118026. * Custom callback helping to override the default shader used in the material.
  118027. */
  118028. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  118029. protected _rebuildInParallel: boolean;
  118030. /**
  118031. * Instantiates a new PBRMaterial instance.
  118032. *
  118033. * @param name The material name
  118034. * @param scene The scene the material will be use in.
  118035. */
  118036. constructor(name: string, scene: Scene);
  118037. /**
  118038. * Gets a boolean indicating that current material needs to register RTT
  118039. */
  118040. readonly hasRenderTargetTextures: boolean;
  118041. /**
  118042. * Gets the name of the material class.
  118043. */
  118044. getClassName(): string;
  118045. /**
  118046. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  118047. */
  118048. /**
  118049. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  118050. */
  118051. useLogarithmicDepth: boolean;
  118052. /**
  118053. * Gets the current transparency mode.
  118054. */
  118055. /**
  118056. * Sets the transparency mode of the material.
  118057. *
  118058. * | Value | Type | Description |
  118059. * | ----- | ----------------------------------- | ----------- |
  118060. * | 0 | OPAQUE | |
  118061. * | 1 | ALPHATEST | |
  118062. * | 2 | ALPHABLEND | |
  118063. * | 3 | ALPHATESTANDBLEND | |
  118064. *
  118065. */
  118066. transparencyMode: Nullable<number>;
  118067. /**
  118068. * Returns true if alpha blending should be disabled.
  118069. */
  118070. private readonly _disableAlphaBlending;
  118071. /**
  118072. * Specifies whether or not this material should be rendered in alpha blend mode.
  118073. */
  118074. needAlphaBlending(): boolean;
  118075. /**
  118076. * Specifies if the mesh will require alpha blending.
  118077. * @param mesh - BJS mesh.
  118078. */
  118079. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  118080. /**
  118081. * Specifies whether or not this material should be rendered in alpha test mode.
  118082. */
  118083. needAlphaTesting(): boolean;
  118084. /**
  118085. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  118086. */
  118087. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  118088. /**
  118089. * Gets the texture used for the alpha test.
  118090. */
  118091. getAlphaTestTexture(): Nullable<BaseTexture>;
  118092. /**
  118093. * Specifies that the submesh is ready to be used.
  118094. * @param mesh - BJS mesh.
  118095. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  118096. * @param useInstances - Specifies that instances should be used.
  118097. * @returns - boolean indicating that the submesh is ready or not.
  118098. */
  118099. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  118100. /**
  118101. * Specifies if the material uses metallic roughness workflow.
  118102. * @returns boolean specifiying if the material uses metallic roughness workflow.
  118103. */
  118104. isMetallicWorkflow(): boolean;
  118105. private _prepareEffect;
  118106. private _prepareDefines;
  118107. /**
  118108. * Force shader compilation
  118109. */
  118110. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  118111. /**
  118112. * Initializes the uniform buffer layout for the shader.
  118113. */
  118114. buildUniformLayout(): void;
  118115. /**
  118116. * Unbinds the material from the mesh
  118117. */
  118118. unbind(): void;
  118119. /**
  118120. * Binds the submesh data.
  118121. * @param world - The world matrix.
  118122. * @param mesh - The BJS mesh.
  118123. * @param subMesh - A submesh of the BJS mesh.
  118124. */
  118125. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  118126. /**
  118127. * Returns the animatable textures.
  118128. * @returns - Array of animatable textures.
  118129. */
  118130. getAnimatables(): IAnimatable[];
  118131. /**
  118132. * Returns the texture used for reflections.
  118133. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  118134. */
  118135. private _getReflectionTexture;
  118136. /**
  118137. * Returns an array of the actively used textures.
  118138. * @returns - Array of BaseTextures
  118139. */
  118140. getActiveTextures(): BaseTexture[];
  118141. /**
  118142. * Checks to see if a texture is used in the material.
  118143. * @param texture - Base texture to use.
  118144. * @returns - Boolean specifying if a texture is used in the material.
  118145. */
  118146. hasTexture(texture: BaseTexture): boolean;
  118147. /**
  118148. * Disposes the resources of the material.
  118149. * @param forceDisposeEffect - Forces the disposal of effects.
  118150. * @param forceDisposeTextures - Forces the disposal of all textures.
  118151. */
  118152. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  118153. }
  118154. }
  118155. declare module BABYLON {
  118156. /**
  118157. * The Physically based material of BJS.
  118158. *
  118159. * This offers the main features of a standard PBR material.
  118160. * For more information, please refer to the documentation :
  118161. * https://doc.babylonjs.com/how_to/physically_based_rendering
  118162. */
  118163. export class PBRMaterial extends PBRBaseMaterial {
  118164. /**
  118165. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  118166. */
  118167. static readonly PBRMATERIAL_OPAQUE: number;
  118168. /**
  118169. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  118170. */
  118171. static readonly PBRMATERIAL_ALPHATEST: number;
  118172. /**
  118173. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  118174. */
  118175. static readonly PBRMATERIAL_ALPHABLEND: number;
  118176. /**
  118177. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  118178. * They are also discarded below the alpha cutoff threshold to improve performances.
  118179. */
  118180. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  118181. /**
  118182. * Defines the default value of how much AO map is occluding the analytical lights
  118183. * (point spot...).
  118184. */
  118185. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  118186. /**
  118187. * Intensity of the direct lights e.g. the four lights available in your scene.
  118188. * This impacts both the direct diffuse and specular highlights.
  118189. */
  118190. directIntensity: number;
  118191. /**
  118192. * Intensity of the emissive part of the material.
  118193. * This helps controlling the emissive effect without modifying the emissive color.
  118194. */
  118195. emissiveIntensity: number;
  118196. /**
  118197. * Intensity of the environment e.g. how much the environment will light the object
  118198. * either through harmonics for rough material or through the refelction for shiny ones.
  118199. */
  118200. environmentIntensity: number;
  118201. /**
  118202. * This is a special control allowing the reduction of the specular highlights coming from the
  118203. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  118204. */
  118205. specularIntensity: number;
  118206. /**
  118207. * Debug Control allowing disabling the bump map on this material.
  118208. */
  118209. disableBumpMap: boolean;
  118210. /**
  118211. * AKA Diffuse Texture in standard nomenclature.
  118212. */
  118213. albedoTexture: BaseTexture;
  118214. /**
  118215. * AKA Occlusion Texture in other nomenclature.
  118216. */
  118217. ambientTexture: BaseTexture;
  118218. /**
  118219. * AKA Occlusion Texture Intensity in other nomenclature.
  118220. */
  118221. ambientTextureStrength: number;
  118222. /**
  118223. * Defines how much the AO map is occluding the analytical lights (point spot...).
  118224. * 1 means it completely occludes it
  118225. * 0 mean it has no impact
  118226. */
  118227. ambientTextureImpactOnAnalyticalLights: number;
  118228. /**
  118229. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  118230. */
  118231. opacityTexture: BaseTexture;
  118232. /**
  118233. * Stores the reflection values in a texture.
  118234. */
  118235. reflectionTexture: Nullable<BaseTexture>;
  118236. /**
  118237. * Stores the emissive values in a texture.
  118238. */
  118239. emissiveTexture: BaseTexture;
  118240. /**
  118241. * AKA Specular texture in other nomenclature.
  118242. */
  118243. reflectivityTexture: BaseTexture;
  118244. /**
  118245. * Used to switch from specular/glossiness to metallic/roughness workflow.
  118246. */
  118247. metallicTexture: BaseTexture;
  118248. /**
  118249. * Specifies the metallic scalar of the metallic/roughness workflow.
  118250. * Can also be used to scale the metalness values of the metallic texture.
  118251. */
  118252. metallic: Nullable<number>;
  118253. /**
  118254. * Specifies the roughness scalar of the metallic/roughness workflow.
  118255. * Can also be used to scale the roughness values of the metallic texture.
  118256. */
  118257. roughness: Nullable<number>;
  118258. /**
  118259. * Specifies the an F0 factor to help configuring the material F0.
  118260. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  118261. * to 0.5 the previously hard coded value stays the same.
  118262. * Can also be used to scale the F0 values of the metallic texture.
  118263. */
  118264. metallicF0Factor: number;
  118265. /**
  118266. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  118267. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  118268. * your expectation as it multiplies with the texture data.
  118269. */
  118270. useMetallicF0FactorFromMetallicTexture: boolean;
  118271. /**
  118272. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  118273. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  118274. */
  118275. microSurfaceTexture: BaseTexture;
  118276. /**
  118277. * Stores surface normal data used to displace a mesh in a texture.
  118278. */
  118279. bumpTexture: BaseTexture;
  118280. /**
  118281. * Stores the pre-calculated light information of a mesh in a texture.
  118282. */
  118283. lightmapTexture: BaseTexture;
  118284. /**
  118285. * Stores the refracted light information in a texture.
  118286. */
  118287. refractionTexture: Nullable<BaseTexture>;
  118288. /**
  118289. * The color of a material in ambient lighting.
  118290. */
  118291. ambientColor: Color3;
  118292. /**
  118293. * AKA Diffuse Color in other nomenclature.
  118294. */
  118295. albedoColor: Color3;
  118296. /**
  118297. * AKA Specular Color in other nomenclature.
  118298. */
  118299. reflectivityColor: Color3;
  118300. /**
  118301. * The color reflected from the material.
  118302. */
  118303. reflectionColor: Color3;
  118304. /**
  118305. * The color emitted from the material.
  118306. */
  118307. emissiveColor: Color3;
  118308. /**
  118309. * AKA Glossiness in other nomenclature.
  118310. */
  118311. microSurface: number;
  118312. /**
  118313. * source material index of refraction (IOR)' / 'destination material IOR.
  118314. */
  118315. indexOfRefraction: number;
  118316. /**
  118317. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  118318. */
  118319. invertRefractionY: boolean;
  118320. /**
  118321. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  118322. * Materials half opaque for instance using refraction could benefit from this control.
  118323. */
  118324. linkRefractionWithTransparency: boolean;
  118325. /**
  118326. * If true, the light map contains occlusion information instead of lighting info.
  118327. */
  118328. useLightmapAsShadowmap: boolean;
  118329. /**
  118330. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  118331. */
  118332. useAlphaFromAlbedoTexture: boolean;
  118333. /**
  118334. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  118335. */
  118336. forceAlphaTest: boolean;
  118337. /**
  118338. * Defines the alpha limits in alpha test mode.
  118339. */
  118340. alphaCutOff: number;
  118341. /**
  118342. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  118343. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  118344. */
  118345. useSpecularOverAlpha: boolean;
  118346. /**
  118347. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  118348. */
  118349. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  118350. /**
  118351. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  118352. */
  118353. useRoughnessFromMetallicTextureAlpha: boolean;
  118354. /**
  118355. * Specifies if the metallic texture contains the roughness information in its green channel.
  118356. */
  118357. useRoughnessFromMetallicTextureGreen: boolean;
  118358. /**
  118359. * Specifies if the metallic texture contains the metallness information in its blue channel.
  118360. */
  118361. useMetallnessFromMetallicTextureBlue: boolean;
  118362. /**
  118363. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  118364. */
  118365. useAmbientOcclusionFromMetallicTextureRed: boolean;
  118366. /**
  118367. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  118368. */
  118369. useAmbientInGrayScale: boolean;
  118370. /**
  118371. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  118372. * The material will try to infer what glossiness each pixel should be.
  118373. */
  118374. useAutoMicroSurfaceFromReflectivityMap: boolean;
  118375. /**
  118376. * BJS is using an harcoded light falloff based on a manually sets up range.
  118377. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  118378. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  118379. */
  118380. /**
  118381. * BJS is using an harcoded light falloff based on a manually sets up range.
  118382. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  118383. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  118384. */
  118385. usePhysicalLightFalloff: boolean;
  118386. /**
  118387. * In order to support the falloff compatibility with gltf, a special mode has been added
  118388. * to reproduce the gltf light falloff.
  118389. */
  118390. /**
  118391. * In order to support the falloff compatibility with gltf, a special mode has been added
  118392. * to reproduce the gltf light falloff.
  118393. */
  118394. useGLTFLightFalloff: boolean;
  118395. /**
  118396. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  118397. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  118398. */
  118399. useRadianceOverAlpha: boolean;
  118400. /**
  118401. * Allows using an object space normal map (instead of tangent space).
  118402. */
  118403. useObjectSpaceNormalMap: boolean;
  118404. /**
  118405. * Allows using the bump map in parallax mode.
  118406. */
  118407. useParallax: boolean;
  118408. /**
  118409. * Allows using the bump map in parallax occlusion mode.
  118410. */
  118411. useParallaxOcclusion: boolean;
  118412. /**
  118413. * Controls the scale bias of the parallax mode.
  118414. */
  118415. parallaxScaleBias: number;
  118416. /**
  118417. * If sets to true, disables all the lights affecting the material.
  118418. */
  118419. disableLighting: boolean;
  118420. /**
  118421. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  118422. */
  118423. forceIrradianceInFragment: boolean;
  118424. /**
  118425. * Number of Simultaneous lights allowed on the material.
  118426. */
  118427. maxSimultaneousLights: number;
  118428. /**
  118429. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  118430. */
  118431. invertNormalMapX: boolean;
  118432. /**
  118433. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  118434. */
  118435. invertNormalMapY: boolean;
  118436. /**
  118437. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  118438. */
  118439. twoSidedLighting: boolean;
  118440. /**
  118441. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  118442. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  118443. */
  118444. useAlphaFresnel: boolean;
  118445. /**
  118446. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  118447. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  118448. */
  118449. useLinearAlphaFresnel: boolean;
  118450. /**
  118451. * Let user defines the brdf lookup texture used for IBL.
  118452. * A default 8bit version is embedded but you could point at :
  118453. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  118454. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  118455. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  118456. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  118457. */
  118458. environmentBRDFTexture: Nullable<BaseTexture>;
  118459. /**
  118460. * Force normal to face away from face.
  118461. */
  118462. forceNormalForward: boolean;
  118463. /**
  118464. * Enables specular anti aliasing in the PBR shader.
  118465. * It will both interacts on the Geometry for analytical and IBL lighting.
  118466. * It also prefilter the roughness map based on the bump values.
  118467. */
  118468. enableSpecularAntiAliasing: boolean;
  118469. /**
  118470. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  118471. * makes the reflect vector face the model (under horizon).
  118472. */
  118473. useHorizonOcclusion: boolean;
  118474. /**
  118475. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  118476. * too much the area relying on ambient texture to define their ambient occlusion.
  118477. */
  118478. useRadianceOcclusion: boolean;
  118479. /**
  118480. * If set to true, no lighting calculations will be applied.
  118481. */
  118482. unlit: boolean;
  118483. /**
  118484. * Gets the image processing configuration used either in this material.
  118485. */
  118486. /**
  118487. * Sets the Default image processing configuration used either in the this material.
  118488. *
  118489. * If sets to null, the scene one is in use.
  118490. */
  118491. imageProcessingConfiguration: ImageProcessingConfiguration;
  118492. /**
  118493. * Gets wether the color curves effect is enabled.
  118494. */
  118495. /**
  118496. * Sets wether the color curves effect is enabled.
  118497. */
  118498. cameraColorCurvesEnabled: boolean;
  118499. /**
  118500. * Gets wether the color grading effect is enabled.
  118501. */
  118502. /**
  118503. * Gets wether the color grading effect is enabled.
  118504. */
  118505. cameraColorGradingEnabled: boolean;
  118506. /**
  118507. * Gets wether tonemapping is enabled or not.
  118508. */
  118509. /**
  118510. * Sets wether tonemapping is enabled or not
  118511. */
  118512. cameraToneMappingEnabled: boolean;
  118513. /**
  118514. * The camera exposure used on this material.
  118515. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  118516. * This corresponds to a photographic exposure.
  118517. */
  118518. /**
  118519. * The camera exposure used on this material.
  118520. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  118521. * This corresponds to a photographic exposure.
  118522. */
  118523. cameraExposure: number;
  118524. /**
  118525. * Gets The camera contrast used on this material.
  118526. */
  118527. /**
  118528. * Sets The camera contrast used on this material.
  118529. */
  118530. cameraContrast: number;
  118531. /**
  118532. * Gets the Color Grading 2D Lookup Texture.
  118533. */
  118534. /**
  118535. * Sets the Color Grading 2D Lookup Texture.
  118536. */
  118537. cameraColorGradingTexture: Nullable<BaseTexture>;
  118538. /**
  118539. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  118540. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  118541. * 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;
  118542. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  118543. */
  118544. /**
  118545. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  118546. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  118547. * 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;
  118548. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  118549. */
  118550. cameraColorCurves: Nullable<ColorCurves>;
  118551. /**
  118552. * Instantiates a new PBRMaterial instance.
  118553. *
  118554. * @param name The material name
  118555. * @param scene The scene the material will be use in.
  118556. */
  118557. constructor(name: string, scene: Scene);
  118558. /**
  118559. * Returns the name of this material class.
  118560. */
  118561. getClassName(): string;
  118562. /**
  118563. * Makes a duplicate of the current material.
  118564. * @param name - name to use for the new material.
  118565. */
  118566. clone(name: string): PBRMaterial;
  118567. /**
  118568. * Serializes this PBR Material.
  118569. * @returns - An object with the serialized material.
  118570. */
  118571. serialize(): any;
  118572. /**
  118573. * Parses a PBR Material from a serialized object.
  118574. * @param source - Serialized object.
  118575. * @param scene - BJS scene instance.
  118576. * @param rootUrl - url for the scene object
  118577. * @returns - PBRMaterial
  118578. */
  118579. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  118580. }
  118581. }
  118582. declare module BABYLON {
  118583. /**
  118584. * Direct draw surface info
  118585. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  118586. */
  118587. export interface DDSInfo {
  118588. /**
  118589. * Width of the texture
  118590. */
  118591. width: number;
  118592. /**
  118593. * Width of the texture
  118594. */
  118595. height: number;
  118596. /**
  118597. * Number of Mipmaps for the texture
  118598. * @see https://en.wikipedia.org/wiki/Mipmap
  118599. */
  118600. mipmapCount: number;
  118601. /**
  118602. * If the textures format is a known fourCC format
  118603. * @see https://www.fourcc.org/
  118604. */
  118605. isFourCC: boolean;
  118606. /**
  118607. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  118608. */
  118609. isRGB: boolean;
  118610. /**
  118611. * If the texture is a lumincance format
  118612. */
  118613. isLuminance: boolean;
  118614. /**
  118615. * If this is a cube texture
  118616. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  118617. */
  118618. isCube: boolean;
  118619. /**
  118620. * If the texture is a compressed format eg. FOURCC_DXT1
  118621. */
  118622. isCompressed: boolean;
  118623. /**
  118624. * The dxgiFormat of the texture
  118625. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  118626. */
  118627. dxgiFormat: number;
  118628. /**
  118629. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  118630. */
  118631. textureType: number;
  118632. /**
  118633. * Sphericle polynomial created for the dds texture
  118634. */
  118635. sphericalPolynomial?: SphericalPolynomial;
  118636. }
  118637. /**
  118638. * Class used to provide DDS decompression tools
  118639. */
  118640. export class DDSTools {
  118641. /**
  118642. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  118643. */
  118644. static StoreLODInAlphaChannel: boolean;
  118645. /**
  118646. * Gets DDS information from an array buffer
  118647. * @param arrayBuffer defines the array buffer to read data from
  118648. * @returns the DDS information
  118649. */
  118650. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  118651. private static _FloatView;
  118652. private static _Int32View;
  118653. private static _ToHalfFloat;
  118654. private static _FromHalfFloat;
  118655. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  118656. private static _GetHalfFloatRGBAArrayBuffer;
  118657. private static _GetFloatRGBAArrayBuffer;
  118658. private static _GetFloatAsUIntRGBAArrayBuffer;
  118659. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  118660. private static _GetRGBAArrayBuffer;
  118661. private static _ExtractLongWordOrder;
  118662. private static _GetRGBArrayBuffer;
  118663. private static _GetLuminanceArrayBuffer;
  118664. /**
  118665. * Uploads DDS Levels to a Babylon Texture
  118666. * @hidden
  118667. */
  118668. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  118669. }
  118670. interface ThinEngine {
  118671. /**
  118672. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  118673. * @param rootUrl defines the url where the file to load is located
  118674. * @param scene defines the current scene
  118675. * @param lodScale defines scale to apply to the mip map selection
  118676. * @param lodOffset defines offset to apply to the mip map selection
  118677. * @param onLoad defines an optional callback raised when the texture is loaded
  118678. * @param onError defines an optional callback raised if there is an issue to load the texture
  118679. * @param format defines the format of the data
  118680. * @param forcedExtension defines the extension to use to pick the right loader
  118681. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  118682. * @returns the cube texture as an InternalTexture
  118683. */
  118684. 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;
  118685. }
  118686. }
  118687. declare module BABYLON {
  118688. /**
  118689. * Implementation of the DDS Texture Loader.
  118690. * @hidden
  118691. */
  118692. export class _DDSTextureLoader implements IInternalTextureLoader {
  118693. /**
  118694. * Defines wether the loader supports cascade loading the different faces.
  118695. */
  118696. readonly supportCascades: boolean;
  118697. /**
  118698. * This returns if the loader support the current file information.
  118699. * @param extension defines the file extension of the file being loaded
  118700. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118701. * @param fallback defines the fallback internal texture if any
  118702. * @param isBase64 defines whether the texture is encoded as a base64
  118703. * @param isBuffer defines whether the texture data are stored as a buffer
  118704. * @returns true if the loader can load the specified file
  118705. */
  118706. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  118707. /**
  118708. * Transform the url before loading if required.
  118709. * @param rootUrl the url of the texture
  118710. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118711. * @returns the transformed texture
  118712. */
  118713. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  118714. /**
  118715. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  118716. * @param rootUrl the url of the texture
  118717. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118718. * @returns the fallback texture
  118719. */
  118720. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  118721. /**
  118722. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  118723. * @param data contains the texture data
  118724. * @param texture defines the BabylonJS internal texture
  118725. * @param createPolynomials will be true if polynomials have been requested
  118726. * @param onLoad defines the callback to trigger once the texture is ready
  118727. * @param onError defines the callback to trigger in case of error
  118728. */
  118729. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  118730. /**
  118731. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  118732. * @param data contains the texture data
  118733. * @param texture defines the BabylonJS internal texture
  118734. * @param callback defines the method to call once ready to upload
  118735. */
  118736. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  118737. }
  118738. }
  118739. declare module BABYLON {
  118740. /**
  118741. * Implementation of the ENV Texture Loader.
  118742. * @hidden
  118743. */
  118744. export class _ENVTextureLoader implements IInternalTextureLoader {
  118745. /**
  118746. * Defines wether the loader supports cascade loading the different faces.
  118747. */
  118748. readonly supportCascades: boolean;
  118749. /**
  118750. * This returns if the loader support the current file information.
  118751. * @param extension defines the file extension of the file being loaded
  118752. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118753. * @param fallback defines the fallback internal texture if any
  118754. * @param isBase64 defines whether the texture is encoded as a base64
  118755. * @param isBuffer defines whether the texture data are stored as a buffer
  118756. * @returns true if the loader can load the specified file
  118757. */
  118758. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  118759. /**
  118760. * Transform the url before loading if required.
  118761. * @param rootUrl the url of the texture
  118762. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118763. * @returns the transformed texture
  118764. */
  118765. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  118766. /**
  118767. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  118768. * @param rootUrl the url of the texture
  118769. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118770. * @returns the fallback texture
  118771. */
  118772. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  118773. /**
  118774. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  118775. * @param data contains the texture data
  118776. * @param texture defines the BabylonJS internal texture
  118777. * @param createPolynomials will be true if polynomials have been requested
  118778. * @param onLoad defines the callback to trigger once the texture is ready
  118779. * @param onError defines the callback to trigger in case of error
  118780. */
  118781. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  118782. /**
  118783. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  118784. * @param data contains the texture data
  118785. * @param texture defines the BabylonJS internal texture
  118786. * @param callback defines the method to call once ready to upload
  118787. */
  118788. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  118789. }
  118790. }
  118791. declare module BABYLON {
  118792. /**
  118793. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  118794. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  118795. */
  118796. export class KhronosTextureContainer {
  118797. /** contents of the KTX container file */
  118798. arrayBuffer: any;
  118799. private static HEADER_LEN;
  118800. private static COMPRESSED_2D;
  118801. private static COMPRESSED_3D;
  118802. private static TEX_2D;
  118803. private static TEX_3D;
  118804. /**
  118805. * Gets the openGL type
  118806. */
  118807. glType: number;
  118808. /**
  118809. * Gets the openGL type size
  118810. */
  118811. glTypeSize: number;
  118812. /**
  118813. * Gets the openGL format
  118814. */
  118815. glFormat: number;
  118816. /**
  118817. * Gets the openGL internal format
  118818. */
  118819. glInternalFormat: number;
  118820. /**
  118821. * Gets the base internal format
  118822. */
  118823. glBaseInternalFormat: number;
  118824. /**
  118825. * Gets image width in pixel
  118826. */
  118827. pixelWidth: number;
  118828. /**
  118829. * Gets image height in pixel
  118830. */
  118831. pixelHeight: number;
  118832. /**
  118833. * Gets image depth in pixels
  118834. */
  118835. pixelDepth: number;
  118836. /**
  118837. * Gets the number of array elements
  118838. */
  118839. numberOfArrayElements: number;
  118840. /**
  118841. * Gets the number of faces
  118842. */
  118843. numberOfFaces: number;
  118844. /**
  118845. * Gets the number of mipmap levels
  118846. */
  118847. numberOfMipmapLevels: number;
  118848. /**
  118849. * Gets the bytes of key value data
  118850. */
  118851. bytesOfKeyValueData: number;
  118852. /**
  118853. * Gets the load type
  118854. */
  118855. loadType: number;
  118856. /**
  118857. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  118858. */
  118859. isInvalid: boolean;
  118860. /**
  118861. * Creates a new KhronosTextureContainer
  118862. * @param arrayBuffer contents of the KTX container file
  118863. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  118864. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  118865. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  118866. */
  118867. constructor(
  118868. /** contents of the KTX container file */
  118869. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  118870. /**
  118871. * Uploads KTX content to a Babylon Texture.
  118872. * It is assumed that the texture has already been created & is currently bound
  118873. * @hidden
  118874. */
  118875. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  118876. private _upload2DCompressedLevels;
  118877. }
  118878. }
  118879. declare module BABYLON {
  118880. /**
  118881. * Implementation of the KTX Texture Loader.
  118882. * @hidden
  118883. */
  118884. export class _KTXTextureLoader implements IInternalTextureLoader {
  118885. /**
  118886. * Defines wether the loader supports cascade loading the different faces.
  118887. */
  118888. readonly supportCascades: boolean;
  118889. /**
  118890. * This returns if the loader support the current file information.
  118891. * @param extension defines the file extension of the file being loaded
  118892. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118893. * @param fallback defines the fallback internal texture if any
  118894. * @param isBase64 defines whether the texture is encoded as a base64
  118895. * @param isBuffer defines whether the texture data are stored as a buffer
  118896. * @returns true if the loader can load the specified file
  118897. */
  118898. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  118899. /**
  118900. * Transform the url before loading if required.
  118901. * @param rootUrl the url of the texture
  118902. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118903. * @returns the transformed texture
  118904. */
  118905. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  118906. /**
  118907. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  118908. * @param rootUrl the url of the texture
  118909. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118910. * @returns the fallback texture
  118911. */
  118912. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  118913. /**
  118914. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  118915. * @param data contains the texture data
  118916. * @param texture defines the BabylonJS internal texture
  118917. * @param createPolynomials will be true if polynomials have been requested
  118918. * @param onLoad defines the callback to trigger once the texture is ready
  118919. * @param onError defines the callback to trigger in case of error
  118920. */
  118921. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  118922. /**
  118923. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  118924. * @param data contains the texture data
  118925. * @param texture defines the BabylonJS internal texture
  118926. * @param callback defines the method to call once ready to upload
  118927. */
  118928. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  118929. }
  118930. }
  118931. declare module BABYLON {
  118932. /** @hidden */
  118933. export var _forceSceneHelpersToBundle: boolean;
  118934. interface Scene {
  118935. /**
  118936. * Creates a default light for the scene.
  118937. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  118938. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  118939. */
  118940. createDefaultLight(replace?: boolean): void;
  118941. /**
  118942. * Creates a default camera for the scene.
  118943. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  118944. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  118945. * @param replace has default false, when true replaces the active camera in the scene
  118946. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  118947. */
  118948. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  118949. /**
  118950. * Creates a default camera and a default light.
  118951. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  118952. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  118953. * @param replace has the default false, when true replaces the active camera/light in the scene
  118954. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  118955. */
  118956. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  118957. /**
  118958. * Creates a new sky box
  118959. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  118960. * @param environmentTexture defines the texture to use as environment texture
  118961. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  118962. * @param scale defines the overall scale of the skybox
  118963. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  118964. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  118965. * @returns a new mesh holding the sky box
  118966. */
  118967. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  118968. /**
  118969. * Creates a new environment
  118970. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  118971. * @param options defines the options you can use to configure the environment
  118972. * @returns the new EnvironmentHelper
  118973. */
  118974. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  118975. /**
  118976. * Creates a new VREXperienceHelper
  118977. * @see http://doc.babylonjs.com/how_to/webvr_helper
  118978. * @param webVROptions defines the options used to create the new VREXperienceHelper
  118979. * @returns a new VREXperienceHelper
  118980. */
  118981. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  118982. /**
  118983. * Creates a new WebXRDefaultExperience
  118984. * @see http://doc.babylonjs.com/how_to/webxr
  118985. * @param options experience options
  118986. * @returns a promise for a new WebXRDefaultExperience
  118987. */
  118988. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  118989. }
  118990. }
  118991. declare module BABYLON {
  118992. /**
  118993. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  118994. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  118995. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  118996. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  118997. */
  118998. export class VideoDome extends TransformNode {
  118999. /**
  119000. * Define the video source as a Monoscopic panoramic 360 video.
  119001. */
  119002. static readonly MODE_MONOSCOPIC: number;
  119003. /**
  119004. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  119005. */
  119006. static readonly MODE_TOPBOTTOM: number;
  119007. /**
  119008. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  119009. */
  119010. static readonly MODE_SIDEBYSIDE: number;
  119011. private _halfDome;
  119012. private _useDirectMapping;
  119013. /**
  119014. * The video texture being displayed on the sphere
  119015. */
  119016. protected _videoTexture: VideoTexture;
  119017. /**
  119018. * Gets the video texture being displayed on the sphere
  119019. */
  119020. readonly videoTexture: VideoTexture;
  119021. /**
  119022. * The skybox material
  119023. */
  119024. protected _material: BackgroundMaterial;
  119025. /**
  119026. * The surface used for the skybox
  119027. */
  119028. protected _mesh: Mesh;
  119029. /**
  119030. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  119031. */
  119032. private _halfDomeMask;
  119033. /**
  119034. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  119035. * Also see the options.resolution property.
  119036. */
  119037. fovMultiplier: number;
  119038. private _videoMode;
  119039. /**
  119040. * Gets or set the current video mode for the video. It can be:
  119041. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  119042. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  119043. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  119044. */
  119045. videoMode: number;
  119046. /**
  119047. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  119048. *
  119049. */
  119050. /**
  119051. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  119052. */
  119053. halfDome: boolean;
  119054. /**
  119055. * Oberserver used in Stereoscopic VR Mode.
  119056. */
  119057. private _onBeforeCameraRenderObserver;
  119058. /**
  119059. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  119060. * @param name Element's name, child elements will append suffixes for their own names.
  119061. * @param urlsOrVideo defines the url(s) or the video element to use
  119062. * @param options An object containing optional or exposed sub element properties
  119063. */
  119064. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  119065. resolution?: number;
  119066. clickToPlay?: boolean;
  119067. autoPlay?: boolean;
  119068. loop?: boolean;
  119069. size?: number;
  119070. poster?: string;
  119071. faceForward?: boolean;
  119072. useDirectMapping?: boolean;
  119073. halfDomeMode?: boolean;
  119074. }, scene: Scene);
  119075. private _changeVideoMode;
  119076. /**
  119077. * Releases resources associated with this node.
  119078. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  119079. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  119080. */
  119081. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  119082. }
  119083. }
  119084. declare module BABYLON {
  119085. /**
  119086. * This class can be used to get instrumentation data from a Babylon engine
  119087. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  119088. */
  119089. export class EngineInstrumentation implements IDisposable {
  119090. /**
  119091. * Define the instrumented engine.
  119092. */
  119093. engine: Engine;
  119094. private _captureGPUFrameTime;
  119095. private _gpuFrameTimeToken;
  119096. private _gpuFrameTime;
  119097. private _captureShaderCompilationTime;
  119098. private _shaderCompilationTime;
  119099. private _onBeginFrameObserver;
  119100. private _onEndFrameObserver;
  119101. private _onBeforeShaderCompilationObserver;
  119102. private _onAfterShaderCompilationObserver;
  119103. /**
  119104. * Gets the perf counter used for GPU frame time
  119105. */
  119106. readonly gpuFrameTimeCounter: PerfCounter;
  119107. /**
  119108. * Gets the GPU frame time capture status
  119109. */
  119110. /**
  119111. * Enable or disable the GPU frame time capture
  119112. */
  119113. captureGPUFrameTime: boolean;
  119114. /**
  119115. * Gets the perf counter used for shader compilation time
  119116. */
  119117. readonly shaderCompilationTimeCounter: PerfCounter;
  119118. /**
  119119. * Gets the shader compilation time capture status
  119120. */
  119121. /**
  119122. * Enable or disable the shader compilation time capture
  119123. */
  119124. captureShaderCompilationTime: boolean;
  119125. /**
  119126. * Instantiates a new engine instrumentation.
  119127. * This class can be used to get instrumentation data from a Babylon engine
  119128. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  119129. * @param engine Defines the engine to instrument
  119130. */
  119131. constructor(
  119132. /**
  119133. * Define the instrumented engine.
  119134. */
  119135. engine: Engine);
  119136. /**
  119137. * Dispose and release associated resources.
  119138. */
  119139. dispose(): void;
  119140. }
  119141. }
  119142. declare module BABYLON {
  119143. /**
  119144. * This class can be used to get instrumentation data from a Babylon engine
  119145. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  119146. */
  119147. export class SceneInstrumentation implements IDisposable {
  119148. /**
  119149. * Defines the scene to instrument
  119150. */
  119151. scene: Scene;
  119152. private _captureActiveMeshesEvaluationTime;
  119153. private _activeMeshesEvaluationTime;
  119154. private _captureRenderTargetsRenderTime;
  119155. private _renderTargetsRenderTime;
  119156. private _captureFrameTime;
  119157. private _frameTime;
  119158. private _captureRenderTime;
  119159. private _renderTime;
  119160. private _captureInterFrameTime;
  119161. private _interFrameTime;
  119162. private _captureParticlesRenderTime;
  119163. private _particlesRenderTime;
  119164. private _captureSpritesRenderTime;
  119165. private _spritesRenderTime;
  119166. private _capturePhysicsTime;
  119167. private _physicsTime;
  119168. private _captureAnimationsTime;
  119169. private _animationsTime;
  119170. private _captureCameraRenderTime;
  119171. private _cameraRenderTime;
  119172. private _onBeforeActiveMeshesEvaluationObserver;
  119173. private _onAfterActiveMeshesEvaluationObserver;
  119174. private _onBeforeRenderTargetsRenderObserver;
  119175. private _onAfterRenderTargetsRenderObserver;
  119176. private _onAfterRenderObserver;
  119177. private _onBeforeDrawPhaseObserver;
  119178. private _onAfterDrawPhaseObserver;
  119179. private _onBeforeAnimationsObserver;
  119180. private _onBeforeParticlesRenderingObserver;
  119181. private _onAfterParticlesRenderingObserver;
  119182. private _onBeforeSpritesRenderingObserver;
  119183. private _onAfterSpritesRenderingObserver;
  119184. private _onBeforePhysicsObserver;
  119185. private _onAfterPhysicsObserver;
  119186. private _onAfterAnimationsObserver;
  119187. private _onBeforeCameraRenderObserver;
  119188. private _onAfterCameraRenderObserver;
  119189. /**
  119190. * Gets the perf counter used for active meshes evaluation time
  119191. */
  119192. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  119193. /**
  119194. * Gets the active meshes evaluation time capture status
  119195. */
  119196. /**
  119197. * Enable or disable the active meshes evaluation time capture
  119198. */
  119199. captureActiveMeshesEvaluationTime: boolean;
  119200. /**
  119201. * Gets the perf counter used for render targets render time
  119202. */
  119203. readonly renderTargetsRenderTimeCounter: PerfCounter;
  119204. /**
  119205. * Gets the render targets render time capture status
  119206. */
  119207. /**
  119208. * Enable or disable the render targets render time capture
  119209. */
  119210. captureRenderTargetsRenderTime: boolean;
  119211. /**
  119212. * Gets the perf counter used for particles render time
  119213. */
  119214. readonly particlesRenderTimeCounter: PerfCounter;
  119215. /**
  119216. * Gets the particles render time capture status
  119217. */
  119218. /**
  119219. * Enable or disable the particles render time capture
  119220. */
  119221. captureParticlesRenderTime: boolean;
  119222. /**
  119223. * Gets the perf counter used for sprites render time
  119224. */
  119225. readonly spritesRenderTimeCounter: PerfCounter;
  119226. /**
  119227. * Gets the sprites render time capture status
  119228. */
  119229. /**
  119230. * Enable or disable the sprites render time capture
  119231. */
  119232. captureSpritesRenderTime: boolean;
  119233. /**
  119234. * Gets the perf counter used for physics time
  119235. */
  119236. readonly physicsTimeCounter: PerfCounter;
  119237. /**
  119238. * Gets the physics time capture status
  119239. */
  119240. /**
  119241. * Enable or disable the physics time capture
  119242. */
  119243. capturePhysicsTime: boolean;
  119244. /**
  119245. * Gets the perf counter used for animations time
  119246. */
  119247. readonly animationsTimeCounter: PerfCounter;
  119248. /**
  119249. * Gets the animations time capture status
  119250. */
  119251. /**
  119252. * Enable or disable the animations time capture
  119253. */
  119254. captureAnimationsTime: boolean;
  119255. /**
  119256. * Gets the perf counter used for frame time capture
  119257. */
  119258. readonly frameTimeCounter: PerfCounter;
  119259. /**
  119260. * Gets the frame time capture status
  119261. */
  119262. /**
  119263. * Enable or disable the frame time capture
  119264. */
  119265. captureFrameTime: boolean;
  119266. /**
  119267. * Gets the perf counter used for inter-frames time capture
  119268. */
  119269. readonly interFrameTimeCounter: PerfCounter;
  119270. /**
  119271. * Gets the inter-frames time capture status
  119272. */
  119273. /**
  119274. * Enable or disable the inter-frames time capture
  119275. */
  119276. captureInterFrameTime: boolean;
  119277. /**
  119278. * Gets the perf counter used for render time capture
  119279. */
  119280. readonly renderTimeCounter: PerfCounter;
  119281. /**
  119282. * Gets the render time capture status
  119283. */
  119284. /**
  119285. * Enable or disable the render time capture
  119286. */
  119287. captureRenderTime: boolean;
  119288. /**
  119289. * Gets the perf counter used for camera render time capture
  119290. */
  119291. readonly cameraRenderTimeCounter: PerfCounter;
  119292. /**
  119293. * Gets the camera render time capture status
  119294. */
  119295. /**
  119296. * Enable or disable the camera render time capture
  119297. */
  119298. captureCameraRenderTime: boolean;
  119299. /**
  119300. * Gets the perf counter used for draw calls
  119301. */
  119302. readonly drawCallsCounter: PerfCounter;
  119303. /**
  119304. * Instantiates a new scene instrumentation.
  119305. * This class can be used to get instrumentation data from a Babylon engine
  119306. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  119307. * @param scene Defines the scene to instrument
  119308. */
  119309. constructor(
  119310. /**
  119311. * Defines the scene to instrument
  119312. */
  119313. scene: Scene);
  119314. /**
  119315. * Dispose and release associated resources.
  119316. */
  119317. dispose(): void;
  119318. }
  119319. }
  119320. declare module BABYLON {
  119321. /** @hidden */
  119322. export var glowMapGenerationPixelShader: {
  119323. name: string;
  119324. shader: string;
  119325. };
  119326. }
  119327. declare module BABYLON {
  119328. /** @hidden */
  119329. export var glowMapGenerationVertexShader: {
  119330. name: string;
  119331. shader: string;
  119332. };
  119333. }
  119334. declare module BABYLON {
  119335. /**
  119336. * Effect layer options. This helps customizing the behaviour
  119337. * of the effect layer.
  119338. */
  119339. export interface IEffectLayerOptions {
  119340. /**
  119341. * Multiplication factor apply to the canvas size to compute the render target size
  119342. * used to generated the objects (the smaller the faster).
  119343. */
  119344. mainTextureRatio: number;
  119345. /**
  119346. * Enforces a fixed size texture to ensure effect stability across devices.
  119347. */
  119348. mainTextureFixedSize?: number;
  119349. /**
  119350. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  119351. */
  119352. alphaBlendingMode: number;
  119353. /**
  119354. * The camera attached to the layer.
  119355. */
  119356. camera: Nullable<Camera>;
  119357. /**
  119358. * The rendering group to draw the layer in.
  119359. */
  119360. renderingGroupId: number;
  119361. }
  119362. /**
  119363. * The effect layer Helps adding post process effect blended with the main pass.
  119364. *
  119365. * This can be for instance use to generate glow or higlight effects on the scene.
  119366. *
  119367. * The effect layer class can not be used directly and is intented to inherited from to be
  119368. * customized per effects.
  119369. */
  119370. export abstract class EffectLayer {
  119371. private _vertexBuffers;
  119372. private _indexBuffer;
  119373. private _cachedDefines;
  119374. private _effectLayerMapGenerationEffect;
  119375. private _effectLayerOptions;
  119376. private _mergeEffect;
  119377. protected _scene: Scene;
  119378. protected _engine: Engine;
  119379. protected _maxSize: number;
  119380. protected _mainTextureDesiredSize: ISize;
  119381. protected _mainTexture: RenderTargetTexture;
  119382. protected _shouldRender: boolean;
  119383. protected _postProcesses: PostProcess[];
  119384. protected _textures: BaseTexture[];
  119385. protected _emissiveTextureAndColor: {
  119386. texture: Nullable<BaseTexture>;
  119387. color: Color4;
  119388. };
  119389. /**
  119390. * The name of the layer
  119391. */
  119392. name: string;
  119393. /**
  119394. * The clear color of the texture used to generate the glow map.
  119395. */
  119396. neutralColor: Color4;
  119397. /**
  119398. * Specifies wether the highlight layer is enabled or not.
  119399. */
  119400. isEnabled: boolean;
  119401. /**
  119402. * Gets the camera attached to the layer.
  119403. */
  119404. readonly camera: Nullable<Camera>;
  119405. /**
  119406. * Gets the rendering group id the layer should render in.
  119407. */
  119408. renderingGroupId: number;
  119409. /**
  119410. * An event triggered when the effect layer has been disposed.
  119411. */
  119412. onDisposeObservable: Observable<EffectLayer>;
  119413. /**
  119414. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  119415. */
  119416. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  119417. /**
  119418. * An event triggered when the generated texture is being merged in the scene.
  119419. */
  119420. onBeforeComposeObservable: Observable<EffectLayer>;
  119421. /**
  119422. * An event triggered when the mesh is rendered into the effect render target.
  119423. */
  119424. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  119425. /**
  119426. * An event triggered after the mesh has been rendered into the effect render target.
  119427. */
  119428. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  119429. /**
  119430. * An event triggered when the generated texture has been merged in the scene.
  119431. */
  119432. onAfterComposeObservable: Observable<EffectLayer>;
  119433. /**
  119434. * An event triggered when the efffect layer changes its size.
  119435. */
  119436. onSizeChangedObservable: Observable<EffectLayer>;
  119437. /** @hidden */
  119438. static _SceneComponentInitialization: (scene: Scene) => void;
  119439. /**
  119440. * Instantiates a new effect Layer and references it in the scene.
  119441. * @param name The name of the layer
  119442. * @param scene The scene to use the layer in
  119443. */
  119444. constructor(
  119445. /** The Friendly of the effect in the scene */
  119446. name: string, scene: Scene);
  119447. /**
  119448. * Get the effect name of the layer.
  119449. * @return The effect name
  119450. */
  119451. abstract getEffectName(): string;
  119452. /**
  119453. * Checks for the readiness of the element composing the layer.
  119454. * @param subMesh the mesh to check for
  119455. * @param useInstances specify wether or not to use instances to render the mesh
  119456. * @return true if ready otherwise, false
  119457. */
  119458. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  119459. /**
  119460. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  119461. * @returns true if the effect requires stencil during the main canvas render pass.
  119462. */
  119463. abstract needStencil(): boolean;
  119464. /**
  119465. * Create the merge effect. This is the shader use to blit the information back
  119466. * to the main canvas at the end of the scene rendering.
  119467. * @returns The effect containing the shader used to merge the effect on the main canvas
  119468. */
  119469. protected abstract _createMergeEffect(): Effect;
  119470. /**
  119471. * Creates the render target textures and post processes used in the effect layer.
  119472. */
  119473. protected abstract _createTextureAndPostProcesses(): void;
  119474. /**
  119475. * Implementation specific of rendering the generating effect on the main canvas.
  119476. * @param effect The effect used to render through
  119477. */
  119478. protected abstract _internalRender(effect: Effect): void;
  119479. /**
  119480. * Sets the required values for both the emissive texture and and the main color.
  119481. */
  119482. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  119483. /**
  119484. * Free any resources and references associated to a mesh.
  119485. * Internal use
  119486. * @param mesh The mesh to free.
  119487. */
  119488. abstract _disposeMesh(mesh: Mesh): void;
  119489. /**
  119490. * Serializes this layer (Glow or Highlight for example)
  119491. * @returns a serialized layer object
  119492. */
  119493. abstract serialize?(): any;
  119494. /**
  119495. * Initializes the effect layer with the required options.
  119496. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  119497. */
  119498. protected _init(options: Partial<IEffectLayerOptions>): void;
  119499. /**
  119500. * Generates the index buffer of the full screen quad blending to the main canvas.
  119501. */
  119502. private _generateIndexBuffer;
  119503. /**
  119504. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  119505. */
  119506. private _generateVertexBuffer;
  119507. /**
  119508. * Sets the main texture desired size which is the closest power of two
  119509. * of the engine canvas size.
  119510. */
  119511. private _setMainTextureSize;
  119512. /**
  119513. * Creates the main texture for the effect layer.
  119514. */
  119515. protected _createMainTexture(): void;
  119516. /**
  119517. * Adds specific effects defines.
  119518. * @param defines The defines to add specifics to.
  119519. */
  119520. protected _addCustomEffectDefines(defines: string[]): void;
  119521. /**
  119522. * Checks for the readiness of the element composing the layer.
  119523. * @param subMesh the mesh to check for
  119524. * @param useInstances specify wether or not to use instances to render the mesh
  119525. * @param emissiveTexture the associated emissive texture used to generate the glow
  119526. * @return true if ready otherwise, false
  119527. */
  119528. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  119529. /**
  119530. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  119531. */
  119532. render(): void;
  119533. /**
  119534. * Determine if a given mesh will be used in the current effect.
  119535. * @param mesh mesh to test
  119536. * @returns true if the mesh will be used
  119537. */
  119538. hasMesh(mesh: AbstractMesh): boolean;
  119539. /**
  119540. * Returns true if the layer contains information to display, otherwise false.
  119541. * @returns true if the glow layer should be rendered
  119542. */
  119543. shouldRender(): boolean;
  119544. /**
  119545. * Returns true if the mesh should render, otherwise false.
  119546. * @param mesh The mesh to render
  119547. * @returns true if it should render otherwise false
  119548. */
  119549. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  119550. /**
  119551. * Returns true if the mesh can be rendered, otherwise false.
  119552. * @param mesh The mesh to render
  119553. * @param material The material used on the mesh
  119554. * @returns true if it can be rendered otherwise false
  119555. */
  119556. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  119557. /**
  119558. * Returns true if the mesh should render, otherwise false.
  119559. * @param mesh The mesh to render
  119560. * @returns true if it should render otherwise false
  119561. */
  119562. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  119563. /**
  119564. * Renders the submesh passed in parameter to the generation map.
  119565. */
  119566. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  119567. /**
  119568. * Defines wether the current material of the mesh should be use to render the effect.
  119569. * @param mesh defines the current mesh to render
  119570. */
  119571. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  119572. /**
  119573. * Rebuild the required buffers.
  119574. * @hidden Internal use only.
  119575. */
  119576. _rebuild(): void;
  119577. /**
  119578. * Dispose only the render target textures and post process.
  119579. */
  119580. private _disposeTextureAndPostProcesses;
  119581. /**
  119582. * Dispose the highlight layer and free resources.
  119583. */
  119584. dispose(): void;
  119585. /**
  119586. * Gets the class name of the effect layer
  119587. * @returns the string with the class name of the effect layer
  119588. */
  119589. getClassName(): string;
  119590. /**
  119591. * Creates an effect layer from parsed effect layer data
  119592. * @param parsedEffectLayer defines effect layer data
  119593. * @param scene defines the current scene
  119594. * @param rootUrl defines the root URL containing the effect layer information
  119595. * @returns a parsed effect Layer
  119596. */
  119597. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  119598. }
  119599. }
  119600. declare module BABYLON {
  119601. interface AbstractScene {
  119602. /**
  119603. * The list of effect layers (highlights/glow) added to the scene
  119604. * @see http://doc.babylonjs.com/how_to/highlight_layer
  119605. * @see http://doc.babylonjs.com/how_to/glow_layer
  119606. */
  119607. effectLayers: Array<EffectLayer>;
  119608. /**
  119609. * Removes the given effect layer from this scene.
  119610. * @param toRemove defines the effect layer to remove
  119611. * @returns the index of the removed effect layer
  119612. */
  119613. removeEffectLayer(toRemove: EffectLayer): number;
  119614. /**
  119615. * Adds the given effect layer to this scene
  119616. * @param newEffectLayer defines the effect layer to add
  119617. */
  119618. addEffectLayer(newEffectLayer: EffectLayer): void;
  119619. }
  119620. /**
  119621. * Defines the layer scene component responsible to manage any effect layers
  119622. * in a given scene.
  119623. */
  119624. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  119625. /**
  119626. * The component name helpfull to identify the component in the list of scene components.
  119627. */
  119628. readonly name: string;
  119629. /**
  119630. * The scene the component belongs to.
  119631. */
  119632. scene: Scene;
  119633. private _engine;
  119634. private _renderEffects;
  119635. private _needStencil;
  119636. private _previousStencilState;
  119637. /**
  119638. * Creates a new instance of the component for the given scene
  119639. * @param scene Defines the scene to register the component in
  119640. */
  119641. constructor(scene: Scene);
  119642. /**
  119643. * Registers the component in a given scene
  119644. */
  119645. register(): void;
  119646. /**
  119647. * Rebuilds the elements related to this component in case of
  119648. * context lost for instance.
  119649. */
  119650. rebuild(): void;
  119651. /**
  119652. * Serializes the component data to the specified json object
  119653. * @param serializationObject The object to serialize to
  119654. */
  119655. serialize(serializationObject: any): void;
  119656. /**
  119657. * Adds all the elements from the container to the scene
  119658. * @param container the container holding the elements
  119659. */
  119660. addFromContainer(container: AbstractScene): void;
  119661. /**
  119662. * Removes all the elements in the container from the scene
  119663. * @param container contains the elements to remove
  119664. * @param dispose if the removed element should be disposed (default: false)
  119665. */
  119666. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  119667. /**
  119668. * Disposes the component and the associated ressources.
  119669. */
  119670. dispose(): void;
  119671. private _isReadyForMesh;
  119672. private _renderMainTexture;
  119673. private _setStencil;
  119674. private _setStencilBack;
  119675. private _draw;
  119676. private _drawCamera;
  119677. private _drawRenderingGroup;
  119678. }
  119679. }
  119680. declare module BABYLON {
  119681. /** @hidden */
  119682. export var glowMapMergePixelShader: {
  119683. name: string;
  119684. shader: string;
  119685. };
  119686. }
  119687. declare module BABYLON {
  119688. /** @hidden */
  119689. export var glowMapMergeVertexShader: {
  119690. name: string;
  119691. shader: string;
  119692. };
  119693. }
  119694. declare module BABYLON {
  119695. interface AbstractScene {
  119696. /**
  119697. * Return a the first highlight layer of the scene with a given name.
  119698. * @param name The name of the highlight layer to look for.
  119699. * @return The highlight layer if found otherwise null.
  119700. */
  119701. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  119702. }
  119703. /**
  119704. * Glow layer options. This helps customizing the behaviour
  119705. * of the glow layer.
  119706. */
  119707. export interface IGlowLayerOptions {
  119708. /**
  119709. * Multiplication factor apply to the canvas size to compute the render target size
  119710. * used to generated the glowing objects (the smaller the faster).
  119711. */
  119712. mainTextureRatio: number;
  119713. /**
  119714. * Enforces a fixed size texture to ensure resize independant blur.
  119715. */
  119716. mainTextureFixedSize?: number;
  119717. /**
  119718. * How big is the kernel of the blur texture.
  119719. */
  119720. blurKernelSize: number;
  119721. /**
  119722. * The camera attached to the layer.
  119723. */
  119724. camera: Nullable<Camera>;
  119725. /**
  119726. * Enable MSAA by chosing the number of samples.
  119727. */
  119728. mainTextureSamples?: number;
  119729. /**
  119730. * The rendering group to draw the layer in.
  119731. */
  119732. renderingGroupId: number;
  119733. }
  119734. /**
  119735. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  119736. *
  119737. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  119738. *
  119739. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  119740. */
  119741. export class GlowLayer extends EffectLayer {
  119742. /**
  119743. * Effect Name of the layer.
  119744. */
  119745. static readonly EffectName: string;
  119746. /**
  119747. * The default blur kernel size used for the glow.
  119748. */
  119749. static DefaultBlurKernelSize: number;
  119750. /**
  119751. * The default texture size ratio used for the glow.
  119752. */
  119753. static DefaultTextureRatio: number;
  119754. /**
  119755. * Sets the kernel size of the blur.
  119756. */
  119757. /**
  119758. * Gets the kernel size of the blur.
  119759. */
  119760. blurKernelSize: number;
  119761. /**
  119762. * Sets the glow intensity.
  119763. */
  119764. /**
  119765. * Gets the glow intensity.
  119766. */
  119767. intensity: number;
  119768. private _options;
  119769. private _intensity;
  119770. private _horizontalBlurPostprocess1;
  119771. private _verticalBlurPostprocess1;
  119772. private _horizontalBlurPostprocess2;
  119773. private _verticalBlurPostprocess2;
  119774. private _blurTexture1;
  119775. private _blurTexture2;
  119776. private _postProcesses1;
  119777. private _postProcesses2;
  119778. private _includedOnlyMeshes;
  119779. private _excludedMeshes;
  119780. private _meshesUsingTheirOwnMaterials;
  119781. /**
  119782. * Callback used to let the user override the color selection on a per mesh basis
  119783. */
  119784. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  119785. /**
  119786. * Callback used to let the user override the texture selection on a per mesh basis
  119787. */
  119788. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  119789. /**
  119790. * Instantiates a new glow Layer and references it to the scene.
  119791. * @param name The name of the layer
  119792. * @param scene The scene to use the layer in
  119793. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  119794. */
  119795. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  119796. /**
  119797. * Get the effect name of the layer.
  119798. * @return The effect name
  119799. */
  119800. getEffectName(): string;
  119801. /**
  119802. * Create the merge effect. This is the shader use to blit the information back
  119803. * to the main canvas at the end of the scene rendering.
  119804. */
  119805. protected _createMergeEffect(): Effect;
  119806. /**
  119807. * Creates the render target textures and post processes used in the glow layer.
  119808. */
  119809. protected _createTextureAndPostProcesses(): void;
  119810. /**
  119811. * Checks for the readiness of the element composing the layer.
  119812. * @param subMesh the mesh to check for
  119813. * @param useInstances specify wether or not to use instances to render the mesh
  119814. * @param emissiveTexture the associated emissive texture used to generate the glow
  119815. * @return true if ready otherwise, false
  119816. */
  119817. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  119818. /**
  119819. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  119820. */
  119821. needStencil(): boolean;
  119822. /**
  119823. * Returns true if the mesh can be rendered, otherwise false.
  119824. * @param mesh The mesh to render
  119825. * @param material The material used on the mesh
  119826. * @returns true if it can be rendered otherwise false
  119827. */
  119828. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  119829. /**
  119830. * Implementation specific of rendering the generating effect on the main canvas.
  119831. * @param effect The effect used to render through
  119832. */
  119833. protected _internalRender(effect: Effect): void;
  119834. /**
  119835. * Sets the required values for both the emissive texture and and the main color.
  119836. */
  119837. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  119838. /**
  119839. * Returns true if the mesh should render, otherwise false.
  119840. * @param mesh The mesh to render
  119841. * @returns true if it should render otherwise false
  119842. */
  119843. protected _shouldRenderMesh(mesh: Mesh): boolean;
  119844. /**
  119845. * Adds specific effects defines.
  119846. * @param defines The defines to add specifics to.
  119847. */
  119848. protected _addCustomEffectDefines(defines: string[]): void;
  119849. /**
  119850. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  119851. * @param mesh The mesh to exclude from the glow layer
  119852. */
  119853. addExcludedMesh(mesh: Mesh): void;
  119854. /**
  119855. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  119856. * @param mesh The mesh to remove
  119857. */
  119858. removeExcludedMesh(mesh: Mesh): void;
  119859. /**
  119860. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  119861. * @param mesh The mesh to include in the glow layer
  119862. */
  119863. addIncludedOnlyMesh(mesh: Mesh): void;
  119864. /**
  119865. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  119866. * @param mesh The mesh to remove
  119867. */
  119868. removeIncludedOnlyMesh(mesh: Mesh): void;
  119869. /**
  119870. * Determine if a given mesh will be used in the glow layer
  119871. * @param mesh The mesh to test
  119872. * @returns true if the mesh will be highlighted by the current glow layer
  119873. */
  119874. hasMesh(mesh: AbstractMesh): boolean;
  119875. /**
  119876. * Defines wether the current material of the mesh should be use to render the effect.
  119877. * @param mesh defines the current mesh to render
  119878. */
  119879. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  119880. /**
  119881. * Add a mesh to be rendered through its own material and not with emissive only.
  119882. * @param mesh The mesh for which we need to use its material
  119883. */
  119884. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  119885. /**
  119886. * Remove a mesh from being rendered through its own material and not with emissive only.
  119887. * @param mesh The mesh for which we need to not use its material
  119888. */
  119889. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  119890. /**
  119891. * Free any resources and references associated to a mesh.
  119892. * Internal use
  119893. * @param mesh The mesh to free.
  119894. * @hidden
  119895. */
  119896. _disposeMesh(mesh: Mesh): void;
  119897. /**
  119898. * Gets the class name of the effect layer
  119899. * @returns the string with the class name of the effect layer
  119900. */
  119901. getClassName(): string;
  119902. /**
  119903. * Serializes this glow layer
  119904. * @returns a serialized glow layer object
  119905. */
  119906. serialize(): any;
  119907. /**
  119908. * Creates a Glow Layer from parsed glow layer data
  119909. * @param parsedGlowLayer defines glow layer data
  119910. * @param scene defines the current scene
  119911. * @param rootUrl defines the root URL containing the glow layer information
  119912. * @returns a parsed Glow Layer
  119913. */
  119914. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  119915. }
  119916. }
  119917. declare module BABYLON {
  119918. /** @hidden */
  119919. export var glowBlurPostProcessPixelShader: {
  119920. name: string;
  119921. shader: string;
  119922. };
  119923. }
  119924. declare module BABYLON {
  119925. interface AbstractScene {
  119926. /**
  119927. * Return a the first highlight layer of the scene with a given name.
  119928. * @param name The name of the highlight layer to look for.
  119929. * @return The highlight layer if found otherwise null.
  119930. */
  119931. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  119932. }
  119933. /**
  119934. * Highlight layer options. This helps customizing the behaviour
  119935. * of the highlight layer.
  119936. */
  119937. export interface IHighlightLayerOptions {
  119938. /**
  119939. * Multiplication factor apply to the canvas size to compute the render target size
  119940. * used to generated the glowing objects (the smaller the faster).
  119941. */
  119942. mainTextureRatio: number;
  119943. /**
  119944. * Enforces a fixed size texture to ensure resize independant blur.
  119945. */
  119946. mainTextureFixedSize?: number;
  119947. /**
  119948. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  119949. * of the picture to blur (the smaller the faster).
  119950. */
  119951. blurTextureSizeRatio: number;
  119952. /**
  119953. * How big in texel of the blur texture is the vertical blur.
  119954. */
  119955. blurVerticalSize: number;
  119956. /**
  119957. * How big in texel of the blur texture is the horizontal blur.
  119958. */
  119959. blurHorizontalSize: number;
  119960. /**
  119961. * Alpha blending mode used to apply the blur. Default is combine.
  119962. */
  119963. alphaBlendingMode: number;
  119964. /**
  119965. * The camera attached to the layer.
  119966. */
  119967. camera: Nullable<Camera>;
  119968. /**
  119969. * Should we display highlight as a solid stroke?
  119970. */
  119971. isStroke?: boolean;
  119972. /**
  119973. * The rendering group to draw the layer in.
  119974. */
  119975. renderingGroupId: number;
  119976. }
  119977. /**
  119978. * The highlight layer Helps adding a glow effect around a mesh.
  119979. *
  119980. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  119981. * glowy meshes to your scene.
  119982. *
  119983. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  119984. */
  119985. export class HighlightLayer extends EffectLayer {
  119986. name: string;
  119987. /**
  119988. * Effect Name of the highlight layer.
  119989. */
  119990. static readonly EffectName: string;
  119991. /**
  119992. * The neutral color used during the preparation of the glow effect.
  119993. * This is black by default as the blend operation is a blend operation.
  119994. */
  119995. static NeutralColor: Color4;
  119996. /**
  119997. * Stencil value used for glowing meshes.
  119998. */
  119999. static GlowingMeshStencilReference: number;
  120000. /**
  120001. * Stencil value used for the other meshes in the scene.
  120002. */
  120003. static NormalMeshStencilReference: number;
  120004. /**
  120005. * Specifies whether or not the inner glow is ACTIVE in the layer.
  120006. */
  120007. innerGlow: boolean;
  120008. /**
  120009. * Specifies whether or not the outer glow is ACTIVE in the layer.
  120010. */
  120011. outerGlow: boolean;
  120012. /**
  120013. * Specifies the horizontal size of the blur.
  120014. */
  120015. /**
  120016. * Gets the horizontal size of the blur.
  120017. */
  120018. blurHorizontalSize: number;
  120019. /**
  120020. * Specifies the vertical size of the blur.
  120021. */
  120022. /**
  120023. * Gets the vertical size of the blur.
  120024. */
  120025. blurVerticalSize: number;
  120026. /**
  120027. * An event triggered when the highlight layer is being blurred.
  120028. */
  120029. onBeforeBlurObservable: Observable<HighlightLayer>;
  120030. /**
  120031. * An event triggered when the highlight layer has been blurred.
  120032. */
  120033. onAfterBlurObservable: Observable<HighlightLayer>;
  120034. private _instanceGlowingMeshStencilReference;
  120035. private _options;
  120036. private _downSamplePostprocess;
  120037. private _horizontalBlurPostprocess;
  120038. private _verticalBlurPostprocess;
  120039. private _blurTexture;
  120040. private _meshes;
  120041. private _excludedMeshes;
  120042. /**
  120043. * Instantiates a new highlight Layer and references it to the scene..
  120044. * @param name The name of the layer
  120045. * @param scene The scene to use the layer in
  120046. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  120047. */
  120048. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  120049. /**
  120050. * Get the effect name of the layer.
  120051. * @return The effect name
  120052. */
  120053. getEffectName(): string;
  120054. /**
  120055. * Create the merge effect. This is the shader use to blit the information back
  120056. * to the main canvas at the end of the scene rendering.
  120057. */
  120058. protected _createMergeEffect(): Effect;
  120059. /**
  120060. * Creates the render target textures and post processes used in the highlight layer.
  120061. */
  120062. protected _createTextureAndPostProcesses(): void;
  120063. /**
  120064. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  120065. */
  120066. needStencil(): boolean;
  120067. /**
  120068. * Checks for the readiness of the element composing the layer.
  120069. * @param subMesh the mesh to check for
  120070. * @param useInstances specify wether or not to use instances to render the mesh
  120071. * @param emissiveTexture the associated emissive texture used to generate the glow
  120072. * @return true if ready otherwise, false
  120073. */
  120074. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  120075. /**
  120076. * Implementation specific of rendering the generating effect on the main canvas.
  120077. * @param effect The effect used to render through
  120078. */
  120079. protected _internalRender(effect: Effect): void;
  120080. /**
  120081. * Returns true if the layer contains information to display, otherwise false.
  120082. */
  120083. shouldRender(): boolean;
  120084. /**
  120085. * Returns true if the mesh should render, otherwise false.
  120086. * @param mesh The mesh to render
  120087. * @returns true if it should render otherwise false
  120088. */
  120089. protected _shouldRenderMesh(mesh: Mesh): boolean;
  120090. /**
  120091. * Sets the required values for both the emissive texture and and the main color.
  120092. */
  120093. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  120094. /**
  120095. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  120096. * @param mesh The mesh to exclude from the highlight layer
  120097. */
  120098. addExcludedMesh(mesh: Mesh): void;
  120099. /**
  120100. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  120101. * @param mesh The mesh to highlight
  120102. */
  120103. removeExcludedMesh(mesh: Mesh): void;
  120104. /**
  120105. * Determine if a given mesh will be highlighted by the current HighlightLayer
  120106. * @param mesh mesh to test
  120107. * @returns true if the mesh will be highlighted by the current HighlightLayer
  120108. */
  120109. hasMesh(mesh: AbstractMesh): boolean;
  120110. /**
  120111. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  120112. * @param mesh The mesh to highlight
  120113. * @param color The color of the highlight
  120114. * @param glowEmissiveOnly Extract the glow from the emissive texture
  120115. */
  120116. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  120117. /**
  120118. * Remove a mesh from the highlight layer in order to make it stop glowing.
  120119. * @param mesh The mesh to highlight
  120120. */
  120121. removeMesh(mesh: Mesh): void;
  120122. /**
  120123. * Force the stencil to the normal expected value for none glowing parts
  120124. */
  120125. private _defaultStencilReference;
  120126. /**
  120127. * Free any resources and references associated to a mesh.
  120128. * Internal use
  120129. * @param mesh The mesh to free.
  120130. * @hidden
  120131. */
  120132. _disposeMesh(mesh: Mesh): void;
  120133. /**
  120134. * Dispose the highlight layer and free resources.
  120135. */
  120136. dispose(): void;
  120137. /**
  120138. * Gets the class name of the effect layer
  120139. * @returns the string with the class name of the effect layer
  120140. */
  120141. getClassName(): string;
  120142. /**
  120143. * Serializes this Highlight layer
  120144. * @returns a serialized Highlight layer object
  120145. */
  120146. serialize(): any;
  120147. /**
  120148. * Creates a Highlight layer from parsed Highlight layer data
  120149. * @param parsedHightlightLayer defines the Highlight layer data
  120150. * @param scene defines the current scene
  120151. * @param rootUrl defines the root URL containing the Highlight layer information
  120152. * @returns a parsed Highlight layer
  120153. */
  120154. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  120155. }
  120156. }
  120157. declare module BABYLON {
  120158. interface AbstractScene {
  120159. /**
  120160. * The list of layers (background and foreground) of the scene
  120161. */
  120162. layers: Array<Layer>;
  120163. }
  120164. /**
  120165. * Defines the layer scene component responsible to manage any layers
  120166. * in a given scene.
  120167. */
  120168. export class LayerSceneComponent implements ISceneComponent {
  120169. /**
  120170. * The component name helpfull to identify the component in the list of scene components.
  120171. */
  120172. readonly name: string;
  120173. /**
  120174. * The scene the component belongs to.
  120175. */
  120176. scene: Scene;
  120177. private _engine;
  120178. /**
  120179. * Creates a new instance of the component for the given scene
  120180. * @param scene Defines the scene to register the component in
  120181. */
  120182. constructor(scene: Scene);
  120183. /**
  120184. * Registers the component in a given scene
  120185. */
  120186. register(): void;
  120187. /**
  120188. * Rebuilds the elements related to this component in case of
  120189. * context lost for instance.
  120190. */
  120191. rebuild(): void;
  120192. /**
  120193. * Disposes the component and the associated ressources.
  120194. */
  120195. dispose(): void;
  120196. private _draw;
  120197. private _drawCameraPredicate;
  120198. private _drawCameraBackground;
  120199. private _drawCameraForeground;
  120200. private _drawRenderTargetPredicate;
  120201. private _drawRenderTargetBackground;
  120202. private _drawRenderTargetForeground;
  120203. /**
  120204. * Adds all the elements from the container to the scene
  120205. * @param container the container holding the elements
  120206. */
  120207. addFromContainer(container: AbstractScene): void;
  120208. /**
  120209. * Removes all the elements in the container from the scene
  120210. * @param container contains the elements to remove
  120211. * @param dispose if the removed element should be disposed (default: false)
  120212. */
  120213. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  120214. }
  120215. }
  120216. declare module BABYLON {
  120217. /** @hidden */
  120218. export var layerPixelShader: {
  120219. name: string;
  120220. shader: string;
  120221. };
  120222. }
  120223. declare module BABYLON {
  120224. /** @hidden */
  120225. export var layerVertexShader: {
  120226. name: string;
  120227. shader: string;
  120228. };
  120229. }
  120230. declare module BABYLON {
  120231. /**
  120232. * This represents a full screen 2d layer.
  120233. * This can be useful to display a picture in the background of your scene for instance.
  120234. * @see https://www.babylonjs-playground.com/#08A2BS#1
  120235. */
  120236. export class Layer {
  120237. /**
  120238. * Define the name of the layer.
  120239. */
  120240. name: string;
  120241. /**
  120242. * Define the texture the layer should display.
  120243. */
  120244. texture: Nullable<Texture>;
  120245. /**
  120246. * Is the layer in background or foreground.
  120247. */
  120248. isBackground: boolean;
  120249. /**
  120250. * Define the color of the layer (instead of texture).
  120251. */
  120252. color: Color4;
  120253. /**
  120254. * Define the scale of the layer in order to zoom in out of the texture.
  120255. */
  120256. scale: Vector2;
  120257. /**
  120258. * Define an offset for the layer in order to shift the texture.
  120259. */
  120260. offset: Vector2;
  120261. /**
  120262. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  120263. */
  120264. alphaBlendingMode: number;
  120265. /**
  120266. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  120267. * Alpha test will not mix with the background color in case of transparency.
  120268. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  120269. */
  120270. alphaTest: boolean;
  120271. /**
  120272. * Define a mask to restrict the layer to only some of the scene cameras.
  120273. */
  120274. layerMask: number;
  120275. /**
  120276. * Define the list of render target the layer is visible into.
  120277. */
  120278. renderTargetTextures: RenderTargetTexture[];
  120279. /**
  120280. * Define if the layer is only used in renderTarget or if it also
  120281. * renders in the main frame buffer of the canvas.
  120282. */
  120283. renderOnlyInRenderTargetTextures: boolean;
  120284. private _scene;
  120285. private _vertexBuffers;
  120286. private _indexBuffer;
  120287. private _effect;
  120288. private _previousDefines;
  120289. /**
  120290. * An event triggered when the layer is disposed.
  120291. */
  120292. onDisposeObservable: Observable<Layer>;
  120293. private _onDisposeObserver;
  120294. /**
  120295. * Back compatibility with callback before the onDisposeObservable existed.
  120296. * The set callback will be triggered when the layer has been disposed.
  120297. */
  120298. onDispose: () => void;
  120299. /**
  120300. * An event triggered before rendering the scene
  120301. */
  120302. onBeforeRenderObservable: Observable<Layer>;
  120303. private _onBeforeRenderObserver;
  120304. /**
  120305. * Back compatibility with callback before the onBeforeRenderObservable existed.
  120306. * The set callback will be triggered just before rendering the layer.
  120307. */
  120308. onBeforeRender: () => void;
  120309. /**
  120310. * An event triggered after rendering the scene
  120311. */
  120312. onAfterRenderObservable: Observable<Layer>;
  120313. private _onAfterRenderObserver;
  120314. /**
  120315. * Back compatibility with callback before the onAfterRenderObservable existed.
  120316. * The set callback will be triggered just after rendering the layer.
  120317. */
  120318. onAfterRender: () => void;
  120319. /**
  120320. * Instantiates a new layer.
  120321. * This represents a full screen 2d layer.
  120322. * This can be useful to display a picture in the background of your scene for instance.
  120323. * @see https://www.babylonjs-playground.com/#08A2BS#1
  120324. * @param name Define the name of the layer in the scene
  120325. * @param imgUrl Define the url of the texture to display in the layer
  120326. * @param scene Define the scene the layer belongs to
  120327. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  120328. * @param color Defines a color for the layer
  120329. */
  120330. constructor(
  120331. /**
  120332. * Define the name of the layer.
  120333. */
  120334. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  120335. private _createIndexBuffer;
  120336. /** @hidden */
  120337. _rebuild(): void;
  120338. /**
  120339. * Renders the layer in the scene.
  120340. */
  120341. render(): void;
  120342. /**
  120343. * Disposes and releases the associated ressources.
  120344. */
  120345. dispose(): void;
  120346. }
  120347. }
  120348. declare module BABYLON {
  120349. /** @hidden */
  120350. export var lensFlarePixelShader: {
  120351. name: string;
  120352. shader: string;
  120353. };
  120354. }
  120355. declare module BABYLON {
  120356. /** @hidden */
  120357. export var lensFlareVertexShader: {
  120358. name: string;
  120359. shader: string;
  120360. };
  120361. }
  120362. declare module BABYLON {
  120363. /**
  120364. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  120365. * It is usually composed of several `lensFlare`.
  120366. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  120367. */
  120368. export class LensFlareSystem {
  120369. /**
  120370. * Define the name of the lens flare system
  120371. */
  120372. name: string;
  120373. /**
  120374. * List of lens flares used in this system.
  120375. */
  120376. lensFlares: LensFlare[];
  120377. /**
  120378. * Define a limit from the border the lens flare can be visible.
  120379. */
  120380. borderLimit: number;
  120381. /**
  120382. * Define a viewport border we do not want to see the lens flare in.
  120383. */
  120384. viewportBorder: number;
  120385. /**
  120386. * Define a predicate which could limit the list of meshes able to occlude the effect.
  120387. */
  120388. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  120389. /**
  120390. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  120391. */
  120392. layerMask: number;
  120393. /**
  120394. * Define the id of the lens flare system in the scene.
  120395. * (equal to name by default)
  120396. */
  120397. id: string;
  120398. private _scene;
  120399. private _emitter;
  120400. private _vertexBuffers;
  120401. private _indexBuffer;
  120402. private _effect;
  120403. private _positionX;
  120404. private _positionY;
  120405. private _isEnabled;
  120406. /** @hidden */
  120407. static _SceneComponentInitialization: (scene: Scene) => void;
  120408. /**
  120409. * Instantiates a lens flare system.
  120410. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  120411. * It is usually composed of several `lensFlare`.
  120412. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  120413. * @param name Define the name of the lens flare system in the scene
  120414. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  120415. * @param scene Define the scene the lens flare system belongs to
  120416. */
  120417. constructor(
  120418. /**
  120419. * Define the name of the lens flare system
  120420. */
  120421. name: string, emitter: any, scene: Scene);
  120422. /**
  120423. * Define if the lens flare system is enabled.
  120424. */
  120425. isEnabled: boolean;
  120426. /**
  120427. * Get the scene the effects belongs to.
  120428. * @returns the scene holding the lens flare system
  120429. */
  120430. getScene(): Scene;
  120431. /**
  120432. * Get the emitter of the lens flare system.
  120433. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  120434. * @returns the emitter of the lens flare system
  120435. */
  120436. getEmitter(): any;
  120437. /**
  120438. * Set the emitter of the lens flare system.
  120439. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  120440. * @param newEmitter Define the new emitter of the system
  120441. */
  120442. setEmitter(newEmitter: any): void;
  120443. /**
  120444. * Get the lens flare system emitter position.
  120445. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  120446. * @returns the position
  120447. */
  120448. getEmitterPosition(): Vector3;
  120449. /**
  120450. * @hidden
  120451. */
  120452. computeEffectivePosition(globalViewport: Viewport): boolean;
  120453. /** @hidden */
  120454. _isVisible(): boolean;
  120455. /**
  120456. * @hidden
  120457. */
  120458. render(): boolean;
  120459. /**
  120460. * Dispose and release the lens flare with its associated resources.
  120461. */
  120462. dispose(): void;
  120463. /**
  120464. * Parse a lens flare system from a JSON repressentation
  120465. * @param parsedLensFlareSystem Define the JSON to parse
  120466. * @param scene Define the scene the parsed system should be instantiated in
  120467. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  120468. * @returns the parsed system
  120469. */
  120470. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  120471. /**
  120472. * Serialize the current Lens Flare System into a JSON representation.
  120473. * @returns the serialized JSON
  120474. */
  120475. serialize(): any;
  120476. }
  120477. }
  120478. declare module BABYLON {
  120479. /**
  120480. * This represents one of the lens effect in a `lensFlareSystem`.
  120481. * It controls one of the indiviual texture used in the effect.
  120482. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  120483. */
  120484. export class LensFlare {
  120485. /**
  120486. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  120487. */
  120488. size: number;
  120489. /**
  120490. * 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.
  120491. */
  120492. position: number;
  120493. /**
  120494. * Define the lens color.
  120495. */
  120496. color: Color3;
  120497. /**
  120498. * Define the lens texture.
  120499. */
  120500. texture: Nullable<Texture>;
  120501. /**
  120502. * Define the alpha mode to render this particular lens.
  120503. */
  120504. alphaMode: number;
  120505. private _system;
  120506. /**
  120507. * Creates a new Lens Flare.
  120508. * This represents one of the lens effect in a `lensFlareSystem`.
  120509. * It controls one of the indiviual texture used in the effect.
  120510. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  120511. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  120512. * @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.
  120513. * @param color Define the lens color
  120514. * @param imgUrl Define the lens texture url
  120515. * @param system Define the `lensFlareSystem` this flare is part of
  120516. * @returns The newly created Lens Flare
  120517. */
  120518. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  120519. /**
  120520. * Instantiates a new Lens Flare.
  120521. * This represents one of the lens effect in a `lensFlareSystem`.
  120522. * It controls one of the indiviual texture used in the effect.
  120523. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  120524. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  120525. * @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.
  120526. * @param color Define the lens color
  120527. * @param imgUrl Define the lens texture url
  120528. * @param system Define the `lensFlareSystem` this flare is part of
  120529. */
  120530. constructor(
  120531. /**
  120532. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  120533. */
  120534. size: number,
  120535. /**
  120536. * 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.
  120537. */
  120538. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  120539. /**
  120540. * Dispose and release the lens flare with its associated resources.
  120541. */
  120542. dispose(): void;
  120543. }
  120544. }
  120545. declare module BABYLON {
  120546. interface AbstractScene {
  120547. /**
  120548. * The list of lens flare system added to the scene
  120549. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  120550. */
  120551. lensFlareSystems: Array<LensFlareSystem>;
  120552. /**
  120553. * Removes the given lens flare system from this scene.
  120554. * @param toRemove The lens flare system to remove
  120555. * @returns The index of the removed lens flare system
  120556. */
  120557. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  120558. /**
  120559. * Adds the given lens flare system to this scene
  120560. * @param newLensFlareSystem The lens flare system to add
  120561. */
  120562. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  120563. /**
  120564. * Gets a lens flare system using its name
  120565. * @param name defines the name to look for
  120566. * @returns the lens flare system or null if not found
  120567. */
  120568. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  120569. /**
  120570. * Gets a lens flare system using its id
  120571. * @param id defines the id to look for
  120572. * @returns the lens flare system or null if not found
  120573. */
  120574. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  120575. }
  120576. /**
  120577. * Defines the lens flare scene component responsible to manage any lens flares
  120578. * in a given scene.
  120579. */
  120580. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  120581. /**
  120582. * The component name helpfull to identify the component in the list of scene components.
  120583. */
  120584. readonly name: string;
  120585. /**
  120586. * The scene the component belongs to.
  120587. */
  120588. scene: Scene;
  120589. /**
  120590. * Creates a new instance of the component for the given scene
  120591. * @param scene Defines the scene to register the component in
  120592. */
  120593. constructor(scene: Scene);
  120594. /**
  120595. * Registers the component in a given scene
  120596. */
  120597. register(): void;
  120598. /**
  120599. * Rebuilds the elements related to this component in case of
  120600. * context lost for instance.
  120601. */
  120602. rebuild(): void;
  120603. /**
  120604. * Adds all the elements from the container to the scene
  120605. * @param container the container holding the elements
  120606. */
  120607. addFromContainer(container: AbstractScene): void;
  120608. /**
  120609. * Removes all the elements in the container from the scene
  120610. * @param container contains the elements to remove
  120611. * @param dispose if the removed element should be disposed (default: false)
  120612. */
  120613. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  120614. /**
  120615. * Serializes the component data to the specified json object
  120616. * @param serializationObject The object to serialize to
  120617. */
  120618. serialize(serializationObject: any): void;
  120619. /**
  120620. * Disposes the component and the associated ressources.
  120621. */
  120622. dispose(): void;
  120623. private _draw;
  120624. }
  120625. }
  120626. declare module BABYLON {
  120627. /**
  120628. * Defines the shadow generator component responsible to manage any shadow generators
  120629. * in a given scene.
  120630. */
  120631. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  120632. /**
  120633. * The component name helpfull to identify the component in the list of scene components.
  120634. */
  120635. readonly name: string;
  120636. /**
  120637. * The scene the component belongs to.
  120638. */
  120639. scene: Scene;
  120640. /**
  120641. * Creates a new instance of the component for the given scene
  120642. * @param scene Defines the scene to register the component in
  120643. */
  120644. constructor(scene: Scene);
  120645. /**
  120646. * Registers the component in a given scene
  120647. */
  120648. register(): void;
  120649. /**
  120650. * Rebuilds the elements related to this component in case of
  120651. * context lost for instance.
  120652. */
  120653. rebuild(): void;
  120654. /**
  120655. * Serializes the component data to the specified json object
  120656. * @param serializationObject The object to serialize to
  120657. */
  120658. serialize(serializationObject: any): void;
  120659. /**
  120660. * Adds all the elements from the container to the scene
  120661. * @param container the container holding the elements
  120662. */
  120663. addFromContainer(container: AbstractScene): void;
  120664. /**
  120665. * Removes all the elements in the container from the scene
  120666. * @param container contains the elements to remove
  120667. * @param dispose if the removed element should be disposed (default: false)
  120668. */
  120669. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  120670. /**
  120671. * Rebuilds the elements related to this component in case of
  120672. * context lost for instance.
  120673. */
  120674. dispose(): void;
  120675. private _gatherRenderTargets;
  120676. }
  120677. }
  120678. declare module BABYLON {
  120679. /**
  120680. * A point light is a light defined by an unique point in world space.
  120681. * The light is emitted in every direction from this point.
  120682. * A good example of a point light is a standard light bulb.
  120683. * Documentation: https://doc.babylonjs.com/babylon101/lights
  120684. */
  120685. export class PointLight extends ShadowLight {
  120686. private _shadowAngle;
  120687. /**
  120688. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  120689. * This specifies what angle the shadow will use to be created.
  120690. *
  120691. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  120692. */
  120693. /**
  120694. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  120695. * This specifies what angle the shadow will use to be created.
  120696. *
  120697. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  120698. */
  120699. shadowAngle: number;
  120700. /**
  120701. * Gets the direction if it has been set.
  120702. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  120703. */
  120704. /**
  120705. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  120706. */
  120707. direction: Vector3;
  120708. /**
  120709. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  120710. * A PointLight emits the light in every direction.
  120711. * It can cast shadows.
  120712. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  120713. * ```javascript
  120714. * var pointLight = new PointLight("pl", camera.position, scene);
  120715. * ```
  120716. * Documentation : https://doc.babylonjs.com/babylon101/lights
  120717. * @param name The light friendly name
  120718. * @param position The position of the point light in the scene
  120719. * @param scene The scene the lights belongs to
  120720. */
  120721. constructor(name: string, position: Vector3, scene: Scene);
  120722. /**
  120723. * Returns the string "PointLight"
  120724. * @returns the class name
  120725. */
  120726. getClassName(): string;
  120727. /**
  120728. * Returns the integer 0.
  120729. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  120730. */
  120731. getTypeID(): number;
  120732. /**
  120733. * Specifies wether or not the shadowmap should be a cube texture.
  120734. * @returns true if the shadowmap needs to be a cube texture.
  120735. */
  120736. needCube(): boolean;
  120737. /**
  120738. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  120739. * @param faceIndex The index of the face we are computed the direction to generate shadow
  120740. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  120741. */
  120742. getShadowDirection(faceIndex?: number): Vector3;
  120743. /**
  120744. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  120745. * - fov = PI / 2
  120746. * - aspect ratio : 1.0
  120747. * - z-near and far equal to the active camera minZ and maxZ.
  120748. * Returns the PointLight.
  120749. */
  120750. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  120751. protected _buildUniformLayout(): void;
  120752. /**
  120753. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  120754. * @param effect The effect to update
  120755. * @param lightIndex The index of the light in the effect to update
  120756. * @returns The point light
  120757. */
  120758. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  120759. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  120760. /**
  120761. * Prepares the list of defines specific to the light type.
  120762. * @param defines the list of defines
  120763. * @param lightIndex defines the index of the light for the effect
  120764. */
  120765. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  120766. }
  120767. }
  120768. declare module BABYLON {
  120769. /**
  120770. * Header information of HDR texture files.
  120771. */
  120772. export interface HDRInfo {
  120773. /**
  120774. * The height of the texture in pixels.
  120775. */
  120776. height: number;
  120777. /**
  120778. * The width of the texture in pixels.
  120779. */
  120780. width: number;
  120781. /**
  120782. * The index of the beginning of the data in the binary file.
  120783. */
  120784. dataPosition: number;
  120785. }
  120786. /**
  120787. * This groups tools to convert HDR texture to native colors array.
  120788. */
  120789. export class HDRTools {
  120790. private static Ldexp;
  120791. private static Rgbe2float;
  120792. private static readStringLine;
  120793. /**
  120794. * Reads header information from an RGBE texture stored in a native array.
  120795. * More information on this format are available here:
  120796. * https://en.wikipedia.org/wiki/RGBE_image_format
  120797. *
  120798. * @param uint8array The binary file stored in native array.
  120799. * @return The header information.
  120800. */
  120801. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  120802. /**
  120803. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  120804. * This RGBE texture needs to store the information as a panorama.
  120805. *
  120806. * More information on this format are available here:
  120807. * https://en.wikipedia.org/wiki/RGBE_image_format
  120808. *
  120809. * @param buffer The binary file stored in an array buffer.
  120810. * @param size The expected size of the extracted cubemap.
  120811. * @return The Cube Map information.
  120812. */
  120813. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  120814. /**
  120815. * Returns the pixels data extracted from an RGBE texture.
  120816. * This pixels will be stored left to right up to down in the R G B order in one array.
  120817. *
  120818. * More information on this format are available here:
  120819. * https://en.wikipedia.org/wiki/RGBE_image_format
  120820. *
  120821. * @param uint8array The binary file stored in an array buffer.
  120822. * @param hdrInfo The header information of the file.
  120823. * @return The pixels data in RGB right to left up to down order.
  120824. */
  120825. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  120826. private static RGBE_ReadPixels_RLE;
  120827. }
  120828. }
  120829. declare module BABYLON {
  120830. /**
  120831. * This represents a texture coming from an HDR input.
  120832. *
  120833. * The only supported format is currently panorama picture stored in RGBE format.
  120834. * Example of such files can be found on HDRLib: http://hdrlib.com/
  120835. */
  120836. export class HDRCubeTexture extends BaseTexture {
  120837. private static _facesMapping;
  120838. private _generateHarmonics;
  120839. private _noMipmap;
  120840. private _textureMatrix;
  120841. private _size;
  120842. private _onLoad;
  120843. private _onError;
  120844. /**
  120845. * The texture URL.
  120846. */
  120847. url: string;
  120848. /**
  120849. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  120850. */
  120851. coordinatesMode: number;
  120852. protected _isBlocking: boolean;
  120853. /**
  120854. * Sets wether or not the texture is blocking during loading.
  120855. */
  120856. /**
  120857. * Gets wether or not the texture is blocking during loading.
  120858. */
  120859. isBlocking: boolean;
  120860. protected _rotationY: number;
  120861. /**
  120862. * Sets texture matrix rotation angle around Y axis in radians.
  120863. */
  120864. /**
  120865. * Gets texture matrix rotation angle around Y axis radians.
  120866. */
  120867. rotationY: number;
  120868. /**
  120869. * Gets or sets the center of the bounding box associated with the cube texture
  120870. * It must define where the camera used to render the texture was set
  120871. */
  120872. boundingBoxPosition: Vector3;
  120873. private _boundingBoxSize;
  120874. /**
  120875. * Gets or sets the size of the bounding box associated with the cube texture
  120876. * When defined, the cubemap will switch to local mode
  120877. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  120878. * @example https://www.babylonjs-playground.com/#RNASML
  120879. */
  120880. boundingBoxSize: Vector3;
  120881. /**
  120882. * Instantiates an HDRTexture from the following parameters.
  120883. *
  120884. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  120885. * @param scene The scene the texture will be used in
  120886. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  120887. * @param noMipmap Forces to not generate the mipmap if true
  120888. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  120889. * @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)
  120890. * @param reserved Reserved flag for internal use.
  120891. */
  120892. 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>);
  120893. /**
  120894. * Get the current class name of the texture useful for serialization or dynamic coding.
  120895. * @returns "HDRCubeTexture"
  120896. */
  120897. getClassName(): string;
  120898. /**
  120899. * Occurs when the file is raw .hdr file.
  120900. */
  120901. private loadTexture;
  120902. clone(): HDRCubeTexture;
  120903. delayLoad(): void;
  120904. /**
  120905. * Get the texture reflection matrix used to rotate/transform the reflection.
  120906. * @returns the reflection matrix
  120907. */
  120908. getReflectionTextureMatrix(): Matrix;
  120909. /**
  120910. * Set the texture reflection matrix used to rotate/transform the reflection.
  120911. * @param value Define the reflection matrix to set
  120912. */
  120913. setReflectionTextureMatrix(value: Matrix): void;
  120914. /**
  120915. * Parses a JSON representation of an HDR Texture in order to create the texture
  120916. * @param parsedTexture Define the JSON representation
  120917. * @param scene Define the scene the texture should be created in
  120918. * @param rootUrl Define the root url in case we need to load relative dependencies
  120919. * @returns the newly created texture after parsing
  120920. */
  120921. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  120922. serialize(): any;
  120923. }
  120924. }
  120925. declare module BABYLON {
  120926. /**
  120927. * Class used to control physics engine
  120928. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  120929. */
  120930. export class PhysicsEngine implements IPhysicsEngine {
  120931. private _physicsPlugin;
  120932. /**
  120933. * Global value used to control the smallest number supported by the simulation
  120934. */
  120935. static Epsilon: number;
  120936. private _impostors;
  120937. private _joints;
  120938. private _subTimeStep;
  120939. /**
  120940. * Gets the gravity vector used by the simulation
  120941. */
  120942. gravity: Vector3;
  120943. /**
  120944. * Factory used to create the default physics plugin.
  120945. * @returns The default physics plugin
  120946. */
  120947. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  120948. /**
  120949. * Creates a new Physics Engine
  120950. * @param gravity defines the gravity vector used by the simulation
  120951. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  120952. */
  120953. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  120954. /**
  120955. * Sets the gravity vector used by the simulation
  120956. * @param gravity defines the gravity vector to use
  120957. */
  120958. setGravity(gravity: Vector3): void;
  120959. /**
  120960. * Set the time step of the physics engine.
  120961. * Default is 1/60.
  120962. * To slow it down, enter 1/600 for example.
  120963. * To speed it up, 1/30
  120964. * @param newTimeStep defines the new timestep to apply to this world.
  120965. */
  120966. setTimeStep(newTimeStep?: number): void;
  120967. /**
  120968. * Get the time step of the physics engine.
  120969. * @returns the current time step
  120970. */
  120971. getTimeStep(): number;
  120972. /**
  120973. * Set the sub time step of the physics engine.
  120974. * Default is 0 meaning there is no sub steps
  120975. * To increase physics resolution precision, set a small value (like 1 ms)
  120976. * @param subTimeStep defines the new sub timestep used for physics resolution.
  120977. */
  120978. setSubTimeStep(subTimeStep?: number): void;
  120979. /**
  120980. * Get the sub time step of the physics engine.
  120981. * @returns the current sub time step
  120982. */
  120983. getSubTimeStep(): number;
  120984. /**
  120985. * Release all resources
  120986. */
  120987. dispose(): void;
  120988. /**
  120989. * Gets the name of the current physics plugin
  120990. * @returns the name of the plugin
  120991. */
  120992. getPhysicsPluginName(): string;
  120993. /**
  120994. * Adding a new impostor for the impostor tracking.
  120995. * This will be done by the impostor itself.
  120996. * @param impostor the impostor to add
  120997. */
  120998. addImpostor(impostor: PhysicsImpostor): void;
  120999. /**
  121000. * Remove an impostor from the engine.
  121001. * This impostor and its mesh will not longer be updated by the physics engine.
  121002. * @param impostor the impostor to remove
  121003. */
  121004. removeImpostor(impostor: PhysicsImpostor): void;
  121005. /**
  121006. * Add a joint to the physics engine
  121007. * @param mainImpostor defines the main impostor to which the joint is added.
  121008. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  121009. * @param joint defines the joint that will connect both impostors.
  121010. */
  121011. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  121012. /**
  121013. * Removes a joint from the simulation
  121014. * @param mainImpostor defines the impostor used with the joint
  121015. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  121016. * @param joint defines the joint to remove
  121017. */
  121018. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  121019. /**
  121020. * Called by the scene. No need to call it.
  121021. * @param delta defines the timespam between frames
  121022. */
  121023. _step(delta: number): void;
  121024. /**
  121025. * Gets the current plugin used to run the simulation
  121026. * @returns current plugin
  121027. */
  121028. getPhysicsPlugin(): IPhysicsEnginePlugin;
  121029. /**
  121030. * Gets the list of physic impostors
  121031. * @returns an array of PhysicsImpostor
  121032. */
  121033. getImpostors(): Array<PhysicsImpostor>;
  121034. /**
  121035. * Gets the impostor for a physics enabled object
  121036. * @param object defines the object impersonated by the impostor
  121037. * @returns the PhysicsImpostor or null if not found
  121038. */
  121039. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  121040. /**
  121041. * Gets the impostor for a physics body object
  121042. * @param body defines physics body used by the impostor
  121043. * @returns the PhysicsImpostor or null if not found
  121044. */
  121045. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  121046. /**
  121047. * Does a raycast in the physics world
  121048. * @param from when should the ray start?
  121049. * @param to when should the ray end?
  121050. * @returns PhysicsRaycastResult
  121051. */
  121052. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  121053. }
  121054. }
  121055. declare module BABYLON {
  121056. /** @hidden */
  121057. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  121058. private _useDeltaForWorldStep;
  121059. world: any;
  121060. name: string;
  121061. private _physicsMaterials;
  121062. private _fixedTimeStep;
  121063. private _cannonRaycastResult;
  121064. private _raycastResult;
  121065. private _physicsBodysToRemoveAfterStep;
  121066. BJSCANNON: any;
  121067. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  121068. setGravity(gravity: Vector3): void;
  121069. setTimeStep(timeStep: number): void;
  121070. getTimeStep(): number;
  121071. executeStep(delta: number): void;
  121072. private _removeMarkedPhysicsBodiesFromWorld;
  121073. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  121074. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  121075. generatePhysicsBody(impostor: PhysicsImpostor): void;
  121076. private _processChildMeshes;
  121077. removePhysicsBody(impostor: PhysicsImpostor): void;
  121078. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  121079. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  121080. private _addMaterial;
  121081. private _checkWithEpsilon;
  121082. private _createShape;
  121083. private _createHeightmap;
  121084. private _minus90X;
  121085. private _plus90X;
  121086. private _tmpPosition;
  121087. private _tmpDeltaPosition;
  121088. private _tmpUnityRotation;
  121089. private _updatePhysicsBodyTransformation;
  121090. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  121091. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  121092. isSupported(): boolean;
  121093. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  121094. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  121095. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  121096. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  121097. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  121098. getBodyMass(impostor: PhysicsImpostor): number;
  121099. getBodyFriction(impostor: PhysicsImpostor): number;
  121100. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  121101. getBodyRestitution(impostor: PhysicsImpostor): number;
  121102. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  121103. sleepBody(impostor: PhysicsImpostor): void;
  121104. wakeUpBody(impostor: PhysicsImpostor): void;
  121105. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  121106. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  121107. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  121108. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  121109. getRadius(impostor: PhysicsImpostor): number;
  121110. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  121111. dispose(): void;
  121112. private _extendNamespace;
  121113. /**
  121114. * Does a raycast in the physics world
  121115. * @param from when should the ray start?
  121116. * @param to when should the ray end?
  121117. * @returns PhysicsRaycastResult
  121118. */
  121119. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  121120. }
  121121. }
  121122. declare module BABYLON {
  121123. /** @hidden */
  121124. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  121125. world: any;
  121126. name: string;
  121127. BJSOIMO: any;
  121128. private _raycastResult;
  121129. constructor(iterations?: number, oimoInjection?: any);
  121130. setGravity(gravity: Vector3): void;
  121131. setTimeStep(timeStep: number): void;
  121132. getTimeStep(): number;
  121133. private _tmpImpostorsArray;
  121134. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  121135. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  121136. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  121137. generatePhysicsBody(impostor: PhysicsImpostor): void;
  121138. private _tmpPositionVector;
  121139. removePhysicsBody(impostor: PhysicsImpostor): void;
  121140. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  121141. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  121142. isSupported(): boolean;
  121143. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  121144. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  121145. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  121146. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  121147. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  121148. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  121149. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  121150. getBodyMass(impostor: PhysicsImpostor): number;
  121151. getBodyFriction(impostor: PhysicsImpostor): number;
  121152. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  121153. getBodyRestitution(impostor: PhysicsImpostor): number;
  121154. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  121155. sleepBody(impostor: PhysicsImpostor): void;
  121156. wakeUpBody(impostor: PhysicsImpostor): void;
  121157. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  121158. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  121159. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  121160. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  121161. getRadius(impostor: PhysicsImpostor): number;
  121162. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  121163. dispose(): void;
  121164. /**
  121165. * Does a raycast in the physics world
  121166. * @param from when should the ray start?
  121167. * @param to when should the ray end?
  121168. * @returns PhysicsRaycastResult
  121169. */
  121170. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  121171. }
  121172. }
  121173. declare module BABYLON {
  121174. /**
  121175. * Class containing static functions to help procedurally build meshes
  121176. */
  121177. export class RibbonBuilder {
  121178. /**
  121179. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  121180. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  121181. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  121182. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  121183. * * 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
  121184. * * 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
  121185. * * 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
  121186. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121187. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121188. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121189. * * 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
  121190. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  121191. * * 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
  121192. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  121193. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121194. * @param name defines the name of the mesh
  121195. * @param options defines the options used to create the mesh
  121196. * @param scene defines the hosting scene
  121197. * @returns the ribbon mesh
  121198. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  121199. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121200. */
  121201. static CreateRibbon(name: string, options: {
  121202. pathArray: Vector3[][];
  121203. closeArray?: boolean;
  121204. closePath?: boolean;
  121205. offset?: number;
  121206. updatable?: boolean;
  121207. sideOrientation?: number;
  121208. frontUVs?: Vector4;
  121209. backUVs?: Vector4;
  121210. instance?: Mesh;
  121211. invertUV?: boolean;
  121212. uvs?: Vector2[];
  121213. colors?: Color4[];
  121214. }, scene?: Nullable<Scene>): Mesh;
  121215. }
  121216. }
  121217. declare module BABYLON {
  121218. /**
  121219. * Class containing static functions to help procedurally build meshes
  121220. */
  121221. export class ShapeBuilder {
  121222. /**
  121223. * 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.
  121224. * * 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.
  121225. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  121226. * * 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.
  121227. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  121228. * * 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
  121229. * * 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
  121230. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  121231. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121232. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121233. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  121234. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121235. * @param name defines the name of the mesh
  121236. * @param options defines the options used to create the mesh
  121237. * @param scene defines the hosting scene
  121238. * @returns the extruded shape mesh
  121239. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121240. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  121241. */
  121242. static ExtrudeShape(name: string, options: {
  121243. shape: Vector3[];
  121244. path: Vector3[];
  121245. scale?: number;
  121246. rotation?: number;
  121247. cap?: number;
  121248. updatable?: boolean;
  121249. sideOrientation?: number;
  121250. frontUVs?: Vector4;
  121251. backUVs?: Vector4;
  121252. instance?: Mesh;
  121253. invertUV?: boolean;
  121254. }, scene?: Nullable<Scene>): Mesh;
  121255. /**
  121256. * Creates an custom extruded shape mesh.
  121257. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  121258. * * 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.
  121259. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  121260. * * 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
  121261. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  121262. * * 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
  121263. * * It must returns a float value that will be the scale value applied to the shape on each path point
  121264. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  121265. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  121266. * * 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
  121267. * * 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
  121268. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  121269. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121270. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121271. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121273. * @param name defines the name of the mesh
  121274. * @param options defines the options used to create the mesh
  121275. * @param scene defines the hosting scene
  121276. * @returns the custom extruded shape mesh
  121277. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  121278. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121279. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  121280. */
  121281. static ExtrudeShapeCustom(name: string, options: {
  121282. shape: Vector3[];
  121283. path: Vector3[];
  121284. scaleFunction?: any;
  121285. rotationFunction?: any;
  121286. ribbonCloseArray?: boolean;
  121287. ribbonClosePath?: boolean;
  121288. cap?: number;
  121289. updatable?: boolean;
  121290. sideOrientation?: number;
  121291. frontUVs?: Vector4;
  121292. backUVs?: Vector4;
  121293. instance?: Mesh;
  121294. invertUV?: boolean;
  121295. }, scene?: Nullable<Scene>): Mesh;
  121296. private static _ExtrudeShapeGeneric;
  121297. }
  121298. }
  121299. declare module BABYLON {
  121300. /**
  121301. * AmmoJS Physics plugin
  121302. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  121303. * @see https://github.com/kripken/ammo.js/
  121304. */
  121305. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  121306. private _useDeltaForWorldStep;
  121307. /**
  121308. * Reference to the Ammo library
  121309. */
  121310. bjsAMMO: any;
  121311. /**
  121312. * Created ammoJS world which physics bodies are added to
  121313. */
  121314. world: any;
  121315. /**
  121316. * Name of the plugin
  121317. */
  121318. name: string;
  121319. private _timeStep;
  121320. private _fixedTimeStep;
  121321. private _maxSteps;
  121322. private _tmpQuaternion;
  121323. private _tmpAmmoTransform;
  121324. private _tmpAmmoQuaternion;
  121325. private _tmpAmmoConcreteContactResultCallback;
  121326. private _collisionConfiguration;
  121327. private _dispatcher;
  121328. private _overlappingPairCache;
  121329. private _solver;
  121330. private _softBodySolver;
  121331. private _tmpAmmoVectorA;
  121332. private _tmpAmmoVectorB;
  121333. private _tmpAmmoVectorC;
  121334. private _tmpAmmoVectorD;
  121335. private _tmpContactCallbackResult;
  121336. private _tmpAmmoVectorRCA;
  121337. private _tmpAmmoVectorRCB;
  121338. private _raycastResult;
  121339. private static readonly DISABLE_COLLISION_FLAG;
  121340. private static readonly KINEMATIC_FLAG;
  121341. private static readonly DISABLE_DEACTIVATION_FLAG;
  121342. /**
  121343. * Initializes the ammoJS plugin
  121344. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  121345. * @param ammoInjection can be used to inject your own ammo reference
  121346. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  121347. */
  121348. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  121349. /**
  121350. * Sets the gravity of the physics world (m/(s^2))
  121351. * @param gravity Gravity to set
  121352. */
  121353. setGravity(gravity: Vector3): void;
  121354. /**
  121355. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  121356. * @param timeStep timestep to use in seconds
  121357. */
  121358. setTimeStep(timeStep: number): void;
  121359. /**
  121360. * 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)
  121361. * @param fixedTimeStep fixedTimeStep to use in seconds
  121362. */
  121363. setFixedTimeStep(fixedTimeStep: number): void;
  121364. /**
  121365. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  121366. * @param maxSteps the maximum number of steps by the physics engine per frame
  121367. */
  121368. setMaxSteps(maxSteps: number): void;
  121369. /**
  121370. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  121371. * @returns the current timestep in seconds
  121372. */
  121373. getTimeStep(): number;
  121374. /**
  121375. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  121376. */
  121377. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  121378. private _isImpostorInContact;
  121379. private _isImpostorPairInContact;
  121380. private _stepSimulation;
  121381. /**
  121382. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  121383. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  121384. * After the step the babylon meshes are set to the position of the physics imposters
  121385. * @param delta amount of time to step forward
  121386. * @param impostors array of imposters to update before/after the step
  121387. */
  121388. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  121389. /**
  121390. * Update babylon mesh to match physics world object
  121391. * @param impostor imposter to match
  121392. */
  121393. private _afterSoftStep;
  121394. /**
  121395. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  121396. * @param impostor imposter to match
  121397. */
  121398. private _ropeStep;
  121399. /**
  121400. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  121401. * @param impostor imposter to match
  121402. */
  121403. private _softbodyOrClothStep;
  121404. private _tmpVector;
  121405. private _tmpMatrix;
  121406. /**
  121407. * Applies an impulse on the imposter
  121408. * @param impostor imposter to apply impulse to
  121409. * @param force amount of force to be applied to the imposter
  121410. * @param contactPoint the location to apply the impulse on the imposter
  121411. */
  121412. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  121413. /**
  121414. * Applies a force on the imposter
  121415. * @param impostor imposter to apply force
  121416. * @param force amount of force to be applied to the imposter
  121417. * @param contactPoint the location to apply the force on the imposter
  121418. */
  121419. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  121420. /**
  121421. * Creates a physics body using the plugin
  121422. * @param impostor the imposter to create the physics body on
  121423. */
  121424. generatePhysicsBody(impostor: PhysicsImpostor): void;
  121425. /**
  121426. * Removes the physics body from the imposter and disposes of the body's memory
  121427. * @param impostor imposter to remove the physics body from
  121428. */
  121429. removePhysicsBody(impostor: PhysicsImpostor): void;
  121430. /**
  121431. * Generates a joint
  121432. * @param impostorJoint the imposter joint to create the joint with
  121433. */
  121434. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  121435. /**
  121436. * Removes a joint
  121437. * @param impostorJoint the imposter joint to remove the joint from
  121438. */
  121439. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  121440. private _addMeshVerts;
  121441. /**
  121442. * Initialise the soft body vertices to match its object's (mesh) vertices
  121443. * Softbody vertices (nodes) are in world space and to match this
  121444. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  121445. * @param impostor to create the softbody for
  121446. */
  121447. private _softVertexData;
  121448. /**
  121449. * Create an impostor's soft body
  121450. * @param impostor to create the softbody for
  121451. */
  121452. private _createSoftbody;
  121453. /**
  121454. * Create cloth for an impostor
  121455. * @param impostor to create the softbody for
  121456. */
  121457. private _createCloth;
  121458. /**
  121459. * Create rope for an impostor
  121460. * @param impostor to create the softbody for
  121461. */
  121462. private _createRope;
  121463. /**
  121464. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  121465. * @param impostor to create the custom physics shape for
  121466. */
  121467. private _createCustom;
  121468. private _addHullVerts;
  121469. private _createShape;
  121470. /**
  121471. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  121472. * @param impostor imposter containing the physics body and babylon object
  121473. */
  121474. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  121475. /**
  121476. * Sets the babylon object's position/rotation from the physics body's position/rotation
  121477. * @param impostor imposter containing the physics body and babylon object
  121478. * @param newPosition new position
  121479. * @param newRotation new rotation
  121480. */
  121481. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  121482. /**
  121483. * If this plugin is supported
  121484. * @returns true if its supported
  121485. */
  121486. isSupported(): boolean;
  121487. /**
  121488. * Sets the linear velocity of the physics body
  121489. * @param impostor imposter to set the velocity on
  121490. * @param velocity velocity to set
  121491. */
  121492. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  121493. /**
  121494. * Sets the angular velocity of the physics body
  121495. * @param impostor imposter to set the velocity on
  121496. * @param velocity velocity to set
  121497. */
  121498. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  121499. /**
  121500. * gets the linear velocity
  121501. * @param impostor imposter to get linear velocity from
  121502. * @returns linear velocity
  121503. */
  121504. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  121505. /**
  121506. * gets the angular velocity
  121507. * @param impostor imposter to get angular velocity from
  121508. * @returns angular velocity
  121509. */
  121510. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  121511. /**
  121512. * Sets the mass of physics body
  121513. * @param impostor imposter to set the mass on
  121514. * @param mass mass to set
  121515. */
  121516. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  121517. /**
  121518. * Gets the mass of the physics body
  121519. * @param impostor imposter to get the mass from
  121520. * @returns mass
  121521. */
  121522. getBodyMass(impostor: PhysicsImpostor): number;
  121523. /**
  121524. * Gets friction of the impostor
  121525. * @param impostor impostor to get friction from
  121526. * @returns friction value
  121527. */
  121528. getBodyFriction(impostor: PhysicsImpostor): number;
  121529. /**
  121530. * Sets friction of the impostor
  121531. * @param impostor impostor to set friction on
  121532. * @param friction friction value
  121533. */
  121534. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  121535. /**
  121536. * Gets restitution of the impostor
  121537. * @param impostor impostor to get restitution from
  121538. * @returns restitution value
  121539. */
  121540. getBodyRestitution(impostor: PhysicsImpostor): number;
  121541. /**
  121542. * Sets resitution of the impostor
  121543. * @param impostor impostor to set resitution on
  121544. * @param restitution resitution value
  121545. */
  121546. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  121547. /**
  121548. * Gets pressure inside the impostor
  121549. * @param impostor impostor to get pressure from
  121550. * @returns pressure value
  121551. */
  121552. getBodyPressure(impostor: PhysicsImpostor): number;
  121553. /**
  121554. * Sets pressure inside a soft body impostor
  121555. * Cloth and rope must remain 0 pressure
  121556. * @param impostor impostor to set pressure on
  121557. * @param pressure pressure value
  121558. */
  121559. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  121560. /**
  121561. * Gets stiffness of the impostor
  121562. * @param impostor impostor to get stiffness from
  121563. * @returns pressure value
  121564. */
  121565. getBodyStiffness(impostor: PhysicsImpostor): number;
  121566. /**
  121567. * Sets stiffness of the impostor
  121568. * @param impostor impostor to set stiffness on
  121569. * @param stiffness stiffness value from 0 to 1
  121570. */
  121571. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  121572. /**
  121573. * Gets velocityIterations of the impostor
  121574. * @param impostor impostor to get velocity iterations from
  121575. * @returns velocityIterations value
  121576. */
  121577. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  121578. /**
  121579. * Sets velocityIterations of the impostor
  121580. * @param impostor impostor to set velocity iterations on
  121581. * @param velocityIterations velocityIterations value
  121582. */
  121583. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  121584. /**
  121585. * Gets positionIterations of the impostor
  121586. * @param impostor impostor to get position iterations from
  121587. * @returns positionIterations value
  121588. */
  121589. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  121590. /**
  121591. * Sets positionIterations of the impostor
  121592. * @param impostor impostor to set position on
  121593. * @param positionIterations positionIterations value
  121594. */
  121595. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  121596. /**
  121597. * Append an anchor to a cloth object
  121598. * @param impostor is the cloth impostor to add anchor to
  121599. * @param otherImpostor is the rigid impostor to anchor to
  121600. * @param width ratio across width from 0 to 1
  121601. * @param height ratio up height from 0 to 1
  121602. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  121603. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  121604. */
  121605. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  121606. /**
  121607. * Append an hook to a rope object
  121608. * @param impostor is the rope impostor to add hook to
  121609. * @param otherImpostor is the rigid impostor to hook to
  121610. * @param length ratio along the rope from 0 to 1
  121611. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  121612. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  121613. */
  121614. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  121615. /**
  121616. * Sleeps the physics body and stops it from being active
  121617. * @param impostor impostor to sleep
  121618. */
  121619. sleepBody(impostor: PhysicsImpostor): void;
  121620. /**
  121621. * Activates the physics body
  121622. * @param impostor impostor to activate
  121623. */
  121624. wakeUpBody(impostor: PhysicsImpostor): void;
  121625. /**
  121626. * Updates the distance parameters of the joint
  121627. * @param joint joint to update
  121628. * @param maxDistance maximum distance of the joint
  121629. * @param minDistance minimum distance of the joint
  121630. */
  121631. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  121632. /**
  121633. * Sets a motor on the joint
  121634. * @param joint joint to set motor on
  121635. * @param speed speed of the motor
  121636. * @param maxForce maximum force of the motor
  121637. * @param motorIndex index of the motor
  121638. */
  121639. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  121640. /**
  121641. * Sets the motors limit
  121642. * @param joint joint to set limit on
  121643. * @param upperLimit upper limit
  121644. * @param lowerLimit lower limit
  121645. */
  121646. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  121647. /**
  121648. * Syncs the position and rotation of a mesh with the impostor
  121649. * @param mesh mesh to sync
  121650. * @param impostor impostor to update the mesh with
  121651. */
  121652. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  121653. /**
  121654. * Gets the radius of the impostor
  121655. * @param impostor impostor to get radius from
  121656. * @returns the radius
  121657. */
  121658. getRadius(impostor: PhysicsImpostor): number;
  121659. /**
  121660. * Gets the box size of the impostor
  121661. * @param impostor impostor to get box size from
  121662. * @param result the resulting box size
  121663. */
  121664. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  121665. /**
  121666. * Disposes of the impostor
  121667. */
  121668. dispose(): void;
  121669. /**
  121670. * Does a raycast in the physics world
  121671. * @param from when should the ray start?
  121672. * @param to when should the ray end?
  121673. * @returns PhysicsRaycastResult
  121674. */
  121675. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  121676. }
  121677. }
  121678. declare module BABYLON {
  121679. interface AbstractScene {
  121680. /**
  121681. * The list of reflection probes added to the scene
  121682. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  121683. */
  121684. reflectionProbes: Array<ReflectionProbe>;
  121685. /**
  121686. * Removes the given reflection probe from this scene.
  121687. * @param toRemove The reflection probe to remove
  121688. * @returns The index of the removed reflection probe
  121689. */
  121690. removeReflectionProbe(toRemove: ReflectionProbe): number;
  121691. /**
  121692. * Adds the given reflection probe to this scene.
  121693. * @param newReflectionProbe The reflection probe to add
  121694. */
  121695. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  121696. }
  121697. /**
  121698. * Class used to generate realtime reflection / refraction cube textures
  121699. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  121700. */
  121701. export class ReflectionProbe {
  121702. /** defines the name of the probe */
  121703. name: string;
  121704. private _scene;
  121705. private _renderTargetTexture;
  121706. private _projectionMatrix;
  121707. private _viewMatrix;
  121708. private _target;
  121709. private _add;
  121710. private _attachedMesh;
  121711. private _invertYAxis;
  121712. /** Gets or sets probe position (center of the cube map) */
  121713. position: Vector3;
  121714. /**
  121715. * Creates a new reflection probe
  121716. * @param name defines the name of the probe
  121717. * @param size defines the texture resolution (for each face)
  121718. * @param scene defines the hosting scene
  121719. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  121720. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  121721. */
  121722. constructor(
  121723. /** defines the name of the probe */
  121724. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  121725. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  121726. samples: number;
  121727. /** Gets or sets the refresh rate to use (on every frame by default) */
  121728. refreshRate: number;
  121729. /**
  121730. * Gets the hosting scene
  121731. * @returns a Scene
  121732. */
  121733. getScene(): Scene;
  121734. /** Gets the internal CubeTexture used to render to */
  121735. readonly cubeTexture: RenderTargetTexture;
  121736. /** Gets the list of meshes to render */
  121737. readonly renderList: Nullable<AbstractMesh[]>;
  121738. /**
  121739. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  121740. * @param mesh defines the mesh to attach to
  121741. */
  121742. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  121743. /**
  121744. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  121745. * @param renderingGroupId The rendering group id corresponding to its index
  121746. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  121747. */
  121748. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  121749. /**
  121750. * Clean all associated resources
  121751. */
  121752. dispose(): void;
  121753. /**
  121754. * Converts the reflection probe information to a readable string for debug purpose.
  121755. * @param fullDetails Supports for multiple levels of logging within scene loading
  121756. * @returns the human readable reflection probe info
  121757. */
  121758. toString(fullDetails?: boolean): string;
  121759. /**
  121760. * Get the class name of the relfection probe.
  121761. * @returns "ReflectionProbe"
  121762. */
  121763. getClassName(): string;
  121764. /**
  121765. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  121766. * @returns The JSON representation of the texture
  121767. */
  121768. serialize(): any;
  121769. /**
  121770. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  121771. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  121772. * @param scene Define the scene the parsed reflection probe should be instantiated in
  121773. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  121774. * @returns The parsed reflection probe if successful
  121775. */
  121776. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  121777. }
  121778. }
  121779. declare module BABYLON {
  121780. /** @hidden */
  121781. export var _BabylonLoaderRegistered: boolean;
  121782. /**
  121783. * Helps setting up some configuration for the babylon file loader.
  121784. */
  121785. export class BabylonFileLoaderConfiguration {
  121786. /**
  121787. * The loader does not allow injecting custom physix engine into the plugins.
  121788. * Unfortunately in ES6, we need to manually inject them into the plugin.
  121789. * So you could set this variable to your engine import to make it work.
  121790. */
  121791. static LoaderInjectedPhysicsEngine: any;
  121792. }
  121793. }
  121794. declare module BABYLON {
  121795. /**
  121796. * The Physically based simple base material of BJS.
  121797. *
  121798. * This enables better naming and convention enforcements on top of the pbrMaterial.
  121799. * It is used as the base class for both the specGloss and metalRough conventions.
  121800. */
  121801. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  121802. /**
  121803. * Number of Simultaneous lights allowed on the material.
  121804. */
  121805. maxSimultaneousLights: number;
  121806. /**
  121807. * If sets to true, disables all the lights affecting the material.
  121808. */
  121809. disableLighting: boolean;
  121810. /**
  121811. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  121812. */
  121813. environmentTexture: BaseTexture;
  121814. /**
  121815. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  121816. */
  121817. invertNormalMapX: boolean;
  121818. /**
  121819. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  121820. */
  121821. invertNormalMapY: boolean;
  121822. /**
  121823. * Normal map used in the model.
  121824. */
  121825. normalTexture: BaseTexture;
  121826. /**
  121827. * Emissivie color used to self-illuminate the model.
  121828. */
  121829. emissiveColor: Color3;
  121830. /**
  121831. * Emissivie texture used to self-illuminate the model.
  121832. */
  121833. emissiveTexture: BaseTexture;
  121834. /**
  121835. * Occlusion Channel Strenght.
  121836. */
  121837. occlusionStrength: number;
  121838. /**
  121839. * Occlusion Texture of the material (adding extra occlusion effects).
  121840. */
  121841. occlusionTexture: BaseTexture;
  121842. /**
  121843. * Defines the alpha limits in alpha test mode.
  121844. */
  121845. alphaCutOff: number;
  121846. /**
  121847. * Gets the current double sided mode.
  121848. */
  121849. /**
  121850. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  121851. */
  121852. doubleSided: boolean;
  121853. /**
  121854. * Stores the pre-calculated light information of a mesh in a texture.
  121855. */
  121856. lightmapTexture: BaseTexture;
  121857. /**
  121858. * If true, the light map contains occlusion information instead of lighting info.
  121859. */
  121860. useLightmapAsShadowmap: boolean;
  121861. /**
  121862. * Instantiates a new PBRMaterial instance.
  121863. *
  121864. * @param name The material name
  121865. * @param scene The scene the material will be use in.
  121866. */
  121867. constructor(name: string, scene: Scene);
  121868. getClassName(): string;
  121869. }
  121870. }
  121871. declare module BABYLON {
  121872. /**
  121873. * The PBR material of BJS following the metal roughness convention.
  121874. *
  121875. * This fits to the PBR convention in the GLTF definition:
  121876. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  121877. */
  121878. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  121879. /**
  121880. * The base color has two different interpretations depending on the value of metalness.
  121881. * When the material is a metal, the base color is the specific measured reflectance value
  121882. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  121883. * of the material.
  121884. */
  121885. baseColor: Color3;
  121886. /**
  121887. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  121888. * well as opacity information in the alpha channel.
  121889. */
  121890. baseTexture: BaseTexture;
  121891. /**
  121892. * Specifies the metallic scalar value of the material.
  121893. * Can also be used to scale the metalness values of the metallic texture.
  121894. */
  121895. metallic: number;
  121896. /**
  121897. * Specifies the roughness scalar value of the material.
  121898. * Can also be used to scale the roughness values of the metallic texture.
  121899. */
  121900. roughness: number;
  121901. /**
  121902. * Texture containing both the metallic value in the B channel and the
  121903. * roughness value in the G channel to keep better precision.
  121904. */
  121905. metallicRoughnessTexture: BaseTexture;
  121906. /**
  121907. * Instantiates a new PBRMetalRoughnessMaterial instance.
  121908. *
  121909. * @param name The material name
  121910. * @param scene The scene the material will be use in.
  121911. */
  121912. constructor(name: string, scene: Scene);
  121913. /**
  121914. * Return the currrent class name of the material.
  121915. */
  121916. getClassName(): string;
  121917. /**
  121918. * Makes a duplicate of the current material.
  121919. * @param name - name to use for the new material.
  121920. */
  121921. clone(name: string): PBRMetallicRoughnessMaterial;
  121922. /**
  121923. * Serialize the material to a parsable JSON object.
  121924. */
  121925. serialize(): any;
  121926. /**
  121927. * Parses a JSON object correponding to the serialize function.
  121928. */
  121929. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  121930. }
  121931. }
  121932. declare module BABYLON {
  121933. /**
  121934. * The PBR material of BJS following the specular glossiness convention.
  121935. *
  121936. * This fits to the PBR convention in the GLTF definition:
  121937. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  121938. */
  121939. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  121940. /**
  121941. * Specifies the diffuse color of the material.
  121942. */
  121943. diffuseColor: Color3;
  121944. /**
  121945. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  121946. * channel.
  121947. */
  121948. diffuseTexture: BaseTexture;
  121949. /**
  121950. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  121951. */
  121952. specularColor: Color3;
  121953. /**
  121954. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  121955. */
  121956. glossiness: number;
  121957. /**
  121958. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  121959. */
  121960. specularGlossinessTexture: BaseTexture;
  121961. /**
  121962. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  121963. *
  121964. * @param name The material name
  121965. * @param scene The scene the material will be use in.
  121966. */
  121967. constructor(name: string, scene: Scene);
  121968. /**
  121969. * Return the currrent class name of the material.
  121970. */
  121971. getClassName(): string;
  121972. /**
  121973. * Makes a duplicate of the current material.
  121974. * @param name - name to use for the new material.
  121975. */
  121976. clone(name: string): PBRSpecularGlossinessMaterial;
  121977. /**
  121978. * Serialize the material to a parsable JSON object.
  121979. */
  121980. serialize(): any;
  121981. /**
  121982. * Parses a JSON object correponding to the serialize function.
  121983. */
  121984. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  121985. }
  121986. }
  121987. declare module BABYLON {
  121988. /**
  121989. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  121990. * It can help converting any input color in a desired output one. This can then be used to create effects
  121991. * from sepia, black and white to sixties or futuristic rendering...
  121992. *
  121993. * The only supported format is currently 3dl.
  121994. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  121995. */
  121996. export class ColorGradingTexture extends BaseTexture {
  121997. /**
  121998. * The current texture matrix. (will always be identity in color grading texture)
  121999. */
  122000. private _textureMatrix;
  122001. /**
  122002. * The texture URL.
  122003. */
  122004. url: string;
  122005. /**
  122006. * Empty line regex stored for GC.
  122007. */
  122008. private static _noneEmptyLineRegex;
  122009. private _engine;
  122010. /**
  122011. * Instantiates a ColorGradingTexture from the following parameters.
  122012. *
  122013. * @param url The location of the color gradind data (currently only supporting 3dl)
  122014. * @param scene The scene the texture will be used in
  122015. */
  122016. constructor(url: string, scene: Scene);
  122017. /**
  122018. * Returns the texture matrix used in most of the material.
  122019. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  122020. */
  122021. getTextureMatrix(): Matrix;
  122022. /**
  122023. * Occurs when the file being loaded is a .3dl LUT file.
  122024. */
  122025. private load3dlTexture;
  122026. /**
  122027. * Starts the loading process of the texture.
  122028. */
  122029. private loadTexture;
  122030. /**
  122031. * Clones the color gradind texture.
  122032. */
  122033. clone(): ColorGradingTexture;
  122034. /**
  122035. * Called during delayed load for textures.
  122036. */
  122037. delayLoad(): void;
  122038. /**
  122039. * Parses a color grading texture serialized by Babylon.
  122040. * @param parsedTexture The texture information being parsedTexture
  122041. * @param scene The scene to load the texture in
  122042. * @param rootUrl The root url of the data assets to load
  122043. * @return A color gradind texture
  122044. */
  122045. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  122046. /**
  122047. * Serializes the LUT texture to json format.
  122048. */
  122049. serialize(): any;
  122050. }
  122051. }
  122052. declare module BABYLON {
  122053. /**
  122054. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  122055. */
  122056. export class EquiRectangularCubeTexture extends BaseTexture {
  122057. /** The six faces of the cube. */
  122058. private static _FacesMapping;
  122059. private _noMipmap;
  122060. private _onLoad;
  122061. private _onError;
  122062. /** The size of the cubemap. */
  122063. private _size;
  122064. /** The buffer of the image. */
  122065. private _buffer;
  122066. /** The width of the input image. */
  122067. private _width;
  122068. /** The height of the input image. */
  122069. private _height;
  122070. /** The URL to the image. */
  122071. url: string;
  122072. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  122073. coordinatesMode: number;
  122074. /**
  122075. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  122076. * @param url The location of the image
  122077. * @param scene The scene the texture will be used in
  122078. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  122079. * @param noMipmap Forces to not generate the mipmap if true
  122080. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  122081. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  122082. * @param onLoad — defines a callback called when texture is loaded
  122083. * @param onError — defines a callback called if there is an error
  122084. */
  122085. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  122086. /**
  122087. * Load the image data, by putting the image on a canvas and extracting its buffer.
  122088. */
  122089. private loadImage;
  122090. /**
  122091. * Convert the image buffer into a cubemap and create a CubeTexture.
  122092. */
  122093. private loadTexture;
  122094. /**
  122095. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  122096. * @param buffer The ArrayBuffer that should be converted.
  122097. * @returns The buffer as Float32Array.
  122098. */
  122099. private getFloat32ArrayFromArrayBuffer;
  122100. /**
  122101. * Get the current class name of the texture useful for serialization or dynamic coding.
  122102. * @returns "EquiRectangularCubeTexture"
  122103. */
  122104. getClassName(): string;
  122105. /**
  122106. * Create a clone of the current EquiRectangularCubeTexture and return it.
  122107. * @returns A clone of the current EquiRectangularCubeTexture.
  122108. */
  122109. clone(): EquiRectangularCubeTexture;
  122110. }
  122111. }
  122112. declare module BABYLON {
  122113. /**
  122114. * Based on jsTGALoader - Javascript loader for TGA file
  122115. * By Vincent Thibault
  122116. * @see http://blog.robrowser.com/javascript-tga-loader.html
  122117. */
  122118. export class TGATools {
  122119. private static _TYPE_INDEXED;
  122120. private static _TYPE_RGB;
  122121. private static _TYPE_GREY;
  122122. private static _TYPE_RLE_INDEXED;
  122123. private static _TYPE_RLE_RGB;
  122124. private static _TYPE_RLE_GREY;
  122125. private static _ORIGIN_MASK;
  122126. private static _ORIGIN_SHIFT;
  122127. private static _ORIGIN_BL;
  122128. private static _ORIGIN_BR;
  122129. private static _ORIGIN_UL;
  122130. private static _ORIGIN_UR;
  122131. /**
  122132. * Gets the header of a TGA file
  122133. * @param data defines the TGA data
  122134. * @returns the header
  122135. */
  122136. static GetTGAHeader(data: Uint8Array): any;
  122137. /**
  122138. * Uploads TGA content to a Babylon Texture
  122139. * @hidden
  122140. */
  122141. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  122142. /** @hidden */
  122143. 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;
  122144. /** @hidden */
  122145. 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;
  122146. /** @hidden */
  122147. 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;
  122148. /** @hidden */
  122149. 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;
  122150. /** @hidden */
  122151. 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;
  122152. /** @hidden */
  122153. 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;
  122154. }
  122155. }
  122156. declare module BABYLON {
  122157. /**
  122158. * Implementation of the TGA Texture Loader.
  122159. * @hidden
  122160. */
  122161. export class _TGATextureLoader implements IInternalTextureLoader {
  122162. /**
  122163. * Defines wether the loader supports cascade loading the different faces.
  122164. */
  122165. readonly supportCascades: boolean;
  122166. /**
  122167. * This returns if the loader support the current file information.
  122168. * @param extension defines the file extension of the file being loaded
  122169. * @param textureFormatInUse defines the current compressed format in use iun the engine
  122170. * @param fallback defines the fallback internal texture if any
  122171. * @param isBase64 defines whether the texture is encoded as a base64
  122172. * @param isBuffer defines whether the texture data are stored as a buffer
  122173. * @returns true if the loader can load the specified file
  122174. */
  122175. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  122176. /**
  122177. * Transform the url before loading if required.
  122178. * @param rootUrl the url of the texture
  122179. * @param textureFormatInUse defines the current compressed format in use iun the engine
  122180. * @returns the transformed texture
  122181. */
  122182. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  122183. /**
  122184. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  122185. * @param rootUrl the url of the texture
  122186. * @param textureFormatInUse defines the current compressed format in use iun the engine
  122187. * @returns the fallback texture
  122188. */
  122189. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  122190. /**
  122191. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  122192. * @param data contains the texture data
  122193. * @param texture defines the BabylonJS internal texture
  122194. * @param createPolynomials will be true if polynomials have been requested
  122195. * @param onLoad defines the callback to trigger once the texture is ready
  122196. * @param onError defines the callback to trigger in case of error
  122197. */
  122198. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  122199. /**
  122200. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  122201. * @param data contains the texture data
  122202. * @param texture defines the BabylonJS internal texture
  122203. * @param callback defines the method to call once ready to upload
  122204. */
  122205. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  122206. }
  122207. }
  122208. declare module BABYLON {
  122209. /**
  122210. * Info about the .basis files
  122211. */
  122212. class BasisFileInfo {
  122213. /**
  122214. * If the file has alpha
  122215. */
  122216. hasAlpha: boolean;
  122217. /**
  122218. * Info about each image of the basis file
  122219. */
  122220. images: Array<{
  122221. levels: Array<{
  122222. width: number;
  122223. height: number;
  122224. transcodedPixels: ArrayBufferView;
  122225. }>;
  122226. }>;
  122227. }
  122228. /**
  122229. * Result of transcoding a basis file
  122230. */
  122231. class TranscodeResult {
  122232. /**
  122233. * Info about the .basis file
  122234. */
  122235. fileInfo: BasisFileInfo;
  122236. /**
  122237. * Format to use when loading the file
  122238. */
  122239. format: number;
  122240. }
  122241. /**
  122242. * Configuration options for the Basis transcoder
  122243. */
  122244. export class BasisTranscodeConfiguration {
  122245. /**
  122246. * Supported compression formats used to determine the supported output format of the transcoder
  122247. */
  122248. supportedCompressionFormats?: {
  122249. /**
  122250. * etc1 compression format
  122251. */
  122252. etc1?: boolean;
  122253. /**
  122254. * s3tc compression format
  122255. */
  122256. s3tc?: boolean;
  122257. /**
  122258. * pvrtc compression format
  122259. */
  122260. pvrtc?: boolean;
  122261. /**
  122262. * etc2 compression format
  122263. */
  122264. etc2?: boolean;
  122265. };
  122266. /**
  122267. * If mipmap levels should be loaded for transcoded images (Default: true)
  122268. */
  122269. loadMipmapLevels?: boolean;
  122270. /**
  122271. * Index of a single image to load (Default: all images)
  122272. */
  122273. loadSingleImage?: number;
  122274. }
  122275. /**
  122276. * Used to load .Basis files
  122277. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  122278. */
  122279. export class BasisTools {
  122280. private static _IgnoreSupportedFormats;
  122281. /**
  122282. * URL to use when loading the basis transcoder
  122283. */
  122284. static JSModuleURL: string;
  122285. /**
  122286. * URL to use when loading the wasm module for the transcoder
  122287. */
  122288. static WasmModuleURL: string;
  122289. /**
  122290. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  122291. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  122292. * @returns internal format corresponding to the Basis format
  122293. */
  122294. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  122295. private static _WorkerPromise;
  122296. private static _Worker;
  122297. private static _actionId;
  122298. private static _CreateWorkerAsync;
  122299. /**
  122300. * Transcodes a loaded image file to compressed pixel data
  122301. * @param imageData image data to transcode
  122302. * @param config configuration options for the transcoding
  122303. * @returns a promise resulting in the transcoded image
  122304. */
  122305. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  122306. /**
  122307. * Loads a texture from the transcode result
  122308. * @param texture texture load to
  122309. * @param transcodeResult the result of transcoding the basis file to load from
  122310. */
  122311. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  122312. }
  122313. }
  122314. declare module BABYLON {
  122315. /**
  122316. * Loader for .basis file format
  122317. */
  122318. export class _BasisTextureLoader implements IInternalTextureLoader {
  122319. /**
  122320. * Defines whether the loader supports cascade loading the different faces.
  122321. */
  122322. readonly supportCascades: boolean;
  122323. /**
  122324. * This returns if the loader support the current file information.
  122325. * @param extension defines the file extension of the file being loaded
  122326. * @param textureFormatInUse defines the current compressed format in use iun the engine
  122327. * @param fallback defines the fallback internal texture if any
  122328. * @param isBase64 defines whether the texture is encoded as a base64
  122329. * @param isBuffer defines whether the texture data are stored as a buffer
  122330. * @returns true if the loader can load the specified file
  122331. */
  122332. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  122333. /**
  122334. * Transform the url before loading if required.
  122335. * @param rootUrl the url of the texture
  122336. * @param textureFormatInUse defines the current compressed format in use iun the engine
  122337. * @returns the transformed texture
  122338. */
  122339. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  122340. /**
  122341. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  122342. * @param rootUrl the url of the texture
  122343. * @param textureFormatInUse defines the current compressed format in use iun the engine
  122344. * @returns the fallback texture
  122345. */
  122346. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  122347. /**
  122348. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  122349. * @param data contains the texture data
  122350. * @param texture defines the BabylonJS internal texture
  122351. * @param createPolynomials will be true if polynomials have been requested
  122352. * @param onLoad defines the callback to trigger once the texture is ready
  122353. * @param onError defines the callback to trigger in case of error
  122354. */
  122355. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  122356. /**
  122357. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  122358. * @param data contains the texture data
  122359. * @param texture defines the BabylonJS internal texture
  122360. * @param callback defines the method to call once ready to upload
  122361. */
  122362. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  122363. }
  122364. }
  122365. declare module BABYLON {
  122366. /**
  122367. * 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.
  122368. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  122369. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  122370. */
  122371. export class CustomProceduralTexture extends ProceduralTexture {
  122372. private _animate;
  122373. private _time;
  122374. private _config;
  122375. private _texturePath;
  122376. /**
  122377. * Instantiates a new Custom Procedural Texture.
  122378. * 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.
  122379. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  122380. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  122381. * @param name Define the name of the texture
  122382. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  122383. * @param size Define the size of the texture to create
  122384. * @param scene Define the scene the texture belongs to
  122385. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  122386. * @param generateMipMaps Define if the texture should creates mip maps or not
  122387. */
  122388. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  122389. private _loadJson;
  122390. /**
  122391. * Is the texture ready to be used ? (rendered at least once)
  122392. * @returns true if ready, otherwise, false.
  122393. */
  122394. isReady(): boolean;
  122395. /**
  122396. * Render the texture to its associated render target.
  122397. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  122398. */
  122399. render(useCameraPostProcess?: boolean): void;
  122400. /**
  122401. * Update the list of dependant textures samplers in the shader.
  122402. */
  122403. updateTextures(): void;
  122404. /**
  122405. * Update the uniform values of the procedural texture in the shader.
  122406. */
  122407. updateShaderUniforms(): void;
  122408. /**
  122409. * Define if the texture animates or not.
  122410. */
  122411. animate: boolean;
  122412. }
  122413. }
  122414. declare module BABYLON {
  122415. /** @hidden */
  122416. export var noisePixelShader: {
  122417. name: string;
  122418. shader: string;
  122419. };
  122420. }
  122421. declare module BABYLON {
  122422. /**
  122423. * Class used to generate noise procedural textures
  122424. */
  122425. export class NoiseProceduralTexture extends ProceduralTexture {
  122426. private _time;
  122427. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  122428. brightness: number;
  122429. /** Defines the number of octaves to process */
  122430. octaves: number;
  122431. /** Defines the level of persistence (0.8 by default) */
  122432. persistence: number;
  122433. /** Gets or sets animation speed factor (default is 1) */
  122434. animationSpeedFactor: number;
  122435. /**
  122436. * Creates a new NoiseProceduralTexture
  122437. * @param name defines the name fo the texture
  122438. * @param size defines the size of the texture (default is 256)
  122439. * @param scene defines the hosting scene
  122440. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  122441. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  122442. */
  122443. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  122444. private _updateShaderUniforms;
  122445. protected _getDefines(): string;
  122446. /** Generate the current state of the procedural texture */
  122447. render(useCameraPostProcess?: boolean): void;
  122448. /**
  122449. * Serializes this noise procedural texture
  122450. * @returns a serialized noise procedural texture object
  122451. */
  122452. serialize(): any;
  122453. /**
  122454. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  122455. * @param parsedTexture defines parsed texture data
  122456. * @param scene defines the current scene
  122457. * @param rootUrl defines the root URL containing noise procedural texture information
  122458. * @returns a parsed NoiseProceduralTexture
  122459. */
  122460. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  122461. }
  122462. }
  122463. declare module BABYLON {
  122464. /**
  122465. * Raw cube texture where the raw buffers are passed in
  122466. */
  122467. export class RawCubeTexture extends CubeTexture {
  122468. /**
  122469. * Creates a cube texture where the raw buffers are passed in.
  122470. * @param scene defines the scene the texture is attached to
  122471. * @param data defines the array of data to use to create each face
  122472. * @param size defines the size of the textures
  122473. * @param format defines the format of the data
  122474. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  122475. * @param generateMipMaps defines if the engine should generate the mip levels
  122476. * @param invertY defines if data must be stored with Y axis inverted
  122477. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  122478. * @param compression defines the compression used (null by default)
  122479. */
  122480. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  122481. /**
  122482. * Updates the raw cube texture.
  122483. * @param data defines the data to store
  122484. * @param format defines the data format
  122485. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  122486. * @param invertY defines if data must be stored with Y axis inverted
  122487. * @param compression defines the compression used (null by default)
  122488. * @param level defines which level of the texture to update
  122489. */
  122490. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  122491. /**
  122492. * Updates a raw cube texture with RGBD encoded data.
  122493. * @param data defines the array of data [mipmap][face] to use to create each face
  122494. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  122495. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  122496. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  122497. * @returns a promsie that resolves when the operation is complete
  122498. */
  122499. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  122500. /**
  122501. * Clones the raw cube texture.
  122502. * @return a new cube texture
  122503. */
  122504. clone(): CubeTexture;
  122505. /** @hidden */
  122506. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  122507. }
  122508. }
  122509. declare module BABYLON {
  122510. /**
  122511. * Class used to store 3D textures containing user data
  122512. */
  122513. export class RawTexture3D extends Texture {
  122514. /** Gets or sets the texture format to use */
  122515. format: number;
  122516. private _engine;
  122517. /**
  122518. * Create a new RawTexture3D
  122519. * @param data defines the data of the texture
  122520. * @param width defines the width of the texture
  122521. * @param height defines the height of the texture
  122522. * @param depth defines the depth of the texture
  122523. * @param format defines the texture format to use
  122524. * @param scene defines the hosting scene
  122525. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  122526. * @param invertY defines if texture must be stored with Y axis inverted
  122527. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  122528. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  122529. */
  122530. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  122531. /** Gets or sets the texture format to use */
  122532. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  122533. /**
  122534. * Update the texture with new data
  122535. * @param data defines the data to store in the texture
  122536. */
  122537. update(data: ArrayBufferView): void;
  122538. }
  122539. }
  122540. declare module BABYLON {
  122541. /**
  122542. * Class used to store 2D array textures containing user data
  122543. */
  122544. export class RawTexture2DArray extends Texture {
  122545. /** Gets or sets the texture format to use */
  122546. format: number;
  122547. private _engine;
  122548. /**
  122549. * Create a new RawTexture2DArray
  122550. * @param data defines the data of the texture
  122551. * @param width defines the width of the texture
  122552. * @param height defines the height of the texture
  122553. * @param depth defines the number of layers of the texture
  122554. * @param format defines the texture format to use
  122555. * @param scene defines the hosting scene
  122556. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  122557. * @param invertY defines if texture must be stored with Y axis inverted
  122558. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  122559. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  122560. */
  122561. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  122562. /** Gets or sets the texture format to use */
  122563. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  122564. /**
  122565. * Update the texture with new data
  122566. * @param data defines the data to store in the texture
  122567. */
  122568. update(data: ArrayBufferView): void;
  122569. }
  122570. }
  122571. declare module BABYLON {
  122572. /**
  122573. * Creates a refraction texture used by refraction channel of the standard material.
  122574. * It is like a mirror but to see through a material.
  122575. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  122576. */
  122577. export class RefractionTexture extends RenderTargetTexture {
  122578. /**
  122579. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  122580. * 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.
  122581. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  122582. */
  122583. refractionPlane: Plane;
  122584. /**
  122585. * Define how deep under the surface we should see.
  122586. */
  122587. depth: number;
  122588. /**
  122589. * Creates a refraction texture used by refraction channel of the standard material.
  122590. * It is like a mirror but to see through a material.
  122591. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  122592. * @param name Define the texture name
  122593. * @param size Define the size of the underlying texture
  122594. * @param scene Define the scene the refraction belongs to
  122595. * @param generateMipMaps Define if we need to generate mips level for the refraction
  122596. */
  122597. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  122598. /**
  122599. * Clone the refraction texture.
  122600. * @returns the cloned texture
  122601. */
  122602. clone(): RefractionTexture;
  122603. /**
  122604. * Serialize the texture to a JSON representation you could use in Parse later on
  122605. * @returns the serialized JSON representation
  122606. */
  122607. serialize(): any;
  122608. }
  122609. }
  122610. declare module BABYLON {
  122611. /**
  122612. * Defines the options related to the creation of an HtmlElementTexture
  122613. */
  122614. export interface IHtmlElementTextureOptions {
  122615. /**
  122616. * Defines wether mip maps should be created or not.
  122617. */
  122618. generateMipMaps?: boolean;
  122619. /**
  122620. * Defines the sampling mode of the texture.
  122621. */
  122622. samplingMode?: number;
  122623. /**
  122624. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  122625. */
  122626. engine: Nullable<ThinEngine>;
  122627. /**
  122628. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  122629. */
  122630. scene: Nullable<Scene>;
  122631. }
  122632. /**
  122633. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  122634. * To be as efficient as possible depending on your constraints nothing aside the first upload
  122635. * is automatically managed.
  122636. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  122637. * in your application.
  122638. *
  122639. * As the update is not automatic, you need to call them manually.
  122640. */
  122641. export class HtmlElementTexture extends BaseTexture {
  122642. /**
  122643. * The texture URL.
  122644. */
  122645. element: HTMLVideoElement | HTMLCanvasElement;
  122646. private static readonly DefaultOptions;
  122647. private _textureMatrix;
  122648. private _engine;
  122649. private _isVideo;
  122650. private _generateMipMaps;
  122651. private _samplingMode;
  122652. /**
  122653. * Instantiates a HtmlElementTexture from the following parameters.
  122654. *
  122655. * @param name Defines the name of the texture
  122656. * @param element Defines the video or canvas the texture is filled with
  122657. * @param options Defines the other none mandatory texture creation options
  122658. */
  122659. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  122660. private _createInternalTexture;
  122661. /**
  122662. * Returns the texture matrix used in most of the material.
  122663. */
  122664. getTextureMatrix(): Matrix;
  122665. /**
  122666. * Updates the content of the texture.
  122667. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  122668. */
  122669. update(invertY?: Nullable<boolean>): void;
  122670. }
  122671. }
  122672. declare module BABYLON {
  122673. /**
  122674. * Enum used to define the target of a block
  122675. */
  122676. export enum NodeMaterialBlockTargets {
  122677. /** Vertex shader */
  122678. Vertex = 1,
  122679. /** Fragment shader */
  122680. Fragment = 2,
  122681. /** Neutral */
  122682. Neutral = 4,
  122683. /** Vertex and Fragment */
  122684. VertexAndFragment = 3
  122685. }
  122686. }
  122687. declare module BABYLON {
  122688. /**
  122689. * Defines the kind of connection point for node based material
  122690. */
  122691. export enum NodeMaterialBlockConnectionPointTypes {
  122692. /** Float */
  122693. Float = 1,
  122694. /** Int */
  122695. Int = 2,
  122696. /** Vector2 */
  122697. Vector2 = 4,
  122698. /** Vector3 */
  122699. Vector3 = 8,
  122700. /** Vector4 */
  122701. Vector4 = 16,
  122702. /** Color3 */
  122703. Color3 = 32,
  122704. /** Color4 */
  122705. Color4 = 64,
  122706. /** Matrix */
  122707. Matrix = 128,
  122708. /** Detect type based on connection */
  122709. AutoDetect = 1024,
  122710. /** Output type that will be defined by input type */
  122711. BasedOnInput = 2048
  122712. }
  122713. }
  122714. declare module BABYLON {
  122715. /**
  122716. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  122717. */
  122718. export enum NodeMaterialBlockConnectionPointMode {
  122719. /** Value is an uniform */
  122720. Uniform = 0,
  122721. /** Value is a mesh attribute */
  122722. Attribute = 1,
  122723. /** Value is a varying between vertex and fragment shaders */
  122724. Varying = 2,
  122725. /** Mode is undefined */
  122726. Undefined = 3
  122727. }
  122728. }
  122729. declare module BABYLON {
  122730. /**
  122731. * Enum used to define system values e.g. values automatically provided by the system
  122732. */
  122733. export enum NodeMaterialSystemValues {
  122734. /** World */
  122735. World = 1,
  122736. /** View */
  122737. View = 2,
  122738. /** Projection */
  122739. Projection = 3,
  122740. /** ViewProjection */
  122741. ViewProjection = 4,
  122742. /** WorldView */
  122743. WorldView = 5,
  122744. /** WorldViewProjection */
  122745. WorldViewProjection = 6,
  122746. /** CameraPosition */
  122747. CameraPosition = 7,
  122748. /** Fog Color */
  122749. FogColor = 8,
  122750. /** Delta time */
  122751. DeltaTime = 9
  122752. }
  122753. }
  122754. declare module BABYLON {
  122755. /**
  122756. * Root class for all node material optimizers
  122757. */
  122758. export class NodeMaterialOptimizer {
  122759. /**
  122760. * Function used to optimize a NodeMaterial graph
  122761. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  122762. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  122763. */
  122764. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  122765. }
  122766. }
  122767. declare module BABYLON {
  122768. /**
  122769. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  122770. */
  122771. export class TransformBlock extends NodeMaterialBlock {
  122772. /**
  122773. * Defines the value to use to complement W value to transform it to a Vector4
  122774. */
  122775. complementW: number;
  122776. /**
  122777. * Defines the value to use to complement z value to transform it to a Vector4
  122778. */
  122779. complementZ: number;
  122780. /**
  122781. * Creates a new TransformBlock
  122782. * @param name defines the block name
  122783. */
  122784. constructor(name: string);
  122785. /**
  122786. * Gets the current class name
  122787. * @returns the class name
  122788. */
  122789. getClassName(): string;
  122790. /**
  122791. * Gets the vector input
  122792. */
  122793. readonly vector: NodeMaterialConnectionPoint;
  122794. /**
  122795. * Gets the output component
  122796. */
  122797. readonly output: NodeMaterialConnectionPoint;
  122798. /**
  122799. * Gets the matrix transform input
  122800. */
  122801. readonly transform: NodeMaterialConnectionPoint;
  122802. protected _buildBlock(state: NodeMaterialBuildState): this;
  122803. serialize(): any;
  122804. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122805. protected _dumpPropertiesCode(): string;
  122806. }
  122807. }
  122808. declare module BABYLON {
  122809. /**
  122810. * Block used to output the vertex position
  122811. */
  122812. export class VertexOutputBlock extends NodeMaterialBlock {
  122813. /**
  122814. * Creates a new VertexOutputBlock
  122815. * @param name defines the block name
  122816. */
  122817. constructor(name: string);
  122818. /**
  122819. * Gets the current class name
  122820. * @returns the class name
  122821. */
  122822. getClassName(): string;
  122823. /**
  122824. * Gets the vector input component
  122825. */
  122826. readonly vector: NodeMaterialConnectionPoint;
  122827. protected _buildBlock(state: NodeMaterialBuildState): this;
  122828. }
  122829. }
  122830. declare module BABYLON {
  122831. /**
  122832. * Block used to output the final color
  122833. */
  122834. export class FragmentOutputBlock extends NodeMaterialBlock {
  122835. /**
  122836. * Create a new FragmentOutputBlock
  122837. * @param name defines the block name
  122838. */
  122839. constructor(name: string);
  122840. /**
  122841. * Gets the current class name
  122842. * @returns the class name
  122843. */
  122844. getClassName(): string;
  122845. /**
  122846. * Gets the rgba input component
  122847. */
  122848. readonly rgba: NodeMaterialConnectionPoint;
  122849. /**
  122850. * Gets the rgb input component
  122851. */
  122852. readonly rgb: NodeMaterialConnectionPoint;
  122853. /**
  122854. * Gets the a input component
  122855. */
  122856. readonly a: NodeMaterialConnectionPoint;
  122857. protected _buildBlock(state: NodeMaterialBuildState): this;
  122858. }
  122859. }
  122860. declare module BABYLON {
  122861. /**
  122862. * Block used to read a reflection texture from a sampler
  122863. */
  122864. export class ReflectionTextureBlock extends NodeMaterialBlock {
  122865. private _define3DName;
  122866. private _defineCubicName;
  122867. private _defineExplicitName;
  122868. private _defineProjectionName;
  122869. private _defineLocalCubicName;
  122870. private _defineSphericalName;
  122871. private _definePlanarName;
  122872. private _defineEquirectangularName;
  122873. private _defineMirroredEquirectangularFixedName;
  122874. private _defineEquirectangularFixedName;
  122875. private _defineSkyboxName;
  122876. private _cubeSamplerName;
  122877. private _2DSamplerName;
  122878. private _positionUVWName;
  122879. private _directionWName;
  122880. private _reflectionCoordsName;
  122881. private _reflection2DCoordsName;
  122882. private _reflectionColorName;
  122883. private _reflectionMatrixName;
  122884. /**
  122885. * Gets or sets the texture associated with the node
  122886. */
  122887. texture: Nullable<BaseTexture>;
  122888. /**
  122889. * Create a new TextureBlock
  122890. * @param name defines the block name
  122891. */
  122892. constructor(name: string);
  122893. /**
  122894. * Gets the current class name
  122895. * @returns the class name
  122896. */
  122897. getClassName(): string;
  122898. /**
  122899. * Gets the world position input component
  122900. */
  122901. readonly position: NodeMaterialConnectionPoint;
  122902. /**
  122903. * Gets the world position input component
  122904. */
  122905. readonly worldPosition: NodeMaterialConnectionPoint;
  122906. /**
  122907. * Gets the world normal input component
  122908. */
  122909. readonly worldNormal: NodeMaterialConnectionPoint;
  122910. /**
  122911. * Gets the world input component
  122912. */
  122913. readonly world: NodeMaterialConnectionPoint;
  122914. /**
  122915. * Gets the camera (or eye) position component
  122916. */
  122917. readonly cameraPosition: NodeMaterialConnectionPoint;
  122918. /**
  122919. * Gets the view input component
  122920. */
  122921. readonly view: NodeMaterialConnectionPoint;
  122922. /**
  122923. * Gets the rgb output component
  122924. */
  122925. readonly rgb: NodeMaterialConnectionPoint;
  122926. /**
  122927. * Gets the r output component
  122928. */
  122929. readonly r: NodeMaterialConnectionPoint;
  122930. /**
  122931. * Gets the g output component
  122932. */
  122933. readonly g: NodeMaterialConnectionPoint;
  122934. /**
  122935. * Gets the b output component
  122936. */
  122937. readonly b: NodeMaterialConnectionPoint;
  122938. autoConfigure(material: NodeMaterial): void;
  122939. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122940. isReady(): boolean;
  122941. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122942. private _injectVertexCode;
  122943. private _writeOutput;
  122944. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  122945. protected _dumpPropertiesCode(): string;
  122946. serialize(): any;
  122947. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122948. }
  122949. }
  122950. declare module BABYLON {
  122951. /**
  122952. * Interface used to configure the node material editor
  122953. */
  122954. export interface INodeMaterialEditorOptions {
  122955. /** Define the URl to load node editor script */
  122956. editorURL?: string;
  122957. }
  122958. /** @hidden */
  122959. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  122960. /** BONES */
  122961. NUM_BONE_INFLUENCERS: number;
  122962. BonesPerMesh: number;
  122963. BONETEXTURE: boolean;
  122964. /** MORPH TARGETS */
  122965. MORPHTARGETS: boolean;
  122966. MORPHTARGETS_NORMAL: boolean;
  122967. MORPHTARGETS_TANGENT: boolean;
  122968. MORPHTARGETS_UV: boolean;
  122969. NUM_MORPH_INFLUENCERS: number;
  122970. /** IMAGE PROCESSING */
  122971. IMAGEPROCESSING: boolean;
  122972. VIGNETTE: boolean;
  122973. VIGNETTEBLENDMODEMULTIPLY: boolean;
  122974. VIGNETTEBLENDMODEOPAQUE: boolean;
  122975. TONEMAPPING: boolean;
  122976. TONEMAPPING_ACES: boolean;
  122977. CONTRAST: boolean;
  122978. EXPOSURE: boolean;
  122979. COLORCURVES: boolean;
  122980. COLORGRADING: boolean;
  122981. COLORGRADING3D: boolean;
  122982. SAMPLER3DGREENDEPTH: boolean;
  122983. SAMPLER3DBGRMAP: boolean;
  122984. IMAGEPROCESSINGPOSTPROCESS: boolean;
  122985. /** MISC. */
  122986. BUMPDIRECTUV: number;
  122987. constructor();
  122988. setValue(name: string, value: boolean): void;
  122989. }
  122990. /**
  122991. * Class used to configure NodeMaterial
  122992. */
  122993. export interface INodeMaterialOptions {
  122994. /**
  122995. * Defines if blocks should emit comments
  122996. */
  122997. emitComments: boolean;
  122998. }
  122999. /**
  123000. * Class used to create a node based material built by assembling shader blocks
  123001. */
  123002. export class NodeMaterial extends PushMaterial {
  123003. private static _BuildIdGenerator;
  123004. private _options;
  123005. private _vertexCompilationState;
  123006. private _fragmentCompilationState;
  123007. private _sharedData;
  123008. private _buildId;
  123009. private _buildWasSuccessful;
  123010. private _cachedWorldViewMatrix;
  123011. private _cachedWorldViewProjectionMatrix;
  123012. private _optimizers;
  123013. private _animationFrame;
  123014. /** Define the URl to load node editor script */
  123015. static EditorURL: string;
  123016. private BJSNODEMATERIALEDITOR;
  123017. /** Get the inspector from bundle or global */
  123018. private _getGlobalNodeMaterialEditor;
  123019. /**
  123020. * Gets or sets data used by visual editor
  123021. * @see https://nme.babylonjs.com
  123022. */
  123023. editorData: any;
  123024. /**
  123025. * 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)
  123026. */
  123027. ignoreAlpha: boolean;
  123028. /**
  123029. * Defines the maximum number of lights that can be used in the material
  123030. */
  123031. maxSimultaneousLights: number;
  123032. /**
  123033. * Observable raised when the material is built
  123034. */
  123035. onBuildObservable: Observable<NodeMaterial>;
  123036. /**
  123037. * Gets or sets the root nodes of the material vertex shader
  123038. */
  123039. _vertexOutputNodes: NodeMaterialBlock[];
  123040. /**
  123041. * Gets or sets the root nodes of the material fragment (pixel) shader
  123042. */
  123043. _fragmentOutputNodes: NodeMaterialBlock[];
  123044. /** Gets or sets options to control the node material overall behavior */
  123045. options: INodeMaterialOptions;
  123046. /**
  123047. * Default configuration related to image processing available in the standard Material.
  123048. */
  123049. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  123050. /**
  123051. * Gets the image processing configuration used either in this material.
  123052. */
  123053. /**
  123054. * Sets the Default image processing configuration used either in the this material.
  123055. *
  123056. * If sets to null, the scene one is in use.
  123057. */
  123058. imageProcessingConfiguration: ImageProcessingConfiguration;
  123059. /**
  123060. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  123061. */
  123062. attachedBlocks: NodeMaterialBlock[];
  123063. /**
  123064. * Create a new node based material
  123065. * @param name defines the material name
  123066. * @param scene defines the hosting scene
  123067. * @param options defines creation option
  123068. */
  123069. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  123070. /**
  123071. * Gets the current class name of the material e.g. "NodeMaterial"
  123072. * @returns the class name
  123073. */
  123074. getClassName(): string;
  123075. /**
  123076. * Keep track of the image processing observer to allow dispose and replace.
  123077. */
  123078. private _imageProcessingObserver;
  123079. /**
  123080. * Attaches a new image processing configuration to the Standard Material.
  123081. * @param configuration
  123082. */
  123083. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  123084. /**
  123085. * Get a block by its name
  123086. * @param name defines the name of the block to retrieve
  123087. * @returns the required block or null if not found
  123088. */
  123089. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  123090. /**
  123091. * Get a block by its name
  123092. * @param predicate defines the predicate used to find the good candidate
  123093. * @returns the required block or null if not found
  123094. */
  123095. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  123096. /**
  123097. * Get an input block by its name
  123098. * @param predicate defines the predicate used to find the good candidate
  123099. * @returns the required input block or null if not found
  123100. */
  123101. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  123102. /**
  123103. * Gets the list of input blocks attached to this material
  123104. * @returns an array of InputBlocks
  123105. */
  123106. getInputBlocks(): InputBlock[];
  123107. /**
  123108. * Adds a new optimizer to the list of optimizers
  123109. * @param optimizer defines the optimizers to add
  123110. * @returns the current material
  123111. */
  123112. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  123113. /**
  123114. * Remove an optimizer from the list of optimizers
  123115. * @param optimizer defines the optimizers to remove
  123116. * @returns the current material
  123117. */
  123118. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  123119. /**
  123120. * Add a new block to the list of output nodes
  123121. * @param node defines the node to add
  123122. * @returns the current material
  123123. */
  123124. addOutputNode(node: NodeMaterialBlock): this;
  123125. /**
  123126. * Remove a block from the list of root nodes
  123127. * @param node defines the node to remove
  123128. * @returns the current material
  123129. */
  123130. removeOutputNode(node: NodeMaterialBlock): this;
  123131. private _addVertexOutputNode;
  123132. private _removeVertexOutputNode;
  123133. private _addFragmentOutputNode;
  123134. private _removeFragmentOutputNode;
  123135. /**
  123136. * Specifies if the material will require alpha blending
  123137. * @returns a boolean specifying if alpha blending is needed
  123138. */
  123139. needAlphaBlending(): boolean;
  123140. /**
  123141. * Specifies if this material should be rendered in alpha test mode
  123142. * @returns a boolean specifying if an alpha test is needed.
  123143. */
  123144. needAlphaTesting(): boolean;
  123145. private _initializeBlock;
  123146. private _resetDualBlocks;
  123147. /**
  123148. * Remove a block from the current node material
  123149. * @param block defines the block to remove
  123150. */
  123151. removeBlock(block: NodeMaterialBlock): void;
  123152. /**
  123153. * Build the material and generates the inner effect
  123154. * @param verbose defines if the build should log activity
  123155. */
  123156. build(verbose?: boolean): void;
  123157. /**
  123158. * Runs an otpimization phase to try to improve the shader code
  123159. */
  123160. optimize(): void;
  123161. private _prepareDefinesForAttributes;
  123162. /**
  123163. * Get if the submesh is ready to be used and all its information available.
  123164. * Child classes can use it to update shaders
  123165. * @param mesh defines the mesh to check
  123166. * @param subMesh defines which submesh to check
  123167. * @param useInstances specifies that instances should be used
  123168. * @returns a boolean indicating that the submesh is ready or not
  123169. */
  123170. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  123171. /**
  123172. * Get a string representing the shaders built by the current node graph
  123173. */
  123174. readonly compiledShaders: string;
  123175. /**
  123176. * Binds the world matrix to the material
  123177. * @param world defines the world transformation matrix
  123178. */
  123179. bindOnlyWorldMatrix(world: Matrix): void;
  123180. /**
  123181. * Binds the submesh to this material by preparing the effect and shader to draw
  123182. * @param world defines the world transformation matrix
  123183. * @param mesh defines the mesh containing the submesh
  123184. * @param subMesh defines the submesh to bind the material to
  123185. */
  123186. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  123187. /**
  123188. * Gets the active textures from the material
  123189. * @returns an array of textures
  123190. */
  123191. getActiveTextures(): BaseTexture[];
  123192. /**
  123193. * Gets the list of texture blocks
  123194. * @returns an array of texture blocks
  123195. */
  123196. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  123197. /**
  123198. * Specifies if the material uses a texture
  123199. * @param texture defines the texture to check against the material
  123200. * @returns a boolean specifying if the material uses the texture
  123201. */
  123202. hasTexture(texture: BaseTexture): boolean;
  123203. /**
  123204. * Disposes the material
  123205. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  123206. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  123207. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  123208. */
  123209. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  123210. /** Creates the node editor window. */
  123211. private _createNodeEditor;
  123212. /**
  123213. * Launch the node material editor
  123214. * @param config Define the configuration of the editor
  123215. * @return a promise fulfilled when the node editor is visible
  123216. */
  123217. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  123218. /**
  123219. * Clear the current material
  123220. */
  123221. clear(): void;
  123222. /**
  123223. * Clear the current material and set it to a default state
  123224. */
  123225. setToDefault(): void;
  123226. /**
  123227. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  123228. * @param url defines the url to load from
  123229. * @returns a promise that will fullfil when the material is fully loaded
  123230. */
  123231. loadAsync(url: string): Promise<void>;
  123232. private _gatherBlocks;
  123233. /**
  123234. * Generate a string containing the code declaration required to create an equivalent of this material
  123235. * @returns a string
  123236. */
  123237. generateCode(): string;
  123238. /**
  123239. * Serializes this material in a JSON representation
  123240. * @returns the serialized material object
  123241. */
  123242. serialize(): any;
  123243. private _restoreConnections;
  123244. /**
  123245. * Clear the current graph and load a new one from a serialization object
  123246. * @param source defines the JSON representation of the material
  123247. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  123248. */
  123249. loadFromSerialization(source: any, rootUrl?: string): void;
  123250. /**
  123251. * Creates a node material from parsed material data
  123252. * @param source defines the JSON representation of the material
  123253. * @param scene defines the hosting scene
  123254. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  123255. * @returns a new node material
  123256. */
  123257. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  123258. /**
  123259. * Creates a new node material set to default basic configuration
  123260. * @param name defines the name of the material
  123261. * @param scene defines the hosting scene
  123262. * @returns a new NodeMaterial
  123263. */
  123264. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  123265. }
  123266. }
  123267. declare module BABYLON {
  123268. /**
  123269. * Block used to read a texture from a sampler
  123270. */
  123271. export class TextureBlock extends NodeMaterialBlock {
  123272. private _defineName;
  123273. private _linearDefineName;
  123274. private _tempTextureRead;
  123275. private _samplerName;
  123276. private _transformedUVName;
  123277. private _textureTransformName;
  123278. private _textureInfoName;
  123279. private _mainUVName;
  123280. private _mainUVDefineName;
  123281. /**
  123282. * Gets or sets the texture associated with the node
  123283. */
  123284. texture: Nullable<Texture>;
  123285. /**
  123286. * Create a new TextureBlock
  123287. * @param name defines the block name
  123288. */
  123289. constructor(name: string);
  123290. /**
  123291. * Gets the current class name
  123292. * @returns the class name
  123293. */
  123294. getClassName(): string;
  123295. /**
  123296. * Gets the uv input component
  123297. */
  123298. readonly uv: NodeMaterialConnectionPoint;
  123299. /**
  123300. * Gets the rgba output component
  123301. */
  123302. readonly rgba: NodeMaterialConnectionPoint;
  123303. /**
  123304. * Gets the rgb output component
  123305. */
  123306. readonly rgb: NodeMaterialConnectionPoint;
  123307. /**
  123308. * Gets the r output component
  123309. */
  123310. readonly r: NodeMaterialConnectionPoint;
  123311. /**
  123312. * Gets the g output component
  123313. */
  123314. readonly g: NodeMaterialConnectionPoint;
  123315. /**
  123316. * Gets the b output component
  123317. */
  123318. readonly b: NodeMaterialConnectionPoint;
  123319. /**
  123320. * Gets the a output component
  123321. */
  123322. readonly a: NodeMaterialConnectionPoint;
  123323. readonly target: NodeMaterialBlockTargets;
  123324. autoConfigure(material: NodeMaterial): void;
  123325. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  123326. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123327. private _getTextureBase;
  123328. isReady(): boolean;
  123329. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123330. private readonly _isMixed;
  123331. private _injectVertexCode;
  123332. private _writeTextureRead;
  123333. private _writeOutput;
  123334. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  123335. protected _dumpPropertiesCode(): string;
  123336. serialize(): any;
  123337. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123338. }
  123339. }
  123340. declare module BABYLON {
  123341. /**
  123342. * Class used to store shared data between 2 NodeMaterialBuildState
  123343. */
  123344. export class NodeMaterialBuildStateSharedData {
  123345. /**
  123346. * Gets the list of emitted varyings
  123347. */
  123348. temps: string[];
  123349. /**
  123350. * Gets the list of emitted varyings
  123351. */
  123352. varyings: string[];
  123353. /**
  123354. * Gets the varying declaration string
  123355. */
  123356. varyingDeclaration: string;
  123357. /**
  123358. * Input blocks
  123359. */
  123360. inputBlocks: InputBlock[];
  123361. /**
  123362. * Input blocks
  123363. */
  123364. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  123365. /**
  123366. * Bindable blocks (Blocks that need to set data to the effect)
  123367. */
  123368. bindableBlocks: NodeMaterialBlock[];
  123369. /**
  123370. * List of blocks that can provide a compilation fallback
  123371. */
  123372. blocksWithFallbacks: NodeMaterialBlock[];
  123373. /**
  123374. * List of blocks that can provide a define update
  123375. */
  123376. blocksWithDefines: NodeMaterialBlock[];
  123377. /**
  123378. * List of blocks that can provide a repeatable content
  123379. */
  123380. repeatableContentBlocks: NodeMaterialBlock[];
  123381. /**
  123382. * List of blocks that can provide a dynamic list of uniforms
  123383. */
  123384. dynamicUniformBlocks: NodeMaterialBlock[];
  123385. /**
  123386. * List of blocks that can block the isReady function for the material
  123387. */
  123388. blockingBlocks: NodeMaterialBlock[];
  123389. /**
  123390. * Gets the list of animated inputs
  123391. */
  123392. animatedInputs: InputBlock[];
  123393. /**
  123394. * Build Id used to avoid multiple recompilations
  123395. */
  123396. buildId: number;
  123397. /** List of emitted variables */
  123398. variableNames: {
  123399. [key: string]: number;
  123400. };
  123401. /** List of emitted defines */
  123402. defineNames: {
  123403. [key: string]: number;
  123404. };
  123405. /** Should emit comments? */
  123406. emitComments: boolean;
  123407. /** Emit build activity */
  123408. verbose: boolean;
  123409. /** Gets or sets the hosting scene */
  123410. scene: Scene;
  123411. /**
  123412. * Gets the compilation hints emitted at compilation time
  123413. */
  123414. hints: {
  123415. needWorldViewMatrix: boolean;
  123416. needWorldViewProjectionMatrix: boolean;
  123417. needAlphaBlending: boolean;
  123418. needAlphaTesting: boolean;
  123419. };
  123420. /**
  123421. * List of compilation checks
  123422. */
  123423. checks: {
  123424. emitVertex: boolean;
  123425. emitFragment: boolean;
  123426. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  123427. };
  123428. /** Creates a new shared data */
  123429. constructor();
  123430. /**
  123431. * Emits console errors and exceptions if there is a failing check
  123432. */
  123433. emitErrors(): void;
  123434. }
  123435. }
  123436. declare module BABYLON {
  123437. /**
  123438. * Class used to store node based material build state
  123439. */
  123440. export class NodeMaterialBuildState {
  123441. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  123442. supportUniformBuffers: boolean;
  123443. /**
  123444. * Gets the list of emitted attributes
  123445. */
  123446. attributes: string[];
  123447. /**
  123448. * Gets the list of emitted uniforms
  123449. */
  123450. uniforms: string[];
  123451. /**
  123452. * Gets the list of emitted constants
  123453. */
  123454. constants: string[];
  123455. /**
  123456. * Gets the list of emitted samplers
  123457. */
  123458. samplers: string[];
  123459. /**
  123460. * Gets the list of emitted functions
  123461. */
  123462. functions: {
  123463. [key: string]: string;
  123464. };
  123465. /**
  123466. * Gets the list of emitted extensions
  123467. */
  123468. extensions: {
  123469. [key: string]: string;
  123470. };
  123471. /**
  123472. * Gets the target of the compilation state
  123473. */
  123474. target: NodeMaterialBlockTargets;
  123475. /**
  123476. * Gets the list of emitted counters
  123477. */
  123478. counters: {
  123479. [key: string]: number;
  123480. };
  123481. /**
  123482. * Shared data between multiple NodeMaterialBuildState instances
  123483. */
  123484. sharedData: NodeMaterialBuildStateSharedData;
  123485. /** @hidden */
  123486. _vertexState: NodeMaterialBuildState;
  123487. /** @hidden */
  123488. _attributeDeclaration: string;
  123489. /** @hidden */
  123490. _uniformDeclaration: string;
  123491. /** @hidden */
  123492. _constantDeclaration: string;
  123493. /** @hidden */
  123494. _samplerDeclaration: string;
  123495. /** @hidden */
  123496. _varyingTransfer: string;
  123497. private _repeatableContentAnchorIndex;
  123498. /** @hidden */
  123499. _builtCompilationString: string;
  123500. /**
  123501. * Gets the emitted compilation strings
  123502. */
  123503. compilationString: string;
  123504. /**
  123505. * Finalize the compilation strings
  123506. * @param state defines the current compilation state
  123507. */
  123508. finalize(state: NodeMaterialBuildState): void;
  123509. /** @hidden */
  123510. readonly _repeatableContentAnchor: string;
  123511. /** @hidden */
  123512. _getFreeVariableName(prefix: string): string;
  123513. /** @hidden */
  123514. _getFreeDefineName(prefix: string): string;
  123515. /** @hidden */
  123516. _excludeVariableName(name: string): void;
  123517. /** @hidden */
  123518. _emit2DSampler(name: string): void;
  123519. /** @hidden */
  123520. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  123521. /** @hidden */
  123522. _emitExtension(name: string, extension: string): void;
  123523. /** @hidden */
  123524. _emitFunction(name: string, code: string, comments: string): void;
  123525. /** @hidden */
  123526. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  123527. replaceStrings?: {
  123528. search: RegExp;
  123529. replace: string;
  123530. }[];
  123531. repeatKey?: string;
  123532. }): string;
  123533. /** @hidden */
  123534. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  123535. repeatKey?: string;
  123536. removeAttributes?: boolean;
  123537. removeUniforms?: boolean;
  123538. removeVaryings?: boolean;
  123539. removeIfDef?: boolean;
  123540. replaceStrings?: {
  123541. search: RegExp;
  123542. replace: string;
  123543. }[];
  123544. }, storeKey?: string): void;
  123545. /** @hidden */
  123546. _registerTempVariable(name: string): boolean;
  123547. /** @hidden */
  123548. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  123549. /** @hidden */
  123550. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  123551. /** @hidden */
  123552. _emitFloat(value: number): string;
  123553. }
  123554. }
  123555. declare module BABYLON {
  123556. /**
  123557. * Defines a block that can be used inside a node based material
  123558. */
  123559. export class NodeMaterialBlock {
  123560. private _buildId;
  123561. private _buildTarget;
  123562. private _target;
  123563. private _isFinalMerger;
  123564. private _isInput;
  123565. protected _isUnique: boolean;
  123566. /** @hidden */
  123567. _codeVariableName: string;
  123568. /** @hidden */
  123569. _inputs: NodeMaterialConnectionPoint[];
  123570. /** @hidden */
  123571. _outputs: NodeMaterialConnectionPoint[];
  123572. /** @hidden */
  123573. _preparationId: number;
  123574. /**
  123575. * Gets or sets the name of the block
  123576. */
  123577. name: string;
  123578. /**
  123579. * Gets or sets the unique id of the node
  123580. */
  123581. uniqueId: number;
  123582. /**
  123583. * Gets or sets the comments associated with this block
  123584. */
  123585. comments: string;
  123586. /**
  123587. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  123588. */
  123589. readonly isUnique: boolean;
  123590. /**
  123591. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  123592. */
  123593. readonly isFinalMerger: boolean;
  123594. /**
  123595. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  123596. */
  123597. readonly isInput: boolean;
  123598. /**
  123599. * Gets or sets the build Id
  123600. */
  123601. buildId: number;
  123602. /**
  123603. * Gets or sets the target of the block
  123604. */
  123605. target: NodeMaterialBlockTargets;
  123606. /**
  123607. * Gets the list of input points
  123608. */
  123609. readonly inputs: NodeMaterialConnectionPoint[];
  123610. /** Gets the list of output points */
  123611. readonly outputs: NodeMaterialConnectionPoint[];
  123612. /**
  123613. * Find an input by its name
  123614. * @param name defines the name of the input to look for
  123615. * @returns the input or null if not found
  123616. */
  123617. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  123618. /**
  123619. * Find an output by its name
  123620. * @param name defines the name of the outputto look for
  123621. * @returns the output or null if not found
  123622. */
  123623. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  123624. /**
  123625. * Creates a new NodeMaterialBlock
  123626. * @param name defines the block name
  123627. * @param target defines the target of that block (Vertex by default)
  123628. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  123629. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  123630. */
  123631. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  123632. /**
  123633. * Initialize the block and prepare the context for build
  123634. * @param state defines the state that will be used for the build
  123635. */
  123636. initialize(state: NodeMaterialBuildState): void;
  123637. /**
  123638. * Bind data to effect. Will only be called for blocks with isBindable === true
  123639. * @param effect defines the effect to bind data to
  123640. * @param nodeMaterial defines the hosting NodeMaterial
  123641. * @param mesh defines the mesh that will be rendered
  123642. */
  123643. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123644. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  123645. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  123646. protected _writeFloat(value: number): string;
  123647. /**
  123648. * Gets the current class name e.g. "NodeMaterialBlock"
  123649. * @returns the class name
  123650. */
  123651. getClassName(): string;
  123652. /**
  123653. * Register a new input. Must be called inside a block constructor
  123654. * @param name defines the connection point name
  123655. * @param type defines the connection point type
  123656. * @param isOptional defines a boolean indicating that this input can be omitted
  123657. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  123658. * @returns the current block
  123659. */
  123660. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  123661. /**
  123662. * Register a new output. Must be called inside a block constructor
  123663. * @param name defines the connection point name
  123664. * @param type defines the connection point type
  123665. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  123666. * @returns the current block
  123667. */
  123668. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  123669. /**
  123670. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  123671. * @param forOutput defines an optional connection point to check compatibility with
  123672. * @returns the first available input or null
  123673. */
  123674. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  123675. /**
  123676. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  123677. * @param forBlock defines an optional block to check compatibility with
  123678. * @returns the first available input or null
  123679. */
  123680. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  123681. /**
  123682. * Gets the sibling of the given output
  123683. * @param current defines the current output
  123684. * @returns the next output in the list or null
  123685. */
  123686. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  123687. /**
  123688. * Connect current block with another block
  123689. * @param other defines the block to connect with
  123690. * @param options define the various options to help pick the right connections
  123691. * @returns the current block
  123692. */
  123693. connectTo(other: NodeMaterialBlock, options?: {
  123694. input?: string;
  123695. output?: string;
  123696. outputSwizzle?: string;
  123697. }): this | undefined;
  123698. protected _buildBlock(state: NodeMaterialBuildState): void;
  123699. /**
  123700. * Add uniforms, samplers and uniform buffers at compilation time
  123701. * @param state defines the state to update
  123702. * @param nodeMaterial defines the node material requesting the update
  123703. * @param defines defines the material defines to update
  123704. * @param uniformBuffers defines the list of uniform buffer names
  123705. */
  123706. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  123707. /**
  123708. * Add potential fallbacks if shader compilation fails
  123709. * @param mesh defines the mesh to be rendered
  123710. * @param fallbacks defines the current prioritized list of fallbacks
  123711. */
  123712. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  123713. /**
  123714. * Initialize defines for shader compilation
  123715. * @param mesh defines the mesh to be rendered
  123716. * @param nodeMaterial defines the node material requesting the update
  123717. * @param defines defines the material defines to update
  123718. * @param useInstances specifies that instances should be used
  123719. */
  123720. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  123721. /**
  123722. * Update defines for shader compilation
  123723. * @param mesh defines the mesh to be rendered
  123724. * @param nodeMaterial defines the node material requesting the update
  123725. * @param defines defines the material defines to update
  123726. * @param useInstances specifies that instances should be used
  123727. */
  123728. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  123729. /**
  123730. * Lets the block try to connect some inputs automatically
  123731. * @param material defines the hosting NodeMaterial
  123732. */
  123733. autoConfigure(material: NodeMaterial): void;
  123734. /**
  123735. * Function called when a block is declared as repeatable content generator
  123736. * @param vertexShaderState defines the current compilation state for the vertex shader
  123737. * @param fragmentShaderState defines the current compilation state for the fragment shader
  123738. * @param mesh defines the mesh to be rendered
  123739. * @param defines defines the material defines to update
  123740. */
  123741. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  123742. /**
  123743. * Checks if the block is ready
  123744. * @param mesh defines the mesh to be rendered
  123745. * @param nodeMaterial defines the node material requesting the update
  123746. * @param defines defines the material defines to update
  123747. * @param useInstances specifies that instances should be used
  123748. * @returns true if the block is ready
  123749. */
  123750. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  123751. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  123752. private _processBuild;
  123753. /**
  123754. * Compile the current node and generate the shader code
  123755. * @param state defines the current compilation state (uniforms, samplers, current string)
  123756. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  123757. * @returns true if already built
  123758. */
  123759. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  123760. protected _inputRename(name: string): string;
  123761. protected _outputRename(name: string): string;
  123762. protected _dumpPropertiesCode(): string;
  123763. /** @hidden */
  123764. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  123765. /** @hidden */
  123766. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  123767. /**
  123768. * Clone the current block to a new identical block
  123769. * @param scene defines the hosting scene
  123770. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  123771. * @returns a copy of the current block
  123772. */
  123773. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  123774. /**
  123775. * Serializes this block in a JSON representation
  123776. * @returns the serialized block object
  123777. */
  123778. serialize(): any;
  123779. /** @hidden */
  123780. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123781. /**
  123782. * Release resources
  123783. */
  123784. dispose(): void;
  123785. }
  123786. }
  123787. declare module BABYLON {
  123788. /**
  123789. * Enum defining the type of animations supported by InputBlock
  123790. */
  123791. export enum AnimatedInputBlockTypes {
  123792. /** No animation */
  123793. None = 0,
  123794. /** Time based animation. Will only work for floats */
  123795. Time = 1
  123796. }
  123797. }
  123798. declare module BABYLON {
  123799. /**
  123800. * Block used to expose an input value
  123801. */
  123802. export class InputBlock extends NodeMaterialBlock {
  123803. private _mode;
  123804. private _associatedVariableName;
  123805. private _storedValue;
  123806. private _valueCallback;
  123807. private _type;
  123808. private _animationType;
  123809. /** Gets or set a value used to limit the range of float values */
  123810. min: number;
  123811. /** Gets or set a value used to limit the range of float values */
  123812. max: number;
  123813. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  123814. matrixMode: number;
  123815. /** @hidden */
  123816. _systemValue: Nullable<NodeMaterialSystemValues>;
  123817. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  123818. visibleInInspector: boolean;
  123819. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  123820. isConstant: boolean;
  123821. /** Gets or sets the group to use to display this block in the Inspector */
  123822. groupInInspector: string;
  123823. /**
  123824. * Gets or sets the connection point type (default is float)
  123825. */
  123826. readonly type: NodeMaterialBlockConnectionPointTypes;
  123827. /**
  123828. * Creates a new InputBlock
  123829. * @param name defines the block name
  123830. * @param target defines the target of that block (Vertex by default)
  123831. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  123832. */
  123833. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  123834. /**
  123835. * Gets the output component
  123836. */
  123837. readonly output: NodeMaterialConnectionPoint;
  123838. /**
  123839. * Set the source of this connection point to a vertex attribute
  123840. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  123841. * @returns the current connection point
  123842. */
  123843. setAsAttribute(attributeName?: string): InputBlock;
  123844. /**
  123845. * Set the source of this connection point to a system value
  123846. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  123847. * @returns the current connection point
  123848. */
  123849. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  123850. /**
  123851. * Gets or sets the value of that point.
  123852. * Please note that this value will be ignored if valueCallback is defined
  123853. */
  123854. value: any;
  123855. /**
  123856. * Gets or sets a callback used to get the value of that point.
  123857. * Please note that setting this value will force the connection point to ignore the value property
  123858. */
  123859. valueCallback: () => any;
  123860. /**
  123861. * Gets or sets the associated variable name in the shader
  123862. */
  123863. associatedVariableName: string;
  123864. /** Gets or sets the type of animation applied to the input */
  123865. animationType: AnimatedInputBlockTypes;
  123866. /**
  123867. * Gets a boolean indicating that this connection point not defined yet
  123868. */
  123869. readonly isUndefined: boolean;
  123870. /**
  123871. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  123872. * In this case the connection point name must be the name of the uniform to use.
  123873. * Can only be set on inputs
  123874. */
  123875. isUniform: boolean;
  123876. /**
  123877. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  123878. * In this case the connection point name must be the name of the attribute to use
  123879. * Can only be set on inputs
  123880. */
  123881. isAttribute: boolean;
  123882. /**
  123883. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  123884. * Can only be set on exit points
  123885. */
  123886. isVarying: boolean;
  123887. /**
  123888. * Gets a boolean indicating that the current connection point is a system value
  123889. */
  123890. readonly isSystemValue: boolean;
  123891. /**
  123892. * Gets or sets the current well known value or null if not defined as a system value
  123893. */
  123894. systemValue: Nullable<NodeMaterialSystemValues>;
  123895. /**
  123896. * Gets the current class name
  123897. * @returns the class name
  123898. */
  123899. getClassName(): string;
  123900. /**
  123901. * Animate the input if animationType !== None
  123902. * @param scene defines the rendering scene
  123903. */
  123904. animate(scene: Scene): void;
  123905. private _emitDefine;
  123906. initialize(state: NodeMaterialBuildState): void;
  123907. /**
  123908. * Set the input block to its default value (based on its type)
  123909. */
  123910. setDefaultValue(): void;
  123911. private _emitConstant;
  123912. private _emit;
  123913. /** @hidden */
  123914. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  123915. /** @hidden */
  123916. _transmit(effect: Effect, scene: Scene): void;
  123917. protected _buildBlock(state: NodeMaterialBuildState): void;
  123918. protected _dumpPropertiesCode(): string;
  123919. serialize(): any;
  123920. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123921. }
  123922. }
  123923. declare module BABYLON {
  123924. /**
  123925. * Enum used to define the compatibility state between two connection points
  123926. */
  123927. export enum NodeMaterialConnectionPointCompatibilityStates {
  123928. /** Points are compatibles */
  123929. Compatible = 0,
  123930. /** Points are incompatible because of their types */
  123931. TypeIncompatible = 1,
  123932. /** Points are incompatible because of their targets (vertex vs fragment) */
  123933. TargetIncompatible = 2
  123934. }
  123935. /**
  123936. * Defines the direction of a connection point
  123937. */
  123938. export enum NodeMaterialConnectionPointDirection {
  123939. /** Input */
  123940. Input = 0,
  123941. /** Output */
  123942. Output = 1
  123943. }
  123944. /**
  123945. * Defines a connection point for a block
  123946. */
  123947. export class NodeMaterialConnectionPoint {
  123948. /** @hidden */
  123949. _ownerBlock: NodeMaterialBlock;
  123950. /** @hidden */
  123951. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  123952. private _endpoints;
  123953. private _associatedVariableName;
  123954. private _direction;
  123955. /** @hidden */
  123956. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  123957. /** @hidden */
  123958. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  123959. private _type;
  123960. /** @hidden */
  123961. _enforceAssociatedVariableName: boolean;
  123962. /** Gets the direction of the point */
  123963. readonly direction: NodeMaterialConnectionPointDirection;
  123964. /**
  123965. * Gets or sets the additional types supported by this connection point
  123966. */
  123967. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  123968. /**
  123969. * Gets or sets the additional types excluded by this connection point
  123970. */
  123971. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  123972. /**
  123973. * Observable triggered when this point is connected
  123974. */
  123975. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  123976. /**
  123977. * Gets or sets the associated variable name in the shader
  123978. */
  123979. associatedVariableName: string;
  123980. /**
  123981. * Gets or sets the connection point type (default is float)
  123982. */
  123983. type: NodeMaterialBlockConnectionPointTypes;
  123984. /**
  123985. * Gets or sets the connection point name
  123986. */
  123987. name: string;
  123988. /**
  123989. * Gets or sets a boolean indicating that this connection point can be omitted
  123990. */
  123991. isOptional: boolean;
  123992. /**
  123993. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  123994. */
  123995. define: string;
  123996. /** @hidden */
  123997. _prioritizeVertex: boolean;
  123998. private _target;
  123999. /** Gets or sets the target of that connection point */
  124000. target: NodeMaterialBlockTargets;
  124001. /**
  124002. * Gets a boolean indicating that the current point is connected
  124003. */
  124004. readonly isConnected: boolean;
  124005. /**
  124006. * Gets a boolean indicating that the current point is connected to an input block
  124007. */
  124008. readonly isConnectedToInputBlock: boolean;
  124009. /**
  124010. * Gets a the connected input block (if any)
  124011. */
  124012. readonly connectInputBlock: Nullable<InputBlock>;
  124013. /** Get the other side of the connection (if any) */
  124014. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  124015. /** Get the block that owns this connection point */
  124016. readonly ownerBlock: NodeMaterialBlock;
  124017. /** Get the block connected on the other side of this connection (if any) */
  124018. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  124019. /** Get the block connected on the endpoints of this connection (if any) */
  124020. readonly connectedBlocks: Array<NodeMaterialBlock>;
  124021. /** Gets the list of connected endpoints */
  124022. readonly endpoints: NodeMaterialConnectionPoint[];
  124023. /** Gets a boolean indicating if that output point is connected to at least one input */
  124024. readonly hasEndpoints: boolean;
  124025. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  124026. readonly isConnectedInVertexShader: boolean;
  124027. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  124028. readonly isConnectedInFragmentShader: boolean;
  124029. /**
  124030. * Creates a new connection point
  124031. * @param name defines the connection point name
  124032. * @param ownerBlock defines the block hosting this connection point
  124033. * @param direction defines the direction of the connection point
  124034. */
  124035. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  124036. /**
  124037. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  124038. * @returns the class name
  124039. */
  124040. getClassName(): string;
  124041. /**
  124042. * Gets a boolean indicating if the current point can be connected to another point
  124043. * @param connectionPoint defines the other connection point
  124044. * @returns a boolean
  124045. */
  124046. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  124047. /**
  124048. * Gets a number indicating if the current point can be connected to another point
  124049. * @param connectionPoint defines the other connection point
  124050. * @returns a number defining the compatibility state
  124051. */
  124052. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  124053. /**
  124054. * Connect this point to another connection point
  124055. * @param connectionPoint defines the other connection point
  124056. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  124057. * @returns the current connection point
  124058. */
  124059. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  124060. /**
  124061. * Disconnect this point from one of his endpoint
  124062. * @param endpoint defines the other connection point
  124063. * @returns the current connection point
  124064. */
  124065. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  124066. /**
  124067. * Serializes this point in a JSON representation
  124068. * @returns the serialized point object
  124069. */
  124070. serialize(): any;
  124071. /**
  124072. * Release resources
  124073. */
  124074. dispose(): void;
  124075. }
  124076. }
  124077. declare module BABYLON {
  124078. /**
  124079. * Block used to add support for vertex skinning (bones)
  124080. */
  124081. export class BonesBlock extends NodeMaterialBlock {
  124082. /**
  124083. * Creates a new BonesBlock
  124084. * @param name defines the block name
  124085. */
  124086. constructor(name: string);
  124087. /**
  124088. * Initialize the block and prepare the context for build
  124089. * @param state defines the state that will be used for the build
  124090. */
  124091. initialize(state: NodeMaterialBuildState): void;
  124092. /**
  124093. * Gets the current class name
  124094. * @returns the class name
  124095. */
  124096. getClassName(): string;
  124097. /**
  124098. * Gets the matrix indices input component
  124099. */
  124100. readonly matricesIndices: NodeMaterialConnectionPoint;
  124101. /**
  124102. * Gets the matrix weights input component
  124103. */
  124104. readonly matricesWeights: NodeMaterialConnectionPoint;
  124105. /**
  124106. * Gets the extra matrix indices input component
  124107. */
  124108. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  124109. /**
  124110. * Gets the extra matrix weights input component
  124111. */
  124112. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  124113. /**
  124114. * Gets the world input component
  124115. */
  124116. readonly world: NodeMaterialConnectionPoint;
  124117. /**
  124118. * Gets the output component
  124119. */
  124120. readonly output: NodeMaterialConnectionPoint;
  124121. autoConfigure(material: NodeMaterial): void;
  124122. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  124123. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124124. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124125. protected _buildBlock(state: NodeMaterialBuildState): this;
  124126. }
  124127. }
  124128. declare module BABYLON {
  124129. /**
  124130. * Block used to add support for instances
  124131. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  124132. */
  124133. export class InstancesBlock extends NodeMaterialBlock {
  124134. /**
  124135. * Creates a new InstancesBlock
  124136. * @param name defines the block name
  124137. */
  124138. constructor(name: string);
  124139. /**
  124140. * Gets the current class name
  124141. * @returns the class name
  124142. */
  124143. getClassName(): string;
  124144. /**
  124145. * Gets the first world row input component
  124146. */
  124147. readonly world0: NodeMaterialConnectionPoint;
  124148. /**
  124149. * Gets the second world row input component
  124150. */
  124151. readonly world1: NodeMaterialConnectionPoint;
  124152. /**
  124153. * Gets the third world row input component
  124154. */
  124155. readonly world2: NodeMaterialConnectionPoint;
  124156. /**
  124157. * Gets the forth world row input component
  124158. */
  124159. readonly world3: NodeMaterialConnectionPoint;
  124160. /**
  124161. * Gets the world input component
  124162. */
  124163. readonly world: NodeMaterialConnectionPoint;
  124164. /**
  124165. * Gets the output component
  124166. */
  124167. readonly output: NodeMaterialConnectionPoint;
  124168. autoConfigure(material: NodeMaterial): void;
  124169. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  124170. protected _buildBlock(state: NodeMaterialBuildState): this;
  124171. }
  124172. }
  124173. declare module BABYLON {
  124174. /**
  124175. * Block used to add morph targets support to vertex shader
  124176. */
  124177. export class MorphTargetsBlock extends NodeMaterialBlock {
  124178. private _repeatableContentAnchor;
  124179. private _repeatebleContentGenerated;
  124180. /**
  124181. * Create a new MorphTargetsBlock
  124182. * @param name defines the block name
  124183. */
  124184. constructor(name: string);
  124185. /**
  124186. * Gets the current class name
  124187. * @returns the class name
  124188. */
  124189. getClassName(): string;
  124190. /**
  124191. * Gets the position input component
  124192. */
  124193. readonly position: NodeMaterialConnectionPoint;
  124194. /**
  124195. * Gets the normal input component
  124196. */
  124197. readonly normal: NodeMaterialConnectionPoint;
  124198. /**
  124199. * Gets the tangent input component
  124200. */
  124201. readonly tangent: NodeMaterialConnectionPoint;
  124202. /**
  124203. * Gets the tangent input component
  124204. */
  124205. readonly uv: NodeMaterialConnectionPoint;
  124206. /**
  124207. * Gets the position output component
  124208. */
  124209. readonly positionOutput: NodeMaterialConnectionPoint;
  124210. /**
  124211. * Gets the normal output component
  124212. */
  124213. readonly normalOutput: NodeMaterialConnectionPoint;
  124214. /**
  124215. * Gets the tangent output component
  124216. */
  124217. readonly tangentOutput: NodeMaterialConnectionPoint;
  124218. /**
  124219. * Gets the tangent output component
  124220. */
  124221. readonly uvOutput: NodeMaterialConnectionPoint;
  124222. initialize(state: NodeMaterialBuildState): void;
  124223. autoConfigure(material: NodeMaterial): void;
  124224. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124225. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124226. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  124227. protected _buildBlock(state: NodeMaterialBuildState): this;
  124228. }
  124229. }
  124230. declare module BABYLON {
  124231. /**
  124232. * Block used to get data information from a light
  124233. */
  124234. export class LightInformationBlock extends NodeMaterialBlock {
  124235. private _lightDataUniformName;
  124236. private _lightColorUniformName;
  124237. private _lightTypeDefineName;
  124238. /**
  124239. * Gets or sets the light associated with this block
  124240. */
  124241. light: Nullable<Light>;
  124242. /**
  124243. * Creates a new LightInformationBlock
  124244. * @param name defines the block name
  124245. */
  124246. constructor(name: string);
  124247. /**
  124248. * Gets the current class name
  124249. * @returns the class name
  124250. */
  124251. getClassName(): string;
  124252. /**
  124253. * Gets the world position input component
  124254. */
  124255. readonly worldPosition: NodeMaterialConnectionPoint;
  124256. /**
  124257. * Gets the direction output component
  124258. */
  124259. readonly direction: NodeMaterialConnectionPoint;
  124260. /**
  124261. * Gets the direction output component
  124262. */
  124263. readonly color: NodeMaterialConnectionPoint;
  124264. /**
  124265. * Gets the direction output component
  124266. */
  124267. readonly intensity: NodeMaterialConnectionPoint;
  124268. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124269. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124270. protected _buildBlock(state: NodeMaterialBuildState): this;
  124271. serialize(): any;
  124272. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124273. }
  124274. }
  124275. declare module BABYLON {
  124276. /**
  124277. * Block used to add image processing support to fragment shader
  124278. */
  124279. export class ImageProcessingBlock extends NodeMaterialBlock {
  124280. /**
  124281. * Create a new ImageProcessingBlock
  124282. * @param name defines the block name
  124283. */
  124284. constructor(name: string);
  124285. /**
  124286. * Gets the current class name
  124287. * @returns the class name
  124288. */
  124289. getClassName(): string;
  124290. /**
  124291. * Gets the color input component
  124292. */
  124293. readonly color: NodeMaterialConnectionPoint;
  124294. /**
  124295. * Gets the output component
  124296. */
  124297. readonly output: NodeMaterialConnectionPoint;
  124298. /**
  124299. * Initialize the block and prepare the context for build
  124300. * @param state defines the state that will be used for the build
  124301. */
  124302. initialize(state: NodeMaterialBuildState): void;
  124303. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  124304. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124305. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124306. protected _buildBlock(state: NodeMaterialBuildState): this;
  124307. }
  124308. }
  124309. declare module BABYLON {
  124310. /**
  124311. * Block used to pertub normals based on a normal map
  124312. */
  124313. export class PerturbNormalBlock extends NodeMaterialBlock {
  124314. private _tangentSpaceParameterName;
  124315. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  124316. invertX: boolean;
  124317. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  124318. invertY: boolean;
  124319. /**
  124320. * Create a new PerturbNormalBlock
  124321. * @param name defines the block name
  124322. */
  124323. constructor(name: string);
  124324. /**
  124325. * Gets the current class name
  124326. * @returns the class name
  124327. */
  124328. getClassName(): string;
  124329. /**
  124330. * Gets the world position input component
  124331. */
  124332. readonly worldPosition: NodeMaterialConnectionPoint;
  124333. /**
  124334. * Gets the world normal input component
  124335. */
  124336. readonly worldNormal: NodeMaterialConnectionPoint;
  124337. /**
  124338. * Gets the uv input component
  124339. */
  124340. readonly uv: NodeMaterialConnectionPoint;
  124341. /**
  124342. * Gets the normal map color input component
  124343. */
  124344. readonly normalMapColor: NodeMaterialConnectionPoint;
  124345. /**
  124346. * Gets the strength input component
  124347. */
  124348. readonly strength: NodeMaterialConnectionPoint;
  124349. /**
  124350. * Gets the output component
  124351. */
  124352. readonly output: NodeMaterialConnectionPoint;
  124353. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124354. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124355. autoConfigure(material: NodeMaterial): void;
  124356. protected _buildBlock(state: NodeMaterialBuildState): this;
  124357. protected _dumpPropertiesCode(): string;
  124358. serialize(): any;
  124359. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124360. }
  124361. }
  124362. declare module BABYLON {
  124363. /**
  124364. * Block used to discard a pixel if a value is smaller than a cutoff
  124365. */
  124366. export class DiscardBlock extends NodeMaterialBlock {
  124367. /**
  124368. * Create a new DiscardBlock
  124369. * @param name defines the block name
  124370. */
  124371. constructor(name: string);
  124372. /**
  124373. * Gets the current class name
  124374. * @returns the class name
  124375. */
  124376. getClassName(): string;
  124377. /**
  124378. * Gets the color input component
  124379. */
  124380. readonly value: NodeMaterialConnectionPoint;
  124381. /**
  124382. * Gets the cutoff input component
  124383. */
  124384. readonly cutoff: NodeMaterialConnectionPoint;
  124385. protected _buildBlock(state: NodeMaterialBuildState): this;
  124386. }
  124387. }
  124388. declare module BABYLON {
  124389. /**
  124390. * Block used to test if the fragment shader is front facing
  124391. */
  124392. export class FrontFacingBlock extends NodeMaterialBlock {
  124393. /**
  124394. * Creates a new FrontFacingBlock
  124395. * @param name defines the block name
  124396. */
  124397. constructor(name: string);
  124398. /**
  124399. * Gets the current class name
  124400. * @returns the class name
  124401. */
  124402. getClassName(): string;
  124403. /**
  124404. * Gets the output component
  124405. */
  124406. readonly output: NodeMaterialConnectionPoint;
  124407. protected _buildBlock(state: NodeMaterialBuildState): this;
  124408. }
  124409. }
  124410. declare module BABYLON {
  124411. /**
  124412. * Block used to get the derivative value on x and y of a given input
  124413. */
  124414. export class DerivativeBlock extends NodeMaterialBlock {
  124415. /**
  124416. * Create a new DerivativeBlock
  124417. * @param name defines the block name
  124418. */
  124419. constructor(name: string);
  124420. /**
  124421. * Gets the current class name
  124422. * @returns the class name
  124423. */
  124424. getClassName(): string;
  124425. /**
  124426. * Gets the input component
  124427. */
  124428. readonly input: NodeMaterialConnectionPoint;
  124429. /**
  124430. * Gets the derivative output on x
  124431. */
  124432. readonly dx: NodeMaterialConnectionPoint;
  124433. /**
  124434. * Gets the derivative output on y
  124435. */
  124436. readonly dy: NodeMaterialConnectionPoint;
  124437. protected _buildBlock(state: NodeMaterialBuildState): this;
  124438. }
  124439. }
  124440. declare module BABYLON {
  124441. /**
  124442. * Block used to add support for scene fog
  124443. */
  124444. export class FogBlock extends NodeMaterialBlock {
  124445. private _fogDistanceName;
  124446. private _fogParameters;
  124447. /**
  124448. * Create a new FogBlock
  124449. * @param name defines the block name
  124450. */
  124451. constructor(name: string);
  124452. /**
  124453. * Gets the current class name
  124454. * @returns the class name
  124455. */
  124456. getClassName(): string;
  124457. /**
  124458. * Gets the world position input component
  124459. */
  124460. readonly worldPosition: NodeMaterialConnectionPoint;
  124461. /**
  124462. * Gets the view input component
  124463. */
  124464. readonly view: NodeMaterialConnectionPoint;
  124465. /**
  124466. * Gets the color input component
  124467. */
  124468. readonly input: NodeMaterialConnectionPoint;
  124469. /**
  124470. * Gets the fog color input component
  124471. */
  124472. readonly fogColor: NodeMaterialConnectionPoint;
  124473. /**
  124474. * Gets the output component
  124475. */
  124476. readonly output: NodeMaterialConnectionPoint;
  124477. autoConfigure(material: NodeMaterial): void;
  124478. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124479. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124480. protected _buildBlock(state: NodeMaterialBuildState): this;
  124481. }
  124482. }
  124483. declare module BABYLON {
  124484. /**
  124485. * Block used to add light in the fragment shader
  124486. */
  124487. export class LightBlock extends NodeMaterialBlock {
  124488. private _lightId;
  124489. /**
  124490. * Gets or sets the light associated with this block
  124491. */
  124492. light: Nullable<Light>;
  124493. /**
  124494. * Create a new LightBlock
  124495. * @param name defines the block name
  124496. */
  124497. constructor(name: string);
  124498. /**
  124499. * Gets the current class name
  124500. * @returns the class name
  124501. */
  124502. getClassName(): string;
  124503. /**
  124504. * Gets the world position input component
  124505. */
  124506. readonly worldPosition: NodeMaterialConnectionPoint;
  124507. /**
  124508. * Gets the world normal input component
  124509. */
  124510. readonly worldNormal: NodeMaterialConnectionPoint;
  124511. /**
  124512. * Gets the camera (or eye) position component
  124513. */
  124514. readonly cameraPosition: NodeMaterialConnectionPoint;
  124515. /**
  124516. * Gets the glossiness component
  124517. */
  124518. readonly glossiness: NodeMaterialConnectionPoint;
  124519. /**
  124520. * Gets the glossinness power component
  124521. */
  124522. readonly glossPower: NodeMaterialConnectionPoint;
  124523. /**
  124524. * Gets the diffuse color component
  124525. */
  124526. readonly diffuseColor: NodeMaterialConnectionPoint;
  124527. /**
  124528. * Gets the specular color component
  124529. */
  124530. readonly specularColor: NodeMaterialConnectionPoint;
  124531. /**
  124532. * Gets the diffuse output component
  124533. */
  124534. readonly diffuseOutput: NodeMaterialConnectionPoint;
  124535. /**
  124536. * Gets the specular output component
  124537. */
  124538. readonly specularOutput: NodeMaterialConnectionPoint;
  124539. autoConfigure(material: NodeMaterial): void;
  124540. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124541. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  124542. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124543. private _injectVertexCode;
  124544. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  124545. serialize(): any;
  124546. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124547. }
  124548. }
  124549. declare module BABYLON {
  124550. /**
  124551. * Block used to multiply 2 values
  124552. */
  124553. export class MultiplyBlock extends NodeMaterialBlock {
  124554. /**
  124555. * Creates a new MultiplyBlock
  124556. * @param name defines the block name
  124557. */
  124558. constructor(name: string);
  124559. /**
  124560. * Gets the current class name
  124561. * @returns the class name
  124562. */
  124563. getClassName(): string;
  124564. /**
  124565. * Gets the left operand input component
  124566. */
  124567. readonly left: NodeMaterialConnectionPoint;
  124568. /**
  124569. * Gets the right operand input component
  124570. */
  124571. readonly right: NodeMaterialConnectionPoint;
  124572. /**
  124573. * Gets the output component
  124574. */
  124575. readonly output: NodeMaterialConnectionPoint;
  124576. protected _buildBlock(state: NodeMaterialBuildState): this;
  124577. }
  124578. }
  124579. declare module BABYLON {
  124580. /**
  124581. * Block used to add 2 vectors
  124582. */
  124583. export class AddBlock extends NodeMaterialBlock {
  124584. /**
  124585. * Creates a new AddBlock
  124586. * @param name defines the block name
  124587. */
  124588. constructor(name: string);
  124589. /**
  124590. * Gets the current class name
  124591. * @returns the class name
  124592. */
  124593. getClassName(): string;
  124594. /**
  124595. * Gets the left operand input component
  124596. */
  124597. readonly left: NodeMaterialConnectionPoint;
  124598. /**
  124599. * Gets the right operand input component
  124600. */
  124601. readonly right: NodeMaterialConnectionPoint;
  124602. /**
  124603. * Gets the output component
  124604. */
  124605. readonly output: NodeMaterialConnectionPoint;
  124606. protected _buildBlock(state: NodeMaterialBuildState): this;
  124607. }
  124608. }
  124609. declare module BABYLON {
  124610. /**
  124611. * Block used to scale a vector by a float
  124612. */
  124613. export class ScaleBlock extends NodeMaterialBlock {
  124614. /**
  124615. * Creates a new ScaleBlock
  124616. * @param name defines the block name
  124617. */
  124618. constructor(name: string);
  124619. /**
  124620. * Gets the current class name
  124621. * @returns the class name
  124622. */
  124623. getClassName(): string;
  124624. /**
  124625. * Gets the input component
  124626. */
  124627. readonly input: NodeMaterialConnectionPoint;
  124628. /**
  124629. * Gets the factor input component
  124630. */
  124631. readonly factor: NodeMaterialConnectionPoint;
  124632. /**
  124633. * Gets the output component
  124634. */
  124635. readonly output: NodeMaterialConnectionPoint;
  124636. protected _buildBlock(state: NodeMaterialBuildState): this;
  124637. }
  124638. }
  124639. declare module BABYLON {
  124640. /**
  124641. * Block used to clamp a float
  124642. */
  124643. export class ClampBlock extends NodeMaterialBlock {
  124644. /** Gets or sets the minimum range */
  124645. minimum: number;
  124646. /** Gets or sets the maximum range */
  124647. maximum: number;
  124648. /**
  124649. * Creates a new ClampBlock
  124650. * @param name defines the block name
  124651. */
  124652. constructor(name: string);
  124653. /**
  124654. * Gets the current class name
  124655. * @returns the class name
  124656. */
  124657. getClassName(): string;
  124658. /**
  124659. * Gets the value input component
  124660. */
  124661. readonly value: NodeMaterialConnectionPoint;
  124662. /**
  124663. * Gets the output component
  124664. */
  124665. readonly output: NodeMaterialConnectionPoint;
  124666. protected _buildBlock(state: NodeMaterialBuildState): this;
  124667. protected _dumpPropertiesCode(): string;
  124668. serialize(): any;
  124669. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124670. }
  124671. }
  124672. declare module BABYLON {
  124673. /**
  124674. * Block used to apply a cross product between 2 vectors
  124675. */
  124676. export class CrossBlock extends NodeMaterialBlock {
  124677. /**
  124678. * Creates a new CrossBlock
  124679. * @param name defines the block name
  124680. */
  124681. constructor(name: string);
  124682. /**
  124683. * Gets the current class name
  124684. * @returns the class name
  124685. */
  124686. getClassName(): string;
  124687. /**
  124688. * Gets the left operand input component
  124689. */
  124690. readonly left: NodeMaterialConnectionPoint;
  124691. /**
  124692. * Gets the right operand input component
  124693. */
  124694. readonly right: NodeMaterialConnectionPoint;
  124695. /**
  124696. * Gets the output component
  124697. */
  124698. readonly output: NodeMaterialConnectionPoint;
  124699. protected _buildBlock(state: NodeMaterialBuildState): this;
  124700. }
  124701. }
  124702. declare module BABYLON {
  124703. /**
  124704. * Block used to apply a dot product between 2 vectors
  124705. */
  124706. export class DotBlock extends NodeMaterialBlock {
  124707. /**
  124708. * Creates a new DotBlock
  124709. * @param name defines the block name
  124710. */
  124711. constructor(name: string);
  124712. /**
  124713. * Gets the current class name
  124714. * @returns the class name
  124715. */
  124716. getClassName(): string;
  124717. /**
  124718. * Gets the left operand input component
  124719. */
  124720. readonly left: NodeMaterialConnectionPoint;
  124721. /**
  124722. * Gets the right operand input component
  124723. */
  124724. readonly right: NodeMaterialConnectionPoint;
  124725. /**
  124726. * Gets the output component
  124727. */
  124728. readonly output: NodeMaterialConnectionPoint;
  124729. protected _buildBlock(state: NodeMaterialBuildState): this;
  124730. }
  124731. }
  124732. declare module BABYLON {
  124733. /**
  124734. * Block used to remap a float from a range to a new one
  124735. */
  124736. export class RemapBlock extends NodeMaterialBlock {
  124737. /**
  124738. * Gets or sets the source range
  124739. */
  124740. sourceRange: Vector2;
  124741. /**
  124742. * Gets or sets the target range
  124743. */
  124744. targetRange: Vector2;
  124745. /**
  124746. * Creates a new RemapBlock
  124747. * @param name defines the block name
  124748. */
  124749. constructor(name: string);
  124750. /**
  124751. * Gets the current class name
  124752. * @returns the class name
  124753. */
  124754. getClassName(): string;
  124755. /**
  124756. * Gets the input component
  124757. */
  124758. readonly input: NodeMaterialConnectionPoint;
  124759. /**
  124760. * Gets the source min input component
  124761. */
  124762. readonly sourceMin: NodeMaterialConnectionPoint;
  124763. /**
  124764. * Gets the source max input component
  124765. */
  124766. readonly sourceMax: NodeMaterialConnectionPoint;
  124767. /**
  124768. * Gets the target min input component
  124769. */
  124770. readonly targetMin: NodeMaterialConnectionPoint;
  124771. /**
  124772. * Gets the target max input component
  124773. */
  124774. readonly targetMax: NodeMaterialConnectionPoint;
  124775. /**
  124776. * Gets the output component
  124777. */
  124778. readonly output: NodeMaterialConnectionPoint;
  124779. protected _buildBlock(state: NodeMaterialBuildState): this;
  124780. protected _dumpPropertiesCode(): string;
  124781. serialize(): any;
  124782. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124783. }
  124784. }
  124785. declare module BABYLON {
  124786. /**
  124787. * Block used to normalize a vector
  124788. */
  124789. export class NormalizeBlock extends NodeMaterialBlock {
  124790. /**
  124791. * Creates a new NormalizeBlock
  124792. * @param name defines the block name
  124793. */
  124794. constructor(name: string);
  124795. /**
  124796. * Gets the current class name
  124797. * @returns the class name
  124798. */
  124799. getClassName(): string;
  124800. /**
  124801. * Gets the input component
  124802. */
  124803. readonly input: NodeMaterialConnectionPoint;
  124804. /**
  124805. * Gets the output component
  124806. */
  124807. readonly output: NodeMaterialConnectionPoint;
  124808. protected _buildBlock(state: NodeMaterialBuildState): this;
  124809. }
  124810. }
  124811. declare module BABYLON {
  124812. /**
  124813. * Operations supported by the Trigonometry block
  124814. */
  124815. export enum TrigonometryBlockOperations {
  124816. /** Cos */
  124817. Cos = 0,
  124818. /** Sin */
  124819. Sin = 1,
  124820. /** Abs */
  124821. Abs = 2,
  124822. /** Exp */
  124823. Exp = 3,
  124824. /** Exp2 */
  124825. Exp2 = 4,
  124826. /** Round */
  124827. Round = 5,
  124828. /** Floor */
  124829. Floor = 6,
  124830. /** Ceiling */
  124831. Ceiling = 7,
  124832. /** Square root */
  124833. Sqrt = 8,
  124834. /** Log */
  124835. Log = 9,
  124836. /** Tangent */
  124837. Tan = 10,
  124838. /** Arc tangent */
  124839. ArcTan = 11,
  124840. /** Arc cosinus */
  124841. ArcCos = 12,
  124842. /** Arc sinus */
  124843. ArcSin = 13,
  124844. /** Fraction */
  124845. Fract = 14,
  124846. /** Sign */
  124847. Sign = 15,
  124848. /** To radians (from degrees) */
  124849. Radians = 16,
  124850. /** To degrees (from radians) */
  124851. Degrees = 17
  124852. }
  124853. /**
  124854. * Block used to apply trigonometry operation to floats
  124855. */
  124856. export class TrigonometryBlock extends NodeMaterialBlock {
  124857. /**
  124858. * Gets or sets the operation applied by the block
  124859. */
  124860. operation: TrigonometryBlockOperations;
  124861. /**
  124862. * Creates a new TrigonometryBlock
  124863. * @param name defines the block name
  124864. */
  124865. constructor(name: string);
  124866. /**
  124867. * Gets the current class name
  124868. * @returns the class name
  124869. */
  124870. getClassName(): string;
  124871. /**
  124872. * Gets the input component
  124873. */
  124874. readonly input: NodeMaterialConnectionPoint;
  124875. /**
  124876. * Gets the output component
  124877. */
  124878. readonly output: NodeMaterialConnectionPoint;
  124879. protected _buildBlock(state: NodeMaterialBuildState): this;
  124880. serialize(): any;
  124881. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124882. protected _dumpPropertiesCode(): string;
  124883. }
  124884. }
  124885. declare module BABYLON {
  124886. /**
  124887. * Block used to create a Color3/4 out of individual inputs (one for each component)
  124888. */
  124889. export class ColorMergerBlock extends NodeMaterialBlock {
  124890. /**
  124891. * Create a new ColorMergerBlock
  124892. * @param name defines the block name
  124893. */
  124894. constructor(name: string);
  124895. /**
  124896. * Gets the current class name
  124897. * @returns the class name
  124898. */
  124899. getClassName(): string;
  124900. /**
  124901. * Gets the rgb component (input)
  124902. */
  124903. readonly rgbIn: NodeMaterialConnectionPoint;
  124904. /**
  124905. * Gets the r component (input)
  124906. */
  124907. readonly r: NodeMaterialConnectionPoint;
  124908. /**
  124909. * Gets the g component (input)
  124910. */
  124911. readonly g: NodeMaterialConnectionPoint;
  124912. /**
  124913. * Gets the b component (input)
  124914. */
  124915. readonly b: NodeMaterialConnectionPoint;
  124916. /**
  124917. * Gets the a component (input)
  124918. */
  124919. readonly a: NodeMaterialConnectionPoint;
  124920. /**
  124921. * Gets the rgba component (output)
  124922. */
  124923. readonly rgba: NodeMaterialConnectionPoint;
  124924. /**
  124925. * Gets the rgb component (output)
  124926. */
  124927. readonly rgbOut: NodeMaterialConnectionPoint;
  124928. /**
  124929. * Gets the rgb component (output)
  124930. * @deprecated Please use rgbOut instead.
  124931. */
  124932. readonly rgb: NodeMaterialConnectionPoint;
  124933. protected _buildBlock(state: NodeMaterialBuildState): this;
  124934. }
  124935. }
  124936. declare module BABYLON {
  124937. /**
  124938. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  124939. */
  124940. export class VectorMergerBlock extends NodeMaterialBlock {
  124941. /**
  124942. * Create a new VectorMergerBlock
  124943. * @param name defines the block name
  124944. */
  124945. constructor(name: string);
  124946. /**
  124947. * Gets the current class name
  124948. * @returns the class name
  124949. */
  124950. getClassName(): string;
  124951. /**
  124952. * Gets the xyz component (input)
  124953. */
  124954. readonly xyzIn: NodeMaterialConnectionPoint;
  124955. /**
  124956. * Gets the xy component (input)
  124957. */
  124958. readonly xyIn: NodeMaterialConnectionPoint;
  124959. /**
  124960. * Gets the x component (input)
  124961. */
  124962. readonly x: NodeMaterialConnectionPoint;
  124963. /**
  124964. * Gets the y component (input)
  124965. */
  124966. readonly y: NodeMaterialConnectionPoint;
  124967. /**
  124968. * Gets the z component (input)
  124969. */
  124970. readonly z: NodeMaterialConnectionPoint;
  124971. /**
  124972. * Gets the w component (input)
  124973. */
  124974. readonly w: NodeMaterialConnectionPoint;
  124975. /**
  124976. * Gets the xyzw component (output)
  124977. */
  124978. readonly xyzw: NodeMaterialConnectionPoint;
  124979. /**
  124980. * Gets the xyz component (output)
  124981. */
  124982. readonly xyzOut: NodeMaterialConnectionPoint;
  124983. /**
  124984. * Gets the xy component (output)
  124985. */
  124986. readonly xyOut: NodeMaterialConnectionPoint;
  124987. /**
  124988. * Gets the xy component (output)
  124989. * @deprecated Please use xyOut instead.
  124990. */
  124991. readonly xy: NodeMaterialConnectionPoint;
  124992. /**
  124993. * Gets the xyz component (output)
  124994. * @deprecated Please use xyzOut instead.
  124995. */
  124996. readonly xyz: NodeMaterialConnectionPoint;
  124997. protected _buildBlock(state: NodeMaterialBuildState): this;
  124998. }
  124999. }
  125000. declare module BABYLON {
  125001. /**
  125002. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  125003. */
  125004. export class ColorSplitterBlock extends NodeMaterialBlock {
  125005. /**
  125006. * Create a new ColorSplitterBlock
  125007. * @param name defines the block name
  125008. */
  125009. constructor(name: string);
  125010. /**
  125011. * Gets the current class name
  125012. * @returns the class name
  125013. */
  125014. getClassName(): string;
  125015. /**
  125016. * Gets the rgba component (input)
  125017. */
  125018. readonly rgba: NodeMaterialConnectionPoint;
  125019. /**
  125020. * Gets the rgb component (input)
  125021. */
  125022. readonly rgbIn: NodeMaterialConnectionPoint;
  125023. /**
  125024. * Gets the rgb component (output)
  125025. */
  125026. readonly rgbOut: NodeMaterialConnectionPoint;
  125027. /**
  125028. * Gets the r component (output)
  125029. */
  125030. readonly r: NodeMaterialConnectionPoint;
  125031. /**
  125032. * Gets the g component (output)
  125033. */
  125034. readonly g: NodeMaterialConnectionPoint;
  125035. /**
  125036. * Gets the b component (output)
  125037. */
  125038. readonly b: NodeMaterialConnectionPoint;
  125039. /**
  125040. * Gets the a component (output)
  125041. */
  125042. readonly a: NodeMaterialConnectionPoint;
  125043. protected _inputRename(name: string): string;
  125044. protected _outputRename(name: string): string;
  125045. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  125046. }
  125047. }
  125048. declare module BABYLON {
  125049. /**
  125050. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  125051. */
  125052. export class VectorSplitterBlock extends NodeMaterialBlock {
  125053. /**
  125054. * Create a new VectorSplitterBlock
  125055. * @param name defines the block name
  125056. */
  125057. constructor(name: string);
  125058. /**
  125059. * Gets the current class name
  125060. * @returns the class name
  125061. */
  125062. getClassName(): string;
  125063. /**
  125064. * Gets the xyzw component (input)
  125065. */
  125066. readonly xyzw: NodeMaterialConnectionPoint;
  125067. /**
  125068. * Gets the xyz component (input)
  125069. */
  125070. readonly xyzIn: NodeMaterialConnectionPoint;
  125071. /**
  125072. * Gets the xy component (input)
  125073. */
  125074. readonly xyIn: NodeMaterialConnectionPoint;
  125075. /**
  125076. * Gets the xyz component (output)
  125077. */
  125078. readonly xyzOut: NodeMaterialConnectionPoint;
  125079. /**
  125080. * Gets the xy component (output)
  125081. */
  125082. readonly xyOut: NodeMaterialConnectionPoint;
  125083. /**
  125084. * Gets the x component (output)
  125085. */
  125086. readonly x: NodeMaterialConnectionPoint;
  125087. /**
  125088. * Gets the y component (output)
  125089. */
  125090. readonly y: NodeMaterialConnectionPoint;
  125091. /**
  125092. * Gets the z component (output)
  125093. */
  125094. readonly z: NodeMaterialConnectionPoint;
  125095. /**
  125096. * Gets the w component (output)
  125097. */
  125098. readonly w: NodeMaterialConnectionPoint;
  125099. protected _inputRename(name: string): string;
  125100. protected _outputRename(name: string): string;
  125101. protected _buildBlock(state: NodeMaterialBuildState): this;
  125102. }
  125103. }
  125104. declare module BABYLON {
  125105. /**
  125106. * Block used to lerp between 2 values
  125107. */
  125108. export class LerpBlock extends NodeMaterialBlock {
  125109. /**
  125110. * Creates a new LerpBlock
  125111. * @param name defines the block name
  125112. */
  125113. constructor(name: string);
  125114. /**
  125115. * Gets the current class name
  125116. * @returns the class name
  125117. */
  125118. getClassName(): string;
  125119. /**
  125120. * Gets the left operand input component
  125121. */
  125122. readonly left: NodeMaterialConnectionPoint;
  125123. /**
  125124. * Gets the right operand input component
  125125. */
  125126. readonly right: NodeMaterialConnectionPoint;
  125127. /**
  125128. * Gets the gradient operand input component
  125129. */
  125130. readonly gradient: NodeMaterialConnectionPoint;
  125131. /**
  125132. * Gets the output component
  125133. */
  125134. readonly output: NodeMaterialConnectionPoint;
  125135. protected _buildBlock(state: NodeMaterialBuildState): this;
  125136. }
  125137. }
  125138. declare module BABYLON {
  125139. /**
  125140. * Block used to divide 2 vectors
  125141. */
  125142. export class DivideBlock extends NodeMaterialBlock {
  125143. /**
  125144. * Creates a new DivideBlock
  125145. * @param name defines the block name
  125146. */
  125147. constructor(name: string);
  125148. /**
  125149. * Gets the current class name
  125150. * @returns the class name
  125151. */
  125152. getClassName(): string;
  125153. /**
  125154. * Gets the left operand input component
  125155. */
  125156. readonly left: NodeMaterialConnectionPoint;
  125157. /**
  125158. * Gets the right operand input component
  125159. */
  125160. readonly right: NodeMaterialConnectionPoint;
  125161. /**
  125162. * Gets the output component
  125163. */
  125164. readonly output: NodeMaterialConnectionPoint;
  125165. protected _buildBlock(state: NodeMaterialBuildState): this;
  125166. }
  125167. }
  125168. declare module BABYLON {
  125169. /**
  125170. * Block used to subtract 2 vectors
  125171. */
  125172. export class SubtractBlock extends NodeMaterialBlock {
  125173. /**
  125174. * Creates a new SubtractBlock
  125175. * @param name defines the block name
  125176. */
  125177. constructor(name: string);
  125178. /**
  125179. * Gets the current class name
  125180. * @returns the class name
  125181. */
  125182. getClassName(): string;
  125183. /**
  125184. * Gets the left operand input component
  125185. */
  125186. readonly left: NodeMaterialConnectionPoint;
  125187. /**
  125188. * Gets the right operand input component
  125189. */
  125190. readonly right: NodeMaterialConnectionPoint;
  125191. /**
  125192. * Gets the output component
  125193. */
  125194. readonly output: NodeMaterialConnectionPoint;
  125195. protected _buildBlock(state: NodeMaterialBuildState): this;
  125196. }
  125197. }
  125198. declare module BABYLON {
  125199. /**
  125200. * Block used to step a value
  125201. */
  125202. export class StepBlock extends NodeMaterialBlock {
  125203. /**
  125204. * Creates a new StepBlock
  125205. * @param name defines the block name
  125206. */
  125207. constructor(name: string);
  125208. /**
  125209. * Gets the current class name
  125210. * @returns the class name
  125211. */
  125212. getClassName(): string;
  125213. /**
  125214. * Gets the value operand input component
  125215. */
  125216. readonly value: NodeMaterialConnectionPoint;
  125217. /**
  125218. * Gets the edge operand input component
  125219. */
  125220. readonly edge: NodeMaterialConnectionPoint;
  125221. /**
  125222. * Gets the output component
  125223. */
  125224. readonly output: NodeMaterialConnectionPoint;
  125225. protected _buildBlock(state: NodeMaterialBuildState): this;
  125226. }
  125227. }
  125228. declare module BABYLON {
  125229. /**
  125230. * Block used to get the opposite (1 - x) of a value
  125231. */
  125232. export class OneMinusBlock extends NodeMaterialBlock {
  125233. /**
  125234. * Creates a new OneMinusBlock
  125235. * @param name defines the block name
  125236. */
  125237. constructor(name: string);
  125238. /**
  125239. * Gets the current class name
  125240. * @returns the class name
  125241. */
  125242. getClassName(): string;
  125243. /**
  125244. * Gets the input component
  125245. */
  125246. readonly input: NodeMaterialConnectionPoint;
  125247. /**
  125248. * Gets the output component
  125249. */
  125250. readonly output: NodeMaterialConnectionPoint;
  125251. protected _buildBlock(state: NodeMaterialBuildState): this;
  125252. }
  125253. }
  125254. declare module BABYLON {
  125255. /**
  125256. * Block used to get the view direction
  125257. */
  125258. export class ViewDirectionBlock extends NodeMaterialBlock {
  125259. /**
  125260. * Creates a new ViewDirectionBlock
  125261. * @param name defines the block name
  125262. */
  125263. constructor(name: string);
  125264. /**
  125265. * Gets the current class name
  125266. * @returns the class name
  125267. */
  125268. getClassName(): string;
  125269. /**
  125270. * Gets the world position component
  125271. */
  125272. readonly worldPosition: NodeMaterialConnectionPoint;
  125273. /**
  125274. * Gets the camera position component
  125275. */
  125276. readonly cameraPosition: NodeMaterialConnectionPoint;
  125277. /**
  125278. * Gets the output component
  125279. */
  125280. readonly output: NodeMaterialConnectionPoint;
  125281. autoConfigure(material: NodeMaterial): void;
  125282. protected _buildBlock(state: NodeMaterialBuildState): this;
  125283. }
  125284. }
  125285. declare module BABYLON {
  125286. /**
  125287. * Block used to compute fresnel value
  125288. */
  125289. export class FresnelBlock extends NodeMaterialBlock {
  125290. /**
  125291. * Create a new FresnelBlock
  125292. * @param name defines the block name
  125293. */
  125294. constructor(name: string);
  125295. /**
  125296. * Gets the current class name
  125297. * @returns the class name
  125298. */
  125299. getClassName(): string;
  125300. /**
  125301. * Gets the world normal input component
  125302. */
  125303. readonly worldNormal: NodeMaterialConnectionPoint;
  125304. /**
  125305. * Gets the view direction input component
  125306. */
  125307. readonly viewDirection: NodeMaterialConnectionPoint;
  125308. /**
  125309. * Gets the bias input component
  125310. */
  125311. readonly bias: NodeMaterialConnectionPoint;
  125312. /**
  125313. * Gets the camera (or eye) position component
  125314. */
  125315. readonly power: NodeMaterialConnectionPoint;
  125316. /**
  125317. * Gets the fresnel output component
  125318. */
  125319. readonly fresnel: NodeMaterialConnectionPoint;
  125320. autoConfigure(material: NodeMaterial): void;
  125321. protected _buildBlock(state: NodeMaterialBuildState): this;
  125322. }
  125323. }
  125324. declare module BABYLON {
  125325. /**
  125326. * Block used to get the max of 2 values
  125327. */
  125328. export class MaxBlock extends NodeMaterialBlock {
  125329. /**
  125330. * Creates a new MaxBlock
  125331. * @param name defines the block name
  125332. */
  125333. constructor(name: string);
  125334. /**
  125335. * Gets the current class name
  125336. * @returns the class name
  125337. */
  125338. getClassName(): string;
  125339. /**
  125340. * Gets the left operand input component
  125341. */
  125342. readonly left: NodeMaterialConnectionPoint;
  125343. /**
  125344. * Gets the right operand input component
  125345. */
  125346. readonly right: NodeMaterialConnectionPoint;
  125347. /**
  125348. * Gets the output component
  125349. */
  125350. readonly output: NodeMaterialConnectionPoint;
  125351. protected _buildBlock(state: NodeMaterialBuildState): this;
  125352. }
  125353. }
  125354. declare module BABYLON {
  125355. /**
  125356. * Block used to get the min of 2 values
  125357. */
  125358. export class MinBlock extends NodeMaterialBlock {
  125359. /**
  125360. * Creates a new MinBlock
  125361. * @param name defines the block name
  125362. */
  125363. constructor(name: string);
  125364. /**
  125365. * Gets the current class name
  125366. * @returns the class name
  125367. */
  125368. getClassName(): string;
  125369. /**
  125370. * Gets the left operand input component
  125371. */
  125372. readonly left: NodeMaterialConnectionPoint;
  125373. /**
  125374. * Gets the right operand input component
  125375. */
  125376. readonly right: NodeMaterialConnectionPoint;
  125377. /**
  125378. * Gets the output component
  125379. */
  125380. readonly output: NodeMaterialConnectionPoint;
  125381. protected _buildBlock(state: NodeMaterialBuildState): this;
  125382. }
  125383. }
  125384. declare module BABYLON {
  125385. /**
  125386. * Block used to get the distance between 2 values
  125387. */
  125388. export class DistanceBlock extends NodeMaterialBlock {
  125389. /**
  125390. * Creates a new DistanceBlock
  125391. * @param name defines the block name
  125392. */
  125393. constructor(name: string);
  125394. /**
  125395. * Gets the current class name
  125396. * @returns the class name
  125397. */
  125398. getClassName(): string;
  125399. /**
  125400. * Gets the left operand input component
  125401. */
  125402. readonly left: NodeMaterialConnectionPoint;
  125403. /**
  125404. * Gets the right operand input component
  125405. */
  125406. readonly right: NodeMaterialConnectionPoint;
  125407. /**
  125408. * Gets the output component
  125409. */
  125410. readonly output: NodeMaterialConnectionPoint;
  125411. protected _buildBlock(state: NodeMaterialBuildState): this;
  125412. }
  125413. }
  125414. declare module BABYLON {
  125415. /**
  125416. * Block used to get the length of a vector
  125417. */
  125418. export class LengthBlock extends NodeMaterialBlock {
  125419. /**
  125420. * Creates a new LengthBlock
  125421. * @param name defines the block name
  125422. */
  125423. constructor(name: string);
  125424. /**
  125425. * Gets the current class name
  125426. * @returns the class name
  125427. */
  125428. getClassName(): string;
  125429. /**
  125430. * Gets the value input component
  125431. */
  125432. readonly value: NodeMaterialConnectionPoint;
  125433. /**
  125434. * Gets the output component
  125435. */
  125436. readonly output: NodeMaterialConnectionPoint;
  125437. protected _buildBlock(state: NodeMaterialBuildState): this;
  125438. }
  125439. }
  125440. declare module BABYLON {
  125441. /**
  125442. * Block used to get negative version of a value (i.e. x * -1)
  125443. */
  125444. export class NegateBlock extends NodeMaterialBlock {
  125445. /**
  125446. * Creates a new NegateBlock
  125447. * @param name defines the block name
  125448. */
  125449. constructor(name: string);
  125450. /**
  125451. * Gets the current class name
  125452. * @returns the class name
  125453. */
  125454. getClassName(): string;
  125455. /**
  125456. * Gets the value input component
  125457. */
  125458. readonly value: NodeMaterialConnectionPoint;
  125459. /**
  125460. * Gets the output component
  125461. */
  125462. readonly output: NodeMaterialConnectionPoint;
  125463. protected _buildBlock(state: NodeMaterialBuildState): this;
  125464. }
  125465. }
  125466. declare module BABYLON {
  125467. /**
  125468. * Block used to get the value of the first parameter raised to the power of the second
  125469. */
  125470. export class PowBlock extends NodeMaterialBlock {
  125471. /**
  125472. * Creates a new PowBlock
  125473. * @param name defines the block name
  125474. */
  125475. constructor(name: string);
  125476. /**
  125477. * Gets the current class name
  125478. * @returns the class name
  125479. */
  125480. getClassName(): string;
  125481. /**
  125482. * Gets the value operand input component
  125483. */
  125484. readonly value: NodeMaterialConnectionPoint;
  125485. /**
  125486. * Gets the power operand input component
  125487. */
  125488. readonly power: NodeMaterialConnectionPoint;
  125489. /**
  125490. * Gets the output component
  125491. */
  125492. readonly output: NodeMaterialConnectionPoint;
  125493. protected _buildBlock(state: NodeMaterialBuildState): this;
  125494. }
  125495. }
  125496. declare module BABYLON {
  125497. /**
  125498. * Block used to get a random number
  125499. */
  125500. export class RandomNumberBlock extends NodeMaterialBlock {
  125501. /**
  125502. * Creates a new RandomNumberBlock
  125503. * @param name defines the block name
  125504. */
  125505. constructor(name: string);
  125506. /**
  125507. * Gets the current class name
  125508. * @returns the class name
  125509. */
  125510. getClassName(): string;
  125511. /**
  125512. * Gets the seed input component
  125513. */
  125514. readonly seed: NodeMaterialConnectionPoint;
  125515. /**
  125516. * Gets the output component
  125517. */
  125518. readonly output: NodeMaterialConnectionPoint;
  125519. protected _buildBlock(state: NodeMaterialBuildState): this;
  125520. }
  125521. }
  125522. declare module BABYLON {
  125523. /**
  125524. * Block used to compute arc tangent of 2 values
  125525. */
  125526. export class ArcTan2Block extends NodeMaterialBlock {
  125527. /**
  125528. * Creates a new ArcTan2Block
  125529. * @param name defines the block name
  125530. */
  125531. constructor(name: string);
  125532. /**
  125533. * Gets the current class name
  125534. * @returns the class name
  125535. */
  125536. getClassName(): string;
  125537. /**
  125538. * Gets the x operand input component
  125539. */
  125540. readonly x: NodeMaterialConnectionPoint;
  125541. /**
  125542. * Gets the y operand input component
  125543. */
  125544. readonly y: NodeMaterialConnectionPoint;
  125545. /**
  125546. * Gets the output component
  125547. */
  125548. readonly output: NodeMaterialConnectionPoint;
  125549. protected _buildBlock(state: NodeMaterialBuildState): this;
  125550. }
  125551. }
  125552. declare module BABYLON {
  125553. /**
  125554. * Block used to smooth step a value
  125555. */
  125556. export class SmoothStepBlock extends NodeMaterialBlock {
  125557. /**
  125558. * Creates a new SmoothStepBlock
  125559. * @param name defines the block name
  125560. */
  125561. constructor(name: string);
  125562. /**
  125563. * Gets the current class name
  125564. * @returns the class name
  125565. */
  125566. getClassName(): string;
  125567. /**
  125568. * Gets the value operand input component
  125569. */
  125570. readonly value: NodeMaterialConnectionPoint;
  125571. /**
  125572. * Gets the first edge operand input component
  125573. */
  125574. readonly edge0: NodeMaterialConnectionPoint;
  125575. /**
  125576. * Gets the second edge operand input component
  125577. */
  125578. readonly edge1: NodeMaterialConnectionPoint;
  125579. /**
  125580. * Gets the output component
  125581. */
  125582. readonly output: NodeMaterialConnectionPoint;
  125583. protected _buildBlock(state: NodeMaterialBuildState): this;
  125584. }
  125585. }
  125586. declare module BABYLON {
  125587. /**
  125588. * Block used to get the reciprocal (1 / x) of a value
  125589. */
  125590. export class ReciprocalBlock extends NodeMaterialBlock {
  125591. /**
  125592. * Creates a new ReciprocalBlock
  125593. * @param name defines the block name
  125594. */
  125595. constructor(name: string);
  125596. /**
  125597. * Gets the current class name
  125598. * @returns the class name
  125599. */
  125600. getClassName(): string;
  125601. /**
  125602. * Gets the input component
  125603. */
  125604. readonly input: NodeMaterialConnectionPoint;
  125605. /**
  125606. * Gets the output component
  125607. */
  125608. readonly output: NodeMaterialConnectionPoint;
  125609. protected _buildBlock(state: NodeMaterialBuildState): this;
  125610. }
  125611. }
  125612. declare module BABYLON {
  125613. /**
  125614. * Block used to replace a color by another one
  125615. */
  125616. export class ReplaceColorBlock extends NodeMaterialBlock {
  125617. /**
  125618. * Creates a new ReplaceColorBlock
  125619. * @param name defines the block name
  125620. */
  125621. constructor(name: string);
  125622. /**
  125623. * Gets the current class name
  125624. * @returns the class name
  125625. */
  125626. getClassName(): string;
  125627. /**
  125628. * Gets the value input component
  125629. */
  125630. readonly value: NodeMaterialConnectionPoint;
  125631. /**
  125632. * Gets the reference input component
  125633. */
  125634. readonly reference: NodeMaterialConnectionPoint;
  125635. /**
  125636. * Gets the distance input component
  125637. */
  125638. readonly distance: NodeMaterialConnectionPoint;
  125639. /**
  125640. * Gets the replacement input component
  125641. */
  125642. readonly replacement: NodeMaterialConnectionPoint;
  125643. /**
  125644. * Gets the output component
  125645. */
  125646. readonly output: NodeMaterialConnectionPoint;
  125647. protected _buildBlock(state: NodeMaterialBuildState): this;
  125648. }
  125649. }
  125650. declare module BABYLON {
  125651. /**
  125652. * Block used to posterize a value
  125653. * @see https://en.wikipedia.org/wiki/Posterization
  125654. */
  125655. export class PosterizeBlock extends NodeMaterialBlock {
  125656. /**
  125657. * Creates a new PosterizeBlock
  125658. * @param name defines the block name
  125659. */
  125660. constructor(name: string);
  125661. /**
  125662. * Gets the current class name
  125663. * @returns the class name
  125664. */
  125665. getClassName(): string;
  125666. /**
  125667. * Gets the value input component
  125668. */
  125669. readonly value: NodeMaterialConnectionPoint;
  125670. /**
  125671. * Gets the steps input component
  125672. */
  125673. readonly steps: NodeMaterialConnectionPoint;
  125674. /**
  125675. * Gets the output component
  125676. */
  125677. readonly output: NodeMaterialConnectionPoint;
  125678. protected _buildBlock(state: NodeMaterialBuildState): this;
  125679. }
  125680. }
  125681. declare module BABYLON {
  125682. /**
  125683. * Operations supported by the Wave block
  125684. */
  125685. export enum WaveBlockKind {
  125686. /** SawTooth */
  125687. SawTooth = 0,
  125688. /** Square */
  125689. Square = 1,
  125690. /** Triangle */
  125691. Triangle = 2
  125692. }
  125693. /**
  125694. * Block used to apply wave operation to floats
  125695. */
  125696. export class WaveBlock extends NodeMaterialBlock {
  125697. /**
  125698. * Gets or sets the kibnd of wave to be applied by the block
  125699. */
  125700. kind: WaveBlockKind;
  125701. /**
  125702. * Creates a new WaveBlock
  125703. * @param name defines the block name
  125704. */
  125705. constructor(name: string);
  125706. /**
  125707. * Gets the current class name
  125708. * @returns the class name
  125709. */
  125710. getClassName(): string;
  125711. /**
  125712. * Gets the input component
  125713. */
  125714. readonly input: NodeMaterialConnectionPoint;
  125715. /**
  125716. * Gets the output component
  125717. */
  125718. readonly output: NodeMaterialConnectionPoint;
  125719. protected _buildBlock(state: NodeMaterialBuildState): this;
  125720. serialize(): any;
  125721. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  125722. }
  125723. }
  125724. declare module BABYLON {
  125725. /**
  125726. * Class used to store a color step for the GradientBlock
  125727. */
  125728. export class GradientBlockColorStep {
  125729. /**
  125730. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  125731. */
  125732. step: number;
  125733. /**
  125734. * Gets or sets the color associated with this step
  125735. */
  125736. color: Color3;
  125737. /**
  125738. * Creates a new GradientBlockColorStep
  125739. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  125740. * @param color defines the color associated with this step
  125741. */
  125742. constructor(
  125743. /**
  125744. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  125745. */
  125746. step: number,
  125747. /**
  125748. * Gets or sets the color associated with this step
  125749. */
  125750. color: Color3);
  125751. }
  125752. /**
  125753. * Block used to return a color from a gradient based on an input value between 0 and 1
  125754. */
  125755. export class GradientBlock extends NodeMaterialBlock {
  125756. /**
  125757. * Gets or sets the list of color steps
  125758. */
  125759. colorSteps: GradientBlockColorStep[];
  125760. /**
  125761. * Creates a new GradientBlock
  125762. * @param name defines the block name
  125763. */
  125764. constructor(name: string);
  125765. /**
  125766. * Gets the current class name
  125767. * @returns the class name
  125768. */
  125769. getClassName(): string;
  125770. /**
  125771. * Gets the gradient input component
  125772. */
  125773. readonly gradient: NodeMaterialConnectionPoint;
  125774. /**
  125775. * Gets the output component
  125776. */
  125777. readonly output: NodeMaterialConnectionPoint;
  125778. private _writeColorConstant;
  125779. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  125780. serialize(): any;
  125781. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  125782. protected _dumpPropertiesCode(): string;
  125783. }
  125784. }
  125785. declare module BABYLON {
  125786. /**
  125787. * Block used to normalize lerp between 2 values
  125788. */
  125789. export class NLerpBlock extends NodeMaterialBlock {
  125790. /**
  125791. * Creates a new NLerpBlock
  125792. * @param name defines the block name
  125793. */
  125794. constructor(name: string);
  125795. /**
  125796. * Gets the current class name
  125797. * @returns the class name
  125798. */
  125799. getClassName(): string;
  125800. /**
  125801. * Gets the left operand input component
  125802. */
  125803. readonly left: NodeMaterialConnectionPoint;
  125804. /**
  125805. * Gets the right operand input component
  125806. */
  125807. readonly right: NodeMaterialConnectionPoint;
  125808. /**
  125809. * Gets the gradient operand input component
  125810. */
  125811. readonly gradient: NodeMaterialConnectionPoint;
  125812. /**
  125813. * Gets the output component
  125814. */
  125815. readonly output: NodeMaterialConnectionPoint;
  125816. protected _buildBlock(state: NodeMaterialBuildState): this;
  125817. }
  125818. }
  125819. declare module BABYLON {
  125820. /**
  125821. * block used to Generate a Worley Noise 3D Noise Pattern
  125822. */
  125823. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  125824. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  125825. manhattanDistance: boolean;
  125826. /**
  125827. * Creates a new WorleyNoise3DBlock
  125828. * @param name defines the block name
  125829. */
  125830. constructor(name: string);
  125831. /**
  125832. * Gets the current class name
  125833. * @returns the class name
  125834. */
  125835. getClassName(): string;
  125836. /**
  125837. * Gets the seed input component
  125838. */
  125839. readonly seed: NodeMaterialConnectionPoint;
  125840. /**
  125841. * Gets the jitter input component
  125842. */
  125843. readonly jitter: NodeMaterialConnectionPoint;
  125844. /**
  125845. * Gets the output component
  125846. */
  125847. readonly output: NodeMaterialConnectionPoint;
  125848. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  125849. /**
  125850. * Exposes the properties to the UI?
  125851. */
  125852. protected _dumpPropertiesCode(): string;
  125853. /**
  125854. * Exposes the properties to the Seralize?
  125855. */
  125856. serialize(): any;
  125857. /**
  125858. * Exposes the properties to the deseralize?
  125859. */
  125860. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  125861. }
  125862. }
  125863. declare module BABYLON {
  125864. /**
  125865. * block used to Generate a Simplex Perlin 3d Noise Pattern
  125866. */
  125867. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  125868. /**
  125869. * Creates a new SimplexPerlin3DBlock
  125870. * @param name defines the block name
  125871. */
  125872. constructor(name: string);
  125873. /**
  125874. * Gets the current class name
  125875. * @returns the class name
  125876. */
  125877. getClassName(): string;
  125878. /**
  125879. * Gets the seed operand input component
  125880. */
  125881. readonly seed: NodeMaterialConnectionPoint;
  125882. /**
  125883. * Gets the output component
  125884. */
  125885. readonly output: NodeMaterialConnectionPoint;
  125886. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  125887. }
  125888. }
  125889. declare module BABYLON {
  125890. /**
  125891. * Block used to blend normals
  125892. */
  125893. export class NormalBlendBlock extends NodeMaterialBlock {
  125894. /**
  125895. * Creates a new NormalBlendBlock
  125896. * @param name defines the block name
  125897. */
  125898. constructor(name: string);
  125899. /**
  125900. * Gets the current class name
  125901. * @returns the class name
  125902. */
  125903. getClassName(): string;
  125904. /**
  125905. * Gets the first input component
  125906. */
  125907. readonly normalMap0: NodeMaterialConnectionPoint;
  125908. /**
  125909. * Gets the second input component
  125910. */
  125911. readonly normalMap1: NodeMaterialConnectionPoint;
  125912. /**
  125913. * Gets the output component
  125914. */
  125915. readonly output: NodeMaterialConnectionPoint;
  125916. protected _buildBlock(state: NodeMaterialBuildState): this;
  125917. }
  125918. }
  125919. declare module BABYLON {
  125920. /**
  125921. * Block used to rotate a 2d vector by a given angle
  125922. */
  125923. export class Rotate2dBlock extends NodeMaterialBlock {
  125924. /**
  125925. * Creates a new Rotate2dBlock
  125926. * @param name defines the block name
  125927. */
  125928. constructor(name: string);
  125929. /**
  125930. * Gets the current class name
  125931. * @returns the class name
  125932. */
  125933. getClassName(): string;
  125934. /**
  125935. * Gets the input vector
  125936. */
  125937. readonly input: NodeMaterialConnectionPoint;
  125938. /**
  125939. * Gets the input angle
  125940. */
  125941. readonly angle: NodeMaterialConnectionPoint;
  125942. /**
  125943. * Gets the output component
  125944. */
  125945. readonly output: NodeMaterialConnectionPoint;
  125946. autoConfigure(material: NodeMaterial): void;
  125947. protected _buildBlock(state: NodeMaterialBuildState): this;
  125948. }
  125949. }
  125950. declare module BABYLON {
  125951. /**
  125952. * Block used to get the reflected vector from a direction and a normal
  125953. */
  125954. export class ReflectBlock extends NodeMaterialBlock {
  125955. /**
  125956. * Creates a new ReflectBlock
  125957. * @param name defines the block name
  125958. */
  125959. constructor(name: string);
  125960. /**
  125961. * Gets the current class name
  125962. * @returns the class name
  125963. */
  125964. getClassName(): string;
  125965. /**
  125966. * Gets the incident component
  125967. */
  125968. readonly incident: NodeMaterialConnectionPoint;
  125969. /**
  125970. * Gets the normal component
  125971. */
  125972. readonly normal: NodeMaterialConnectionPoint;
  125973. /**
  125974. * Gets the output component
  125975. */
  125976. readonly output: NodeMaterialConnectionPoint;
  125977. protected _buildBlock(state: NodeMaterialBuildState): this;
  125978. }
  125979. }
  125980. declare module BABYLON {
  125981. /**
  125982. * Block used to get the refracted vector from a direction and a normal
  125983. */
  125984. export class RefractBlock extends NodeMaterialBlock {
  125985. /**
  125986. * Creates a new RefractBlock
  125987. * @param name defines the block name
  125988. */
  125989. constructor(name: string);
  125990. /**
  125991. * Gets the current class name
  125992. * @returns the class name
  125993. */
  125994. getClassName(): string;
  125995. /**
  125996. * Gets the incident component
  125997. */
  125998. readonly incident: NodeMaterialConnectionPoint;
  125999. /**
  126000. * Gets the normal component
  126001. */
  126002. readonly normal: NodeMaterialConnectionPoint;
  126003. /**
  126004. * Gets the index of refraction component
  126005. */
  126006. readonly ior: NodeMaterialConnectionPoint;
  126007. /**
  126008. * Gets the output component
  126009. */
  126010. readonly output: NodeMaterialConnectionPoint;
  126011. protected _buildBlock(state: NodeMaterialBuildState): this;
  126012. }
  126013. }
  126014. declare module BABYLON {
  126015. /**
  126016. * Block used to desaturate a color
  126017. */
  126018. export class DesaturateBlock extends NodeMaterialBlock {
  126019. /**
  126020. * Creates a new DesaturateBlock
  126021. * @param name defines the block name
  126022. */
  126023. constructor(name: string);
  126024. /**
  126025. * Gets the current class name
  126026. * @returns the class name
  126027. */
  126028. getClassName(): string;
  126029. /**
  126030. * Gets the color operand input component
  126031. */
  126032. readonly color: NodeMaterialConnectionPoint;
  126033. /**
  126034. * Gets the level operand input component
  126035. */
  126036. readonly level: NodeMaterialConnectionPoint;
  126037. /**
  126038. * Gets the output component
  126039. */
  126040. readonly output: NodeMaterialConnectionPoint;
  126041. protected _buildBlock(state: NodeMaterialBuildState): this;
  126042. }
  126043. }
  126044. declare module BABYLON {
  126045. /**
  126046. * Effect Render Options
  126047. */
  126048. export interface IEffectRendererOptions {
  126049. /**
  126050. * Defines the vertices positions.
  126051. */
  126052. positions?: number[];
  126053. /**
  126054. * Defines the indices.
  126055. */
  126056. indices?: number[];
  126057. }
  126058. /**
  126059. * Helper class to render one or more effects
  126060. */
  126061. export class EffectRenderer {
  126062. private engine;
  126063. private static _DefaultOptions;
  126064. private _vertexBuffers;
  126065. private _indexBuffer;
  126066. private _ringBufferIndex;
  126067. private _ringScreenBuffer;
  126068. private _fullscreenViewport;
  126069. private _getNextFrameBuffer;
  126070. /**
  126071. * Creates an effect renderer
  126072. * @param engine the engine to use for rendering
  126073. * @param options defines the options of the effect renderer
  126074. */
  126075. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  126076. /**
  126077. * Sets the current viewport in normalized coordinates 0-1
  126078. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  126079. */
  126080. setViewport(viewport?: Viewport): void;
  126081. /**
  126082. * Binds the embedded attributes buffer to the effect.
  126083. * @param effect Defines the effect to bind the attributes for
  126084. */
  126085. bindBuffers(effect: Effect): void;
  126086. /**
  126087. * Sets the current effect wrapper to use during draw.
  126088. * The effect needs to be ready before calling this api.
  126089. * This also sets the default full screen position attribute.
  126090. * @param effectWrapper Defines the effect to draw with
  126091. */
  126092. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  126093. /**
  126094. * Draws a full screen quad.
  126095. */
  126096. draw(): void;
  126097. /**
  126098. * renders one or more effects to a specified texture
  126099. * @param effectWrappers list of effects to renderer
  126100. * @param outputTexture texture to draw to, if null it will render to the screen
  126101. */
  126102. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  126103. /**
  126104. * Disposes of the effect renderer
  126105. */
  126106. dispose(): void;
  126107. }
  126108. /**
  126109. * Options to create an EffectWrapper
  126110. */
  126111. interface EffectWrapperCreationOptions {
  126112. /**
  126113. * Engine to use to create the effect
  126114. */
  126115. engine: ThinEngine;
  126116. /**
  126117. * Fragment shader for the effect
  126118. */
  126119. fragmentShader: string;
  126120. /**
  126121. * Vertex shader for the effect
  126122. */
  126123. vertexShader?: string;
  126124. /**
  126125. * Attributes to use in the shader
  126126. */
  126127. attributeNames?: Array<string>;
  126128. /**
  126129. * Uniforms to use in the shader
  126130. */
  126131. uniformNames?: Array<string>;
  126132. /**
  126133. * Texture sampler names to use in the shader
  126134. */
  126135. samplerNames?: Array<string>;
  126136. /**
  126137. * The friendly name of the effect displayed in Spector.
  126138. */
  126139. name?: string;
  126140. }
  126141. /**
  126142. * Wraps an effect to be used for rendering
  126143. */
  126144. export class EffectWrapper {
  126145. /**
  126146. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  126147. */
  126148. onApplyObservable: Observable<{}>;
  126149. /**
  126150. * The underlying effect
  126151. */
  126152. effect: Effect;
  126153. /**
  126154. * Creates an effect to be renderer
  126155. * @param creationOptions options to create the effect
  126156. */
  126157. constructor(creationOptions: EffectWrapperCreationOptions);
  126158. /**
  126159. * Disposes of the effect wrapper
  126160. */
  126161. dispose(): void;
  126162. }
  126163. }
  126164. declare module BABYLON {
  126165. /**
  126166. * Helper class to push actions to a pool of workers.
  126167. */
  126168. export class WorkerPool implements IDisposable {
  126169. private _workerInfos;
  126170. private _pendingActions;
  126171. /**
  126172. * Constructor
  126173. * @param workers Array of workers to use for actions
  126174. */
  126175. constructor(workers: Array<Worker>);
  126176. /**
  126177. * Terminates all workers and clears any pending actions.
  126178. */
  126179. dispose(): void;
  126180. /**
  126181. * Pushes an action to the worker pool. If all the workers are active, the action will be
  126182. * pended until a worker has completed its action.
  126183. * @param action The action to perform. Call onComplete when the action is complete.
  126184. */
  126185. push(action: (worker: Worker, onComplete: () => void) => void): void;
  126186. private _execute;
  126187. }
  126188. }
  126189. declare module BABYLON {
  126190. /**
  126191. * Configuration for Draco compression
  126192. */
  126193. export interface IDracoCompressionConfiguration {
  126194. /**
  126195. * Configuration for the decoder.
  126196. */
  126197. decoder: {
  126198. /**
  126199. * The url to the WebAssembly module.
  126200. */
  126201. wasmUrl?: string;
  126202. /**
  126203. * The url to the WebAssembly binary.
  126204. */
  126205. wasmBinaryUrl?: string;
  126206. /**
  126207. * The url to the fallback JavaScript module.
  126208. */
  126209. fallbackUrl?: string;
  126210. };
  126211. }
  126212. /**
  126213. * Draco compression (https://google.github.io/draco/)
  126214. *
  126215. * This class wraps the Draco module.
  126216. *
  126217. * **Encoder**
  126218. *
  126219. * The encoder is not currently implemented.
  126220. *
  126221. * **Decoder**
  126222. *
  126223. * 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.
  126224. *
  126225. * To update the configuration, use the following code:
  126226. * ```javascript
  126227. * DracoCompression.Configuration = {
  126228. * decoder: {
  126229. * wasmUrl: "<url to the WebAssembly library>",
  126230. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  126231. * fallbackUrl: "<url to the fallback JavaScript library>",
  126232. * }
  126233. * };
  126234. * ```
  126235. *
  126236. * 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.
  126237. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  126238. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  126239. *
  126240. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  126241. * ```javascript
  126242. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  126243. * ```
  126244. *
  126245. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  126246. */
  126247. export class DracoCompression implements IDisposable {
  126248. private _workerPoolPromise?;
  126249. private _decoderModulePromise?;
  126250. /**
  126251. * The configuration. Defaults to the following urls:
  126252. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  126253. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  126254. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  126255. */
  126256. static Configuration: IDracoCompressionConfiguration;
  126257. /**
  126258. * Returns true if the decoder configuration is available.
  126259. */
  126260. static readonly DecoderAvailable: boolean;
  126261. /**
  126262. * Default number of workers to create when creating the draco compression object.
  126263. */
  126264. static DefaultNumWorkers: number;
  126265. private static GetDefaultNumWorkers;
  126266. private static _Default;
  126267. /**
  126268. * Default instance for the draco compression object.
  126269. */
  126270. static readonly Default: DracoCompression;
  126271. /**
  126272. * Constructor
  126273. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  126274. */
  126275. constructor(numWorkers?: number);
  126276. /**
  126277. * Stop all async operations and release resources.
  126278. */
  126279. dispose(): void;
  126280. /**
  126281. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  126282. * @returns a promise that resolves when ready
  126283. */
  126284. whenReadyAsync(): Promise<void>;
  126285. /**
  126286. * Decode Draco compressed mesh data to vertex data.
  126287. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  126288. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  126289. * @returns A promise that resolves with the decoded vertex data
  126290. */
  126291. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  126292. [kind: string]: number;
  126293. }): Promise<VertexData>;
  126294. }
  126295. }
  126296. declare module BABYLON {
  126297. /**
  126298. * Class for building Constructive Solid Geometry
  126299. */
  126300. export class CSG {
  126301. private polygons;
  126302. /**
  126303. * The world matrix
  126304. */
  126305. matrix: Matrix;
  126306. /**
  126307. * Stores the position
  126308. */
  126309. position: Vector3;
  126310. /**
  126311. * Stores the rotation
  126312. */
  126313. rotation: Vector3;
  126314. /**
  126315. * Stores the rotation quaternion
  126316. */
  126317. rotationQuaternion: Nullable<Quaternion>;
  126318. /**
  126319. * Stores the scaling vector
  126320. */
  126321. scaling: Vector3;
  126322. /**
  126323. * Convert the Mesh to CSG
  126324. * @param mesh The Mesh to convert to CSG
  126325. * @returns A new CSG from the Mesh
  126326. */
  126327. static FromMesh(mesh: Mesh): CSG;
  126328. /**
  126329. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  126330. * @param polygons Polygons used to construct a CSG solid
  126331. */
  126332. private static FromPolygons;
  126333. /**
  126334. * Clones, or makes a deep copy, of the CSG
  126335. * @returns A new CSG
  126336. */
  126337. clone(): CSG;
  126338. /**
  126339. * Unions this CSG with another CSG
  126340. * @param csg The CSG to union against this CSG
  126341. * @returns The unioned CSG
  126342. */
  126343. union(csg: CSG): CSG;
  126344. /**
  126345. * Unions this CSG with another CSG in place
  126346. * @param csg The CSG to union against this CSG
  126347. */
  126348. unionInPlace(csg: CSG): void;
  126349. /**
  126350. * Subtracts this CSG with another CSG
  126351. * @param csg The CSG to subtract against this CSG
  126352. * @returns A new CSG
  126353. */
  126354. subtract(csg: CSG): CSG;
  126355. /**
  126356. * Subtracts this CSG with another CSG in place
  126357. * @param csg The CSG to subtact against this CSG
  126358. */
  126359. subtractInPlace(csg: CSG): void;
  126360. /**
  126361. * Intersect this CSG with another CSG
  126362. * @param csg The CSG to intersect against this CSG
  126363. * @returns A new CSG
  126364. */
  126365. intersect(csg: CSG): CSG;
  126366. /**
  126367. * Intersects this CSG with another CSG in place
  126368. * @param csg The CSG to intersect against this CSG
  126369. */
  126370. intersectInPlace(csg: CSG): void;
  126371. /**
  126372. * Return a new CSG solid with solid and empty space switched. This solid is
  126373. * not modified.
  126374. * @returns A new CSG solid with solid and empty space switched
  126375. */
  126376. inverse(): CSG;
  126377. /**
  126378. * Inverses the CSG in place
  126379. */
  126380. inverseInPlace(): void;
  126381. /**
  126382. * This is used to keep meshes transformations so they can be restored
  126383. * when we build back a Babylon Mesh
  126384. * NB : All CSG operations are performed in world coordinates
  126385. * @param csg The CSG to copy the transform attributes from
  126386. * @returns This CSG
  126387. */
  126388. copyTransformAttributes(csg: CSG): CSG;
  126389. /**
  126390. * Build Raw mesh from CSG
  126391. * Coordinates here are in world space
  126392. * @param name The name of the mesh geometry
  126393. * @param scene The Scene
  126394. * @param keepSubMeshes Specifies if the submeshes should be kept
  126395. * @returns A new Mesh
  126396. */
  126397. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  126398. /**
  126399. * Build Mesh from CSG taking material and transforms into account
  126400. * @param name The name of the Mesh
  126401. * @param material The material of the Mesh
  126402. * @param scene The Scene
  126403. * @param keepSubMeshes Specifies if submeshes should be kept
  126404. * @returns The new Mesh
  126405. */
  126406. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  126407. }
  126408. }
  126409. declare module BABYLON {
  126410. /**
  126411. * Class used to create a trail following a mesh
  126412. */
  126413. export class TrailMesh extends Mesh {
  126414. private _generator;
  126415. private _autoStart;
  126416. private _running;
  126417. private _diameter;
  126418. private _length;
  126419. private _sectionPolygonPointsCount;
  126420. private _sectionVectors;
  126421. private _sectionNormalVectors;
  126422. private _beforeRenderObserver;
  126423. /**
  126424. * @constructor
  126425. * @param name The value used by scene.getMeshByName() to do a lookup.
  126426. * @param generator The mesh to generate a trail.
  126427. * @param scene The scene to add this mesh to.
  126428. * @param diameter Diameter of trailing mesh. Default is 1.
  126429. * @param length Length of trailing mesh. Default is 60.
  126430. * @param autoStart Automatically start trailing mesh. Default true.
  126431. */
  126432. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  126433. /**
  126434. * "TrailMesh"
  126435. * @returns "TrailMesh"
  126436. */
  126437. getClassName(): string;
  126438. private _createMesh;
  126439. /**
  126440. * Start trailing mesh.
  126441. */
  126442. start(): void;
  126443. /**
  126444. * Stop trailing mesh.
  126445. */
  126446. stop(): void;
  126447. /**
  126448. * Update trailing mesh geometry.
  126449. */
  126450. update(): void;
  126451. /**
  126452. * Returns a new TrailMesh object.
  126453. * @param name is a string, the name given to the new mesh
  126454. * @param newGenerator use new generator object for cloned trail mesh
  126455. * @returns a new mesh
  126456. */
  126457. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  126458. /**
  126459. * Serializes this trail mesh
  126460. * @param serializationObject object to write serialization to
  126461. */
  126462. serialize(serializationObject: any): void;
  126463. /**
  126464. * Parses a serialized trail mesh
  126465. * @param parsedMesh the serialized mesh
  126466. * @param scene the scene to create the trail mesh in
  126467. * @returns the created trail mesh
  126468. */
  126469. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  126470. }
  126471. }
  126472. declare module BABYLON {
  126473. /**
  126474. * Class containing static functions to help procedurally build meshes
  126475. */
  126476. export class TiledBoxBuilder {
  126477. /**
  126478. * Creates a box mesh
  126479. * 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)
  126480. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  126481. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126482. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126483. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126484. * @param name defines the name of the mesh
  126485. * @param options defines the options used to create the mesh
  126486. * @param scene defines the hosting scene
  126487. * @returns the box mesh
  126488. */
  126489. static CreateTiledBox(name: string, options: {
  126490. pattern?: number;
  126491. width?: number;
  126492. height?: number;
  126493. depth?: number;
  126494. tileSize?: number;
  126495. tileWidth?: number;
  126496. tileHeight?: number;
  126497. alignHorizontal?: number;
  126498. alignVertical?: number;
  126499. faceUV?: Vector4[];
  126500. faceColors?: Color4[];
  126501. sideOrientation?: number;
  126502. updatable?: boolean;
  126503. }, scene?: Nullable<Scene>): Mesh;
  126504. }
  126505. }
  126506. declare module BABYLON {
  126507. /**
  126508. * Class containing static functions to help procedurally build meshes
  126509. */
  126510. export class TorusKnotBuilder {
  126511. /**
  126512. * Creates a torus knot mesh
  126513. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  126514. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  126515. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  126516. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  126517. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126518. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126519. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126520. * @param name defines the name of the mesh
  126521. * @param options defines the options used to create the mesh
  126522. * @param scene defines the hosting scene
  126523. * @returns the torus knot mesh
  126524. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  126525. */
  126526. static CreateTorusKnot(name: string, options: {
  126527. radius?: number;
  126528. tube?: number;
  126529. radialSegments?: number;
  126530. tubularSegments?: number;
  126531. p?: number;
  126532. q?: number;
  126533. updatable?: boolean;
  126534. sideOrientation?: number;
  126535. frontUVs?: Vector4;
  126536. backUVs?: Vector4;
  126537. }, scene: any): Mesh;
  126538. }
  126539. }
  126540. declare module BABYLON {
  126541. /**
  126542. * Polygon
  126543. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  126544. */
  126545. export class Polygon {
  126546. /**
  126547. * Creates a rectangle
  126548. * @param xmin bottom X coord
  126549. * @param ymin bottom Y coord
  126550. * @param xmax top X coord
  126551. * @param ymax top Y coord
  126552. * @returns points that make the resulting rectation
  126553. */
  126554. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  126555. /**
  126556. * Creates a circle
  126557. * @param radius radius of circle
  126558. * @param cx scale in x
  126559. * @param cy scale in y
  126560. * @param numberOfSides number of sides that make up the circle
  126561. * @returns points that make the resulting circle
  126562. */
  126563. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  126564. /**
  126565. * Creates a polygon from input string
  126566. * @param input Input polygon data
  126567. * @returns the parsed points
  126568. */
  126569. static Parse(input: string): Vector2[];
  126570. /**
  126571. * Starts building a polygon from x and y coordinates
  126572. * @param x x coordinate
  126573. * @param y y coordinate
  126574. * @returns the started path2
  126575. */
  126576. static StartingAt(x: number, y: number): Path2;
  126577. }
  126578. /**
  126579. * Builds a polygon
  126580. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  126581. */
  126582. export class PolygonMeshBuilder {
  126583. private _points;
  126584. private _outlinepoints;
  126585. private _holes;
  126586. private _name;
  126587. private _scene;
  126588. private _epoints;
  126589. private _eholes;
  126590. private _addToepoint;
  126591. /**
  126592. * Babylon reference to the earcut plugin.
  126593. */
  126594. bjsEarcut: any;
  126595. /**
  126596. * Creates a PolygonMeshBuilder
  126597. * @param name name of the builder
  126598. * @param contours Path of the polygon
  126599. * @param scene scene to add to when creating the mesh
  126600. * @param earcutInjection can be used to inject your own earcut reference
  126601. */
  126602. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  126603. /**
  126604. * Adds a whole within the polygon
  126605. * @param hole Array of points defining the hole
  126606. * @returns this
  126607. */
  126608. addHole(hole: Vector2[]): PolygonMeshBuilder;
  126609. /**
  126610. * Creates the polygon
  126611. * @param updatable If the mesh should be updatable
  126612. * @param depth The depth of the mesh created
  126613. * @returns the created mesh
  126614. */
  126615. build(updatable?: boolean, depth?: number): Mesh;
  126616. /**
  126617. * Creates the polygon
  126618. * @param depth The depth of the mesh created
  126619. * @returns the created VertexData
  126620. */
  126621. buildVertexData(depth?: number): VertexData;
  126622. /**
  126623. * Adds a side to the polygon
  126624. * @param positions points that make the polygon
  126625. * @param normals normals of the polygon
  126626. * @param uvs uvs of the polygon
  126627. * @param indices indices of the polygon
  126628. * @param bounds bounds of the polygon
  126629. * @param points points of the polygon
  126630. * @param depth depth of the polygon
  126631. * @param flip flip of the polygon
  126632. */
  126633. private addSide;
  126634. }
  126635. }
  126636. declare module BABYLON {
  126637. /**
  126638. * Class containing static functions to help procedurally build meshes
  126639. */
  126640. export class PolygonBuilder {
  126641. /**
  126642. * Creates a polygon mesh
  126643. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  126644. * * 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
  126645. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  126646. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126647. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  126648. * * Remember you can only change the shape positions, not their number when updating a polygon
  126649. * @param name defines the name of the mesh
  126650. * @param options defines the options used to create the mesh
  126651. * @param scene defines the hosting scene
  126652. * @param earcutInjection can be used to inject your own earcut reference
  126653. * @returns the polygon mesh
  126654. */
  126655. static CreatePolygon(name: string, options: {
  126656. shape: Vector3[];
  126657. holes?: Vector3[][];
  126658. depth?: number;
  126659. faceUV?: Vector4[];
  126660. faceColors?: Color4[];
  126661. updatable?: boolean;
  126662. sideOrientation?: number;
  126663. frontUVs?: Vector4;
  126664. backUVs?: Vector4;
  126665. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  126666. /**
  126667. * Creates an extruded polygon mesh, with depth in the Y direction.
  126668. * * 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)
  126669. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  126670. * @param name defines the name of the mesh
  126671. * @param options defines the options used to create the mesh
  126672. * @param scene defines the hosting scene
  126673. * @param earcutInjection can be used to inject your own earcut reference
  126674. * @returns the polygon mesh
  126675. */
  126676. static ExtrudePolygon(name: string, options: {
  126677. shape: Vector3[];
  126678. holes?: Vector3[][];
  126679. depth?: number;
  126680. faceUV?: Vector4[];
  126681. faceColors?: Color4[];
  126682. updatable?: boolean;
  126683. sideOrientation?: number;
  126684. frontUVs?: Vector4;
  126685. backUVs?: Vector4;
  126686. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  126687. }
  126688. }
  126689. declare module BABYLON {
  126690. /**
  126691. * Class containing static functions to help procedurally build meshes
  126692. */
  126693. export class LatheBuilder {
  126694. /**
  126695. * Creates lathe mesh.
  126696. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  126697. * * 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
  126698. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  126699. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  126700. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  126701. * * 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
  126702. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  126703. * * 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
  126704. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126705. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126706. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  126707. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126708. * @param name defines the name of the mesh
  126709. * @param options defines the options used to create the mesh
  126710. * @param scene defines the hosting scene
  126711. * @returns the lathe mesh
  126712. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  126713. */
  126714. static CreateLathe(name: string, options: {
  126715. shape: Vector3[];
  126716. radius?: number;
  126717. tessellation?: number;
  126718. clip?: number;
  126719. arc?: number;
  126720. closed?: boolean;
  126721. updatable?: boolean;
  126722. sideOrientation?: number;
  126723. frontUVs?: Vector4;
  126724. backUVs?: Vector4;
  126725. cap?: number;
  126726. invertUV?: boolean;
  126727. }, scene?: Nullable<Scene>): Mesh;
  126728. }
  126729. }
  126730. declare module BABYLON {
  126731. /**
  126732. * Class containing static functions to help procedurally build meshes
  126733. */
  126734. export class TiledPlaneBuilder {
  126735. /**
  126736. * Creates a tiled plane mesh
  126737. * * The parameter `pattern` will, depending on value, do nothing or
  126738. * * * flip (reflect about central vertical) alternate tiles across and up
  126739. * * * flip every tile on alternate rows
  126740. * * * rotate (180 degs) alternate tiles across and up
  126741. * * * rotate every tile on alternate rows
  126742. * * * flip and rotate alternate tiles across and up
  126743. * * * flip and rotate every tile on alternate rows
  126744. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  126745. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  126746. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126747. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  126748. * * 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)
  126749. * * 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)
  126750. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  126751. * @param name defines the name of the mesh
  126752. * @param options defines the options used to create the mesh
  126753. * @param scene defines the hosting scene
  126754. * @returns the box mesh
  126755. */
  126756. static CreateTiledPlane(name: string, options: {
  126757. pattern?: number;
  126758. tileSize?: number;
  126759. tileWidth?: number;
  126760. tileHeight?: number;
  126761. size?: number;
  126762. width?: number;
  126763. height?: number;
  126764. alignHorizontal?: number;
  126765. alignVertical?: number;
  126766. sideOrientation?: number;
  126767. frontUVs?: Vector4;
  126768. backUVs?: Vector4;
  126769. updatable?: boolean;
  126770. }, scene?: Nullable<Scene>): Mesh;
  126771. }
  126772. }
  126773. declare module BABYLON {
  126774. /**
  126775. * Class containing static functions to help procedurally build meshes
  126776. */
  126777. export class TubeBuilder {
  126778. /**
  126779. * Creates a tube mesh.
  126780. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  126781. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  126782. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  126783. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  126784. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  126785. * * 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)
  126786. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  126787. * * 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
  126788. * * 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
  126789. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126790. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126791. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  126792. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126793. * @param name defines the name of the mesh
  126794. * @param options defines the options used to create the mesh
  126795. * @param scene defines the hosting scene
  126796. * @returns the tube mesh
  126797. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  126798. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  126799. */
  126800. static CreateTube(name: string, options: {
  126801. path: Vector3[];
  126802. radius?: number;
  126803. tessellation?: number;
  126804. radiusFunction?: {
  126805. (i: number, distance: number): number;
  126806. };
  126807. cap?: number;
  126808. arc?: number;
  126809. updatable?: boolean;
  126810. sideOrientation?: number;
  126811. frontUVs?: Vector4;
  126812. backUVs?: Vector4;
  126813. instance?: Mesh;
  126814. invertUV?: boolean;
  126815. }, scene?: Nullable<Scene>): Mesh;
  126816. }
  126817. }
  126818. declare module BABYLON {
  126819. /**
  126820. * Class containing static functions to help procedurally build meshes
  126821. */
  126822. export class IcoSphereBuilder {
  126823. /**
  126824. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  126825. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  126826. * * 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`)
  126827. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  126828. * * 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
  126829. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126830. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126831. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126832. * @param name defines the name of the mesh
  126833. * @param options defines the options used to create the mesh
  126834. * @param scene defines the hosting scene
  126835. * @returns the icosahedron mesh
  126836. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  126837. */
  126838. static CreateIcoSphere(name: string, options: {
  126839. radius?: number;
  126840. radiusX?: number;
  126841. radiusY?: number;
  126842. radiusZ?: number;
  126843. flat?: boolean;
  126844. subdivisions?: number;
  126845. sideOrientation?: number;
  126846. frontUVs?: Vector4;
  126847. backUVs?: Vector4;
  126848. updatable?: boolean;
  126849. }, scene?: Nullable<Scene>): Mesh;
  126850. }
  126851. }
  126852. declare module BABYLON {
  126853. /**
  126854. * Class containing static functions to help procedurally build meshes
  126855. */
  126856. export class DecalBuilder {
  126857. /**
  126858. * Creates a decal mesh.
  126859. * 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
  126860. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  126861. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  126862. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  126863. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  126864. * @param name defines the name of the mesh
  126865. * @param sourceMesh defines the mesh where the decal must be applied
  126866. * @param options defines the options used to create the mesh
  126867. * @param scene defines the hosting scene
  126868. * @returns the decal mesh
  126869. * @see https://doc.babylonjs.com/how_to/decals
  126870. */
  126871. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  126872. position?: Vector3;
  126873. normal?: Vector3;
  126874. size?: Vector3;
  126875. angle?: number;
  126876. }): Mesh;
  126877. }
  126878. }
  126879. declare module BABYLON {
  126880. /**
  126881. * Class containing static functions to help procedurally build meshes
  126882. */
  126883. export class MeshBuilder {
  126884. /**
  126885. * Creates a box mesh
  126886. * * The parameter `size` sets the size (float) of each box side (default 1)
  126887. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  126888. * * 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)
  126889. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  126890. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126891. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126892. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126893. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  126894. * @param name defines the name of the mesh
  126895. * @param options defines the options used to create the mesh
  126896. * @param scene defines the hosting scene
  126897. * @returns the box mesh
  126898. */
  126899. static CreateBox(name: string, options: {
  126900. size?: number;
  126901. width?: number;
  126902. height?: number;
  126903. depth?: number;
  126904. faceUV?: Vector4[];
  126905. faceColors?: Color4[];
  126906. sideOrientation?: number;
  126907. frontUVs?: Vector4;
  126908. backUVs?: Vector4;
  126909. updatable?: boolean;
  126910. }, scene?: Nullable<Scene>): Mesh;
  126911. /**
  126912. * Creates a tiled box mesh
  126913. * * faceTiles sets the pattern, tile size and number of tiles for a face
  126914. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126915. * @param name defines the name of the mesh
  126916. * @param options defines the options used to create the mesh
  126917. * @param scene defines the hosting scene
  126918. * @returns the tiled box mesh
  126919. */
  126920. static CreateTiledBox(name: string, options: {
  126921. pattern?: number;
  126922. size?: number;
  126923. width?: number;
  126924. height?: number;
  126925. depth: number;
  126926. tileSize?: number;
  126927. tileWidth?: number;
  126928. tileHeight?: number;
  126929. faceUV?: Vector4[];
  126930. faceColors?: Color4[];
  126931. alignHorizontal?: number;
  126932. alignVertical?: number;
  126933. sideOrientation?: number;
  126934. updatable?: boolean;
  126935. }, scene?: Nullable<Scene>): Mesh;
  126936. /**
  126937. * Creates a sphere mesh
  126938. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  126939. * * 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`)
  126940. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  126941. * * 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
  126942. * * 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)
  126943. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126944. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126945. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126946. * @param name defines the name of the mesh
  126947. * @param options defines the options used to create the mesh
  126948. * @param scene defines the hosting scene
  126949. * @returns the sphere mesh
  126950. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  126951. */
  126952. static CreateSphere(name: string, options: {
  126953. segments?: number;
  126954. diameter?: number;
  126955. diameterX?: number;
  126956. diameterY?: number;
  126957. diameterZ?: number;
  126958. arc?: number;
  126959. slice?: number;
  126960. sideOrientation?: number;
  126961. frontUVs?: Vector4;
  126962. backUVs?: Vector4;
  126963. updatable?: boolean;
  126964. }, scene?: Nullable<Scene>): Mesh;
  126965. /**
  126966. * Creates a plane polygonal mesh. By default, this is a disc
  126967. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  126968. * * 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
  126969. * * 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
  126970. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126971. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126972. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126973. * @param name defines the name of the mesh
  126974. * @param options defines the options used to create the mesh
  126975. * @param scene defines the hosting scene
  126976. * @returns the plane polygonal mesh
  126977. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  126978. */
  126979. static CreateDisc(name: string, options: {
  126980. radius?: number;
  126981. tessellation?: number;
  126982. arc?: number;
  126983. updatable?: boolean;
  126984. sideOrientation?: number;
  126985. frontUVs?: Vector4;
  126986. backUVs?: Vector4;
  126987. }, scene?: Nullable<Scene>): Mesh;
  126988. /**
  126989. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  126990. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  126991. * * 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`)
  126992. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  126993. * * 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
  126994. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126995. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126996. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126997. * @param name defines the name of the mesh
  126998. * @param options defines the options used to create the mesh
  126999. * @param scene defines the hosting scene
  127000. * @returns the icosahedron mesh
  127001. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  127002. */
  127003. static CreateIcoSphere(name: string, options: {
  127004. radius?: number;
  127005. radiusX?: number;
  127006. radiusY?: number;
  127007. radiusZ?: number;
  127008. flat?: boolean;
  127009. subdivisions?: number;
  127010. sideOrientation?: number;
  127011. frontUVs?: Vector4;
  127012. backUVs?: Vector4;
  127013. updatable?: boolean;
  127014. }, scene?: Nullable<Scene>): Mesh;
  127015. /**
  127016. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  127017. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  127018. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  127019. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  127020. * * 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
  127021. * * 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
  127022. * * 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
  127023. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127024. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127025. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  127026. * * 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
  127027. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  127028. * * 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
  127029. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  127030. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127031. * @param name defines the name of the mesh
  127032. * @param options defines the options used to create the mesh
  127033. * @param scene defines the hosting scene
  127034. * @returns the ribbon mesh
  127035. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  127036. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  127037. */
  127038. static CreateRibbon(name: string, options: {
  127039. pathArray: Vector3[][];
  127040. closeArray?: boolean;
  127041. closePath?: boolean;
  127042. offset?: number;
  127043. updatable?: boolean;
  127044. sideOrientation?: number;
  127045. frontUVs?: Vector4;
  127046. backUVs?: Vector4;
  127047. instance?: Mesh;
  127048. invertUV?: boolean;
  127049. uvs?: Vector2[];
  127050. colors?: Color4[];
  127051. }, scene?: Nullable<Scene>): Mesh;
  127052. /**
  127053. * Creates a cylinder or a cone mesh
  127054. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  127055. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  127056. * * 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.
  127057. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  127058. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  127059. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  127060. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  127061. * * 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).
  127062. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  127063. * * 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).
  127064. * * 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
  127065. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  127066. * * 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
  127067. * * 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.
  127068. * * If `enclose` is false, a ring surface is one element.
  127069. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  127070. * * 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
  127071. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127072. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127073. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127074. * @param name defines the name of the mesh
  127075. * @param options defines the options used to create the mesh
  127076. * @param scene defines the hosting scene
  127077. * @returns the cylinder mesh
  127078. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  127079. */
  127080. static CreateCylinder(name: string, options: {
  127081. height?: number;
  127082. diameterTop?: number;
  127083. diameterBottom?: number;
  127084. diameter?: number;
  127085. tessellation?: number;
  127086. subdivisions?: number;
  127087. arc?: number;
  127088. faceColors?: Color4[];
  127089. faceUV?: Vector4[];
  127090. updatable?: boolean;
  127091. hasRings?: boolean;
  127092. enclose?: boolean;
  127093. cap?: number;
  127094. sideOrientation?: number;
  127095. frontUVs?: Vector4;
  127096. backUVs?: Vector4;
  127097. }, scene?: Nullable<Scene>): Mesh;
  127098. /**
  127099. * Creates a torus mesh
  127100. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  127101. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  127102. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  127103. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127104. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127105. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127106. * @param name defines the name of the mesh
  127107. * @param options defines the options used to create the mesh
  127108. * @param scene defines the hosting scene
  127109. * @returns the torus mesh
  127110. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  127111. */
  127112. static CreateTorus(name: string, options: {
  127113. diameter?: number;
  127114. thickness?: number;
  127115. tessellation?: number;
  127116. updatable?: boolean;
  127117. sideOrientation?: number;
  127118. frontUVs?: Vector4;
  127119. backUVs?: Vector4;
  127120. }, scene?: Nullable<Scene>): Mesh;
  127121. /**
  127122. * Creates a torus knot mesh
  127123. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  127124. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  127125. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  127126. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  127127. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127128. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127129. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127130. * @param name defines the name of the mesh
  127131. * @param options defines the options used to create the mesh
  127132. * @param scene defines the hosting scene
  127133. * @returns the torus knot mesh
  127134. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  127135. */
  127136. static CreateTorusKnot(name: string, options: {
  127137. radius?: number;
  127138. tube?: number;
  127139. radialSegments?: number;
  127140. tubularSegments?: number;
  127141. p?: number;
  127142. q?: number;
  127143. updatable?: boolean;
  127144. sideOrientation?: number;
  127145. frontUVs?: Vector4;
  127146. backUVs?: Vector4;
  127147. }, scene?: Nullable<Scene>): Mesh;
  127148. /**
  127149. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  127150. * * 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
  127151. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  127152. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  127153. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  127154. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  127155. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  127156. * * 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
  127157. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  127158. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127159. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  127160. * @param name defines the name of the new line system
  127161. * @param options defines the options used to create the line system
  127162. * @param scene defines the hosting scene
  127163. * @returns a new line system mesh
  127164. */
  127165. static CreateLineSystem(name: string, options: {
  127166. lines: Vector3[][];
  127167. updatable?: boolean;
  127168. instance?: Nullable<LinesMesh>;
  127169. colors?: Nullable<Color4[][]>;
  127170. useVertexAlpha?: boolean;
  127171. }, scene: Nullable<Scene>): LinesMesh;
  127172. /**
  127173. * Creates a line mesh
  127174. * 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
  127175. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  127176. * * The parameter `points` is an array successive Vector3
  127177. * * 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
  127178. * * The optional parameter `colors` is an array of successive Color4, one per line point
  127179. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  127180. * * When updating an instance, remember that only point positions can change, not the number of points
  127181. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127182. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  127183. * @param name defines the name of the new line system
  127184. * @param options defines the options used to create the line system
  127185. * @param scene defines the hosting scene
  127186. * @returns a new line mesh
  127187. */
  127188. static CreateLines(name: string, options: {
  127189. points: Vector3[];
  127190. updatable?: boolean;
  127191. instance?: Nullable<LinesMesh>;
  127192. colors?: Color4[];
  127193. useVertexAlpha?: boolean;
  127194. }, scene?: Nullable<Scene>): LinesMesh;
  127195. /**
  127196. * Creates a dashed line mesh
  127197. * * 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
  127198. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  127199. * * The parameter `points` is an array successive Vector3
  127200. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  127201. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  127202. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  127203. * * 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
  127204. * * When updating an instance, remember that only point positions can change, not the number of points
  127205. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127206. * @param name defines the name of the mesh
  127207. * @param options defines the options used to create the mesh
  127208. * @param scene defines the hosting scene
  127209. * @returns the dashed line mesh
  127210. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  127211. */
  127212. static CreateDashedLines(name: string, options: {
  127213. points: Vector3[];
  127214. dashSize?: number;
  127215. gapSize?: number;
  127216. dashNb?: number;
  127217. updatable?: boolean;
  127218. instance?: LinesMesh;
  127219. }, scene?: Nullable<Scene>): LinesMesh;
  127220. /**
  127221. * 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.
  127222. * * 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.
  127223. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  127224. * * 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.
  127225. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  127226. * * 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
  127227. * * 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
  127228. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  127229. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127230. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127231. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  127232. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127233. * @param name defines the name of the mesh
  127234. * @param options defines the options used to create the mesh
  127235. * @param scene defines the hosting scene
  127236. * @returns the extruded shape mesh
  127237. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  127238. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  127239. */
  127240. static ExtrudeShape(name: string, options: {
  127241. shape: Vector3[];
  127242. path: Vector3[];
  127243. scale?: number;
  127244. rotation?: number;
  127245. cap?: number;
  127246. updatable?: boolean;
  127247. sideOrientation?: number;
  127248. frontUVs?: Vector4;
  127249. backUVs?: Vector4;
  127250. instance?: Mesh;
  127251. invertUV?: boolean;
  127252. }, scene?: Nullable<Scene>): Mesh;
  127253. /**
  127254. * Creates an custom extruded shape mesh.
  127255. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  127256. * * 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.
  127257. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  127258. * * 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
  127259. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  127260. * * 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
  127261. * * It must returns a float value that will be the scale value applied to the shape on each path point
  127262. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  127263. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  127264. * * 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
  127265. * * 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
  127266. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  127267. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127268. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127269. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  127270. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127271. * @param name defines the name of the mesh
  127272. * @param options defines the options used to create the mesh
  127273. * @param scene defines the hosting scene
  127274. * @returns the custom extruded shape mesh
  127275. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  127276. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  127277. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  127278. */
  127279. static ExtrudeShapeCustom(name: string, options: {
  127280. shape: Vector3[];
  127281. path: Vector3[];
  127282. scaleFunction?: any;
  127283. rotationFunction?: any;
  127284. ribbonCloseArray?: boolean;
  127285. ribbonClosePath?: boolean;
  127286. cap?: number;
  127287. updatable?: boolean;
  127288. sideOrientation?: number;
  127289. frontUVs?: Vector4;
  127290. backUVs?: Vector4;
  127291. instance?: Mesh;
  127292. invertUV?: boolean;
  127293. }, scene?: Nullable<Scene>): Mesh;
  127294. /**
  127295. * Creates lathe mesh.
  127296. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  127297. * * 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
  127298. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  127299. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  127300. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  127301. * * 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
  127302. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  127303. * * 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
  127304. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127305. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127306. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  127307. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127308. * @param name defines the name of the mesh
  127309. * @param options defines the options used to create the mesh
  127310. * @param scene defines the hosting scene
  127311. * @returns the lathe mesh
  127312. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  127313. */
  127314. static CreateLathe(name: string, options: {
  127315. shape: Vector3[];
  127316. radius?: number;
  127317. tessellation?: number;
  127318. clip?: number;
  127319. arc?: number;
  127320. closed?: boolean;
  127321. updatable?: boolean;
  127322. sideOrientation?: number;
  127323. frontUVs?: Vector4;
  127324. backUVs?: Vector4;
  127325. cap?: number;
  127326. invertUV?: boolean;
  127327. }, scene?: Nullable<Scene>): Mesh;
  127328. /**
  127329. * Creates a tiled plane mesh
  127330. * * You can set a limited pattern arrangement with the tiles
  127331. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127332. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127333. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127334. * @param name defines the name of the mesh
  127335. * @param options defines the options used to create the mesh
  127336. * @param scene defines the hosting scene
  127337. * @returns the plane mesh
  127338. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  127339. */
  127340. static CreateTiledPlane(name: string, options: {
  127341. pattern?: number;
  127342. tileSize?: number;
  127343. tileWidth?: number;
  127344. tileHeight?: number;
  127345. size?: number;
  127346. width?: number;
  127347. height?: number;
  127348. alignHorizontal?: number;
  127349. alignVertical?: number;
  127350. sideOrientation?: number;
  127351. frontUVs?: Vector4;
  127352. backUVs?: Vector4;
  127353. updatable?: boolean;
  127354. }, scene?: Nullable<Scene>): Mesh;
  127355. /**
  127356. * Creates a plane mesh
  127357. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  127358. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  127359. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  127360. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127361. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127362. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127363. * @param name defines the name of the mesh
  127364. * @param options defines the options used to create the mesh
  127365. * @param scene defines the hosting scene
  127366. * @returns the plane mesh
  127367. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  127368. */
  127369. static CreatePlane(name: string, options: {
  127370. size?: number;
  127371. width?: number;
  127372. height?: number;
  127373. sideOrientation?: number;
  127374. frontUVs?: Vector4;
  127375. backUVs?: Vector4;
  127376. updatable?: boolean;
  127377. sourcePlane?: Plane;
  127378. }, scene?: Nullable<Scene>): Mesh;
  127379. /**
  127380. * Creates a ground mesh
  127381. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  127382. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  127383. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127384. * @param name defines the name of the mesh
  127385. * @param options defines the options used to create the mesh
  127386. * @param scene defines the hosting scene
  127387. * @returns the ground mesh
  127388. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  127389. */
  127390. static CreateGround(name: string, options: {
  127391. width?: number;
  127392. height?: number;
  127393. subdivisions?: number;
  127394. subdivisionsX?: number;
  127395. subdivisionsY?: number;
  127396. updatable?: boolean;
  127397. }, scene?: Nullable<Scene>): Mesh;
  127398. /**
  127399. * Creates a tiled ground mesh
  127400. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  127401. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  127402. * * 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
  127403. * * 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
  127404. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127405. * @param name defines the name of the mesh
  127406. * @param options defines the options used to create the mesh
  127407. * @param scene defines the hosting scene
  127408. * @returns the tiled ground mesh
  127409. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  127410. */
  127411. static CreateTiledGround(name: string, options: {
  127412. xmin: number;
  127413. zmin: number;
  127414. xmax: number;
  127415. zmax: number;
  127416. subdivisions?: {
  127417. w: number;
  127418. h: number;
  127419. };
  127420. precision?: {
  127421. w: number;
  127422. h: number;
  127423. };
  127424. updatable?: boolean;
  127425. }, scene?: Nullable<Scene>): Mesh;
  127426. /**
  127427. * Creates a ground mesh from a height map
  127428. * * The parameter `url` sets the URL of the height map image resource.
  127429. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  127430. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  127431. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  127432. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  127433. * * 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.
  127434. * * 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).
  127435. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  127436. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127437. * @param name defines the name of the mesh
  127438. * @param url defines the url to the height map
  127439. * @param options defines the options used to create the mesh
  127440. * @param scene defines the hosting scene
  127441. * @returns the ground mesh
  127442. * @see https://doc.babylonjs.com/babylon101/height_map
  127443. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  127444. */
  127445. static CreateGroundFromHeightMap(name: string, url: string, options: {
  127446. width?: number;
  127447. height?: number;
  127448. subdivisions?: number;
  127449. minHeight?: number;
  127450. maxHeight?: number;
  127451. colorFilter?: Color3;
  127452. alphaFilter?: number;
  127453. updatable?: boolean;
  127454. onReady?: (mesh: GroundMesh) => void;
  127455. }, scene?: Nullable<Scene>): GroundMesh;
  127456. /**
  127457. * Creates a polygon mesh
  127458. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  127459. * * 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
  127460. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  127461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127462. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  127463. * * Remember you can only change the shape positions, not their number when updating a polygon
  127464. * @param name defines the name of the mesh
  127465. * @param options defines the options used to create the mesh
  127466. * @param scene defines the hosting scene
  127467. * @param earcutInjection can be used to inject your own earcut reference
  127468. * @returns the polygon mesh
  127469. */
  127470. static CreatePolygon(name: string, options: {
  127471. shape: Vector3[];
  127472. holes?: Vector3[][];
  127473. depth?: number;
  127474. faceUV?: Vector4[];
  127475. faceColors?: Color4[];
  127476. updatable?: boolean;
  127477. sideOrientation?: number;
  127478. frontUVs?: Vector4;
  127479. backUVs?: Vector4;
  127480. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  127481. /**
  127482. * Creates an extruded polygon mesh, with depth in the Y direction.
  127483. * * 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)
  127484. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  127485. * @param name defines the name of the mesh
  127486. * @param options defines the options used to create the mesh
  127487. * @param scene defines the hosting scene
  127488. * @param earcutInjection can be used to inject your own earcut reference
  127489. * @returns the polygon mesh
  127490. */
  127491. static ExtrudePolygon(name: string, options: {
  127492. shape: Vector3[];
  127493. holes?: Vector3[][];
  127494. depth?: number;
  127495. faceUV?: Vector4[];
  127496. faceColors?: Color4[];
  127497. updatable?: boolean;
  127498. sideOrientation?: number;
  127499. frontUVs?: Vector4;
  127500. backUVs?: Vector4;
  127501. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  127502. /**
  127503. * Creates a tube mesh.
  127504. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  127505. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  127506. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  127507. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  127508. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  127509. * * 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)
  127510. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  127511. * * 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
  127512. * * 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
  127513. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127514. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127515. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  127516. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127517. * @param name defines the name of the mesh
  127518. * @param options defines the options used to create the mesh
  127519. * @param scene defines the hosting scene
  127520. * @returns the tube mesh
  127521. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  127522. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  127523. */
  127524. static CreateTube(name: string, options: {
  127525. path: Vector3[];
  127526. radius?: number;
  127527. tessellation?: number;
  127528. radiusFunction?: {
  127529. (i: number, distance: number): number;
  127530. };
  127531. cap?: number;
  127532. arc?: number;
  127533. updatable?: boolean;
  127534. sideOrientation?: number;
  127535. frontUVs?: Vector4;
  127536. backUVs?: Vector4;
  127537. instance?: Mesh;
  127538. invertUV?: boolean;
  127539. }, scene?: Nullable<Scene>): Mesh;
  127540. /**
  127541. * Creates a polyhedron mesh
  127542. * * 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
  127543. * * The parameter `size` (positive float, default 1) sets the polygon size
  127544. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  127545. * * 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`
  127546. * * 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
  127547. * * 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)`)
  127548. * * 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
  127549. * * 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
  127550. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127551. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127552. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127553. * @param name defines the name of the mesh
  127554. * @param options defines the options used to create the mesh
  127555. * @param scene defines the hosting scene
  127556. * @returns the polyhedron mesh
  127557. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  127558. */
  127559. static CreatePolyhedron(name: string, options: {
  127560. type?: number;
  127561. size?: number;
  127562. sizeX?: number;
  127563. sizeY?: number;
  127564. sizeZ?: number;
  127565. custom?: any;
  127566. faceUV?: Vector4[];
  127567. faceColors?: Color4[];
  127568. flat?: boolean;
  127569. updatable?: boolean;
  127570. sideOrientation?: number;
  127571. frontUVs?: Vector4;
  127572. backUVs?: Vector4;
  127573. }, scene?: Nullable<Scene>): Mesh;
  127574. /**
  127575. * Creates a decal mesh.
  127576. * 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
  127577. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  127578. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  127579. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  127580. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  127581. * @param name defines the name of the mesh
  127582. * @param sourceMesh defines the mesh where the decal must be applied
  127583. * @param options defines the options used to create the mesh
  127584. * @param scene defines the hosting scene
  127585. * @returns the decal mesh
  127586. * @see https://doc.babylonjs.com/how_to/decals
  127587. */
  127588. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  127589. position?: Vector3;
  127590. normal?: Vector3;
  127591. size?: Vector3;
  127592. angle?: number;
  127593. }): Mesh;
  127594. }
  127595. }
  127596. declare module BABYLON {
  127597. /**
  127598. * A simplifier interface for future simplification implementations
  127599. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  127600. */
  127601. export interface ISimplifier {
  127602. /**
  127603. * Simplification of a given mesh according to the given settings.
  127604. * Since this requires computation, it is assumed that the function runs async.
  127605. * @param settings The settings of the simplification, including quality and distance
  127606. * @param successCallback A callback that will be called after the mesh was simplified.
  127607. * @param errorCallback in case of an error, this callback will be called. optional.
  127608. */
  127609. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  127610. }
  127611. /**
  127612. * Expected simplification settings.
  127613. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  127614. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  127615. */
  127616. export interface ISimplificationSettings {
  127617. /**
  127618. * Gets or sets the expected quality
  127619. */
  127620. quality: number;
  127621. /**
  127622. * Gets or sets the distance when this optimized version should be used
  127623. */
  127624. distance: number;
  127625. /**
  127626. * Gets an already optimized mesh
  127627. */
  127628. optimizeMesh?: boolean;
  127629. }
  127630. /**
  127631. * Class used to specify simplification options
  127632. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  127633. */
  127634. export class SimplificationSettings implements ISimplificationSettings {
  127635. /** expected quality */
  127636. quality: number;
  127637. /** distance when this optimized version should be used */
  127638. distance: number;
  127639. /** already optimized mesh */
  127640. optimizeMesh?: boolean | undefined;
  127641. /**
  127642. * Creates a SimplificationSettings
  127643. * @param quality expected quality
  127644. * @param distance distance when this optimized version should be used
  127645. * @param optimizeMesh already optimized mesh
  127646. */
  127647. constructor(
  127648. /** expected quality */
  127649. quality: number,
  127650. /** distance when this optimized version should be used */
  127651. distance: number,
  127652. /** already optimized mesh */
  127653. optimizeMesh?: boolean | undefined);
  127654. }
  127655. /**
  127656. * Interface used to define a simplification task
  127657. */
  127658. export interface ISimplificationTask {
  127659. /**
  127660. * Array of settings
  127661. */
  127662. settings: Array<ISimplificationSettings>;
  127663. /**
  127664. * Simplification type
  127665. */
  127666. simplificationType: SimplificationType;
  127667. /**
  127668. * Mesh to simplify
  127669. */
  127670. mesh: Mesh;
  127671. /**
  127672. * Callback called on success
  127673. */
  127674. successCallback?: () => void;
  127675. /**
  127676. * Defines if parallel processing can be used
  127677. */
  127678. parallelProcessing: boolean;
  127679. }
  127680. /**
  127681. * Queue used to order the simplification tasks
  127682. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  127683. */
  127684. export class SimplificationQueue {
  127685. private _simplificationArray;
  127686. /**
  127687. * Gets a boolean indicating that the process is still running
  127688. */
  127689. running: boolean;
  127690. /**
  127691. * Creates a new queue
  127692. */
  127693. constructor();
  127694. /**
  127695. * Adds a new simplification task
  127696. * @param task defines a task to add
  127697. */
  127698. addTask(task: ISimplificationTask): void;
  127699. /**
  127700. * Execute next task
  127701. */
  127702. executeNext(): void;
  127703. /**
  127704. * Execute a simplification task
  127705. * @param task defines the task to run
  127706. */
  127707. runSimplification(task: ISimplificationTask): void;
  127708. private getSimplifier;
  127709. }
  127710. /**
  127711. * The implemented types of simplification
  127712. * At the moment only Quadratic Error Decimation is implemented
  127713. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  127714. */
  127715. export enum SimplificationType {
  127716. /** Quadratic error decimation */
  127717. QUADRATIC = 0
  127718. }
  127719. }
  127720. declare module BABYLON {
  127721. interface Scene {
  127722. /** @hidden (Backing field) */
  127723. _simplificationQueue: SimplificationQueue;
  127724. /**
  127725. * Gets or sets the simplification queue attached to the scene
  127726. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  127727. */
  127728. simplificationQueue: SimplificationQueue;
  127729. }
  127730. interface Mesh {
  127731. /**
  127732. * Simplify the mesh according to the given array of settings.
  127733. * Function will return immediately and will simplify async
  127734. * @param settings a collection of simplification settings
  127735. * @param parallelProcessing should all levels calculate parallel or one after the other
  127736. * @param simplificationType the type of simplification to run
  127737. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  127738. * @returns the current mesh
  127739. */
  127740. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  127741. }
  127742. /**
  127743. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  127744. * created in a scene
  127745. */
  127746. export class SimplicationQueueSceneComponent implements ISceneComponent {
  127747. /**
  127748. * The component name helpfull to identify the component in the list of scene components.
  127749. */
  127750. readonly name: string;
  127751. /**
  127752. * The scene the component belongs to.
  127753. */
  127754. scene: Scene;
  127755. /**
  127756. * Creates a new instance of the component for the given scene
  127757. * @param scene Defines the scene to register the component in
  127758. */
  127759. constructor(scene: Scene);
  127760. /**
  127761. * Registers the component in a given scene
  127762. */
  127763. register(): void;
  127764. /**
  127765. * Rebuilds the elements related to this component in case of
  127766. * context lost for instance.
  127767. */
  127768. rebuild(): void;
  127769. /**
  127770. * Disposes the component and the associated ressources
  127771. */
  127772. dispose(): void;
  127773. private _beforeCameraUpdate;
  127774. }
  127775. }
  127776. declare module BABYLON {
  127777. /**
  127778. * Navigation plugin interface to add navigation constrained by a navigation mesh
  127779. */
  127780. export interface INavigationEnginePlugin {
  127781. /**
  127782. * plugin name
  127783. */
  127784. name: string;
  127785. /**
  127786. * Creates a navigation mesh
  127787. * @param meshes array of all the geometry used to compute the navigatio mesh
  127788. * @param parameters bunch of parameters used to filter geometry
  127789. */
  127790. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  127791. /**
  127792. * Create a navigation mesh debug mesh
  127793. * @param scene is where the mesh will be added
  127794. * @returns debug display mesh
  127795. */
  127796. createDebugNavMesh(scene: Scene): Mesh;
  127797. /**
  127798. * Get a navigation mesh constrained position, closest to the parameter position
  127799. * @param position world position
  127800. * @returns the closest point to position constrained by the navigation mesh
  127801. */
  127802. getClosestPoint(position: Vector3): Vector3;
  127803. /**
  127804. * Get a navigation mesh constrained position, within a particular radius
  127805. * @param position world position
  127806. * @param maxRadius the maximum distance to the constrained world position
  127807. * @returns the closest point to position constrained by the navigation mesh
  127808. */
  127809. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  127810. /**
  127811. * Compute the final position from a segment made of destination-position
  127812. * @param position world position
  127813. * @param destination world position
  127814. * @returns the resulting point along the navmesh
  127815. */
  127816. moveAlong(position: Vector3, destination: Vector3): Vector3;
  127817. /**
  127818. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  127819. * @param start world position
  127820. * @param end world position
  127821. * @returns array containing world position composing the path
  127822. */
  127823. computePath(start: Vector3, end: Vector3): Vector3[];
  127824. /**
  127825. * If this plugin is supported
  127826. * @returns true if plugin is supported
  127827. */
  127828. isSupported(): boolean;
  127829. /**
  127830. * Create a new Crowd so you can add agents
  127831. * @param maxAgents the maximum agent count in the crowd
  127832. * @param maxAgentRadius the maximum radius an agent can have
  127833. * @param scene to attach the crowd to
  127834. * @returns the crowd you can add agents to
  127835. */
  127836. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  127837. /**
  127838. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  127839. * The queries will try to find a solution within those bounds
  127840. * default is (1,1,1)
  127841. * @param extent x,y,z value that define the extent around the queries point of reference
  127842. */
  127843. setDefaultQueryExtent(extent: Vector3): void;
  127844. /**
  127845. * Get the Bounding box extent specified by setDefaultQueryExtent
  127846. * @returns the box extent values
  127847. */
  127848. getDefaultQueryExtent(): Vector3;
  127849. /**
  127850. * Release all resources
  127851. */
  127852. dispose(): void;
  127853. }
  127854. /**
  127855. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  127856. */
  127857. export interface ICrowd {
  127858. /**
  127859. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  127860. * You can attach anything to that node. The node position is updated in the scene update tick.
  127861. * @param pos world position that will be constrained by the navigation mesh
  127862. * @param parameters agent parameters
  127863. * @param transform hooked to the agent that will be update by the scene
  127864. * @returns agent index
  127865. */
  127866. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  127867. /**
  127868. * Returns the agent position in world space
  127869. * @param index agent index returned by addAgent
  127870. * @returns world space position
  127871. */
  127872. getAgentPosition(index: number): Vector3;
  127873. /**
  127874. * Gets the agent velocity in world space
  127875. * @param index agent index returned by addAgent
  127876. * @returns world space velocity
  127877. */
  127878. getAgentVelocity(index: number): Vector3;
  127879. /**
  127880. * remove a particular agent previously created
  127881. * @param index agent index returned by addAgent
  127882. */
  127883. removeAgent(index: number): void;
  127884. /**
  127885. * get the list of all agents attached to this crowd
  127886. * @returns list of agent indices
  127887. */
  127888. getAgents(): number[];
  127889. /**
  127890. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  127891. * @param deltaTime in seconds
  127892. */
  127893. update(deltaTime: number): void;
  127894. /**
  127895. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  127896. * @param index agent index returned by addAgent
  127897. * @param destination targeted world position
  127898. */
  127899. agentGoto(index: number, destination: Vector3): void;
  127900. /**
  127901. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  127902. * The queries will try to find a solution within those bounds
  127903. * default is (1,1,1)
  127904. * @param extent x,y,z value that define the extent around the queries point of reference
  127905. */
  127906. setDefaultQueryExtent(extent: Vector3): void;
  127907. /**
  127908. * Get the Bounding box extent specified by setDefaultQueryExtent
  127909. * @returns the box extent values
  127910. */
  127911. getDefaultQueryExtent(): Vector3;
  127912. /**
  127913. * Release all resources
  127914. */
  127915. dispose(): void;
  127916. }
  127917. /**
  127918. * Configures an agent
  127919. */
  127920. export interface IAgentParameters {
  127921. /**
  127922. * Agent radius. [Limit: >= 0]
  127923. */
  127924. radius: number;
  127925. /**
  127926. * Agent height. [Limit: > 0]
  127927. */
  127928. height: number;
  127929. /**
  127930. * Maximum allowed acceleration. [Limit: >= 0]
  127931. */
  127932. maxAcceleration: number;
  127933. /**
  127934. * Maximum allowed speed. [Limit: >= 0]
  127935. */
  127936. maxSpeed: number;
  127937. /**
  127938. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  127939. */
  127940. collisionQueryRange: number;
  127941. /**
  127942. * The path visibility optimization range. [Limit: > 0]
  127943. */
  127944. pathOptimizationRange: number;
  127945. /**
  127946. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  127947. */
  127948. separationWeight: number;
  127949. }
  127950. /**
  127951. * Configures the navigation mesh creation
  127952. */
  127953. export interface INavMeshParameters {
  127954. /**
  127955. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  127956. */
  127957. cs: number;
  127958. /**
  127959. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  127960. */
  127961. ch: number;
  127962. /**
  127963. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  127964. */
  127965. walkableSlopeAngle: number;
  127966. /**
  127967. * Minimum floor to 'ceiling' height that will still allow the floor area to
  127968. * be considered walkable. [Limit: >= 3] [Units: vx]
  127969. */
  127970. walkableHeight: number;
  127971. /**
  127972. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  127973. */
  127974. walkableClimb: number;
  127975. /**
  127976. * The distance to erode/shrink the walkable area of the heightfield away from
  127977. * obstructions. [Limit: >=0] [Units: vx]
  127978. */
  127979. walkableRadius: number;
  127980. /**
  127981. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  127982. */
  127983. maxEdgeLen: number;
  127984. /**
  127985. * The maximum distance a simplfied contour's border edges should deviate
  127986. * the original raw contour. [Limit: >=0] [Units: vx]
  127987. */
  127988. maxSimplificationError: number;
  127989. /**
  127990. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  127991. */
  127992. minRegionArea: number;
  127993. /**
  127994. * Any regions with a span count smaller than this value will, if possible,
  127995. * be merged with larger regions. [Limit: >=0] [Units: vx]
  127996. */
  127997. mergeRegionArea: number;
  127998. /**
  127999. * The maximum number of vertices allowed for polygons generated during the
  128000. * contour to polygon conversion process. [Limit: >= 3]
  128001. */
  128002. maxVertsPerPoly: number;
  128003. /**
  128004. * Sets the sampling distance to use when generating the detail mesh.
  128005. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  128006. */
  128007. detailSampleDist: number;
  128008. /**
  128009. * The maximum distance the detail mesh surface should deviate from heightfield
  128010. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  128011. */
  128012. detailSampleMaxError: number;
  128013. }
  128014. }
  128015. declare module BABYLON {
  128016. /**
  128017. * RecastJS navigation plugin
  128018. */
  128019. export class RecastJSPlugin implements INavigationEnginePlugin {
  128020. /**
  128021. * Reference to the Recast library
  128022. */
  128023. bjsRECAST: any;
  128024. /**
  128025. * plugin name
  128026. */
  128027. name: string;
  128028. /**
  128029. * the first navmesh created. We might extend this to support multiple navmeshes
  128030. */
  128031. navMesh: any;
  128032. /**
  128033. * Initializes the recastJS plugin
  128034. * @param recastInjection can be used to inject your own recast reference
  128035. */
  128036. constructor(recastInjection?: any);
  128037. /**
  128038. * Creates a navigation mesh
  128039. * @param meshes array of all the geometry used to compute the navigatio mesh
  128040. * @param parameters bunch of parameters used to filter geometry
  128041. */
  128042. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  128043. /**
  128044. * Create a navigation mesh debug mesh
  128045. * @param scene is where the mesh will be added
  128046. * @returns debug display mesh
  128047. */
  128048. createDebugNavMesh(scene: Scene): Mesh;
  128049. /**
  128050. * Get a navigation mesh constrained position, closest to the parameter position
  128051. * @param position world position
  128052. * @returns the closest point to position constrained by the navigation mesh
  128053. */
  128054. getClosestPoint(position: Vector3): Vector3;
  128055. /**
  128056. * Get a navigation mesh constrained position, within a particular radius
  128057. * @param position world position
  128058. * @param maxRadius the maximum distance to the constrained world position
  128059. * @returns the closest point to position constrained by the navigation mesh
  128060. */
  128061. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  128062. /**
  128063. * Compute the final position from a segment made of destination-position
  128064. * @param position world position
  128065. * @param destination world position
  128066. * @returns the resulting point along the navmesh
  128067. */
  128068. moveAlong(position: Vector3, destination: Vector3): Vector3;
  128069. /**
  128070. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  128071. * @param start world position
  128072. * @param end world position
  128073. * @returns array containing world position composing the path
  128074. */
  128075. computePath(start: Vector3, end: Vector3): Vector3[];
  128076. /**
  128077. * Create a new Crowd so you can add agents
  128078. * @param maxAgents the maximum agent count in the crowd
  128079. * @param maxAgentRadius the maximum radius an agent can have
  128080. * @param scene to attach the crowd to
  128081. * @returns the crowd you can add agents to
  128082. */
  128083. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  128084. /**
  128085. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  128086. * The queries will try to find a solution within those bounds
  128087. * default is (1,1,1)
  128088. * @param extent x,y,z value that define the extent around the queries point of reference
  128089. */
  128090. setDefaultQueryExtent(extent: Vector3): void;
  128091. /**
  128092. * Get the Bounding box extent specified by setDefaultQueryExtent
  128093. * @returns the box extent values
  128094. */
  128095. getDefaultQueryExtent(): Vector3;
  128096. /**
  128097. * Disposes
  128098. */
  128099. dispose(): void;
  128100. /**
  128101. * If this plugin is supported
  128102. * @returns true if plugin is supported
  128103. */
  128104. isSupported(): boolean;
  128105. }
  128106. /**
  128107. * Recast detour crowd implementation
  128108. */
  128109. export class RecastJSCrowd implements ICrowd {
  128110. /**
  128111. * Recast/detour plugin
  128112. */
  128113. bjsRECASTPlugin: RecastJSPlugin;
  128114. /**
  128115. * Link to the detour crowd
  128116. */
  128117. recastCrowd: any;
  128118. /**
  128119. * One transform per agent
  128120. */
  128121. transforms: TransformNode[];
  128122. /**
  128123. * All agents created
  128124. */
  128125. agents: number[];
  128126. /**
  128127. * Link to the scene is kept to unregister the crowd from the scene
  128128. */
  128129. private _scene;
  128130. /**
  128131. * Observer for crowd updates
  128132. */
  128133. private _onBeforeAnimationsObserver;
  128134. /**
  128135. * Constructor
  128136. * @param plugin recastJS plugin
  128137. * @param maxAgents the maximum agent count in the crowd
  128138. * @param maxAgentRadius the maximum radius an agent can have
  128139. * @param scene to attach the crowd to
  128140. * @returns the crowd you can add agents to
  128141. */
  128142. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  128143. /**
  128144. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  128145. * You can attach anything to that node. The node position is updated in the scene update tick.
  128146. * @param pos world position that will be constrained by the navigation mesh
  128147. * @param parameters agent parameters
  128148. * @param transform hooked to the agent that will be update by the scene
  128149. * @returns agent index
  128150. */
  128151. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  128152. /**
  128153. * Returns the agent position in world space
  128154. * @param index agent index returned by addAgent
  128155. * @returns world space position
  128156. */
  128157. getAgentPosition(index: number): Vector3;
  128158. /**
  128159. * Returns the agent velocity in world space
  128160. * @param index agent index returned by addAgent
  128161. * @returns world space velocity
  128162. */
  128163. getAgentVelocity(index: number): Vector3;
  128164. /**
  128165. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  128166. * @param index agent index returned by addAgent
  128167. * @param destination targeted world position
  128168. */
  128169. agentGoto(index: number, destination: Vector3): void;
  128170. /**
  128171. * remove a particular agent previously created
  128172. * @param index agent index returned by addAgent
  128173. */
  128174. removeAgent(index: number): void;
  128175. /**
  128176. * get the list of all agents attached to this crowd
  128177. * @returns list of agent indices
  128178. */
  128179. getAgents(): number[];
  128180. /**
  128181. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  128182. * @param deltaTime in seconds
  128183. */
  128184. update(deltaTime: number): void;
  128185. /**
  128186. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  128187. * The queries will try to find a solution within those bounds
  128188. * default is (1,1,1)
  128189. * @param extent x,y,z value that define the extent around the queries point of reference
  128190. */
  128191. setDefaultQueryExtent(extent: Vector3): void;
  128192. /**
  128193. * Get the Bounding box extent specified by setDefaultQueryExtent
  128194. * @returns the box extent values
  128195. */
  128196. getDefaultQueryExtent(): Vector3;
  128197. /**
  128198. * Release all resources
  128199. */
  128200. dispose(): void;
  128201. }
  128202. }
  128203. declare module BABYLON {
  128204. /**
  128205. * Class used to enable access to IndexedDB
  128206. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  128207. */
  128208. export class Database implements IOfflineProvider {
  128209. private _callbackManifestChecked;
  128210. private _currentSceneUrl;
  128211. private _db;
  128212. private _enableSceneOffline;
  128213. private _enableTexturesOffline;
  128214. private _manifestVersionFound;
  128215. private _mustUpdateRessources;
  128216. private _hasReachedQuota;
  128217. private _isSupported;
  128218. private _idbFactory;
  128219. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  128220. private static IsUASupportingBlobStorage;
  128221. /**
  128222. * Gets a boolean indicating if Database storate is enabled (off by default)
  128223. */
  128224. static IDBStorageEnabled: boolean;
  128225. /**
  128226. * Gets a boolean indicating if scene must be saved in the database
  128227. */
  128228. readonly enableSceneOffline: boolean;
  128229. /**
  128230. * Gets a boolean indicating if textures must be saved in the database
  128231. */
  128232. readonly enableTexturesOffline: boolean;
  128233. /**
  128234. * Creates a new Database
  128235. * @param urlToScene defines the url to load the scene
  128236. * @param callbackManifestChecked defines the callback to use when manifest is checked
  128237. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  128238. */
  128239. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  128240. private static _ParseURL;
  128241. private static _ReturnFullUrlLocation;
  128242. private _checkManifestFile;
  128243. /**
  128244. * Open the database and make it available
  128245. * @param successCallback defines the callback to call on success
  128246. * @param errorCallback defines the callback to call on error
  128247. */
  128248. open(successCallback: () => void, errorCallback: () => void): void;
  128249. /**
  128250. * Loads an image from the database
  128251. * @param url defines the url to load from
  128252. * @param image defines the target DOM image
  128253. */
  128254. loadImage(url: string, image: HTMLImageElement): void;
  128255. private _loadImageFromDBAsync;
  128256. private _saveImageIntoDBAsync;
  128257. private _checkVersionFromDB;
  128258. private _loadVersionFromDBAsync;
  128259. private _saveVersionIntoDBAsync;
  128260. /**
  128261. * Loads a file from database
  128262. * @param url defines the URL to load from
  128263. * @param sceneLoaded defines a callback to call on success
  128264. * @param progressCallBack defines a callback to call when progress changed
  128265. * @param errorCallback defines a callback to call on error
  128266. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  128267. */
  128268. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  128269. private _loadFileAsync;
  128270. private _saveFileAsync;
  128271. /**
  128272. * Validates if xhr data is correct
  128273. * @param xhr defines the request to validate
  128274. * @param dataType defines the expected data type
  128275. * @returns true if data is correct
  128276. */
  128277. private static _ValidateXHRData;
  128278. }
  128279. }
  128280. declare module BABYLON {
  128281. /** @hidden */
  128282. export var gpuUpdateParticlesPixelShader: {
  128283. name: string;
  128284. shader: string;
  128285. };
  128286. }
  128287. declare module BABYLON {
  128288. /** @hidden */
  128289. export var gpuUpdateParticlesVertexShader: {
  128290. name: string;
  128291. shader: string;
  128292. };
  128293. }
  128294. declare module BABYLON {
  128295. /** @hidden */
  128296. export var clipPlaneFragmentDeclaration2: {
  128297. name: string;
  128298. shader: string;
  128299. };
  128300. }
  128301. declare module BABYLON {
  128302. /** @hidden */
  128303. export var gpuRenderParticlesPixelShader: {
  128304. name: string;
  128305. shader: string;
  128306. };
  128307. }
  128308. declare module BABYLON {
  128309. /** @hidden */
  128310. export var clipPlaneVertexDeclaration2: {
  128311. name: string;
  128312. shader: string;
  128313. };
  128314. }
  128315. declare module BABYLON {
  128316. /** @hidden */
  128317. export var gpuRenderParticlesVertexShader: {
  128318. name: string;
  128319. shader: string;
  128320. };
  128321. }
  128322. declare module BABYLON {
  128323. /**
  128324. * This represents a GPU particle system in Babylon
  128325. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  128326. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  128327. */
  128328. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  128329. /**
  128330. * The layer mask we are rendering the particles through.
  128331. */
  128332. layerMask: number;
  128333. private _capacity;
  128334. private _activeCount;
  128335. private _currentActiveCount;
  128336. private _accumulatedCount;
  128337. private _renderEffect;
  128338. private _updateEffect;
  128339. private _buffer0;
  128340. private _buffer1;
  128341. private _spriteBuffer;
  128342. private _updateVAO;
  128343. private _renderVAO;
  128344. private _targetIndex;
  128345. private _sourceBuffer;
  128346. private _targetBuffer;
  128347. private _engine;
  128348. private _currentRenderId;
  128349. private _started;
  128350. private _stopped;
  128351. private _timeDelta;
  128352. private _randomTexture;
  128353. private _randomTexture2;
  128354. private _attributesStrideSize;
  128355. private _updateEffectOptions;
  128356. private _randomTextureSize;
  128357. private _actualFrame;
  128358. private readonly _rawTextureWidth;
  128359. /**
  128360. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  128361. */
  128362. static readonly IsSupported: boolean;
  128363. /**
  128364. * An event triggered when the system is disposed.
  128365. */
  128366. onDisposeObservable: Observable<GPUParticleSystem>;
  128367. /**
  128368. * Gets the maximum number of particles active at the same time.
  128369. * @returns The max number of active particles.
  128370. */
  128371. getCapacity(): number;
  128372. /**
  128373. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  128374. * to override the particles.
  128375. */
  128376. forceDepthWrite: boolean;
  128377. /**
  128378. * Gets or set the number of active particles
  128379. */
  128380. activeParticleCount: number;
  128381. private _preWarmDone;
  128382. /**
  128383. * Is this system ready to be used/rendered
  128384. * @return true if the system is ready
  128385. */
  128386. isReady(): boolean;
  128387. /**
  128388. * Gets if the system has been started. (Note: this will still be true after stop is called)
  128389. * @returns True if it has been started, otherwise false.
  128390. */
  128391. isStarted(): boolean;
  128392. /**
  128393. * Starts the particle system and begins to emit
  128394. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  128395. */
  128396. start(delay?: number): void;
  128397. /**
  128398. * Stops the particle system.
  128399. */
  128400. stop(): void;
  128401. /**
  128402. * Remove all active particles
  128403. */
  128404. reset(): void;
  128405. /**
  128406. * Returns the string "GPUParticleSystem"
  128407. * @returns a string containing the class name
  128408. */
  128409. getClassName(): string;
  128410. private _colorGradientsTexture;
  128411. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  128412. /**
  128413. * Adds a new color gradient
  128414. * @param gradient defines the gradient to use (between 0 and 1)
  128415. * @param color1 defines the color to affect to the specified gradient
  128416. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  128417. * @returns the current particle system
  128418. */
  128419. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  128420. /**
  128421. * Remove a specific color gradient
  128422. * @param gradient defines the gradient to remove
  128423. * @returns the current particle system
  128424. */
  128425. removeColorGradient(gradient: number): GPUParticleSystem;
  128426. private _angularSpeedGradientsTexture;
  128427. private _sizeGradientsTexture;
  128428. private _velocityGradientsTexture;
  128429. private _limitVelocityGradientsTexture;
  128430. private _dragGradientsTexture;
  128431. private _addFactorGradient;
  128432. /**
  128433. * Adds a new size gradient
  128434. * @param gradient defines the gradient to use (between 0 and 1)
  128435. * @param factor defines the size factor to affect to the specified gradient
  128436. * @returns the current particle system
  128437. */
  128438. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  128439. /**
  128440. * Remove a specific size gradient
  128441. * @param gradient defines the gradient to remove
  128442. * @returns the current particle system
  128443. */
  128444. removeSizeGradient(gradient: number): GPUParticleSystem;
  128445. /**
  128446. * Adds a new angular speed gradient
  128447. * @param gradient defines the gradient to use (between 0 and 1)
  128448. * @param factor defines the angular speed to affect to the specified gradient
  128449. * @returns the current particle system
  128450. */
  128451. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  128452. /**
  128453. * Remove a specific angular speed gradient
  128454. * @param gradient defines the gradient to remove
  128455. * @returns the current particle system
  128456. */
  128457. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  128458. /**
  128459. * Adds a new velocity gradient
  128460. * @param gradient defines the gradient to use (between 0 and 1)
  128461. * @param factor defines the velocity to affect to the specified gradient
  128462. * @returns the current particle system
  128463. */
  128464. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  128465. /**
  128466. * Remove a specific velocity gradient
  128467. * @param gradient defines the gradient to remove
  128468. * @returns the current particle system
  128469. */
  128470. removeVelocityGradient(gradient: number): GPUParticleSystem;
  128471. /**
  128472. * Adds a new limit velocity gradient
  128473. * @param gradient defines the gradient to use (between 0 and 1)
  128474. * @param factor defines the limit velocity value to affect to the specified gradient
  128475. * @returns the current particle system
  128476. */
  128477. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  128478. /**
  128479. * Remove a specific limit velocity gradient
  128480. * @param gradient defines the gradient to remove
  128481. * @returns the current particle system
  128482. */
  128483. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  128484. /**
  128485. * Adds a new drag gradient
  128486. * @param gradient defines the gradient to use (between 0 and 1)
  128487. * @param factor defines the drag value to affect to the specified gradient
  128488. * @returns the current particle system
  128489. */
  128490. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  128491. /**
  128492. * Remove a specific drag gradient
  128493. * @param gradient defines the gradient to remove
  128494. * @returns the current particle system
  128495. */
  128496. removeDragGradient(gradient: number): GPUParticleSystem;
  128497. /**
  128498. * Not supported by GPUParticleSystem
  128499. * @param gradient defines the gradient to use (between 0 and 1)
  128500. * @param factor defines the emit rate value to affect to the specified gradient
  128501. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  128502. * @returns the current particle system
  128503. */
  128504. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  128505. /**
  128506. * Not supported by GPUParticleSystem
  128507. * @param gradient defines the gradient to remove
  128508. * @returns the current particle system
  128509. */
  128510. removeEmitRateGradient(gradient: number): IParticleSystem;
  128511. /**
  128512. * Not supported by GPUParticleSystem
  128513. * @param gradient defines the gradient to use (between 0 and 1)
  128514. * @param factor defines the start size value to affect to the specified gradient
  128515. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  128516. * @returns the current particle system
  128517. */
  128518. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  128519. /**
  128520. * Not supported by GPUParticleSystem
  128521. * @param gradient defines the gradient to remove
  128522. * @returns the current particle system
  128523. */
  128524. removeStartSizeGradient(gradient: number): IParticleSystem;
  128525. /**
  128526. * Not supported by GPUParticleSystem
  128527. * @param gradient defines the gradient to use (between 0 and 1)
  128528. * @param min defines the color remap minimal range
  128529. * @param max defines the color remap maximal range
  128530. * @returns the current particle system
  128531. */
  128532. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  128533. /**
  128534. * Not supported by GPUParticleSystem
  128535. * @param gradient defines the gradient to remove
  128536. * @returns the current particle system
  128537. */
  128538. removeColorRemapGradient(): IParticleSystem;
  128539. /**
  128540. * Not supported by GPUParticleSystem
  128541. * @param gradient defines the gradient to use (between 0 and 1)
  128542. * @param min defines the alpha remap minimal range
  128543. * @param max defines the alpha remap maximal range
  128544. * @returns the current particle system
  128545. */
  128546. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  128547. /**
  128548. * Not supported by GPUParticleSystem
  128549. * @param gradient defines the gradient to remove
  128550. * @returns the current particle system
  128551. */
  128552. removeAlphaRemapGradient(): IParticleSystem;
  128553. /**
  128554. * Not supported by GPUParticleSystem
  128555. * @param gradient defines the gradient to use (between 0 and 1)
  128556. * @param color defines the color to affect to the specified gradient
  128557. * @returns the current particle system
  128558. */
  128559. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  128560. /**
  128561. * Not supported by GPUParticleSystem
  128562. * @param gradient defines the gradient to remove
  128563. * @returns the current particle system
  128564. */
  128565. removeRampGradient(): IParticleSystem;
  128566. /**
  128567. * Not supported by GPUParticleSystem
  128568. * @returns the list of ramp gradients
  128569. */
  128570. getRampGradients(): Nullable<Array<Color3Gradient>>;
  128571. /**
  128572. * Not supported by GPUParticleSystem
  128573. * Gets or sets a boolean indicating that ramp gradients must be used
  128574. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  128575. */
  128576. useRampGradients: boolean;
  128577. /**
  128578. * Not supported by GPUParticleSystem
  128579. * @param gradient defines the gradient to use (between 0 and 1)
  128580. * @param factor defines the life time factor to affect to the specified gradient
  128581. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  128582. * @returns the current particle system
  128583. */
  128584. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  128585. /**
  128586. * Not supported by GPUParticleSystem
  128587. * @param gradient defines the gradient to remove
  128588. * @returns the current particle system
  128589. */
  128590. removeLifeTimeGradient(gradient: number): IParticleSystem;
  128591. /**
  128592. * Instantiates a GPU particle system.
  128593. * 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.
  128594. * @param name The name of the particle system
  128595. * @param options The options used to create the system
  128596. * @param scene The scene the particle system belongs to
  128597. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  128598. */
  128599. constructor(name: string, options: Partial<{
  128600. capacity: number;
  128601. randomTextureSize: number;
  128602. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  128603. protected _reset(): void;
  128604. private _createUpdateVAO;
  128605. private _createRenderVAO;
  128606. private _initialize;
  128607. /** @hidden */
  128608. _recreateUpdateEffect(): void;
  128609. /** @hidden */
  128610. _recreateRenderEffect(): void;
  128611. /**
  128612. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  128613. * @param preWarm defines if we are in the pre-warmimg phase
  128614. */
  128615. animate(preWarm?: boolean): void;
  128616. private _createFactorGradientTexture;
  128617. private _createSizeGradientTexture;
  128618. private _createAngularSpeedGradientTexture;
  128619. private _createVelocityGradientTexture;
  128620. private _createLimitVelocityGradientTexture;
  128621. private _createDragGradientTexture;
  128622. private _createColorGradientTexture;
  128623. /**
  128624. * Renders the particle system in its current state
  128625. * @param preWarm defines if the system should only update the particles but not render them
  128626. * @returns the current number of particles
  128627. */
  128628. render(preWarm?: boolean): number;
  128629. /**
  128630. * Rebuilds the particle system
  128631. */
  128632. rebuild(): void;
  128633. private _releaseBuffers;
  128634. private _releaseVAOs;
  128635. /**
  128636. * Disposes the particle system and free the associated resources
  128637. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  128638. */
  128639. dispose(disposeTexture?: boolean): void;
  128640. /**
  128641. * Clones the particle system.
  128642. * @param name The name of the cloned object
  128643. * @param newEmitter The new emitter to use
  128644. * @returns the cloned particle system
  128645. */
  128646. clone(name: string, newEmitter: any): GPUParticleSystem;
  128647. /**
  128648. * Serializes the particle system to a JSON object.
  128649. * @returns the JSON object
  128650. */
  128651. serialize(): any;
  128652. /**
  128653. * Parses a JSON object to create a GPU particle system.
  128654. * @param parsedParticleSystem The JSON object to parse
  128655. * @param scene The scene to create the particle system in
  128656. * @param rootUrl The root url to use to load external dependencies like texture
  128657. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  128658. * @returns the parsed GPU particle system
  128659. */
  128660. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  128661. }
  128662. }
  128663. declare module BABYLON {
  128664. /**
  128665. * Represents a set of particle systems working together to create a specific effect
  128666. */
  128667. export class ParticleSystemSet implements IDisposable {
  128668. /**
  128669. * Gets or sets base Assets URL
  128670. */
  128671. static BaseAssetsUrl: string;
  128672. private _emitterCreationOptions;
  128673. private _emitterNode;
  128674. /**
  128675. * Gets the particle system list
  128676. */
  128677. systems: IParticleSystem[];
  128678. /**
  128679. * Gets the emitter node used with this set
  128680. */
  128681. readonly emitterNode: Nullable<TransformNode>;
  128682. /**
  128683. * Creates a new emitter mesh as a sphere
  128684. * @param options defines the options used to create the sphere
  128685. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  128686. * @param scene defines the hosting scene
  128687. */
  128688. setEmitterAsSphere(options: {
  128689. diameter: number;
  128690. segments: number;
  128691. color: Color3;
  128692. }, renderingGroupId: number, scene: Scene): void;
  128693. /**
  128694. * Starts all particle systems of the set
  128695. * @param emitter defines an optional mesh to use as emitter for the particle systems
  128696. */
  128697. start(emitter?: AbstractMesh): void;
  128698. /**
  128699. * Release all associated resources
  128700. */
  128701. dispose(): void;
  128702. /**
  128703. * Serialize the set into a JSON compatible object
  128704. * @returns a JSON compatible representation of the set
  128705. */
  128706. serialize(): any;
  128707. /**
  128708. * Parse a new ParticleSystemSet from a serialized source
  128709. * @param data defines a JSON compatible representation of the set
  128710. * @param scene defines the hosting scene
  128711. * @param gpu defines if we want GPU particles or CPU particles
  128712. * @returns a new ParticleSystemSet
  128713. */
  128714. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  128715. }
  128716. }
  128717. declare module BABYLON {
  128718. /**
  128719. * This class is made for on one-liner static method to help creating particle system set.
  128720. */
  128721. export class ParticleHelper {
  128722. /**
  128723. * Gets or sets base Assets URL
  128724. */
  128725. static BaseAssetsUrl: string;
  128726. /**
  128727. * Create a default particle system that you can tweak
  128728. * @param emitter defines the emitter to use
  128729. * @param capacity defines the system capacity (default is 500 particles)
  128730. * @param scene defines the hosting scene
  128731. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  128732. * @returns the new Particle system
  128733. */
  128734. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  128735. /**
  128736. * This is the main static method (one-liner) of this helper to create different particle systems
  128737. * @param type This string represents the type to the particle system to create
  128738. * @param scene The scene where the particle system should live
  128739. * @param gpu If the system will use gpu
  128740. * @returns the ParticleSystemSet created
  128741. */
  128742. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  128743. /**
  128744. * Static function used to export a particle system to a ParticleSystemSet variable.
  128745. * Please note that the emitter shape is not exported
  128746. * @param systems defines the particle systems to export
  128747. * @returns the created particle system set
  128748. */
  128749. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  128750. }
  128751. }
  128752. declare module BABYLON {
  128753. interface Engine {
  128754. /**
  128755. * Create an effect to use with particle systems.
  128756. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  128757. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  128758. * @param uniformsNames defines a list of attribute names
  128759. * @param samplers defines an array of string used to represent textures
  128760. * @param defines defines the string containing the defines to use to compile the shaders
  128761. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  128762. * @param onCompiled defines a function to call when the effect creation is successful
  128763. * @param onError defines a function to call when the effect creation has failed
  128764. * @returns the new Effect
  128765. */
  128766. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  128767. }
  128768. interface Mesh {
  128769. /**
  128770. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  128771. * @returns an array of IParticleSystem
  128772. */
  128773. getEmittedParticleSystems(): IParticleSystem[];
  128774. /**
  128775. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  128776. * @returns an array of IParticleSystem
  128777. */
  128778. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  128779. }
  128780. /**
  128781. * @hidden
  128782. */
  128783. export var _IDoNeedToBeInTheBuild: number;
  128784. }
  128785. declare module BABYLON {
  128786. /** Defines the 4 color options */
  128787. export enum PointColor {
  128788. /** color value */
  128789. Color = 2,
  128790. /** uv value */
  128791. UV = 1,
  128792. /** random value */
  128793. Random = 0,
  128794. /** stated value */
  128795. Stated = 3
  128796. }
  128797. /**
  128798. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  128799. * 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.
  128800. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  128801. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  128802. *
  128803. * Full documentation here : TO BE ENTERED
  128804. */
  128805. export class PointsCloudSystem implements IDisposable {
  128806. /**
  128807. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  128808. * Example : var p = SPS.particles[i];
  128809. */
  128810. particles: CloudPoint[];
  128811. /**
  128812. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  128813. */
  128814. nbParticles: number;
  128815. /**
  128816. * This a counter for your own usage. It's not set by any SPS functions.
  128817. */
  128818. counter: number;
  128819. /**
  128820. * The PCS name. This name is also given to the underlying mesh.
  128821. */
  128822. name: string;
  128823. /**
  128824. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  128825. */
  128826. mesh: Mesh;
  128827. /**
  128828. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  128829. * Please read :
  128830. */
  128831. vars: any;
  128832. /**
  128833. * @hidden
  128834. */
  128835. _size: number;
  128836. private _scene;
  128837. private _promises;
  128838. private _positions;
  128839. private _indices;
  128840. private _normals;
  128841. private _colors;
  128842. private _uvs;
  128843. private _indices32;
  128844. private _positions32;
  128845. private _colors32;
  128846. private _uvs32;
  128847. private _updatable;
  128848. private _isVisibilityBoxLocked;
  128849. private _alwaysVisible;
  128850. private _groups;
  128851. private _groupCounter;
  128852. private _computeParticleColor;
  128853. private _computeParticleTexture;
  128854. private _computeParticleRotation;
  128855. private _computeBoundingBox;
  128856. private _isReady;
  128857. /**
  128858. * Creates a PCS (Points Cloud System) object
  128859. * @param name (String) is the PCS name, this will be the underlying mesh name
  128860. * @param pointSize (number) is the size for each point
  128861. * @param scene (Scene) is the scene in which the PCS is added
  128862. * @param options defines the options of the PCS e.g.
  128863. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  128864. */
  128865. constructor(name: string, pointSize: number, scene: Scene, options?: {
  128866. updatable?: boolean;
  128867. });
  128868. /**
  128869. * Builds the PCS underlying mesh. Returns a standard Mesh.
  128870. * If no points were added to the PCS, the returned mesh is just a single point.
  128871. * @returns a promise for the created mesh
  128872. */
  128873. buildMeshAsync(): Promise<Mesh>;
  128874. /**
  128875. * @hidden
  128876. */
  128877. private _buildMesh;
  128878. private _addParticle;
  128879. private _randomUnitVector;
  128880. private _getColorIndicesForCoord;
  128881. private _setPointsColorOrUV;
  128882. private _colorFromTexture;
  128883. private _calculateDensity;
  128884. /**
  128885. * Adds points to the PCS in random positions within a unit sphere
  128886. * @param nb (positive integer) the number of particles to be created from this model
  128887. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  128888. * @returns the number of groups in the system
  128889. */
  128890. addPoints(nb: number, pointFunction?: any): number;
  128891. /**
  128892. * Adds points to the PCS from the surface of the model shape
  128893. * @param mesh is any Mesh object that will be used as a surface model for the points
  128894. * @param nb (positive integer) the number of particles to be created from this model
  128895. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  128896. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  128897. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  128898. * @returns the number of groups in the system
  128899. */
  128900. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  128901. /**
  128902. * Adds points to the PCS inside the model shape
  128903. * @param mesh is any Mesh object that will be used as a surface model for the points
  128904. * @param nb (positive integer) the number of particles to be created from this model
  128905. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  128906. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  128907. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  128908. * @returns the number of groups in the system
  128909. */
  128910. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  128911. /**
  128912. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  128913. * This method calls `updateParticle()` for each particle of the SPS.
  128914. * For an animated SPS, it is usually called within the render loop.
  128915. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  128916. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  128917. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  128918. * @returns the PCS.
  128919. */
  128920. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  128921. /**
  128922. * Disposes the PCS.
  128923. */
  128924. dispose(): void;
  128925. /**
  128926. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  128927. * doc :
  128928. * @returns the PCS.
  128929. */
  128930. refreshVisibleSize(): PointsCloudSystem;
  128931. /**
  128932. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  128933. * @param size the size (float) of the visibility box
  128934. * note : this doesn't lock the PCS mesh bounding box.
  128935. * doc :
  128936. */
  128937. setVisibilityBox(size: number): void;
  128938. /**
  128939. * Gets whether the PCS is always visible or not
  128940. * doc :
  128941. */
  128942. /**
  128943. * Sets the PCS as always visible or not
  128944. * doc :
  128945. */
  128946. isAlwaysVisible: boolean;
  128947. /**
  128948. * Tells to `setParticles()` to compute the particle rotations or not
  128949. * Default value : false. The PCS is faster when it's set to false
  128950. * Note : particle rotations are only applied to parent particles
  128951. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  128952. */
  128953. computeParticleRotation: boolean;
  128954. /**
  128955. * Tells to `setParticles()` to compute the particle colors or not.
  128956. * Default value : true. The PCS is faster when it's set to false.
  128957. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  128958. */
  128959. /**
  128960. * Gets if `setParticles()` computes the particle colors or not.
  128961. * Default value : false. The PCS is faster when it's set to false.
  128962. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  128963. */
  128964. computeParticleColor: boolean;
  128965. /**
  128966. * Gets if `setParticles()` computes the particle textures or not.
  128967. * Default value : false. The PCS is faster when it's set to false.
  128968. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  128969. */
  128970. computeParticleTexture: boolean;
  128971. /**
  128972. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  128973. */
  128974. /**
  128975. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  128976. */
  128977. computeBoundingBox: boolean;
  128978. /**
  128979. * This function does nothing. It may be overwritten to set all the particle first values.
  128980. * The PCS doesn't call this function, you may have to call it by your own.
  128981. * doc :
  128982. */
  128983. initParticles(): void;
  128984. /**
  128985. * This function does nothing. It may be overwritten to recycle a particle
  128986. * The PCS doesn't call this function, you can to call it
  128987. * doc :
  128988. * @param particle The particle to recycle
  128989. * @returns the recycled particle
  128990. */
  128991. recycleParticle(particle: CloudPoint): CloudPoint;
  128992. /**
  128993. * Updates a particle : this function should be overwritten by the user.
  128994. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  128995. * doc :
  128996. * @example : just set a particle position or velocity and recycle conditions
  128997. * @param particle The particle to update
  128998. * @returns the updated particle
  128999. */
  129000. updateParticle(particle: CloudPoint): CloudPoint;
  129001. /**
  129002. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  129003. * This does nothing and may be overwritten by the user.
  129004. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  129005. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  129006. * @param update the boolean update value actually passed to setParticles()
  129007. */
  129008. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  129009. /**
  129010. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  129011. * This will be passed three parameters.
  129012. * This does nothing and may be overwritten by the user.
  129013. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  129014. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  129015. * @param update the boolean update value actually passed to setParticles()
  129016. */
  129017. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  129018. }
  129019. }
  129020. declare module BABYLON {
  129021. /**
  129022. * Represents one particle of a points cloud system.
  129023. */
  129024. export class CloudPoint {
  129025. /**
  129026. * particle global index
  129027. */
  129028. idx: number;
  129029. /**
  129030. * The color of the particle
  129031. */
  129032. color: Nullable<Color4>;
  129033. /**
  129034. * The world space position of the particle.
  129035. */
  129036. position: Vector3;
  129037. /**
  129038. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  129039. */
  129040. rotation: Vector3;
  129041. /**
  129042. * The world space rotation quaternion of the particle.
  129043. */
  129044. rotationQuaternion: Nullable<Quaternion>;
  129045. /**
  129046. * The uv of the particle.
  129047. */
  129048. uv: Nullable<Vector2>;
  129049. /**
  129050. * The current speed of the particle.
  129051. */
  129052. velocity: Vector3;
  129053. /**
  129054. * The pivot point in the particle local space.
  129055. */
  129056. pivot: Vector3;
  129057. /**
  129058. * Must the particle be translated from its pivot point in its local space ?
  129059. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  129060. * Default : false
  129061. */
  129062. translateFromPivot: boolean;
  129063. /**
  129064. * Index of this particle in the global "positions" array (Internal use)
  129065. * @hidden
  129066. */
  129067. _pos: number;
  129068. /**
  129069. * @hidden Index of this particle in the global "indices" array (Internal use)
  129070. */
  129071. _ind: number;
  129072. /**
  129073. * Group this particle belongs to
  129074. */
  129075. _group: PointsGroup;
  129076. /**
  129077. * Group id of this particle
  129078. */
  129079. groupId: number;
  129080. /**
  129081. * Index of the particle in its group id (Internal use)
  129082. */
  129083. idxInGroup: number;
  129084. /**
  129085. * @hidden Particle BoundingInfo object (Internal use)
  129086. */
  129087. _boundingInfo: BoundingInfo;
  129088. /**
  129089. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  129090. */
  129091. _pcs: PointsCloudSystem;
  129092. /**
  129093. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  129094. */
  129095. _stillInvisible: boolean;
  129096. /**
  129097. * @hidden Last computed particle rotation matrix
  129098. */
  129099. _rotationMatrix: number[];
  129100. /**
  129101. * Parent particle Id, if any.
  129102. * Default null.
  129103. */
  129104. parentId: Nullable<number>;
  129105. /**
  129106. * @hidden Internal global position in the PCS.
  129107. */
  129108. _globalPosition: Vector3;
  129109. /**
  129110. * Creates a Point Cloud object.
  129111. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  129112. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  129113. * @param group (PointsGroup) is the group the particle belongs to
  129114. * @param groupId (integer) is the group identifier in the PCS.
  129115. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  129116. * @param pcs defines the PCS it is associated to
  129117. */
  129118. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  129119. /**
  129120. * get point size
  129121. */
  129122. /**
  129123. * Set point size
  129124. */
  129125. size: Vector3;
  129126. /**
  129127. * Legacy support, changed quaternion to rotationQuaternion
  129128. */
  129129. /**
  129130. * Legacy support, changed quaternion to rotationQuaternion
  129131. */
  129132. quaternion: Nullable<Quaternion>;
  129133. /**
  129134. * Returns a boolean. True if the particle intersects a mesh, else false
  129135. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  129136. * @param target is the object (point or mesh) what the intersection is computed against
  129137. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  129138. * @returns true if it intersects
  129139. */
  129140. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  129141. /**
  129142. * get the rotation matrix of the particle
  129143. * @hidden
  129144. */
  129145. getRotationMatrix(m: Matrix): void;
  129146. }
  129147. /**
  129148. * Represents a group of points in a points cloud system
  129149. * * PCS internal tool, don't use it manually.
  129150. */
  129151. export class PointsGroup {
  129152. /**
  129153. * The group id
  129154. * @hidden
  129155. */
  129156. groupID: number;
  129157. /**
  129158. * image data for group (internal use)
  129159. * @hidden
  129160. */
  129161. _groupImageData: Nullable<ArrayBufferView>;
  129162. /**
  129163. * Image Width (internal use)
  129164. * @hidden
  129165. */
  129166. _groupImgWidth: number;
  129167. /**
  129168. * Image Height (internal use)
  129169. * @hidden
  129170. */
  129171. _groupImgHeight: number;
  129172. /**
  129173. * Custom position function (internal use)
  129174. * @hidden
  129175. */
  129176. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  129177. /**
  129178. * density per facet for surface points
  129179. * @hidden
  129180. */
  129181. _groupDensity: number[];
  129182. /**
  129183. * Only when points are colored by texture carries pointer to texture list array
  129184. * @hidden
  129185. */
  129186. _textureNb: number;
  129187. /**
  129188. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  129189. * PCS internal tool, don't use it manually.
  129190. * @hidden
  129191. */
  129192. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  129193. }
  129194. }
  129195. declare module BABYLON {
  129196. interface Scene {
  129197. /** @hidden (Backing field) */
  129198. _physicsEngine: Nullable<IPhysicsEngine>;
  129199. /** @hidden */
  129200. _physicsTimeAccumulator: number;
  129201. /**
  129202. * Gets the current physics engine
  129203. * @returns a IPhysicsEngine or null if none attached
  129204. */
  129205. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  129206. /**
  129207. * Enables physics to the current scene
  129208. * @param gravity defines the scene's gravity for the physics engine
  129209. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  129210. * @return a boolean indicating if the physics engine was initialized
  129211. */
  129212. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  129213. /**
  129214. * Disables and disposes the physics engine associated with the scene
  129215. */
  129216. disablePhysicsEngine(): void;
  129217. /**
  129218. * Gets a boolean indicating if there is an active physics engine
  129219. * @returns a boolean indicating if there is an active physics engine
  129220. */
  129221. isPhysicsEnabled(): boolean;
  129222. /**
  129223. * Deletes a physics compound impostor
  129224. * @param compound defines the compound to delete
  129225. */
  129226. deleteCompoundImpostor(compound: any): void;
  129227. /**
  129228. * An event triggered when physic simulation is about to be run
  129229. */
  129230. onBeforePhysicsObservable: Observable<Scene>;
  129231. /**
  129232. * An event triggered when physic simulation has been done
  129233. */
  129234. onAfterPhysicsObservable: Observable<Scene>;
  129235. }
  129236. interface AbstractMesh {
  129237. /** @hidden */
  129238. _physicsImpostor: Nullable<PhysicsImpostor>;
  129239. /**
  129240. * Gets or sets impostor used for physic simulation
  129241. * @see http://doc.babylonjs.com/features/physics_engine
  129242. */
  129243. physicsImpostor: Nullable<PhysicsImpostor>;
  129244. /**
  129245. * Gets the current physics impostor
  129246. * @see http://doc.babylonjs.com/features/physics_engine
  129247. * @returns a physics impostor or null
  129248. */
  129249. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  129250. /** Apply a physic impulse to the mesh
  129251. * @param force defines the force to apply
  129252. * @param contactPoint defines where to apply the force
  129253. * @returns the current mesh
  129254. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  129255. */
  129256. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  129257. /**
  129258. * Creates a physic joint between two meshes
  129259. * @param otherMesh defines the other mesh to use
  129260. * @param pivot1 defines the pivot to use on this mesh
  129261. * @param pivot2 defines the pivot to use on the other mesh
  129262. * @param options defines additional options (can be plugin dependent)
  129263. * @returns the current mesh
  129264. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  129265. */
  129266. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  129267. /** @hidden */
  129268. _disposePhysicsObserver: Nullable<Observer<Node>>;
  129269. }
  129270. /**
  129271. * Defines the physics engine scene component responsible to manage a physics engine
  129272. */
  129273. export class PhysicsEngineSceneComponent implements ISceneComponent {
  129274. /**
  129275. * The component name helpful to identify the component in the list of scene components.
  129276. */
  129277. readonly name: string;
  129278. /**
  129279. * The scene the component belongs to.
  129280. */
  129281. scene: Scene;
  129282. /**
  129283. * Creates a new instance of the component for the given scene
  129284. * @param scene Defines the scene to register the component in
  129285. */
  129286. constructor(scene: Scene);
  129287. /**
  129288. * Registers the component in a given scene
  129289. */
  129290. register(): void;
  129291. /**
  129292. * Rebuilds the elements related to this component in case of
  129293. * context lost for instance.
  129294. */
  129295. rebuild(): void;
  129296. /**
  129297. * Disposes the component and the associated ressources
  129298. */
  129299. dispose(): void;
  129300. }
  129301. }
  129302. declare module BABYLON {
  129303. /**
  129304. * A helper for physics simulations
  129305. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129306. */
  129307. export class PhysicsHelper {
  129308. private _scene;
  129309. private _physicsEngine;
  129310. /**
  129311. * Initializes the Physics helper
  129312. * @param scene Babylon.js scene
  129313. */
  129314. constructor(scene: Scene);
  129315. /**
  129316. * Applies a radial explosion impulse
  129317. * @param origin the origin of the explosion
  129318. * @param radiusOrEventOptions the radius or the options of radial explosion
  129319. * @param strength the explosion strength
  129320. * @param falloff possible options: Constant & Linear. Defaults to Constant
  129321. * @returns A physics radial explosion event, or null
  129322. */
  129323. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  129324. /**
  129325. * Applies a radial explosion force
  129326. * @param origin the origin of the explosion
  129327. * @param radiusOrEventOptions the radius or the options of radial explosion
  129328. * @param strength the explosion strength
  129329. * @param falloff possible options: Constant & Linear. Defaults to Constant
  129330. * @returns A physics radial explosion event, or null
  129331. */
  129332. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  129333. /**
  129334. * Creates a gravitational field
  129335. * @param origin the origin of the explosion
  129336. * @param radiusOrEventOptions the radius or the options of radial explosion
  129337. * @param strength the explosion strength
  129338. * @param falloff possible options: Constant & Linear. Defaults to Constant
  129339. * @returns A physics gravitational field event, or null
  129340. */
  129341. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  129342. /**
  129343. * Creates a physics updraft event
  129344. * @param origin the origin of the updraft
  129345. * @param radiusOrEventOptions the radius or the options of the updraft
  129346. * @param strength the strength of the updraft
  129347. * @param height the height of the updraft
  129348. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  129349. * @returns A physics updraft event, or null
  129350. */
  129351. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  129352. /**
  129353. * Creates a physics vortex event
  129354. * @param origin the of the vortex
  129355. * @param radiusOrEventOptions the radius or the options of the vortex
  129356. * @param strength the strength of the vortex
  129357. * @param height the height of the vortex
  129358. * @returns a Physics vortex event, or null
  129359. * A physics vortex event or null
  129360. */
  129361. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  129362. }
  129363. /**
  129364. * Represents a physics radial explosion event
  129365. */
  129366. class PhysicsRadialExplosionEvent {
  129367. private _scene;
  129368. private _options;
  129369. private _sphere;
  129370. private _dataFetched;
  129371. /**
  129372. * Initializes a radial explosioin event
  129373. * @param _scene BabylonJS scene
  129374. * @param _options The options for the vortex event
  129375. */
  129376. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  129377. /**
  129378. * Returns the data related to the radial explosion event (sphere).
  129379. * @returns The radial explosion event data
  129380. */
  129381. getData(): PhysicsRadialExplosionEventData;
  129382. /**
  129383. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  129384. * @param impostor A physics imposter
  129385. * @param origin the origin of the explosion
  129386. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  129387. */
  129388. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  129389. /**
  129390. * Triggers affecterd impostors callbacks
  129391. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  129392. */
  129393. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  129394. /**
  129395. * Disposes the sphere.
  129396. * @param force Specifies if the sphere should be disposed by force
  129397. */
  129398. dispose(force?: boolean): void;
  129399. /*** Helpers ***/
  129400. private _prepareSphere;
  129401. private _intersectsWithSphere;
  129402. }
  129403. /**
  129404. * Represents a gravitational field event
  129405. */
  129406. class PhysicsGravitationalFieldEvent {
  129407. private _physicsHelper;
  129408. private _scene;
  129409. private _origin;
  129410. private _options;
  129411. private _tickCallback;
  129412. private _sphere;
  129413. private _dataFetched;
  129414. /**
  129415. * Initializes the physics gravitational field event
  129416. * @param _physicsHelper A physics helper
  129417. * @param _scene BabylonJS scene
  129418. * @param _origin The origin position of the gravitational field event
  129419. * @param _options The options for the vortex event
  129420. */
  129421. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  129422. /**
  129423. * Returns the data related to the gravitational field event (sphere).
  129424. * @returns A gravitational field event
  129425. */
  129426. getData(): PhysicsGravitationalFieldEventData;
  129427. /**
  129428. * Enables the gravitational field.
  129429. */
  129430. enable(): void;
  129431. /**
  129432. * Disables the gravitational field.
  129433. */
  129434. disable(): void;
  129435. /**
  129436. * Disposes the sphere.
  129437. * @param force The force to dispose from the gravitational field event
  129438. */
  129439. dispose(force?: boolean): void;
  129440. private _tick;
  129441. }
  129442. /**
  129443. * Represents a physics updraft event
  129444. */
  129445. class PhysicsUpdraftEvent {
  129446. private _scene;
  129447. private _origin;
  129448. private _options;
  129449. private _physicsEngine;
  129450. private _originTop;
  129451. private _originDirection;
  129452. private _tickCallback;
  129453. private _cylinder;
  129454. private _cylinderPosition;
  129455. private _dataFetched;
  129456. /**
  129457. * Initializes the physics updraft event
  129458. * @param _scene BabylonJS scene
  129459. * @param _origin The origin position of the updraft
  129460. * @param _options The options for the updraft event
  129461. */
  129462. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  129463. /**
  129464. * Returns the data related to the updraft event (cylinder).
  129465. * @returns A physics updraft event
  129466. */
  129467. getData(): PhysicsUpdraftEventData;
  129468. /**
  129469. * Enables the updraft.
  129470. */
  129471. enable(): void;
  129472. /**
  129473. * Disables the updraft.
  129474. */
  129475. disable(): void;
  129476. /**
  129477. * Disposes the cylinder.
  129478. * @param force Specifies if the updraft should be disposed by force
  129479. */
  129480. dispose(force?: boolean): void;
  129481. private getImpostorHitData;
  129482. private _tick;
  129483. /*** Helpers ***/
  129484. private _prepareCylinder;
  129485. private _intersectsWithCylinder;
  129486. }
  129487. /**
  129488. * Represents a physics vortex event
  129489. */
  129490. class PhysicsVortexEvent {
  129491. private _scene;
  129492. private _origin;
  129493. private _options;
  129494. private _physicsEngine;
  129495. private _originTop;
  129496. private _tickCallback;
  129497. private _cylinder;
  129498. private _cylinderPosition;
  129499. private _dataFetched;
  129500. /**
  129501. * Initializes the physics vortex event
  129502. * @param _scene The BabylonJS scene
  129503. * @param _origin The origin position of the vortex
  129504. * @param _options The options for the vortex event
  129505. */
  129506. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  129507. /**
  129508. * Returns the data related to the vortex event (cylinder).
  129509. * @returns The physics vortex event data
  129510. */
  129511. getData(): PhysicsVortexEventData;
  129512. /**
  129513. * Enables the vortex.
  129514. */
  129515. enable(): void;
  129516. /**
  129517. * Disables the cortex.
  129518. */
  129519. disable(): void;
  129520. /**
  129521. * Disposes the sphere.
  129522. * @param force
  129523. */
  129524. dispose(force?: boolean): void;
  129525. private getImpostorHitData;
  129526. private _tick;
  129527. /*** Helpers ***/
  129528. private _prepareCylinder;
  129529. private _intersectsWithCylinder;
  129530. }
  129531. /**
  129532. * Options fot the radial explosion event
  129533. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129534. */
  129535. export class PhysicsRadialExplosionEventOptions {
  129536. /**
  129537. * The radius of the sphere for the radial explosion.
  129538. */
  129539. radius: number;
  129540. /**
  129541. * The strenth of the explosion.
  129542. */
  129543. strength: number;
  129544. /**
  129545. * The strenght of the force in correspondence to the distance of the affected object
  129546. */
  129547. falloff: PhysicsRadialImpulseFalloff;
  129548. /**
  129549. * Sphere options for the radial explosion.
  129550. */
  129551. sphere: {
  129552. segments: number;
  129553. diameter: number;
  129554. };
  129555. /**
  129556. * Sphere options for the radial explosion.
  129557. */
  129558. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  129559. }
  129560. /**
  129561. * Options fot the updraft event
  129562. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129563. */
  129564. export class PhysicsUpdraftEventOptions {
  129565. /**
  129566. * The radius of the cylinder for the vortex
  129567. */
  129568. radius: number;
  129569. /**
  129570. * The strenth of the updraft.
  129571. */
  129572. strength: number;
  129573. /**
  129574. * The height of the cylinder for the updraft.
  129575. */
  129576. height: number;
  129577. /**
  129578. * The mode for the the updraft.
  129579. */
  129580. updraftMode: PhysicsUpdraftMode;
  129581. }
  129582. /**
  129583. * Options fot the vortex event
  129584. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129585. */
  129586. export class PhysicsVortexEventOptions {
  129587. /**
  129588. * The radius of the cylinder for the vortex
  129589. */
  129590. radius: number;
  129591. /**
  129592. * The strenth of the vortex.
  129593. */
  129594. strength: number;
  129595. /**
  129596. * The height of the cylinder for the vortex.
  129597. */
  129598. height: number;
  129599. /**
  129600. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  129601. */
  129602. centripetalForceThreshold: number;
  129603. /**
  129604. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  129605. */
  129606. centripetalForceMultiplier: number;
  129607. /**
  129608. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  129609. */
  129610. centrifugalForceMultiplier: number;
  129611. /**
  129612. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  129613. */
  129614. updraftForceMultiplier: number;
  129615. }
  129616. /**
  129617. * The strenght of the force in correspondence to the distance of the affected object
  129618. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129619. */
  129620. export enum PhysicsRadialImpulseFalloff {
  129621. /** Defines that impulse is constant in strength across it's whole radius */
  129622. Constant = 0,
  129623. /** Defines that impulse gets weaker if it's further from the origin */
  129624. Linear = 1
  129625. }
  129626. /**
  129627. * The strength of the force in correspondence to the distance of the affected object
  129628. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129629. */
  129630. export enum PhysicsUpdraftMode {
  129631. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  129632. Center = 0,
  129633. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  129634. Perpendicular = 1
  129635. }
  129636. /**
  129637. * Interface for a physics hit data
  129638. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129639. */
  129640. export interface PhysicsHitData {
  129641. /**
  129642. * The force applied at the contact point
  129643. */
  129644. force: Vector3;
  129645. /**
  129646. * The contact point
  129647. */
  129648. contactPoint: Vector3;
  129649. /**
  129650. * The distance from the origin to the contact point
  129651. */
  129652. distanceFromOrigin: number;
  129653. }
  129654. /**
  129655. * Interface for radial explosion event data
  129656. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129657. */
  129658. export interface PhysicsRadialExplosionEventData {
  129659. /**
  129660. * A sphere used for the radial explosion event
  129661. */
  129662. sphere: Mesh;
  129663. }
  129664. /**
  129665. * Interface for gravitational field event data
  129666. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129667. */
  129668. export interface PhysicsGravitationalFieldEventData {
  129669. /**
  129670. * A sphere mesh used for the gravitational field event
  129671. */
  129672. sphere: Mesh;
  129673. }
  129674. /**
  129675. * Interface for updraft event data
  129676. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129677. */
  129678. export interface PhysicsUpdraftEventData {
  129679. /**
  129680. * A cylinder used for the updraft event
  129681. */
  129682. cylinder: Mesh;
  129683. }
  129684. /**
  129685. * Interface for vortex event data
  129686. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129687. */
  129688. export interface PhysicsVortexEventData {
  129689. /**
  129690. * A cylinder used for the vortex event
  129691. */
  129692. cylinder: Mesh;
  129693. }
  129694. /**
  129695. * Interface for an affected physics impostor
  129696. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129697. */
  129698. export interface PhysicsAffectedImpostorWithData {
  129699. /**
  129700. * The impostor affected by the effect
  129701. */
  129702. impostor: PhysicsImpostor;
  129703. /**
  129704. * The data about the hit/horce from the explosion
  129705. */
  129706. hitData: PhysicsHitData;
  129707. }
  129708. }
  129709. declare module BABYLON {
  129710. /** @hidden */
  129711. export var blackAndWhitePixelShader: {
  129712. name: string;
  129713. shader: string;
  129714. };
  129715. }
  129716. declare module BABYLON {
  129717. /**
  129718. * Post process used to render in black and white
  129719. */
  129720. export class BlackAndWhitePostProcess extends PostProcess {
  129721. /**
  129722. * Linear about to convert he result to black and white (default: 1)
  129723. */
  129724. degree: number;
  129725. /**
  129726. * Creates a black and white post process
  129727. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  129728. * @param name The name of the effect.
  129729. * @param options The required width/height ratio to downsize to before computing the render pass.
  129730. * @param camera The camera to apply the render pass to.
  129731. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129732. * @param engine The engine which the post process will be applied. (default: current engine)
  129733. * @param reusable If the post process can be reused on the same frame. (default: false)
  129734. */
  129735. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  129736. }
  129737. }
  129738. declare module BABYLON {
  129739. /**
  129740. * This represents a set of one or more post processes in Babylon.
  129741. * A post process can be used to apply a shader to a texture after it is rendered.
  129742. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  129743. */
  129744. export class PostProcessRenderEffect {
  129745. private _postProcesses;
  129746. private _getPostProcesses;
  129747. private _singleInstance;
  129748. private _cameras;
  129749. private _indicesForCamera;
  129750. /**
  129751. * Name of the effect
  129752. * @hidden
  129753. */
  129754. _name: string;
  129755. /**
  129756. * Instantiates a post process render effect.
  129757. * A post process can be used to apply a shader to a texture after it is rendered.
  129758. * @param engine The engine the effect is tied to
  129759. * @param name The name of the effect
  129760. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  129761. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  129762. */
  129763. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  129764. /**
  129765. * Checks if all the post processes in the effect are supported.
  129766. */
  129767. readonly isSupported: boolean;
  129768. /**
  129769. * Updates the current state of the effect
  129770. * @hidden
  129771. */
  129772. _update(): void;
  129773. /**
  129774. * Attaches the effect on cameras
  129775. * @param cameras The camera to attach to.
  129776. * @hidden
  129777. */
  129778. _attachCameras(cameras: Camera): void;
  129779. /**
  129780. * Attaches the effect on cameras
  129781. * @param cameras The camera to attach to.
  129782. * @hidden
  129783. */
  129784. _attachCameras(cameras: Camera[]): void;
  129785. /**
  129786. * Detaches the effect on cameras
  129787. * @param cameras The camera to detatch from.
  129788. * @hidden
  129789. */
  129790. _detachCameras(cameras: Camera): void;
  129791. /**
  129792. * Detatches the effect on cameras
  129793. * @param cameras The camera to detatch from.
  129794. * @hidden
  129795. */
  129796. _detachCameras(cameras: Camera[]): void;
  129797. /**
  129798. * Enables the effect on given cameras
  129799. * @param cameras The camera to enable.
  129800. * @hidden
  129801. */
  129802. _enable(cameras: Camera): void;
  129803. /**
  129804. * Enables the effect on given cameras
  129805. * @param cameras The camera to enable.
  129806. * @hidden
  129807. */
  129808. _enable(cameras: Nullable<Camera[]>): void;
  129809. /**
  129810. * Disables the effect on the given cameras
  129811. * @param cameras The camera to disable.
  129812. * @hidden
  129813. */
  129814. _disable(cameras: Camera): void;
  129815. /**
  129816. * Disables the effect on the given cameras
  129817. * @param cameras The camera to disable.
  129818. * @hidden
  129819. */
  129820. _disable(cameras: Nullable<Camera[]>): void;
  129821. /**
  129822. * Gets a list of the post processes contained in the effect.
  129823. * @param camera The camera to get the post processes on.
  129824. * @returns The list of the post processes in the effect.
  129825. */
  129826. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  129827. }
  129828. }
  129829. declare module BABYLON {
  129830. /** @hidden */
  129831. export var extractHighlightsPixelShader: {
  129832. name: string;
  129833. shader: string;
  129834. };
  129835. }
  129836. declare module BABYLON {
  129837. /**
  129838. * 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.
  129839. */
  129840. export class ExtractHighlightsPostProcess extends PostProcess {
  129841. /**
  129842. * The luminance threshold, pixels below this value will be set to black.
  129843. */
  129844. threshold: number;
  129845. /** @hidden */
  129846. _exposure: number;
  129847. /**
  129848. * Post process which has the input texture to be used when performing highlight extraction
  129849. * @hidden
  129850. */
  129851. _inputPostProcess: Nullable<PostProcess>;
  129852. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129853. }
  129854. }
  129855. declare module BABYLON {
  129856. /** @hidden */
  129857. export var bloomMergePixelShader: {
  129858. name: string;
  129859. shader: string;
  129860. };
  129861. }
  129862. declare module BABYLON {
  129863. /**
  129864. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  129865. */
  129866. export class BloomMergePostProcess extends PostProcess {
  129867. /** Weight of the bloom to be added to the original input. */
  129868. weight: number;
  129869. /**
  129870. * Creates a new instance of @see BloomMergePostProcess
  129871. * @param name The name of the effect.
  129872. * @param originalFromInput Post process which's input will be used for the merge.
  129873. * @param blurred Blurred highlights post process which's output will be used.
  129874. * @param weight Weight of the bloom to be added to the original input.
  129875. * @param options The required width/height ratio to downsize to before computing the render pass.
  129876. * @param camera The camera to apply the render pass to.
  129877. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129878. * @param engine The engine which the post process will be applied. (default: current engine)
  129879. * @param reusable If the post process can be reused on the same frame. (default: false)
  129880. * @param textureType Type of textures used when performing the post process. (default: 0)
  129881. * @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)
  129882. */
  129883. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  129884. /** Weight of the bloom to be added to the original input. */
  129885. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129886. }
  129887. }
  129888. declare module BABYLON {
  129889. /**
  129890. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  129891. */
  129892. export class BloomEffect extends PostProcessRenderEffect {
  129893. private bloomScale;
  129894. /**
  129895. * @hidden Internal
  129896. */
  129897. _effects: Array<PostProcess>;
  129898. /**
  129899. * @hidden Internal
  129900. */
  129901. _downscale: ExtractHighlightsPostProcess;
  129902. private _blurX;
  129903. private _blurY;
  129904. private _merge;
  129905. /**
  129906. * The luminance threshold to find bright areas of the image to bloom.
  129907. */
  129908. threshold: number;
  129909. /**
  129910. * The strength of the bloom.
  129911. */
  129912. weight: number;
  129913. /**
  129914. * Specifies the size of the bloom blur kernel, relative to the final output size
  129915. */
  129916. kernel: number;
  129917. /**
  129918. * Creates a new instance of @see BloomEffect
  129919. * @param scene The scene the effect belongs to.
  129920. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  129921. * @param bloomKernel The size of the kernel to be used when applying the blur.
  129922. * @param bloomWeight The the strength of bloom.
  129923. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  129924. * @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)
  129925. */
  129926. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  129927. /**
  129928. * Disposes each of the internal effects for a given camera.
  129929. * @param camera The camera to dispose the effect on.
  129930. */
  129931. disposeEffects(camera: Camera): void;
  129932. /**
  129933. * @hidden Internal
  129934. */
  129935. _updateEffects(): void;
  129936. /**
  129937. * Internal
  129938. * @returns if all the contained post processes are ready.
  129939. * @hidden
  129940. */
  129941. _isReady(): boolean;
  129942. }
  129943. }
  129944. declare module BABYLON {
  129945. /** @hidden */
  129946. export var chromaticAberrationPixelShader: {
  129947. name: string;
  129948. shader: string;
  129949. };
  129950. }
  129951. declare module BABYLON {
  129952. /**
  129953. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  129954. */
  129955. export class ChromaticAberrationPostProcess extends PostProcess {
  129956. /**
  129957. * The amount of seperation of rgb channels (default: 30)
  129958. */
  129959. aberrationAmount: number;
  129960. /**
  129961. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  129962. */
  129963. radialIntensity: number;
  129964. /**
  129965. * 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))
  129966. */
  129967. direction: Vector2;
  129968. /**
  129969. * 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))
  129970. */
  129971. centerPosition: Vector2;
  129972. /**
  129973. * Creates a new instance ChromaticAberrationPostProcess
  129974. * @param name The name of the effect.
  129975. * @param screenWidth The width of the screen to apply the effect on.
  129976. * @param screenHeight The height of the screen to apply the effect on.
  129977. * @param options The required width/height ratio to downsize to before computing the render pass.
  129978. * @param camera The camera to apply the render pass to.
  129979. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129980. * @param engine The engine which the post process will be applied. (default: current engine)
  129981. * @param reusable If the post process can be reused on the same frame. (default: false)
  129982. * @param textureType Type of textures used when performing the post process. (default: 0)
  129983. * @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)
  129984. */
  129985. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129986. }
  129987. }
  129988. declare module BABYLON {
  129989. /** @hidden */
  129990. export var circleOfConfusionPixelShader: {
  129991. name: string;
  129992. shader: string;
  129993. };
  129994. }
  129995. declare module BABYLON {
  129996. /**
  129997. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  129998. */
  129999. export class CircleOfConfusionPostProcess extends PostProcess {
  130000. /**
  130001. * 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.
  130002. */
  130003. lensSize: number;
  130004. /**
  130005. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  130006. */
  130007. fStop: number;
  130008. /**
  130009. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  130010. */
  130011. focusDistance: number;
  130012. /**
  130013. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  130014. */
  130015. focalLength: number;
  130016. private _depthTexture;
  130017. /**
  130018. * Creates a new instance CircleOfConfusionPostProcess
  130019. * @param name The name of the effect.
  130020. * @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.
  130021. * @param options The required width/height ratio to downsize to before computing the render pass.
  130022. * @param camera The camera to apply the render pass to.
  130023. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130024. * @param engine The engine which the post process will be applied. (default: current engine)
  130025. * @param reusable If the post process can be reused on the same frame. (default: false)
  130026. * @param textureType Type of textures used when performing the post process. (default: 0)
  130027. * @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)
  130028. */
  130029. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  130030. /**
  130031. * 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.
  130032. */
  130033. depthTexture: RenderTargetTexture;
  130034. }
  130035. }
  130036. declare module BABYLON {
  130037. /** @hidden */
  130038. export var colorCorrectionPixelShader: {
  130039. name: string;
  130040. shader: string;
  130041. };
  130042. }
  130043. declare module BABYLON {
  130044. /**
  130045. *
  130046. * This post-process allows the modification of rendered colors by using
  130047. * a 'look-up table' (LUT). This effect is also called Color Grading.
  130048. *
  130049. * The object needs to be provided an url to a texture containing the color
  130050. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  130051. * Use an image editing software to tweak the LUT to match your needs.
  130052. *
  130053. * For an example of a color LUT, see here:
  130054. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  130055. * For explanations on color grading, see here:
  130056. * @see http://udn.epicgames.com/Three/ColorGrading.html
  130057. *
  130058. */
  130059. export class ColorCorrectionPostProcess extends PostProcess {
  130060. private _colorTableTexture;
  130061. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  130062. }
  130063. }
  130064. declare module BABYLON {
  130065. /** @hidden */
  130066. export var convolutionPixelShader: {
  130067. name: string;
  130068. shader: string;
  130069. };
  130070. }
  130071. declare module BABYLON {
  130072. /**
  130073. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  130074. * input texture to perform effects such as edge detection or sharpening
  130075. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  130076. */
  130077. export class ConvolutionPostProcess extends PostProcess {
  130078. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  130079. kernel: number[];
  130080. /**
  130081. * Creates a new instance ConvolutionPostProcess
  130082. * @param name The name of the effect.
  130083. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  130084. * @param options The required width/height ratio to downsize to before computing the render pass.
  130085. * @param camera The camera to apply the render pass to.
  130086. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130087. * @param engine The engine which the post process will be applied. (default: current engine)
  130088. * @param reusable If the post process can be reused on the same frame. (default: false)
  130089. * @param textureType Type of textures used when performing the post process. (default: 0)
  130090. */
  130091. constructor(name: string,
  130092. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  130093. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  130094. /**
  130095. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  130096. */
  130097. static EdgeDetect0Kernel: number[];
  130098. /**
  130099. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  130100. */
  130101. static EdgeDetect1Kernel: number[];
  130102. /**
  130103. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  130104. */
  130105. static EdgeDetect2Kernel: number[];
  130106. /**
  130107. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  130108. */
  130109. static SharpenKernel: number[];
  130110. /**
  130111. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  130112. */
  130113. static EmbossKernel: number[];
  130114. /**
  130115. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  130116. */
  130117. static GaussianKernel: number[];
  130118. }
  130119. }
  130120. declare module BABYLON {
  130121. /**
  130122. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  130123. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  130124. * based on samples that have a large difference in distance than the center pixel.
  130125. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  130126. */
  130127. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  130128. direction: Vector2;
  130129. /**
  130130. * Creates a new instance CircleOfConfusionPostProcess
  130131. * @param name The name of the effect.
  130132. * @param scene The scene the effect belongs to.
  130133. * @param direction The direction the blur should be applied.
  130134. * @param kernel The size of the kernel used to blur.
  130135. * @param options The required width/height ratio to downsize to before computing the render pass.
  130136. * @param camera The camera to apply the render pass to.
  130137. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  130138. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  130139. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130140. * @param engine The engine which the post process will be applied. (default: current engine)
  130141. * @param reusable If the post process can be reused on the same frame. (default: false)
  130142. * @param textureType Type of textures used when performing the post process. (default: 0)
  130143. * @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)
  130144. */
  130145. 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);
  130146. }
  130147. }
  130148. declare module BABYLON {
  130149. /** @hidden */
  130150. export var depthOfFieldMergePixelShader: {
  130151. name: string;
  130152. shader: string;
  130153. };
  130154. }
  130155. declare module BABYLON {
  130156. /**
  130157. * Options to be set when merging outputs from the default pipeline.
  130158. */
  130159. export class DepthOfFieldMergePostProcessOptions {
  130160. /**
  130161. * The original image to merge on top of
  130162. */
  130163. originalFromInput: PostProcess;
  130164. /**
  130165. * Parameters to perform the merge of the depth of field effect
  130166. */
  130167. depthOfField?: {
  130168. circleOfConfusion: PostProcess;
  130169. blurSteps: Array<PostProcess>;
  130170. };
  130171. /**
  130172. * Parameters to perform the merge of bloom effect
  130173. */
  130174. bloom?: {
  130175. blurred: PostProcess;
  130176. weight: number;
  130177. };
  130178. }
  130179. /**
  130180. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  130181. */
  130182. export class DepthOfFieldMergePostProcess extends PostProcess {
  130183. private blurSteps;
  130184. /**
  130185. * Creates a new instance of DepthOfFieldMergePostProcess
  130186. * @param name The name of the effect.
  130187. * @param originalFromInput Post process which's input will be used for the merge.
  130188. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  130189. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  130190. * @param options The required width/height ratio to downsize to before computing the render pass.
  130191. * @param camera The camera to apply the render pass to.
  130192. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130193. * @param engine The engine which the post process will be applied. (default: current engine)
  130194. * @param reusable If the post process can be reused on the same frame. (default: false)
  130195. * @param textureType Type of textures used when performing the post process. (default: 0)
  130196. * @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)
  130197. */
  130198. 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);
  130199. /**
  130200. * Updates the effect with the current post process compile time values and recompiles the shader.
  130201. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  130202. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  130203. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  130204. * @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
  130205. * @param onCompiled Called when the shader has been compiled.
  130206. * @param onError Called if there is an error when compiling a shader.
  130207. */
  130208. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  130209. }
  130210. }
  130211. declare module BABYLON {
  130212. /**
  130213. * Specifies the level of max blur that should be applied when using the depth of field effect
  130214. */
  130215. export enum DepthOfFieldEffectBlurLevel {
  130216. /**
  130217. * Subtle blur
  130218. */
  130219. Low = 0,
  130220. /**
  130221. * Medium blur
  130222. */
  130223. Medium = 1,
  130224. /**
  130225. * Large blur
  130226. */
  130227. High = 2
  130228. }
  130229. /**
  130230. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  130231. */
  130232. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  130233. private _circleOfConfusion;
  130234. /**
  130235. * @hidden Internal, blurs from high to low
  130236. */
  130237. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  130238. private _depthOfFieldBlurY;
  130239. private _dofMerge;
  130240. /**
  130241. * @hidden Internal post processes in depth of field effect
  130242. */
  130243. _effects: Array<PostProcess>;
  130244. /**
  130245. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  130246. */
  130247. focalLength: number;
  130248. /**
  130249. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  130250. */
  130251. fStop: number;
  130252. /**
  130253. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  130254. */
  130255. focusDistance: number;
  130256. /**
  130257. * 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.
  130258. */
  130259. lensSize: number;
  130260. /**
  130261. * Creates a new instance DepthOfFieldEffect
  130262. * @param scene The scene the effect belongs to.
  130263. * @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.
  130264. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  130265. * @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)
  130266. */
  130267. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  130268. /**
  130269. * Get the current class name of the current effet
  130270. * @returns "DepthOfFieldEffect"
  130271. */
  130272. getClassName(): string;
  130273. /**
  130274. * 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.
  130275. */
  130276. depthTexture: RenderTargetTexture;
  130277. /**
  130278. * Disposes each of the internal effects for a given camera.
  130279. * @param camera The camera to dispose the effect on.
  130280. */
  130281. disposeEffects(camera: Camera): void;
  130282. /**
  130283. * @hidden Internal
  130284. */
  130285. _updateEffects(): void;
  130286. /**
  130287. * Internal
  130288. * @returns if all the contained post processes are ready.
  130289. * @hidden
  130290. */
  130291. _isReady(): boolean;
  130292. }
  130293. }
  130294. declare module BABYLON {
  130295. /** @hidden */
  130296. export var displayPassPixelShader: {
  130297. name: string;
  130298. shader: string;
  130299. };
  130300. }
  130301. declare module BABYLON {
  130302. /**
  130303. * DisplayPassPostProcess which produces an output the same as it's input
  130304. */
  130305. export class DisplayPassPostProcess extends PostProcess {
  130306. /**
  130307. * Creates the DisplayPassPostProcess
  130308. * @param name The name of the effect.
  130309. * @param options The required width/height ratio to downsize to before computing the render pass.
  130310. * @param camera The camera to apply the render pass to.
  130311. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130312. * @param engine The engine which the post process will be applied. (default: current engine)
  130313. * @param reusable If the post process can be reused on the same frame. (default: false)
  130314. */
  130315. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  130316. }
  130317. }
  130318. declare module BABYLON {
  130319. /** @hidden */
  130320. export var filterPixelShader: {
  130321. name: string;
  130322. shader: string;
  130323. };
  130324. }
  130325. declare module BABYLON {
  130326. /**
  130327. * Applies a kernel filter to the image
  130328. */
  130329. export class FilterPostProcess extends PostProcess {
  130330. /** The matrix to be applied to the image */
  130331. kernelMatrix: Matrix;
  130332. /**
  130333. *
  130334. * @param name The name of the effect.
  130335. * @param kernelMatrix The matrix to be applied to the image
  130336. * @param options The required width/height ratio to downsize to before computing the render pass.
  130337. * @param camera The camera to apply the render pass to.
  130338. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130339. * @param engine The engine which the post process will be applied. (default: current engine)
  130340. * @param reusable If the post process can be reused on the same frame. (default: false)
  130341. */
  130342. constructor(name: string,
  130343. /** The matrix to be applied to the image */
  130344. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  130345. }
  130346. }
  130347. declare module BABYLON {
  130348. /** @hidden */
  130349. export var fxaaPixelShader: {
  130350. name: string;
  130351. shader: string;
  130352. };
  130353. }
  130354. declare module BABYLON {
  130355. /** @hidden */
  130356. export var fxaaVertexShader: {
  130357. name: string;
  130358. shader: string;
  130359. };
  130360. }
  130361. declare module BABYLON {
  130362. /**
  130363. * Fxaa post process
  130364. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  130365. */
  130366. export class FxaaPostProcess extends PostProcess {
  130367. /** @hidden */
  130368. texelWidth: number;
  130369. /** @hidden */
  130370. texelHeight: number;
  130371. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  130372. private _getDefines;
  130373. }
  130374. }
  130375. declare module BABYLON {
  130376. /** @hidden */
  130377. export var grainPixelShader: {
  130378. name: string;
  130379. shader: string;
  130380. };
  130381. }
  130382. declare module BABYLON {
  130383. /**
  130384. * The GrainPostProcess adds noise to the image at mid luminance levels
  130385. */
  130386. export class GrainPostProcess extends PostProcess {
  130387. /**
  130388. * The intensity of the grain added (default: 30)
  130389. */
  130390. intensity: number;
  130391. /**
  130392. * If the grain should be randomized on every frame
  130393. */
  130394. animated: boolean;
  130395. /**
  130396. * Creates a new instance of @see GrainPostProcess
  130397. * @param name The name of the effect.
  130398. * @param options The required width/height ratio to downsize to before computing the render pass.
  130399. * @param camera The camera to apply the render pass to.
  130400. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130401. * @param engine The engine which the post process will be applied. (default: current engine)
  130402. * @param reusable If the post process can be reused on the same frame. (default: false)
  130403. * @param textureType Type of textures used when performing the post process. (default: 0)
  130404. * @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)
  130405. */
  130406. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  130407. }
  130408. }
  130409. declare module BABYLON {
  130410. /** @hidden */
  130411. export var highlightsPixelShader: {
  130412. name: string;
  130413. shader: string;
  130414. };
  130415. }
  130416. declare module BABYLON {
  130417. /**
  130418. * Extracts highlights from the image
  130419. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  130420. */
  130421. export class HighlightsPostProcess extends PostProcess {
  130422. /**
  130423. * Extracts highlights from the image
  130424. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  130425. * @param name The name of the effect.
  130426. * @param options The required width/height ratio to downsize to before computing the render pass.
  130427. * @param camera The camera to apply the render pass to.
  130428. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130429. * @param engine The engine which the post process will be applied. (default: current engine)
  130430. * @param reusable If the post process can be reused on the same frame. (default: false)
  130431. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  130432. */
  130433. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  130434. }
  130435. }
  130436. declare module BABYLON {
  130437. /** @hidden */
  130438. export var mrtFragmentDeclaration: {
  130439. name: string;
  130440. shader: string;
  130441. };
  130442. }
  130443. declare module BABYLON {
  130444. /** @hidden */
  130445. export var geometryPixelShader: {
  130446. name: string;
  130447. shader: string;
  130448. };
  130449. }
  130450. declare module BABYLON {
  130451. /** @hidden */
  130452. export var geometryVertexShader: {
  130453. name: string;
  130454. shader: string;
  130455. };
  130456. }
  130457. declare module BABYLON {
  130458. /** @hidden */
  130459. interface ISavedTransformationMatrix {
  130460. world: Matrix;
  130461. viewProjection: Matrix;
  130462. }
  130463. /**
  130464. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  130465. */
  130466. export class GeometryBufferRenderer {
  130467. /**
  130468. * Constant used to retrieve the position texture index in the G-Buffer textures array
  130469. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  130470. */
  130471. static readonly POSITION_TEXTURE_TYPE: number;
  130472. /**
  130473. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  130474. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  130475. */
  130476. static readonly VELOCITY_TEXTURE_TYPE: number;
  130477. /**
  130478. * Dictionary used to store the previous transformation matrices of each rendered mesh
  130479. * in order to compute objects velocities when enableVelocity is set to "true"
  130480. * @hidden
  130481. */
  130482. _previousTransformationMatrices: {
  130483. [index: number]: ISavedTransformationMatrix;
  130484. };
  130485. /**
  130486. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  130487. * in order to compute objects velocities when enableVelocity is set to "true"
  130488. * @hidden
  130489. */
  130490. _previousBonesTransformationMatrices: {
  130491. [index: number]: Float32Array;
  130492. };
  130493. /**
  130494. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  130495. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  130496. */
  130497. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  130498. private _scene;
  130499. private _multiRenderTarget;
  130500. private _ratio;
  130501. private _enablePosition;
  130502. private _enableVelocity;
  130503. private _positionIndex;
  130504. private _velocityIndex;
  130505. protected _effect: Effect;
  130506. protected _cachedDefines: string;
  130507. /**
  130508. * Set the render list (meshes to be rendered) used in the G buffer.
  130509. */
  130510. renderList: Mesh[];
  130511. /**
  130512. * Gets wether or not G buffer are supported by the running hardware.
  130513. * This requires draw buffer supports
  130514. */
  130515. readonly isSupported: boolean;
  130516. /**
  130517. * Returns the index of the given texture type in the G-Buffer textures array
  130518. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  130519. * @returns the index of the given texture type in the G-Buffer textures array
  130520. */
  130521. getTextureIndex(textureType: number): number;
  130522. /**
  130523. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  130524. */
  130525. /**
  130526. * Sets whether or not objects positions are enabled for the G buffer.
  130527. */
  130528. enablePosition: boolean;
  130529. /**
  130530. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  130531. */
  130532. /**
  130533. * Sets wether or not objects velocities are enabled for the G buffer.
  130534. */
  130535. enableVelocity: boolean;
  130536. /**
  130537. * Gets the scene associated with the buffer.
  130538. */
  130539. readonly scene: Scene;
  130540. /**
  130541. * Gets the ratio used by the buffer during its creation.
  130542. * How big is the buffer related to the main canvas.
  130543. */
  130544. readonly ratio: number;
  130545. /** @hidden */
  130546. static _SceneComponentInitialization: (scene: Scene) => void;
  130547. /**
  130548. * Creates a new G Buffer for the scene
  130549. * @param scene The scene the buffer belongs to
  130550. * @param ratio How big is the buffer related to the main canvas.
  130551. */
  130552. constructor(scene: Scene, ratio?: number);
  130553. /**
  130554. * Checks wether everything is ready to render a submesh to the G buffer.
  130555. * @param subMesh the submesh to check readiness for
  130556. * @param useInstances is the mesh drawn using instance or not
  130557. * @returns true if ready otherwise false
  130558. */
  130559. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  130560. /**
  130561. * Gets the current underlying G Buffer.
  130562. * @returns the buffer
  130563. */
  130564. getGBuffer(): MultiRenderTarget;
  130565. /**
  130566. * Gets the number of samples used to render the buffer (anti aliasing).
  130567. */
  130568. /**
  130569. * Sets the number of samples used to render the buffer (anti aliasing).
  130570. */
  130571. samples: number;
  130572. /**
  130573. * Disposes the renderer and frees up associated resources.
  130574. */
  130575. dispose(): void;
  130576. protected _createRenderTargets(): void;
  130577. private _copyBonesTransformationMatrices;
  130578. }
  130579. }
  130580. declare module BABYLON {
  130581. interface Scene {
  130582. /** @hidden (Backing field) */
  130583. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  130584. /**
  130585. * Gets or Sets the current geometry buffer associated to the scene.
  130586. */
  130587. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  130588. /**
  130589. * Enables a GeometryBufferRender and associates it with the scene
  130590. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  130591. * @returns the GeometryBufferRenderer
  130592. */
  130593. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  130594. /**
  130595. * Disables the GeometryBufferRender associated with the scene
  130596. */
  130597. disableGeometryBufferRenderer(): void;
  130598. }
  130599. /**
  130600. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  130601. * in several rendering techniques.
  130602. */
  130603. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  130604. /**
  130605. * The component name helpful to identify the component in the list of scene components.
  130606. */
  130607. readonly name: string;
  130608. /**
  130609. * The scene the component belongs to.
  130610. */
  130611. scene: Scene;
  130612. /**
  130613. * Creates a new instance of the component for the given scene
  130614. * @param scene Defines the scene to register the component in
  130615. */
  130616. constructor(scene: Scene);
  130617. /**
  130618. * Registers the component in a given scene
  130619. */
  130620. register(): void;
  130621. /**
  130622. * Rebuilds the elements related to this component in case of
  130623. * context lost for instance.
  130624. */
  130625. rebuild(): void;
  130626. /**
  130627. * Disposes the component and the associated ressources
  130628. */
  130629. dispose(): void;
  130630. private _gatherRenderTargets;
  130631. }
  130632. }
  130633. declare module BABYLON {
  130634. /** @hidden */
  130635. export var motionBlurPixelShader: {
  130636. name: string;
  130637. shader: string;
  130638. };
  130639. }
  130640. declare module BABYLON {
  130641. /**
  130642. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  130643. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  130644. * As an example, all you have to do is to create the post-process:
  130645. * var mb = new BABYLON.MotionBlurPostProcess(
  130646. * 'mb', // The name of the effect.
  130647. * scene, // The scene containing the objects to blur according to their velocity.
  130648. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  130649. * camera // The camera to apply the render pass to.
  130650. * );
  130651. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  130652. */
  130653. export class MotionBlurPostProcess extends PostProcess {
  130654. /**
  130655. * Defines how much the image is blurred by the movement. Default value is equal to 1
  130656. */
  130657. motionStrength: number;
  130658. /**
  130659. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  130660. */
  130661. /**
  130662. * Sets the number of iterations to be used for motion blur quality
  130663. */
  130664. motionBlurSamples: number;
  130665. private _motionBlurSamples;
  130666. private _geometryBufferRenderer;
  130667. /**
  130668. * Creates a new instance MotionBlurPostProcess
  130669. * @param name The name of the effect.
  130670. * @param scene The scene containing the objects to blur according to their velocity.
  130671. * @param options The required width/height ratio to downsize to before computing the render pass.
  130672. * @param camera The camera to apply the render pass to.
  130673. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130674. * @param engine The engine which the post process will be applied. (default: current engine)
  130675. * @param reusable If the post process can be reused on the same frame. (default: false)
  130676. * @param textureType Type of textures used when performing the post process. (default: 0)
  130677. * @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)
  130678. */
  130679. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  130680. /**
  130681. * Excludes the given skinned mesh from computing bones velocities.
  130682. * 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.
  130683. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  130684. */
  130685. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  130686. /**
  130687. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  130688. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  130689. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  130690. */
  130691. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  130692. /**
  130693. * Disposes the post process.
  130694. * @param camera The camera to dispose the post process on.
  130695. */
  130696. dispose(camera?: Camera): void;
  130697. }
  130698. }
  130699. declare module BABYLON {
  130700. /** @hidden */
  130701. export var refractionPixelShader: {
  130702. name: string;
  130703. shader: string;
  130704. };
  130705. }
  130706. declare module BABYLON {
  130707. /**
  130708. * Post process which applies a refractin texture
  130709. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  130710. */
  130711. export class RefractionPostProcess extends PostProcess {
  130712. /** the base color of the refraction (used to taint the rendering) */
  130713. color: Color3;
  130714. /** simulated refraction depth */
  130715. depth: number;
  130716. /** the coefficient of the base color (0 to remove base color tainting) */
  130717. colorLevel: number;
  130718. private _refTexture;
  130719. private _ownRefractionTexture;
  130720. /**
  130721. * Gets or sets the refraction texture
  130722. * Please note that you are responsible for disposing the texture if you set it manually
  130723. */
  130724. refractionTexture: Texture;
  130725. /**
  130726. * Initializes the RefractionPostProcess
  130727. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  130728. * @param name The name of the effect.
  130729. * @param refractionTextureUrl Url of the refraction texture to use
  130730. * @param color the base color of the refraction (used to taint the rendering)
  130731. * @param depth simulated refraction depth
  130732. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  130733. * @param camera The camera to apply the render pass to.
  130734. * @param options The required width/height ratio to downsize to before computing the render pass.
  130735. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130736. * @param engine The engine which the post process will be applied. (default: current engine)
  130737. * @param reusable If the post process can be reused on the same frame. (default: false)
  130738. */
  130739. constructor(name: string, refractionTextureUrl: string,
  130740. /** the base color of the refraction (used to taint the rendering) */
  130741. color: Color3,
  130742. /** simulated refraction depth */
  130743. depth: number,
  130744. /** the coefficient of the base color (0 to remove base color tainting) */
  130745. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  130746. /**
  130747. * Disposes of the post process
  130748. * @param camera Camera to dispose post process on
  130749. */
  130750. dispose(camera: Camera): void;
  130751. }
  130752. }
  130753. declare module BABYLON {
  130754. /** @hidden */
  130755. export var sharpenPixelShader: {
  130756. name: string;
  130757. shader: string;
  130758. };
  130759. }
  130760. declare module BABYLON {
  130761. /**
  130762. * The SharpenPostProcess applies a sharpen kernel to every pixel
  130763. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  130764. */
  130765. export class SharpenPostProcess extends PostProcess {
  130766. /**
  130767. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  130768. */
  130769. colorAmount: number;
  130770. /**
  130771. * How much sharpness should be applied (default: 0.3)
  130772. */
  130773. edgeAmount: number;
  130774. /**
  130775. * Creates a new instance ConvolutionPostProcess
  130776. * @param name The name of the effect.
  130777. * @param options The required width/height ratio to downsize to before computing the render pass.
  130778. * @param camera The camera to apply the render pass to.
  130779. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130780. * @param engine The engine which the post process will be applied. (default: current engine)
  130781. * @param reusable If the post process can be reused on the same frame. (default: false)
  130782. * @param textureType Type of textures used when performing the post process. (default: 0)
  130783. * @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)
  130784. */
  130785. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  130786. }
  130787. }
  130788. declare module BABYLON {
  130789. /**
  130790. * PostProcessRenderPipeline
  130791. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  130792. */
  130793. export class PostProcessRenderPipeline {
  130794. private engine;
  130795. private _renderEffects;
  130796. private _renderEffectsForIsolatedPass;
  130797. /**
  130798. * List of inspectable custom properties (used by the Inspector)
  130799. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  130800. */
  130801. inspectableCustomProperties: IInspectable[];
  130802. /**
  130803. * @hidden
  130804. */
  130805. protected _cameras: Camera[];
  130806. /** @hidden */
  130807. _name: string;
  130808. /**
  130809. * Gets pipeline name
  130810. */
  130811. readonly name: string;
  130812. /** Gets the list of attached cameras */
  130813. readonly cameras: Camera[];
  130814. /**
  130815. * Initializes a PostProcessRenderPipeline
  130816. * @param engine engine to add the pipeline to
  130817. * @param name name of the pipeline
  130818. */
  130819. constructor(engine: Engine, name: string);
  130820. /**
  130821. * Gets the class name
  130822. * @returns "PostProcessRenderPipeline"
  130823. */
  130824. getClassName(): string;
  130825. /**
  130826. * If all the render effects in the pipeline are supported
  130827. */
  130828. readonly isSupported: boolean;
  130829. /**
  130830. * Adds an effect to the pipeline
  130831. * @param renderEffect the effect to add
  130832. */
  130833. addEffect(renderEffect: PostProcessRenderEffect): void;
  130834. /** @hidden */
  130835. _rebuild(): void;
  130836. /** @hidden */
  130837. _enableEffect(renderEffectName: string, cameras: Camera): void;
  130838. /** @hidden */
  130839. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  130840. /** @hidden */
  130841. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  130842. /** @hidden */
  130843. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  130844. /** @hidden */
  130845. _attachCameras(cameras: Camera, unique: boolean): void;
  130846. /** @hidden */
  130847. _attachCameras(cameras: Camera[], unique: boolean): void;
  130848. /** @hidden */
  130849. _detachCameras(cameras: Camera): void;
  130850. /** @hidden */
  130851. _detachCameras(cameras: Nullable<Camera[]>): void;
  130852. /** @hidden */
  130853. _update(): void;
  130854. /** @hidden */
  130855. _reset(): void;
  130856. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  130857. /**
  130858. * Disposes of the pipeline
  130859. */
  130860. dispose(): void;
  130861. }
  130862. }
  130863. declare module BABYLON {
  130864. /**
  130865. * PostProcessRenderPipelineManager class
  130866. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  130867. */
  130868. export class PostProcessRenderPipelineManager {
  130869. private _renderPipelines;
  130870. /**
  130871. * Initializes a PostProcessRenderPipelineManager
  130872. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  130873. */
  130874. constructor();
  130875. /**
  130876. * Gets the list of supported render pipelines
  130877. */
  130878. readonly supportedPipelines: PostProcessRenderPipeline[];
  130879. /**
  130880. * Adds a pipeline to the manager
  130881. * @param renderPipeline The pipeline to add
  130882. */
  130883. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  130884. /**
  130885. * Attaches a camera to the pipeline
  130886. * @param renderPipelineName The name of the pipeline to attach to
  130887. * @param cameras the camera to attach
  130888. * @param unique if the camera can be attached multiple times to the pipeline
  130889. */
  130890. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  130891. /**
  130892. * Detaches a camera from the pipeline
  130893. * @param renderPipelineName The name of the pipeline to detach from
  130894. * @param cameras the camera to detach
  130895. */
  130896. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  130897. /**
  130898. * Enables an effect by name on a pipeline
  130899. * @param renderPipelineName the name of the pipeline to enable the effect in
  130900. * @param renderEffectName the name of the effect to enable
  130901. * @param cameras the cameras that the effect should be enabled on
  130902. */
  130903. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  130904. /**
  130905. * Disables an effect by name on a pipeline
  130906. * @param renderPipelineName the name of the pipeline to disable the effect in
  130907. * @param renderEffectName the name of the effect to disable
  130908. * @param cameras the cameras that the effect should be disabled on
  130909. */
  130910. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  130911. /**
  130912. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  130913. */
  130914. update(): void;
  130915. /** @hidden */
  130916. _rebuild(): void;
  130917. /**
  130918. * Disposes of the manager and pipelines
  130919. */
  130920. dispose(): void;
  130921. }
  130922. }
  130923. declare module BABYLON {
  130924. interface Scene {
  130925. /** @hidden (Backing field) */
  130926. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  130927. /**
  130928. * Gets the postprocess render pipeline manager
  130929. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  130930. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  130931. */
  130932. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  130933. }
  130934. /**
  130935. * Defines the Render Pipeline scene component responsible to rendering pipelines
  130936. */
  130937. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  130938. /**
  130939. * The component name helpfull to identify the component in the list of scene components.
  130940. */
  130941. readonly name: string;
  130942. /**
  130943. * The scene the component belongs to.
  130944. */
  130945. scene: Scene;
  130946. /**
  130947. * Creates a new instance of the component for the given scene
  130948. * @param scene Defines the scene to register the component in
  130949. */
  130950. constructor(scene: Scene);
  130951. /**
  130952. * Registers the component in a given scene
  130953. */
  130954. register(): void;
  130955. /**
  130956. * Rebuilds the elements related to this component in case of
  130957. * context lost for instance.
  130958. */
  130959. rebuild(): void;
  130960. /**
  130961. * Disposes the component and the associated ressources
  130962. */
  130963. dispose(): void;
  130964. private _gatherRenderTargets;
  130965. }
  130966. }
  130967. declare module BABYLON {
  130968. /**
  130969. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  130970. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  130971. */
  130972. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  130973. private _scene;
  130974. private _camerasToBeAttached;
  130975. /**
  130976. * ID of the sharpen post process,
  130977. */
  130978. private readonly SharpenPostProcessId;
  130979. /**
  130980. * @ignore
  130981. * ID of the image processing post process;
  130982. */
  130983. readonly ImageProcessingPostProcessId: string;
  130984. /**
  130985. * @ignore
  130986. * ID of the Fast Approximate Anti-Aliasing post process;
  130987. */
  130988. readonly FxaaPostProcessId: string;
  130989. /**
  130990. * ID of the chromatic aberration post process,
  130991. */
  130992. private readonly ChromaticAberrationPostProcessId;
  130993. /**
  130994. * ID of the grain post process
  130995. */
  130996. private readonly GrainPostProcessId;
  130997. /**
  130998. * Sharpen post process which will apply a sharpen convolution to enhance edges
  130999. */
  131000. sharpen: SharpenPostProcess;
  131001. private _sharpenEffect;
  131002. private bloom;
  131003. /**
  131004. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  131005. */
  131006. depthOfField: DepthOfFieldEffect;
  131007. /**
  131008. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  131009. */
  131010. fxaa: FxaaPostProcess;
  131011. /**
  131012. * Image post processing pass used to perform operations such as tone mapping or color grading.
  131013. */
  131014. imageProcessing: ImageProcessingPostProcess;
  131015. /**
  131016. * Chromatic aberration post process which will shift rgb colors in the image
  131017. */
  131018. chromaticAberration: ChromaticAberrationPostProcess;
  131019. private _chromaticAberrationEffect;
  131020. /**
  131021. * Grain post process which add noise to the image
  131022. */
  131023. grain: GrainPostProcess;
  131024. private _grainEffect;
  131025. /**
  131026. * Glow post process which adds a glow to emissive areas of the image
  131027. */
  131028. private _glowLayer;
  131029. /**
  131030. * Animations which can be used to tweak settings over a period of time
  131031. */
  131032. animations: Animation[];
  131033. private _imageProcessingConfigurationObserver;
  131034. private _sharpenEnabled;
  131035. private _bloomEnabled;
  131036. private _depthOfFieldEnabled;
  131037. private _depthOfFieldBlurLevel;
  131038. private _fxaaEnabled;
  131039. private _imageProcessingEnabled;
  131040. private _defaultPipelineTextureType;
  131041. private _bloomScale;
  131042. private _chromaticAberrationEnabled;
  131043. private _grainEnabled;
  131044. private _buildAllowed;
  131045. /**
  131046. * Gets active scene
  131047. */
  131048. readonly scene: Scene;
  131049. /**
  131050. * Enable or disable the sharpen process from the pipeline
  131051. */
  131052. sharpenEnabled: boolean;
  131053. private _resizeObserver;
  131054. private _hardwareScaleLevel;
  131055. private _bloomKernel;
  131056. /**
  131057. * Specifies the size of the bloom blur kernel, relative to the final output size
  131058. */
  131059. bloomKernel: number;
  131060. /**
  131061. * Specifies the weight of the bloom in the final rendering
  131062. */
  131063. private _bloomWeight;
  131064. /**
  131065. * Specifies the luma threshold for the area that will be blurred by the bloom
  131066. */
  131067. private _bloomThreshold;
  131068. private _hdr;
  131069. /**
  131070. * The strength of the bloom.
  131071. */
  131072. bloomWeight: number;
  131073. /**
  131074. * The strength of the bloom.
  131075. */
  131076. bloomThreshold: number;
  131077. /**
  131078. * The scale of the bloom, lower value will provide better performance.
  131079. */
  131080. bloomScale: number;
  131081. /**
  131082. * Enable or disable the bloom from the pipeline
  131083. */
  131084. bloomEnabled: boolean;
  131085. private _rebuildBloom;
  131086. /**
  131087. * If the depth of field is enabled.
  131088. */
  131089. depthOfFieldEnabled: boolean;
  131090. /**
  131091. * Blur level of the depth of field effect. (Higher blur will effect performance)
  131092. */
  131093. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  131094. /**
  131095. * If the anti aliasing is enabled.
  131096. */
  131097. fxaaEnabled: boolean;
  131098. private _samples;
  131099. /**
  131100. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  131101. */
  131102. samples: number;
  131103. /**
  131104. * If image processing is enabled.
  131105. */
  131106. imageProcessingEnabled: boolean;
  131107. /**
  131108. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  131109. */
  131110. glowLayerEnabled: boolean;
  131111. /**
  131112. * Gets the glow layer (or null if not defined)
  131113. */
  131114. readonly glowLayer: Nullable<GlowLayer>;
  131115. /**
  131116. * Enable or disable the chromaticAberration process from the pipeline
  131117. */
  131118. chromaticAberrationEnabled: boolean;
  131119. /**
  131120. * Enable or disable the grain process from the pipeline
  131121. */
  131122. grainEnabled: boolean;
  131123. /**
  131124. * @constructor
  131125. * @param name - The rendering pipeline name (default: "")
  131126. * @param hdr - If high dynamic range textures should be used (default: true)
  131127. * @param scene - The scene linked to this pipeline (default: the last created scene)
  131128. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  131129. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  131130. */
  131131. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  131132. /**
  131133. * Get the class name
  131134. * @returns "DefaultRenderingPipeline"
  131135. */
  131136. getClassName(): string;
  131137. /**
  131138. * Force the compilation of the entire pipeline.
  131139. */
  131140. prepare(): void;
  131141. private _hasCleared;
  131142. private _prevPostProcess;
  131143. private _prevPrevPostProcess;
  131144. private _setAutoClearAndTextureSharing;
  131145. private _depthOfFieldSceneObserver;
  131146. private _buildPipeline;
  131147. private _disposePostProcesses;
  131148. /**
  131149. * Adds a camera to the pipeline
  131150. * @param camera the camera to be added
  131151. */
  131152. addCamera(camera: Camera): void;
  131153. /**
  131154. * Removes a camera from the pipeline
  131155. * @param camera the camera to remove
  131156. */
  131157. removeCamera(camera: Camera): void;
  131158. /**
  131159. * Dispose of the pipeline and stop all post processes
  131160. */
  131161. dispose(): void;
  131162. /**
  131163. * Serialize the rendering pipeline (Used when exporting)
  131164. * @returns the serialized object
  131165. */
  131166. serialize(): any;
  131167. /**
  131168. * Parse the serialized pipeline
  131169. * @param source Source pipeline.
  131170. * @param scene The scene to load the pipeline to.
  131171. * @param rootUrl The URL of the serialized pipeline.
  131172. * @returns An instantiated pipeline from the serialized object.
  131173. */
  131174. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  131175. }
  131176. }
  131177. declare module BABYLON {
  131178. /** @hidden */
  131179. export var lensHighlightsPixelShader: {
  131180. name: string;
  131181. shader: string;
  131182. };
  131183. }
  131184. declare module BABYLON {
  131185. /** @hidden */
  131186. export var depthOfFieldPixelShader: {
  131187. name: string;
  131188. shader: string;
  131189. };
  131190. }
  131191. declare module BABYLON {
  131192. /**
  131193. * BABYLON.JS Chromatic Aberration GLSL Shader
  131194. * Author: Olivier Guyot
  131195. * Separates very slightly R, G and B colors on the edges of the screen
  131196. * Inspired by Francois Tarlier & Martins Upitis
  131197. */
  131198. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  131199. /**
  131200. * @ignore
  131201. * The chromatic aberration PostProcess id in the pipeline
  131202. */
  131203. LensChromaticAberrationEffect: string;
  131204. /**
  131205. * @ignore
  131206. * The highlights enhancing PostProcess id in the pipeline
  131207. */
  131208. HighlightsEnhancingEffect: string;
  131209. /**
  131210. * @ignore
  131211. * The depth-of-field PostProcess id in the pipeline
  131212. */
  131213. LensDepthOfFieldEffect: string;
  131214. private _scene;
  131215. private _depthTexture;
  131216. private _grainTexture;
  131217. private _chromaticAberrationPostProcess;
  131218. private _highlightsPostProcess;
  131219. private _depthOfFieldPostProcess;
  131220. private _edgeBlur;
  131221. private _grainAmount;
  131222. private _chromaticAberration;
  131223. private _distortion;
  131224. private _highlightsGain;
  131225. private _highlightsThreshold;
  131226. private _dofDistance;
  131227. private _dofAperture;
  131228. private _dofDarken;
  131229. private _dofPentagon;
  131230. private _blurNoise;
  131231. /**
  131232. * @constructor
  131233. *
  131234. * Effect parameters are as follow:
  131235. * {
  131236. * chromatic_aberration: number; // from 0 to x (1 for realism)
  131237. * edge_blur: number; // from 0 to x (1 for realism)
  131238. * distortion: number; // from 0 to x (1 for realism)
  131239. * grain_amount: number; // from 0 to 1
  131240. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  131241. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  131242. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  131243. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  131244. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  131245. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  131246. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  131247. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  131248. * }
  131249. * Note: if an effect parameter is unset, effect is disabled
  131250. *
  131251. * @param name The rendering pipeline name
  131252. * @param parameters - An object containing all parameters (see above)
  131253. * @param scene The scene linked to this pipeline
  131254. * @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)
  131255. * @param cameras The array of cameras that the rendering pipeline will be attached to
  131256. */
  131257. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  131258. /**
  131259. * Get the class name
  131260. * @returns "LensRenderingPipeline"
  131261. */
  131262. getClassName(): string;
  131263. /**
  131264. * Gets associated scene
  131265. */
  131266. readonly scene: Scene;
  131267. /**
  131268. * Gets or sets the edge blur
  131269. */
  131270. edgeBlur: number;
  131271. /**
  131272. * Gets or sets the grain amount
  131273. */
  131274. grainAmount: number;
  131275. /**
  131276. * Gets or sets the chromatic aberration amount
  131277. */
  131278. chromaticAberration: number;
  131279. /**
  131280. * Gets or sets the depth of field aperture
  131281. */
  131282. dofAperture: number;
  131283. /**
  131284. * Gets or sets the edge distortion
  131285. */
  131286. edgeDistortion: number;
  131287. /**
  131288. * Gets or sets the depth of field distortion
  131289. */
  131290. dofDistortion: number;
  131291. /**
  131292. * Gets or sets the darken out of focus amount
  131293. */
  131294. darkenOutOfFocus: number;
  131295. /**
  131296. * Gets or sets a boolean indicating if blur noise is enabled
  131297. */
  131298. blurNoise: boolean;
  131299. /**
  131300. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  131301. */
  131302. pentagonBokeh: boolean;
  131303. /**
  131304. * Gets or sets the highlight grain amount
  131305. */
  131306. highlightsGain: number;
  131307. /**
  131308. * Gets or sets the highlight threshold
  131309. */
  131310. highlightsThreshold: number;
  131311. /**
  131312. * Sets the amount of blur at the edges
  131313. * @param amount blur amount
  131314. */
  131315. setEdgeBlur(amount: number): void;
  131316. /**
  131317. * Sets edge blur to 0
  131318. */
  131319. disableEdgeBlur(): void;
  131320. /**
  131321. * Sets the amout of grain
  131322. * @param amount Amount of grain
  131323. */
  131324. setGrainAmount(amount: number): void;
  131325. /**
  131326. * Set grain amount to 0
  131327. */
  131328. disableGrain(): void;
  131329. /**
  131330. * Sets the chromatic aberration amount
  131331. * @param amount amount of chromatic aberration
  131332. */
  131333. setChromaticAberration(amount: number): void;
  131334. /**
  131335. * Sets chromatic aberration amount to 0
  131336. */
  131337. disableChromaticAberration(): void;
  131338. /**
  131339. * Sets the EdgeDistortion amount
  131340. * @param amount amount of EdgeDistortion
  131341. */
  131342. setEdgeDistortion(amount: number): void;
  131343. /**
  131344. * Sets edge distortion to 0
  131345. */
  131346. disableEdgeDistortion(): void;
  131347. /**
  131348. * Sets the FocusDistance amount
  131349. * @param amount amount of FocusDistance
  131350. */
  131351. setFocusDistance(amount: number): void;
  131352. /**
  131353. * Disables depth of field
  131354. */
  131355. disableDepthOfField(): void;
  131356. /**
  131357. * Sets the Aperture amount
  131358. * @param amount amount of Aperture
  131359. */
  131360. setAperture(amount: number): void;
  131361. /**
  131362. * Sets the DarkenOutOfFocus amount
  131363. * @param amount amount of DarkenOutOfFocus
  131364. */
  131365. setDarkenOutOfFocus(amount: number): void;
  131366. private _pentagonBokehIsEnabled;
  131367. /**
  131368. * Creates a pentagon bokeh effect
  131369. */
  131370. enablePentagonBokeh(): void;
  131371. /**
  131372. * Disables the pentagon bokeh effect
  131373. */
  131374. disablePentagonBokeh(): void;
  131375. /**
  131376. * Enables noise blur
  131377. */
  131378. enableNoiseBlur(): void;
  131379. /**
  131380. * Disables noise blur
  131381. */
  131382. disableNoiseBlur(): void;
  131383. /**
  131384. * Sets the HighlightsGain amount
  131385. * @param amount amount of HighlightsGain
  131386. */
  131387. setHighlightsGain(amount: number): void;
  131388. /**
  131389. * Sets the HighlightsThreshold amount
  131390. * @param amount amount of HighlightsThreshold
  131391. */
  131392. setHighlightsThreshold(amount: number): void;
  131393. /**
  131394. * Disables highlights
  131395. */
  131396. disableHighlights(): void;
  131397. /**
  131398. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  131399. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  131400. */
  131401. dispose(disableDepthRender?: boolean): void;
  131402. private _createChromaticAberrationPostProcess;
  131403. private _createHighlightsPostProcess;
  131404. private _createDepthOfFieldPostProcess;
  131405. private _createGrainTexture;
  131406. }
  131407. }
  131408. declare module BABYLON {
  131409. /** @hidden */
  131410. export var ssao2PixelShader: {
  131411. name: string;
  131412. shader: string;
  131413. };
  131414. }
  131415. declare module BABYLON {
  131416. /** @hidden */
  131417. export var ssaoCombinePixelShader: {
  131418. name: string;
  131419. shader: string;
  131420. };
  131421. }
  131422. declare module BABYLON {
  131423. /**
  131424. * Render pipeline to produce ssao effect
  131425. */
  131426. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  131427. /**
  131428. * @ignore
  131429. * The PassPostProcess id in the pipeline that contains the original scene color
  131430. */
  131431. SSAOOriginalSceneColorEffect: string;
  131432. /**
  131433. * @ignore
  131434. * The SSAO PostProcess id in the pipeline
  131435. */
  131436. SSAORenderEffect: string;
  131437. /**
  131438. * @ignore
  131439. * The horizontal blur PostProcess id in the pipeline
  131440. */
  131441. SSAOBlurHRenderEffect: string;
  131442. /**
  131443. * @ignore
  131444. * The vertical blur PostProcess id in the pipeline
  131445. */
  131446. SSAOBlurVRenderEffect: string;
  131447. /**
  131448. * @ignore
  131449. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  131450. */
  131451. SSAOCombineRenderEffect: string;
  131452. /**
  131453. * The output strength of the SSAO post-process. Default value is 1.0.
  131454. */
  131455. totalStrength: number;
  131456. /**
  131457. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  131458. */
  131459. maxZ: number;
  131460. /**
  131461. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  131462. */
  131463. minZAspect: number;
  131464. private _samples;
  131465. /**
  131466. * Number of samples used for the SSAO calculations. Default value is 8
  131467. */
  131468. samples: number;
  131469. private _textureSamples;
  131470. /**
  131471. * Number of samples to use for antialiasing
  131472. */
  131473. textureSamples: number;
  131474. /**
  131475. * Ratio object used for SSAO ratio and blur ratio
  131476. */
  131477. private _ratio;
  131478. /**
  131479. * Dynamically generated sphere sampler.
  131480. */
  131481. private _sampleSphere;
  131482. /**
  131483. * Blur filter offsets
  131484. */
  131485. private _samplerOffsets;
  131486. private _expensiveBlur;
  131487. /**
  131488. * If bilateral blur should be used
  131489. */
  131490. expensiveBlur: boolean;
  131491. /**
  131492. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  131493. */
  131494. radius: number;
  131495. /**
  131496. * The base color of the SSAO post-process
  131497. * The final result is "base + ssao" between [0, 1]
  131498. */
  131499. base: number;
  131500. /**
  131501. * Support test.
  131502. */
  131503. static readonly IsSupported: boolean;
  131504. private _scene;
  131505. private _depthTexture;
  131506. private _normalTexture;
  131507. private _randomTexture;
  131508. private _originalColorPostProcess;
  131509. private _ssaoPostProcess;
  131510. private _blurHPostProcess;
  131511. private _blurVPostProcess;
  131512. private _ssaoCombinePostProcess;
  131513. /**
  131514. * Gets active scene
  131515. */
  131516. readonly scene: Scene;
  131517. /**
  131518. * @constructor
  131519. * @param name The rendering pipeline name
  131520. * @param scene The scene linked to this pipeline
  131521. * @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 }
  131522. * @param cameras The array of cameras that the rendering pipeline will be attached to
  131523. */
  131524. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  131525. /**
  131526. * Get the class name
  131527. * @returns "SSAO2RenderingPipeline"
  131528. */
  131529. getClassName(): string;
  131530. /**
  131531. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  131532. */
  131533. dispose(disableGeometryBufferRenderer?: boolean): void;
  131534. private _createBlurPostProcess;
  131535. /** @hidden */
  131536. _rebuild(): void;
  131537. private _bits;
  131538. private _radicalInverse_VdC;
  131539. private _hammersley;
  131540. private _hemisphereSample_uniform;
  131541. private _generateHemisphere;
  131542. private _createSSAOPostProcess;
  131543. private _createSSAOCombinePostProcess;
  131544. private _createRandomTexture;
  131545. /**
  131546. * Serialize the rendering pipeline (Used when exporting)
  131547. * @returns the serialized object
  131548. */
  131549. serialize(): any;
  131550. /**
  131551. * Parse the serialized pipeline
  131552. * @param source Source pipeline.
  131553. * @param scene The scene to load the pipeline to.
  131554. * @param rootUrl The URL of the serialized pipeline.
  131555. * @returns An instantiated pipeline from the serialized object.
  131556. */
  131557. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  131558. }
  131559. }
  131560. declare module BABYLON {
  131561. /** @hidden */
  131562. export var ssaoPixelShader: {
  131563. name: string;
  131564. shader: string;
  131565. };
  131566. }
  131567. declare module BABYLON {
  131568. /**
  131569. * Render pipeline to produce ssao effect
  131570. */
  131571. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  131572. /**
  131573. * @ignore
  131574. * The PassPostProcess id in the pipeline that contains the original scene color
  131575. */
  131576. SSAOOriginalSceneColorEffect: string;
  131577. /**
  131578. * @ignore
  131579. * The SSAO PostProcess id in the pipeline
  131580. */
  131581. SSAORenderEffect: string;
  131582. /**
  131583. * @ignore
  131584. * The horizontal blur PostProcess id in the pipeline
  131585. */
  131586. SSAOBlurHRenderEffect: string;
  131587. /**
  131588. * @ignore
  131589. * The vertical blur PostProcess id in the pipeline
  131590. */
  131591. SSAOBlurVRenderEffect: string;
  131592. /**
  131593. * @ignore
  131594. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  131595. */
  131596. SSAOCombineRenderEffect: string;
  131597. /**
  131598. * The output strength of the SSAO post-process. Default value is 1.0.
  131599. */
  131600. totalStrength: number;
  131601. /**
  131602. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  131603. */
  131604. radius: number;
  131605. /**
  131606. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  131607. * Must not be equal to fallOff and superior to fallOff.
  131608. * Default value is 0.0075
  131609. */
  131610. area: number;
  131611. /**
  131612. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  131613. * Must not be equal to area and inferior to area.
  131614. * Default value is 0.000001
  131615. */
  131616. fallOff: number;
  131617. /**
  131618. * The base color of the SSAO post-process
  131619. * The final result is "base + ssao" between [0, 1]
  131620. */
  131621. base: number;
  131622. private _scene;
  131623. private _depthTexture;
  131624. private _randomTexture;
  131625. private _originalColorPostProcess;
  131626. private _ssaoPostProcess;
  131627. private _blurHPostProcess;
  131628. private _blurVPostProcess;
  131629. private _ssaoCombinePostProcess;
  131630. private _firstUpdate;
  131631. /**
  131632. * Gets active scene
  131633. */
  131634. readonly scene: Scene;
  131635. /**
  131636. * @constructor
  131637. * @param name - The rendering pipeline name
  131638. * @param scene - The scene linked to this pipeline
  131639. * @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 }
  131640. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  131641. */
  131642. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  131643. /**
  131644. * Get the class name
  131645. * @returns "SSAORenderingPipeline"
  131646. */
  131647. getClassName(): string;
  131648. /**
  131649. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  131650. */
  131651. dispose(disableDepthRender?: boolean): void;
  131652. private _createBlurPostProcess;
  131653. /** @hidden */
  131654. _rebuild(): void;
  131655. private _createSSAOPostProcess;
  131656. private _createSSAOCombinePostProcess;
  131657. private _createRandomTexture;
  131658. }
  131659. }
  131660. declare module BABYLON {
  131661. /** @hidden */
  131662. export var standardPixelShader: {
  131663. name: string;
  131664. shader: string;
  131665. };
  131666. }
  131667. declare module BABYLON {
  131668. /**
  131669. * Standard rendering pipeline
  131670. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  131671. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  131672. */
  131673. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  131674. /**
  131675. * Public members
  131676. */
  131677. /**
  131678. * Post-process which contains the original scene color before the pipeline applies all the effects
  131679. */
  131680. originalPostProcess: Nullable<PostProcess>;
  131681. /**
  131682. * Post-process used to down scale an image x4
  131683. */
  131684. downSampleX4PostProcess: Nullable<PostProcess>;
  131685. /**
  131686. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  131687. */
  131688. brightPassPostProcess: Nullable<PostProcess>;
  131689. /**
  131690. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  131691. */
  131692. blurHPostProcesses: PostProcess[];
  131693. /**
  131694. * Post-process array storing all the vertical blur post-processes used by the pipeline
  131695. */
  131696. blurVPostProcesses: PostProcess[];
  131697. /**
  131698. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  131699. */
  131700. textureAdderPostProcess: Nullable<PostProcess>;
  131701. /**
  131702. * Post-process used to create volumetric lighting effect
  131703. */
  131704. volumetricLightPostProcess: Nullable<PostProcess>;
  131705. /**
  131706. * Post-process used to smooth the previous volumetric light post-process on the X axis
  131707. */
  131708. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  131709. /**
  131710. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  131711. */
  131712. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  131713. /**
  131714. * Post-process used to merge the volumetric light effect and the real scene color
  131715. */
  131716. volumetricLightMergePostProces: Nullable<PostProcess>;
  131717. /**
  131718. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  131719. */
  131720. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  131721. /**
  131722. * Base post-process used to calculate the average luminance of the final image for HDR
  131723. */
  131724. luminancePostProcess: Nullable<PostProcess>;
  131725. /**
  131726. * Post-processes used to create down sample post-processes in order to get
  131727. * the average luminance of the final image for HDR
  131728. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  131729. */
  131730. luminanceDownSamplePostProcesses: PostProcess[];
  131731. /**
  131732. * Post-process used to create a HDR effect (light adaptation)
  131733. */
  131734. hdrPostProcess: Nullable<PostProcess>;
  131735. /**
  131736. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  131737. */
  131738. textureAdderFinalPostProcess: Nullable<PostProcess>;
  131739. /**
  131740. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  131741. */
  131742. lensFlareFinalPostProcess: Nullable<PostProcess>;
  131743. /**
  131744. * Post-process used to merge the final HDR post-process and the real scene color
  131745. */
  131746. hdrFinalPostProcess: Nullable<PostProcess>;
  131747. /**
  131748. * Post-process used to create a lens flare effect
  131749. */
  131750. lensFlarePostProcess: Nullable<PostProcess>;
  131751. /**
  131752. * Post-process that merges the result of the lens flare post-process and the real scene color
  131753. */
  131754. lensFlareComposePostProcess: Nullable<PostProcess>;
  131755. /**
  131756. * Post-process used to create a motion blur effect
  131757. */
  131758. motionBlurPostProcess: Nullable<PostProcess>;
  131759. /**
  131760. * Post-process used to create a depth of field effect
  131761. */
  131762. depthOfFieldPostProcess: Nullable<PostProcess>;
  131763. /**
  131764. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  131765. */
  131766. fxaaPostProcess: Nullable<FxaaPostProcess>;
  131767. /**
  131768. * Represents the brightness threshold in order to configure the illuminated surfaces
  131769. */
  131770. brightThreshold: number;
  131771. /**
  131772. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  131773. */
  131774. blurWidth: number;
  131775. /**
  131776. * Sets if the blur for highlighted surfaces must be only horizontal
  131777. */
  131778. horizontalBlur: boolean;
  131779. /**
  131780. * Gets the overall exposure used by the pipeline
  131781. */
  131782. /**
  131783. * Sets the overall exposure used by the pipeline
  131784. */
  131785. exposure: number;
  131786. /**
  131787. * Texture used typically to simulate "dirty" on camera lens
  131788. */
  131789. lensTexture: Nullable<Texture>;
  131790. /**
  131791. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  131792. */
  131793. volumetricLightCoefficient: number;
  131794. /**
  131795. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  131796. */
  131797. volumetricLightPower: number;
  131798. /**
  131799. * Used the set the blur intensity to smooth the volumetric lights
  131800. */
  131801. volumetricLightBlurScale: number;
  131802. /**
  131803. * Light (spot or directional) used to generate the volumetric lights rays
  131804. * The source light must have a shadow generate so the pipeline can get its
  131805. * depth map
  131806. */
  131807. sourceLight: Nullable<SpotLight | DirectionalLight>;
  131808. /**
  131809. * For eye adaptation, represents the minimum luminance the eye can see
  131810. */
  131811. hdrMinimumLuminance: number;
  131812. /**
  131813. * For eye adaptation, represents the decrease luminance speed
  131814. */
  131815. hdrDecreaseRate: number;
  131816. /**
  131817. * For eye adaptation, represents the increase luminance speed
  131818. */
  131819. hdrIncreaseRate: number;
  131820. /**
  131821. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  131822. */
  131823. /**
  131824. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  131825. */
  131826. hdrAutoExposure: boolean;
  131827. /**
  131828. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  131829. */
  131830. lensColorTexture: Nullable<Texture>;
  131831. /**
  131832. * The overall strengh for the lens flare effect
  131833. */
  131834. lensFlareStrength: number;
  131835. /**
  131836. * Dispersion coefficient for lens flare ghosts
  131837. */
  131838. lensFlareGhostDispersal: number;
  131839. /**
  131840. * Main lens flare halo width
  131841. */
  131842. lensFlareHaloWidth: number;
  131843. /**
  131844. * Based on the lens distortion effect, defines how much the lens flare result
  131845. * is distorted
  131846. */
  131847. lensFlareDistortionStrength: number;
  131848. /**
  131849. * Configures the blur intensity used for for lens flare (halo)
  131850. */
  131851. lensFlareBlurWidth: number;
  131852. /**
  131853. * Lens star texture must be used to simulate rays on the flares and is available
  131854. * in the documentation
  131855. */
  131856. lensStarTexture: Nullable<Texture>;
  131857. /**
  131858. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  131859. * flare effect by taking account of the dirt texture
  131860. */
  131861. lensFlareDirtTexture: Nullable<Texture>;
  131862. /**
  131863. * Represents the focal length for the depth of field effect
  131864. */
  131865. depthOfFieldDistance: number;
  131866. /**
  131867. * Represents the blur intensity for the blurred part of the depth of field effect
  131868. */
  131869. depthOfFieldBlurWidth: number;
  131870. /**
  131871. * Gets how much the image is blurred by the movement while using the motion blur post-process
  131872. */
  131873. /**
  131874. * Sets how much the image is blurred by the movement while using the motion blur post-process
  131875. */
  131876. motionStrength: number;
  131877. /**
  131878. * Gets wether or not the motion blur post-process is object based or screen based.
  131879. */
  131880. /**
  131881. * Sets wether or not the motion blur post-process should be object based or screen based
  131882. */
  131883. objectBasedMotionBlur: boolean;
  131884. /**
  131885. * List of animations for the pipeline (IAnimatable implementation)
  131886. */
  131887. animations: Animation[];
  131888. /**
  131889. * Private members
  131890. */
  131891. private _scene;
  131892. private _currentDepthOfFieldSource;
  131893. private _basePostProcess;
  131894. private _fixedExposure;
  131895. private _currentExposure;
  131896. private _hdrAutoExposure;
  131897. private _hdrCurrentLuminance;
  131898. private _motionStrength;
  131899. private _isObjectBasedMotionBlur;
  131900. private _floatTextureType;
  131901. private _camerasToBeAttached;
  131902. private _ratio;
  131903. private _bloomEnabled;
  131904. private _depthOfFieldEnabled;
  131905. private _vlsEnabled;
  131906. private _lensFlareEnabled;
  131907. private _hdrEnabled;
  131908. private _motionBlurEnabled;
  131909. private _fxaaEnabled;
  131910. private _motionBlurSamples;
  131911. private _volumetricLightStepsCount;
  131912. private _samples;
  131913. /**
  131914. * @ignore
  131915. * Specifies if the bloom pipeline is enabled
  131916. */
  131917. BloomEnabled: boolean;
  131918. /**
  131919. * @ignore
  131920. * Specifies if the depth of field pipeline is enabed
  131921. */
  131922. DepthOfFieldEnabled: boolean;
  131923. /**
  131924. * @ignore
  131925. * Specifies if the lens flare pipeline is enabed
  131926. */
  131927. LensFlareEnabled: boolean;
  131928. /**
  131929. * @ignore
  131930. * Specifies if the HDR pipeline is enabled
  131931. */
  131932. HDREnabled: boolean;
  131933. /**
  131934. * @ignore
  131935. * Specifies if the volumetric lights scattering effect is enabled
  131936. */
  131937. VLSEnabled: boolean;
  131938. /**
  131939. * @ignore
  131940. * Specifies if the motion blur effect is enabled
  131941. */
  131942. MotionBlurEnabled: boolean;
  131943. /**
  131944. * Specifies if anti-aliasing is enabled
  131945. */
  131946. fxaaEnabled: boolean;
  131947. /**
  131948. * Specifies the number of steps used to calculate the volumetric lights
  131949. * Typically in interval [50, 200]
  131950. */
  131951. volumetricLightStepsCount: number;
  131952. /**
  131953. * Specifies the number of samples used for the motion blur effect
  131954. * Typically in interval [16, 64]
  131955. */
  131956. motionBlurSamples: number;
  131957. /**
  131958. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  131959. */
  131960. samples: number;
  131961. /**
  131962. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  131963. * @constructor
  131964. * @param name The rendering pipeline name
  131965. * @param scene The scene linked to this pipeline
  131966. * @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)
  131967. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  131968. * @param cameras The array of cameras that the rendering pipeline will be attached to
  131969. */
  131970. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  131971. private _buildPipeline;
  131972. private _createDownSampleX4PostProcess;
  131973. private _createBrightPassPostProcess;
  131974. private _createBlurPostProcesses;
  131975. private _createTextureAdderPostProcess;
  131976. private _createVolumetricLightPostProcess;
  131977. private _createLuminancePostProcesses;
  131978. private _createHdrPostProcess;
  131979. private _createLensFlarePostProcess;
  131980. private _createDepthOfFieldPostProcess;
  131981. private _createMotionBlurPostProcess;
  131982. private _getDepthTexture;
  131983. private _disposePostProcesses;
  131984. /**
  131985. * Dispose of the pipeline and stop all post processes
  131986. */
  131987. dispose(): void;
  131988. /**
  131989. * Serialize the rendering pipeline (Used when exporting)
  131990. * @returns the serialized object
  131991. */
  131992. serialize(): any;
  131993. /**
  131994. * Parse the serialized pipeline
  131995. * @param source Source pipeline.
  131996. * @param scene The scene to load the pipeline to.
  131997. * @param rootUrl The URL of the serialized pipeline.
  131998. * @returns An instantiated pipeline from the serialized object.
  131999. */
  132000. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  132001. /**
  132002. * Luminance steps
  132003. */
  132004. static LuminanceSteps: number;
  132005. }
  132006. }
  132007. declare module BABYLON {
  132008. /** @hidden */
  132009. export var tonemapPixelShader: {
  132010. name: string;
  132011. shader: string;
  132012. };
  132013. }
  132014. declare module BABYLON {
  132015. /** Defines operator used for tonemapping */
  132016. export enum TonemappingOperator {
  132017. /** Hable */
  132018. Hable = 0,
  132019. /** Reinhard */
  132020. Reinhard = 1,
  132021. /** HejiDawson */
  132022. HejiDawson = 2,
  132023. /** Photographic */
  132024. Photographic = 3
  132025. }
  132026. /**
  132027. * Defines a post process to apply tone mapping
  132028. */
  132029. export class TonemapPostProcess extends PostProcess {
  132030. private _operator;
  132031. /** Defines the required exposure adjustement */
  132032. exposureAdjustment: number;
  132033. /**
  132034. * Creates a new TonemapPostProcess
  132035. * @param name defines the name of the postprocess
  132036. * @param _operator defines the operator to use
  132037. * @param exposureAdjustment defines the required exposure adjustement
  132038. * @param camera defines the camera to use (can be null)
  132039. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  132040. * @param engine defines the hosting engine (can be ignore if camera is set)
  132041. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  132042. */
  132043. constructor(name: string, _operator: TonemappingOperator,
  132044. /** Defines the required exposure adjustement */
  132045. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  132046. }
  132047. }
  132048. declare module BABYLON {
  132049. /** @hidden */
  132050. export var depthVertexShader: {
  132051. name: string;
  132052. shader: string;
  132053. };
  132054. }
  132055. declare module BABYLON {
  132056. /** @hidden */
  132057. export var volumetricLightScatteringPixelShader: {
  132058. name: string;
  132059. shader: string;
  132060. };
  132061. }
  132062. declare module BABYLON {
  132063. /** @hidden */
  132064. export var volumetricLightScatteringPassVertexShader: {
  132065. name: string;
  132066. shader: string;
  132067. };
  132068. }
  132069. declare module BABYLON {
  132070. /** @hidden */
  132071. export var volumetricLightScatteringPassPixelShader: {
  132072. name: string;
  132073. shader: string;
  132074. };
  132075. }
  132076. declare module BABYLON {
  132077. /**
  132078. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  132079. */
  132080. export class VolumetricLightScatteringPostProcess extends PostProcess {
  132081. private _volumetricLightScatteringPass;
  132082. private _volumetricLightScatteringRTT;
  132083. private _viewPort;
  132084. private _screenCoordinates;
  132085. private _cachedDefines;
  132086. /**
  132087. * If not undefined, the mesh position is computed from the attached node position
  132088. */
  132089. attachedNode: {
  132090. position: Vector3;
  132091. };
  132092. /**
  132093. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  132094. */
  132095. customMeshPosition: Vector3;
  132096. /**
  132097. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  132098. */
  132099. useCustomMeshPosition: boolean;
  132100. /**
  132101. * If the post-process should inverse the light scattering direction
  132102. */
  132103. invert: boolean;
  132104. /**
  132105. * The internal mesh used by the post-process
  132106. */
  132107. mesh: Mesh;
  132108. /**
  132109. * @hidden
  132110. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  132111. */
  132112. useDiffuseColor: boolean;
  132113. /**
  132114. * Array containing the excluded meshes not rendered in the internal pass
  132115. */
  132116. excludedMeshes: AbstractMesh[];
  132117. /**
  132118. * Controls the overall intensity of the post-process
  132119. */
  132120. exposure: number;
  132121. /**
  132122. * Dissipates each sample's contribution in range [0, 1]
  132123. */
  132124. decay: number;
  132125. /**
  132126. * Controls the overall intensity of each sample
  132127. */
  132128. weight: number;
  132129. /**
  132130. * Controls the density of each sample
  132131. */
  132132. density: number;
  132133. /**
  132134. * @constructor
  132135. * @param name The post-process name
  132136. * @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)
  132137. * @param camera The camera that the post-process will be attached to
  132138. * @param mesh The mesh used to create the light scattering
  132139. * @param samples The post-process quality, default 100
  132140. * @param samplingModeThe post-process filtering mode
  132141. * @param engine The babylon engine
  132142. * @param reusable If the post-process is reusable
  132143. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  132144. */
  132145. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  132146. /**
  132147. * Returns the string "VolumetricLightScatteringPostProcess"
  132148. * @returns "VolumetricLightScatteringPostProcess"
  132149. */
  132150. getClassName(): string;
  132151. private _isReady;
  132152. /**
  132153. * Sets the new light position for light scattering effect
  132154. * @param position The new custom light position
  132155. */
  132156. setCustomMeshPosition(position: Vector3): void;
  132157. /**
  132158. * Returns the light position for light scattering effect
  132159. * @return Vector3 The custom light position
  132160. */
  132161. getCustomMeshPosition(): Vector3;
  132162. /**
  132163. * Disposes the internal assets and detaches the post-process from the camera
  132164. */
  132165. dispose(camera: Camera): void;
  132166. /**
  132167. * Returns the render target texture used by the post-process
  132168. * @return the render target texture used by the post-process
  132169. */
  132170. getPass(): RenderTargetTexture;
  132171. private _meshExcluded;
  132172. private _createPass;
  132173. private _updateMeshScreenCoordinates;
  132174. /**
  132175. * Creates a default mesh for the Volumeric Light Scattering post-process
  132176. * @param name The mesh name
  132177. * @param scene The scene where to create the mesh
  132178. * @return the default mesh
  132179. */
  132180. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  132181. }
  132182. }
  132183. declare module BABYLON {
  132184. interface Scene {
  132185. /** @hidden (Backing field) */
  132186. _boundingBoxRenderer: BoundingBoxRenderer;
  132187. /** @hidden (Backing field) */
  132188. _forceShowBoundingBoxes: boolean;
  132189. /**
  132190. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  132191. */
  132192. forceShowBoundingBoxes: boolean;
  132193. /**
  132194. * Gets the bounding box renderer associated with the scene
  132195. * @returns a BoundingBoxRenderer
  132196. */
  132197. getBoundingBoxRenderer(): BoundingBoxRenderer;
  132198. }
  132199. interface AbstractMesh {
  132200. /** @hidden (Backing field) */
  132201. _showBoundingBox: boolean;
  132202. /**
  132203. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  132204. */
  132205. showBoundingBox: boolean;
  132206. }
  132207. /**
  132208. * Component responsible of rendering the bounding box of the meshes in a scene.
  132209. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  132210. */
  132211. export class BoundingBoxRenderer implements ISceneComponent {
  132212. /**
  132213. * The component name helpfull to identify the component in the list of scene components.
  132214. */
  132215. readonly name: string;
  132216. /**
  132217. * The scene the component belongs to.
  132218. */
  132219. scene: Scene;
  132220. /**
  132221. * Color of the bounding box lines placed in front of an object
  132222. */
  132223. frontColor: Color3;
  132224. /**
  132225. * Color of the bounding box lines placed behind an object
  132226. */
  132227. backColor: Color3;
  132228. /**
  132229. * Defines if the renderer should show the back lines or not
  132230. */
  132231. showBackLines: boolean;
  132232. /**
  132233. * @hidden
  132234. */
  132235. renderList: SmartArray<BoundingBox>;
  132236. private _colorShader;
  132237. private _vertexBuffers;
  132238. private _indexBuffer;
  132239. private _fillIndexBuffer;
  132240. private _fillIndexData;
  132241. /**
  132242. * Instantiates a new bounding box renderer in a scene.
  132243. * @param scene the scene the renderer renders in
  132244. */
  132245. constructor(scene: Scene);
  132246. /**
  132247. * Registers the component in a given scene
  132248. */
  132249. register(): void;
  132250. private _evaluateSubMesh;
  132251. private _activeMesh;
  132252. private _prepareRessources;
  132253. private _createIndexBuffer;
  132254. /**
  132255. * Rebuilds the elements related to this component in case of
  132256. * context lost for instance.
  132257. */
  132258. rebuild(): void;
  132259. /**
  132260. * @hidden
  132261. */
  132262. reset(): void;
  132263. /**
  132264. * Render the bounding boxes of a specific rendering group
  132265. * @param renderingGroupId defines the rendering group to render
  132266. */
  132267. render(renderingGroupId: number): void;
  132268. /**
  132269. * In case of occlusion queries, we can render the occlusion bounding box through this method
  132270. * @param mesh Define the mesh to render the occlusion bounding box for
  132271. */
  132272. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  132273. /**
  132274. * Dispose and release the resources attached to this renderer.
  132275. */
  132276. dispose(): void;
  132277. }
  132278. }
  132279. declare module BABYLON {
  132280. /** @hidden */
  132281. export var depthPixelShader: {
  132282. name: string;
  132283. shader: string;
  132284. };
  132285. }
  132286. declare module BABYLON {
  132287. /**
  132288. * This represents a depth renderer in Babylon.
  132289. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  132290. */
  132291. export class DepthRenderer {
  132292. private _scene;
  132293. private _depthMap;
  132294. private _effect;
  132295. private readonly _storeNonLinearDepth;
  132296. private readonly _clearColor;
  132297. /** Get if the depth renderer is using packed depth or not */
  132298. readonly isPacked: boolean;
  132299. private _cachedDefines;
  132300. private _camera;
  132301. /**
  132302. * Specifiess that the depth renderer will only be used within
  132303. * the camera it is created for.
  132304. * This can help forcing its rendering during the camera processing.
  132305. */
  132306. useOnlyInActiveCamera: boolean;
  132307. /** @hidden */
  132308. static _SceneComponentInitialization: (scene: Scene) => void;
  132309. /**
  132310. * Instantiates a depth renderer
  132311. * @param scene The scene the renderer belongs to
  132312. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  132313. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  132314. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  132315. */
  132316. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  132317. /**
  132318. * Creates the depth rendering effect and checks if the effect is ready.
  132319. * @param subMesh The submesh to be used to render the depth map of
  132320. * @param useInstances If multiple world instances should be used
  132321. * @returns if the depth renderer is ready to render the depth map
  132322. */
  132323. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  132324. /**
  132325. * Gets the texture which the depth map will be written to.
  132326. * @returns The depth map texture
  132327. */
  132328. getDepthMap(): RenderTargetTexture;
  132329. /**
  132330. * Disposes of the depth renderer.
  132331. */
  132332. dispose(): void;
  132333. }
  132334. }
  132335. declare module BABYLON {
  132336. interface Scene {
  132337. /** @hidden (Backing field) */
  132338. _depthRenderer: {
  132339. [id: string]: DepthRenderer;
  132340. };
  132341. /**
  132342. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  132343. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  132344. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  132345. * @returns the created depth renderer
  132346. */
  132347. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  132348. /**
  132349. * Disables a depth renderer for a given camera
  132350. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  132351. */
  132352. disableDepthRenderer(camera?: Nullable<Camera>): void;
  132353. }
  132354. /**
  132355. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  132356. * in several rendering techniques.
  132357. */
  132358. export class DepthRendererSceneComponent implements ISceneComponent {
  132359. /**
  132360. * The component name helpfull to identify the component in the list of scene components.
  132361. */
  132362. readonly name: string;
  132363. /**
  132364. * The scene the component belongs to.
  132365. */
  132366. scene: Scene;
  132367. /**
  132368. * Creates a new instance of the component for the given scene
  132369. * @param scene Defines the scene to register the component in
  132370. */
  132371. constructor(scene: Scene);
  132372. /**
  132373. * Registers the component in a given scene
  132374. */
  132375. register(): void;
  132376. /**
  132377. * Rebuilds the elements related to this component in case of
  132378. * context lost for instance.
  132379. */
  132380. rebuild(): void;
  132381. /**
  132382. * Disposes the component and the associated ressources
  132383. */
  132384. dispose(): void;
  132385. private _gatherRenderTargets;
  132386. private _gatherActiveCameraRenderTargets;
  132387. }
  132388. }
  132389. declare module BABYLON {
  132390. /** @hidden */
  132391. export var outlinePixelShader: {
  132392. name: string;
  132393. shader: string;
  132394. };
  132395. }
  132396. declare module BABYLON {
  132397. /** @hidden */
  132398. export var outlineVertexShader: {
  132399. name: string;
  132400. shader: string;
  132401. };
  132402. }
  132403. declare module BABYLON {
  132404. interface Scene {
  132405. /** @hidden */
  132406. _outlineRenderer: OutlineRenderer;
  132407. /**
  132408. * Gets the outline renderer associated with the scene
  132409. * @returns a OutlineRenderer
  132410. */
  132411. getOutlineRenderer(): OutlineRenderer;
  132412. }
  132413. interface AbstractMesh {
  132414. /** @hidden (Backing field) */
  132415. _renderOutline: boolean;
  132416. /**
  132417. * Gets or sets a boolean indicating if the outline must be rendered as well
  132418. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  132419. */
  132420. renderOutline: boolean;
  132421. /** @hidden (Backing field) */
  132422. _renderOverlay: boolean;
  132423. /**
  132424. * Gets or sets a boolean indicating if the overlay must be rendered as well
  132425. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  132426. */
  132427. renderOverlay: boolean;
  132428. }
  132429. /**
  132430. * This class is responsible to draw bothe outline/overlay of meshes.
  132431. * It should not be used directly but through the available method on mesh.
  132432. */
  132433. export class OutlineRenderer implements ISceneComponent {
  132434. /**
  132435. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  132436. */
  132437. private static _StencilReference;
  132438. /**
  132439. * The name of the component. Each component must have a unique name.
  132440. */
  132441. name: string;
  132442. /**
  132443. * The scene the component belongs to.
  132444. */
  132445. scene: Scene;
  132446. /**
  132447. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  132448. */
  132449. zOffset: number;
  132450. private _engine;
  132451. private _effect;
  132452. private _cachedDefines;
  132453. private _savedDepthWrite;
  132454. /**
  132455. * Instantiates a new outline renderer. (There could be only one per scene).
  132456. * @param scene Defines the scene it belongs to
  132457. */
  132458. constructor(scene: Scene);
  132459. /**
  132460. * Register the component to one instance of a scene.
  132461. */
  132462. register(): void;
  132463. /**
  132464. * Rebuilds the elements related to this component in case of
  132465. * context lost for instance.
  132466. */
  132467. rebuild(): void;
  132468. /**
  132469. * Disposes the component and the associated ressources.
  132470. */
  132471. dispose(): void;
  132472. /**
  132473. * Renders the outline in the canvas.
  132474. * @param subMesh Defines the sumesh to render
  132475. * @param batch Defines the batch of meshes in case of instances
  132476. * @param useOverlay Defines if the rendering is for the overlay or the outline
  132477. */
  132478. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  132479. /**
  132480. * Returns whether or not the outline renderer is ready for a given submesh.
  132481. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  132482. * @param subMesh Defines the submesh to check readyness for
  132483. * @param useInstances Defines wheter wee are trying to render instances or not
  132484. * @returns true if ready otherwise false
  132485. */
  132486. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  132487. private _beforeRenderingMesh;
  132488. private _afterRenderingMesh;
  132489. }
  132490. }
  132491. declare module BABYLON {
  132492. /**
  132493. * Class used to manage multiple sprites of different sizes on the same spritesheet
  132494. * @see http://doc.babylonjs.com/babylon101/sprites
  132495. */
  132496. export class SpritePackedManager extends SpriteManager {
  132497. /** defines the packed manager's name */
  132498. name: string;
  132499. /**
  132500. * Creates a new sprite manager from a packed sprite sheet
  132501. * @param name defines the manager's name
  132502. * @param imgUrl defines the sprite sheet url
  132503. * @param capacity defines the maximum allowed number of sprites
  132504. * @param scene defines the hosting scene
  132505. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  132506. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  132507. * @param samplingMode defines the smapling mode to use with spritesheet
  132508. * @param fromPacked set to true; do not alter
  132509. */
  132510. constructor(
  132511. /** defines the packed manager's name */
  132512. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  132513. }
  132514. }
  132515. declare module BABYLON {
  132516. /**
  132517. * Defines the list of states available for a task inside a AssetsManager
  132518. */
  132519. export enum AssetTaskState {
  132520. /**
  132521. * Initialization
  132522. */
  132523. INIT = 0,
  132524. /**
  132525. * Running
  132526. */
  132527. RUNNING = 1,
  132528. /**
  132529. * Done
  132530. */
  132531. DONE = 2,
  132532. /**
  132533. * Error
  132534. */
  132535. ERROR = 3
  132536. }
  132537. /**
  132538. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  132539. */
  132540. export abstract class AbstractAssetTask {
  132541. /**
  132542. * Task name
  132543. */ name: string;
  132544. /**
  132545. * Callback called when the task is successful
  132546. */
  132547. onSuccess: (task: any) => void;
  132548. /**
  132549. * Callback called when the task is not successful
  132550. */
  132551. onError: (task: any, message?: string, exception?: any) => void;
  132552. /**
  132553. * Creates a new AssetsManager
  132554. * @param name defines the name of the task
  132555. */
  132556. constructor(
  132557. /**
  132558. * Task name
  132559. */ name: string);
  132560. private _isCompleted;
  132561. private _taskState;
  132562. private _errorObject;
  132563. /**
  132564. * Get if the task is completed
  132565. */
  132566. readonly isCompleted: boolean;
  132567. /**
  132568. * Gets the current state of the task
  132569. */
  132570. readonly taskState: AssetTaskState;
  132571. /**
  132572. * Gets the current error object (if task is in error)
  132573. */
  132574. readonly errorObject: {
  132575. message?: string;
  132576. exception?: any;
  132577. };
  132578. /**
  132579. * Internal only
  132580. * @hidden
  132581. */
  132582. _setErrorObject(message?: string, exception?: any): void;
  132583. /**
  132584. * Execute the current task
  132585. * @param scene defines the scene where you want your assets to be loaded
  132586. * @param onSuccess is a callback called when the task is successfully executed
  132587. * @param onError is a callback called if an error occurs
  132588. */
  132589. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132590. /**
  132591. * Execute the current task
  132592. * @param scene defines the scene where you want your assets to be loaded
  132593. * @param onSuccess is a callback called when the task is successfully executed
  132594. * @param onError is a callback called if an error occurs
  132595. */
  132596. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132597. /**
  132598. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  132599. * This can be used with failed tasks that have the reason for failure fixed.
  132600. */
  132601. reset(): void;
  132602. private onErrorCallback;
  132603. private onDoneCallback;
  132604. }
  132605. /**
  132606. * Define the interface used by progress events raised during assets loading
  132607. */
  132608. export interface IAssetsProgressEvent {
  132609. /**
  132610. * Defines the number of remaining tasks to process
  132611. */
  132612. remainingCount: number;
  132613. /**
  132614. * Defines the total number of tasks
  132615. */
  132616. totalCount: number;
  132617. /**
  132618. * Defines the task that was just processed
  132619. */
  132620. task: AbstractAssetTask;
  132621. }
  132622. /**
  132623. * Class used to share progress information about assets loading
  132624. */
  132625. export class AssetsProgressEvent implements IAssetsProgressEvent {
  132626. /**
  132627. * Defines the number of remaining tasks to process
  132628. */
  132629. remainingCount: number;
  132630. /**
  132631. * Defines the total number of tasks
  132632. */
  132633. totalCount: number;
  132634. /**
  132635. * Defines the task that was just processed
  132636. */
  132637. task: AbstractAssetTask;
  132638. /**
  132639. * Creates a AssetsProgressEvent
  132640. * @param remainingCount defines the number of remaining tasks to process
  132641. * @param totalCount defines the total number of tasks
  132642. * @param task defines the task that was just processed
  132643. */
  132644. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  132645. }
  132646. /**
  132647. * Define a task used by AssetsManager to load meshes
  132648. */
  132649. export class MeshAssetTask extends AbstractAssetTask {
  132650. /**
  132651. * Defines the name of the task
  132652. */
  132653. name: string;
  132654. /**
  132655. * Defines the list of mesh's names you want to load
  132656. */
  132657. meshesNames: any;
  132658. /**
  132659. * Defines the root url to use as a base to load your meshes and associated resources
  132660. */
  132661. rootUrl: string;
  132662. /**
  132663. * Defines the filename of the scene to load from
  132664. */
  132665. sceneFilename: string;
  132666. /**
  132667. * Gets the list of loaded meshes
  132668. */
  132669. loadedMeshes: Array<AbstractMesh>;
  132670. /**
  132671. * Gets the list of loaded particle systems
  132672. */
  132673. loadedParticleSystems: Array<IParticleSystem>;
  132674. /**
  132675. * Gets the list of loaded skeletons
  132676. */
  132677. loadedSkeletons: Array<Skeleton>;
  132678. /**
  132679. * Gets the list of loaded animation groups
  132680. */
  132681. loadedAnimationGroups: Array<AnimationGroup>;
  132682. /**
  132683. * Callback called when the task is successful
  132684. */
  132685. onSuccess: (task: MeshAssetTask) => void;
  132686. /**
  132687. * Callback called when the task is successful
  132688. */
  132689. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  132690. /**
  132691. * Creates a new MeshAssetTask
  132692. * @param name defines the name of the task
  132693. * @param meshesNames defines the list of mesh's names you want to load
  132694. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  132695. * @param sceneFilename defines the filename of the scene to load from
  132696. */
  132697. constructor(
  132698. /**
  132699. * Defines the name of the task
  132700. */
  132701. name: string,
  132702. /**
  132703. * Defines the list of mesh's names you want to load
  132704. */
  132705. meshesNames: any,
  132706. /**
  132707. * Defines the root url to use as a base to load your meshes and associated resources
  132708. */
  132709. rootUrl: string,
  132710. /**
  132711. * Defines the filename of the scene to load from
  132712. */
  132713. sceneFilename: string);
  132714. /**
  132715. * Execute the current task
  132716. * @param scene defines the scene where you want your assets to be loaded
  132717. * @param onSuccess is a callback called when the task is successfully executed
  132718. * @param onError is a callback called if an error occurs
  132719. */
  132720. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132721. }
  132722. /**
  132723. * Define a task used by AssetsManager to load text content
  132724. */
  132725. export class TextFileAssetTask extends AbstractAssetTask {
  132726. /**
  132727. * Defines the name of the task
  132728. */
  132729. name: string;
  132730. /**
  132731. * Defines the location of the file to load
  132732. */
  132733. url: string;
  132734. /**
  132735. * Gets the loaded text string
  132736. */
  132737. text: string;
  132738. /**
  132739. * Callback called when the task is successful
  132740. */
  132741. onSuccess: (task: TextFileAssetTask) => void;
  132742. /**
  132743. * Callback called when the task is successful
  132744. */
  132745. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  132746. /**
  132747. * Creates a new TextFileAssetTask object
  132748. * @param name defines the name of the task
  132749. * @param url defines the location of the file to load
  132750. */
  132751. constructor(
  132752. /**
  132753. * Defines the name of the task
  132754. */
  132755. name: string,
  132756. /**
  132757. * Defines the location of the file to load
  132758. */
  132759. url: string);
  132760. /**
  132761. * Execute the current task
  132762. * @param scene defines the scene where you want your assets to be loaded
  132763. * @param onSuccess is a callback called when the task is successfully executed
  132764. * @param onError is a callback called if an error occurs
  132765. */
  132766. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132767. }
  132768. /**
  132769. * Define a task used by AssetsManager to load binary data
  132770. */
  132771. export class BinaryFileAssetTask extends AbstractAssetTask {
  132772. /**
  132773. * Defines the name of the task
  132774. */
  132775. name: string;
  132776. /**
  132777. * Defines the location of the file to load
  132778. */
  132779. url: string;
  132780. /**
  132781. * Gets the lodaded data (as an array buffer)
  132782. */
  132783. data: ArrayBuffer;
  132784. /**
  132785. * Callback called when the task is successful
  132786. */
  132787. onSuccess: (task: BinaryFileAssetTask) => void;
  132788. /**
  132789. * Callback called when the task is successful
  132790. */
  132791. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  132792. /**
  132793. * Creates a new BinaryFileAssetTask object
  132794. * @param name defines the name of the new task
  132795. * @param url defines the location of the file to load
  132796. */
  132797. constructor(
  132798. /**
  132799. * Defines the name of the task
  132800. */
  132801. name: string,
  132802. /**
  132803. * Defines the location of the file to load
  132804. */
  132805. url: string);
  132806. /**
  132807. * Execute the current task
  132808. * @param scene defines the scene where you want your assets to be loaded
  132809. * @param onSuccess is a callback called when the task is successfully executed
  132810. * @param onError is a callback called if an error occurs
  132811. */
  132812. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132813. }
  132814. /**
  132815. * Define a task used by AssetsManager to load images
  132816. */
  132817. export class ImageAssetTask extends AbstractAssetTask {
  132818. /**
  132819. * Defines the name of the task
  132820. */
  132821. name: string;
  132822. /**
  132823. * Defines the location of the image to load
  132824. */
  132825. url: string;
  132826. /**
  132827. * Gets the loaded images
  132828. */
  132829. image: HTMLImageElement;
  132830. /**
  132831. * Callback called when the task is successful
  132832. */
  132833. onSuccess: (task: ImageAssetTask) => void;
  132834. /**
  132835. * Callback called when the task is successful
  132836. */
  132837. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  132838. /**
  132839. * Creates a new ImageAssetTask
  132840. * @param name defines the name of the task
  132841. * @param url defines the location of the image to load
  132842. */
  132843. constructor(
  132844. /**
  132845. * Defines the name of the task
  132846. */
  132847. name: string,
  132848. /**
  132849. * Defines the location of the image to load
  132850. */
  132851. url: string);
  132852. /**
  132853. * Execute the current task
  132854. * @param scene defines the scene where you want your assets to be loaded
  132855. * @param onSuccess is a callback called when the task is successfully executed
  132856. * @param onError is a callback called if an error occurs
  132857. */
  132858. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132859. }
  132860. /**
  132861. * Defines the interface used by texture loading tasks
  132862. */
  132863. export interface ITextureAssetTask<TEX extends BaseTexture> {
  132864. /**
  132865. * Gets the loaded texture
  132866. */
  132867. texture: TEX;
  132868. }
  132869. /**
  132870. * Define a task used by AssetsManager to load 2D textures
  132871. */
  132872. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  132873. /**
  132874. * Defines the name of the task
  132875. */
  132876. name: string;
  132877. /**
  132878. * Defines the location of the file to load
  132879. */
  132880. url: string;
  132881. /**
  132882. * Defines if mipmap should not be generated (default is false)
  132883. */
  132884. noMipmap?: boolean | undefined;
  132885. /**
  132886. * Defines if texture must be inverted on Y axis (default is false)
  132887. */
  132888. invertY?: boolean | undefined;
  132889. /**
  132890. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  132891. */
  132892. samplingMode: number;
  132893. /**
  132894. * Gets the loaded texture
  132895. */
  132896. texture: Texture;
  132897. /**
  132898. * Callback called when the task is successful
  132899. */
  132900. onSuccess: (task: TextureAssetTask) => void;
  132901. /**
  132902. * Callback called when the task is successful
  132903. */
  132904. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  132905. /**
  132906. * Creates a new TextureAssetTask object
  132907. * @param name defines the name of the task
  132908. * @param url defines the location of the file to load
  132909. * @param noMipmap defines if mipmap should not be generated (default is false)
  132910. * @param invertY defines if texture must be inverted on Y axis (default is false)
  132911. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  132912. */
  132913. constructor(
  132914. /**
  132915. * Defines the name of the task
  132916. */
  132917. name: string,
  132918. /**
  132919. * Defines the location of the file to load
  132920. */
  132921. url: string,
  132922. /**
  132923. * Defines if mipmap should not be generated (default is false)
  132924. */
  132925. noMipmap?: boolean | undefined,
  132926. /**
  132927. * Defines if texture must be inverted on Y axis (default is false)
  132928. */
  132929. invertY?: boolean | undefined,
  132930. /**
  132931. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  132932. */
  132933. samplingMode?: number);
  132934. /**
  132935. * Execute the current task
  132936. * @param scene defines the scene where you want your assets to be loaded
  132937. * @param onSuccess is a callback called when the task is successfully executed
  132938. * @param onError is a callback called if an error occurs
  132939. */
  132940. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132941. }
  132942. /**
  132943. * Define a task used by AssetsManager to load cube textures
  132944. */
  132945. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  132946. /**
  132947. * Defines the name of the task
  132948. */
  132949. name: string;
  132950. /**
  132951. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  132952. */
  132953. url: string;
  132954. /**
  132955. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  132956. */
  132957. extensions?: string[] | undefined;
  132958. /**
  132959. * Defines if mipmaps should not be generated (default is false)
  132960. */
  132961. noMipmap?: boolean | undefined;
  132962. /**
  132963. * Defines the explicit list of files (undefined by default)
  132964. */
  132965. files?: string[] | undefined;
  132966. /**
  132967. * Gets the loaded texture
  132968. */
  132969. texture: CubeTexture;
  132970. /**
  132971. * Callback called when the task is successful
  132972. */
  132973. onSuccess: (task: CubeTextureAssetTask) => void;
  132974. /**
  132975. * Callback called when the task is successful
  132976. */
  132977. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  132978. /**
  132979. * Creates a new CubeTextureAssetTask
  132980. * @param name defines the name of the task
  132981. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  132982. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  132983. * @param noMipmap defines if mipmaps should not be generated (default is false)
  132984. * @param files defines the explicit list of files (undefined by default)
  132985. */
  132986. constructor(
  132987. /**
  132988. * Defines the name of the task
  132989. */
  132990. name: string,
  132991. /**
  132992. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  132993. */
  132994. url: string,
  132995. /**
  132996. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  132997. */
  132998. extensions?: string[] | undefined,
  132999. /**
  133000. * Defines if mipmaps should not be generated (default is false)
  133001. */
  133002. noMipmap?: boolean | undefined,
  133003. /**
  133004. * Defines the explicit list of files (undefined by default)
  133005. */
  133006. files?: string[] | undefined);
  133007. /**
  133008. * Execute the current task
  133009. * @param scene defines the scene where you want your assets to be loaded
  133010. * @param onSuccess is a callback called when the task is successfully executed
  133011. * @param onError is a callback called if an error occurs
  133012. */
  133013. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  133014. }
  133015. /**
  133016. * Define a task used by AssetsManager to load HDR cube textures
  133017. */
  133018. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  133019. /**
  133020. * Defines the name of the task
  133021. */
  133022. name: string;
  133023. /**
  133024. * Defines the location of the file to load
  133025. */
  133026. url: string;
  133027. /**
  133028. * Defines the desired size (the more it increases the longer the generation will be)
  133029. */
  133030. size: number;
  133031. /**
  133032. * Defines if mipmaps should not be generated (default is false)
  133033. */
  133034. noMipmap: boolean;
  133035. /**
  133036. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  133037. */
  133038. generateHarmonics: boolean;
  133039. /**
  133040. * 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)
  133041. */
  133042. gammaSpace: boolean;
  133043. /**
  133044. * Internal Use Only
  133045. */
  133046. reserved: boolean;
  133047. /**
  133048. * Gets the loaded texture
  133049. */
  133050. texture: HDRCubeTexture;
  133051. /**
  133052. * Callback called when the task is successful
  133053. */
  133054. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  133055. /**
  133056. * Callback called when the task is successful
  133057. */
  133058. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  133059. /**
  133060. * Creates a new HDRCubeTextureAssetTask object
  133061. * @param name defines the name of the task
  133062. * @param url defines the location of the file to load
  133063. * @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.
  133064. * @param noMipmap defines if mipmaps should not be generated (default is false)
  133065. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  133066. * @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)
  133067. * @param reserved Internal use only
  133068. */
  133069. constructor(
  133070. /**
  133071. * Defines the name of the task
  133072. */
  133073. name: string,
  133074. /**
  133075. * Defines the location of the file to load
  133076. */
  133077. url: string,
  133078. /**
  133079. * Defines the desired size (the more it increases the longer the generation will be)
  133080. */
  133081. size: number,
  133082. /**
  133083. * Defines if mipmaps should not be generated (default is false)
  133084. */
  133085. noMipmap?: boolean,
  133086. /**
  133087. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  133088. */
  133089. generateHarmonics?: boolean,
  133090. /**
  133091. * 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)
  133092. */
  133093. gammaSpace?: boolean,
  133094. /**
  133095. * Internal Use Only
  133096. */
  133097. reserved?: boolean);
  133098. /**
  133099. * Execute the current task
  133100. * @param scene defines the scene where you want your assets to be loaded
  133101. * @param onSuccess is a callback called when the task is successfully executed
  133102. * @param onError is a callback called if an error occurs
  133103. */
  133104. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  133105. }
  133106. /**
  133107. * Define a task used by AssetsManager to load Equirectangular cube textures
  133108. */
  133109. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  133110. /**
  133111. * Defines the name of the task
  133112. */
  133113. name: string;
  133114. /**
  133115. * Defines the location of the file to load
  133116. */
  133117. url: string;
  133118. /**
  133119. * Defines the desired size (the more it increases the longer the generation will be)
  133120. */
  133121. size: number;
  133122. /**
  133123. * Defines if mipmaps should not be generated (default is false)
  133124. */
  133125. noMipmap: boolean;
  133126. /**
  133127. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  133128. * but the standard material would require them in Gamma space) (default is true)
  133129. */
  133130. gammaSpace: boolean;
  133131. /**
  133132. * Gets the loaded texture
  133133. */
  133134. texture: EquiRectangularCubeTexture;
  133135. /**
  133136. * Callback called when the task is successful
  133137. */
  133138. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  133139. /**
  133140. * Callback called when the task is successful
  133141. */
  133142. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  133143. /**
  133144. * Creates a new EquiRectangularCubeTextureAssetTask object
  133145. * @param name defines the name of the task
  133146. * @param url defines the location of the file to load
  133147. * @param size defines the desired size (the more it increases the longer the generation will be)
  133148. * If the size is omitted this implies you are using a preprocessed cubemap.
  133149. * @param noMipmap defines if mipmaps should not be generated (default is false)
  133150. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  133151. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  133152. * (default is true)
  133153. */
  133154. constructor(
  133155. /**
  133156. * Defines the name of the task
  133157. */
  133158. name: string,
  133159. /**
  133160. * Defines the location of the file to load
  133161. */
  133162. url: string,
  133163. /**
  133164. * Defines the desired size (the more it increases the longer the generation will be)
  133165. */
  133166. size: number,
  133167. /**
  133168. * Defines if mipmaps should not be generated (default is false)
  133169. */
  133170. noMipmap?: boolean,
  133171. /**
  133172. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  133173. * but the standard material would require them in Gamma space) (default is true)
  133174. */
  133175. gammaSpace?: boolean);
  133176. /**
  133177. * Execute the current task
  133178. * @param scene defines the scene where you want your assets to be loaded
  133179. * @param onSuccess is a callback called when the task is successfully executed
  133180. * @param onError is a callback called if an error occurs
  133181. */
  133182. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  133183. }
  133184. /**
  133185. * This class can be used to easily import assets into a scene
  133186. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  133187. */
  133188. export class AssetsManager {
  133189. private _scene;
  133190. private _isLoading;
  133191. protected _tasks: AbstractAssetTask[];
  133192. protected _waitingTasksCount: number;
  133193. protected _totalTasksCount: number;
  133194. /**
  133195. * Callback called when all tasks are processed
  133196. */
  133197. onFinish: (tasks: AbstractAssetTask[]) => void;
  133198. /**
  133199. * Callback called when a task is successful
  133200. */
  133201. onTaskSuccess: (task: AbstractAssetTask) => void;
  133202. /**
  133203. * Callback called when a task had an error
  133204. */
  133205. onTaskError: (task: AbstractAssetTask) => void;
  133206. /**
  133207. * Callback called when a task is done (whatever the result is)
  133208. */
  133209. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  133210. /**
  133211. * Observable called when all tasks are processed
  133212. */
  133213. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  133214. /**
  133215. * Observable called when a task had an error
  133216. */
  133217. onTaskErrorObservable: Observable<AbstractAssetTask>;
  133218. /**
  133219. * Observable called when all tasks were executed
  133220. */
  133221. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  133222. /**
  133223. * Observable called when a task is done (whatever the result is)
  133224. */
  133225. onProgressObservable: Observable<IAssetsProgressEvent>;
  133226. /**
  133227. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  133228. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  133229. */
  133230. useDefaultLoadingScreen: boolean;
  133231. /**
  133232. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  133233. * when all assets have been downloaded.
  133234. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  133235. */
  133236. autoHideLoadingUI: boolean;
  133237. /**
  133238. * Creates a new AssetsManager
  133239. * @param scene defines the scene to work on
  133240. */
  133241. constructor(scene: Scene);
  133242. /**
  133243. * Add a MeshAssetTask to the list of active tasks
  133244. * @param taskName defines the name of the new task
  133245. * @param meshesNames defines the name of meshes to load
  133246. * @param rootUrl defines the root url to use to locate files
  133247. * @param sceneFilename defines the filename of the scene file
  133248. * @returns a new MeshAssetTask object
  133249. */
  133250. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  133251. /**
  133252. * Add a TextFileAssetTask to the list of active tasks
  133253. * @param taskName defines the name of the new task
  133254. * @param url defines the url of the file to load
  133255. * @returns a new TextFileAssetTask object
  133256. */
  133257. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  133258. /**
  133259. * Add a BinaryFileAssetTask to the list of active tasks
  133260. * @param taskName defines the name of the new task
  133261. * @param url defines the url of the file to load
  133262. * @returns a new BinaryFileAssetTask object
  133263. */
  133264. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  133265. /**
  133266. * Add a ImageAssetTask to the list of active tasks
  133267. * @param taskName defines the name of the new task
  133268. * @param url defines the url of the file to load
  133269. * @returns a new ImageAssetTask object
  133270. */
  133271. addImageTask(taskName: string, url: string): ImageAssetTask;
  133272. /**
  133273. * Add a TextureAssetTask to the list of active tasks
  133274. * @param taskName defines the name of the new task
  133275. * @param url defines the url of the file to load
  133276. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  133277. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  133278. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  133279. * @returns a new TextureAssetTask object
  133280. */
  133281. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  133282. /**
  133283. * Add a CubeTextureAssetTask to the list of active tasks
  133284. * @param taskName defines the name of the new task
  133285. * @param url defines the url of the file to load
  133286. * @param extensions defines the extension to use to load the cube map (can be null)
  133287. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  133288. * @param files defines the list of files to load (can be null)
  133289. * @returns a new CubeTextureAssetTask object
  133290. */
  133291. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  133292. /**
  133293. *
  133294. * Add a HDRCubeTextureAssetTask to the list of active tasks
  133295. * @param taskName defines the name of the new task
  133296. * @param url defines the url of the file to load
  133297. * @param size defines the size you want for the cubemap (can be null)
  133298. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  133299. * @param generateHarmonics defines if you want to automatically generate (true by default)
  133300. * @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)
  133301. * @param reserved Internal use only
  133302. * @returns a new HDRCubeTextureAssetTask object
  133303. */
  133304. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  133305. /**
  133306. *
  133307. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  133308. * @param taskName defines the name of the new task
  133309. * @param url defines the url of the file to load
  133310. * @param size defines the size you want for the cubemap (can be null)
  133311. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  133312. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  133313. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  133314. * @returns a new EquiRectangularCubeTextureAssetTask object
  133315. */
  133316. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  133317. /**
  133318. * Remove a task from the assets manager.
  133319. * @param task the task to remove
  133320. */
  133321. removeTask(task: AbstractAssetTask): void;
  133322. private _decreaseWaitingTasksCount;
  133323. private _runTask;
  133324. /**
  133325. * Reset the AssetsManager and remove all tasks
  133326. * @return the current instance of the AssetsManager
  133327. */
  133328. reset(): AssetsManager;
  133329. /**
  133330. * Start the loading process
  133331. * @return the current instance of the AssetsManager
  133332. */
  133333. load(): AssetsManager;
  133334. /**
  133335. * Start the loading process as an async operation
  133336. * @return a promise returning the list of failed tasks
  133337. */
  133338. loadAsync(): Promise<void>;
  133339. }
  133340. }
  133341. declare module BABYLON {
  133342. /**
  133343. * Wrapper class for promise with external resolve and reject.
  133344. */
  133345. export class Deferred<T> {
  133346. /**
  133347. * The promise associated with this deferred object.
  133348. */
  133349. readonly promise: Promise<T>;
  133350. private _resolve;
  133351. private _reject;
  133352. /**
  133353. * The resolve method of the promise associated with this deferred object.
  133354. */
  133355. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  133356. /**
  133357. * The reject method of the promise associated with this deferred object.
  133358. */
  133359. readonly reject: (reason?: any) => void;
  133360. /**
  133361. * Constructor for this deferred object.
  133362. */
  133363. constructor();
  133364. }
  133365. }
  133366. declare module BABYLON {
  133367. /**
  133368. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  133369. */
  133370. export class MeshExploder {
  133371. private _centerMesh;
  133372. private _meshes;
  133373. private _meshesOrigins;
  133374. private _toCenterVectors;
  133375. private _scaledDirection;
  133376. private _newPosition;
  133377. private _centerPosition;
  133378. /**
  133379. * Explodes meshes from a center mesh.
  133380. * @param meshes The meshes to explode.
  133381. * @param centerMesh The mesh to be center of explosion.
  133382. */
  133383. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  133384. private _setCenterMesh;
  133385. /**
  133386. * Get class name
  133387. * @returns "MeshExploder"
  133388. */
  133389. getClassName(): string;
  133390. /**
  133391. * "Exploded meshes"
  133392. * @returns Array of meshes with the centerMesh at index 0.
  133393. */
  133394. getMeshes(): Array<Mesh>;
  133395. /**
  133396. * Explodes meshes giving a specific direction
  133397. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  133398. */
  133399. explode(direction?: number): void;
  133400. }
  133401. }
  133402. declare module BABYLON {
  133403. /**
  133404. * Class used to help managing file picking and drag'n'drop
  133405. */
  133406. export class FilesInput {
  133407. /**
  133408. * List of files ready to be loaded
  133409. */
  133410. static readonly FilesToLoad: {
  133411. [key: string]: File;
  133412. };
  133413. /**
  133414. * Callback called when a file is processed
  133415. */
  133416. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  133417. private _engine;
  133418. private _currentScene;
  133419. private _sceneLoadedCallback;
  133420. private _progressCallback;
  133421. private _additionalRenderLoopLogicCallback;
  133422. private _textureLoadingCallback;
  133423. private _startingProcessingFilesCallback;
  133424. private _onReloadCallback;
  133425. private _errorCallback;
  133426. private _elementToMonitor;
  133427. private _sceneFileToLoad;
  133428. private _filesToLoad;
  133429. /**
  133430. * Creates a new FilesInput
  133431. * @param engine defines the rendering engine
  133432. * @param scene defines the hosting scene
  133433. * @param sceneLoadedCallback callback called when scene is loaded
  133434. * @param progressCallback callback called to track progress
  133435. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  133436. * @param textureLoadingCallback callback called when a texture is loading
  133437. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  133438. * @param onReloadCallback callback called when a reload is requested
  133439. * @param errorCallback callback call if an error occurs
  133440. */
  133441. 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);
  133442. private _dragEnterHandler;
  133443. private _dragOverHandler;
  133444. private _dropHandler;
  133445. /**
  133446. * Calls this function to listen to drag'n'drop events on a specific DOM element
  133447. * @param elementToMonitor defines the DOM element to track
  133448. */
  133449. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  133450. /**
  133451. * Release all associated resources
  133452. */
  133453. dispose(): void;
  133454. private renderFunction;
  133455. private drag;
  133456. private drop;
  133457. private _traverseFolder;
  133458. private _processFiles;
  133459. /**
  133460. * Load files from a drop event
  133461. * @param event defines the drop event to use as source
  133462. */
  133463. loadFiles(event: any): void;
  133464. private _processReload;
  133465. /**
  133466. * Reload the current scene from the loaded files
  133467. */
  133468. reload(): void;
  133469. }
  133470. }
  133471. declare module BABYLON {
  133472. /**
  133473. * Defines the root class used to create scene optimization to use with SceneOptimizer
  133474. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133475. */
  133476. export class SceneOptimization {
  133477. /**
  133478. * Defines the priority of this optimization (0 by default which means first in the list)
  133479. */
  133480. priority: number;
  133481. /**
  133482. * Gets a string describing the action executed by the current optimization
  133483. * @returns description string
  133484. */
  133485. getDescription(): string;
  133486. /**
  133487. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133488. * @param scene defines the current scene where to apply this optimization
  133489. * @param optimizer defines the current optimizer
  133490. * @returns true if everything that can be done was applied
  133491. */
  133492. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133493. /**
  133494. * Creates the SceneOptimization object
  133495. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  133496. * @param desc defines the description associated with the optimization
  133497. */
  133498. constructor(
  133499. /**
  133500. * Defines the priority of this optimization (0 by default which means first in the list)
  133501. */
  133502. priority?: number);
  133503. }
  133504. /**
  133505. * Defines an optimization used to reduce the size of render target textures
  133506. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133507. */
  133508. export class TextureOptimization extends SceneOptimization {
  133509. /**
  133510. * Defines the priority of this optimization (0 by default which means first in the list)
  133511. */
  133512. priority: number;
  133513. /**
  133514. * 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
  133515. */
  133516. maximumSize: number;
  133517. /**
  133518. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  133519. */
  133520. step: number;
  133521. /**
  133522. * Gets a string describing the action executed by the current optimization
  133523. * @returns description string
  133524. */
  133525. getDescription(): string;
  133526. /**
  133527. * Creates the TextureOptimization object
  133528. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  133529. * @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
  133530. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  133531. */
  133532. constructor(
  133533. /**
  133534. * Defines the priority of this optimization (0 by default which means first in the list)
  133535. */
  133536. priority?: number,
  133537. /**
  133538. * 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
  133539. */
  133540. maximumSize?: number,
  133541. /**
  133542. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  133543. */
  133544. step?: number);
  133545. /**
  133546. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133547. * @param scene defines the current scene where to apply this optimization
  133548. * @param optimizer defines the current optimizer
  133549. * @returns true if everything that can be done was applied
  133550. */
  133551. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133552. }
  133553. /**
  133554. * Defines an optimization used to increase or decrease the rendering resolution
  133555. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133556. */
  133557. export class HardwareScalingOptimization extends SceneOptimization {
  133558. /**
  133559. * Defines the priority of this optimization (0 by default which means first in the list)
  133560. */
  133561. priority: number;
  133562. /**
  133563. * Defines the maximum scale to use (2 by default)
  133564. */
  133565. maximumScale: number;
  133566. /**
  133567. * Defines the step to use between two passes (0.5 by default)
  133568. */
  133569. step: number;
  133570. private _currentScale;
  133571. private _directionOffset;
  133572. /**
  133573. * Gets a string describing the action executed by the current optimization
  133574. * @return description string
  133575. */
  133576. getDescription(): string;
  133577. /**
  133578. * Creates the HardwareScalingOptimization object
  133579. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  133580. * @param maximumScale defines the maximum scale to use (2 by default)
  133581. * @param step defines the step to use between two passes (0.5 by default)
  133582. */
  133583. constructor(
  133584. /**
  133585. * Defines the priority of this optimization (0 by default which means first in the list)
  133586. */
  133587. priority?: number,
  133588. /**
  133589. * Defines the maximum scale to use (2 by default)
  133590. */
  133591. maximumScale?: number,
  133592. /**
  133593. * Defines the step to use between two passes (0.5 by default)
  133594. */
  133595. step?: number);
  133596. /**
  133597. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133598. * @param scene defines the current scene where to apply this optimization
  133599. * @param optimizer defines the current optimizer
  133600. * @returns true if everything that can be done was applied
  133601. */
  133602. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133603. }
  133604. /**
  133605. * Defines an optimization used to remove shadows
  133606. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133607. */
  133608. export class ShadowsOptimization extends SceneOptimization {
  133609. /**
  133610. * Gets a string describing the action executed by the current optimization
  133611. * @return description string
  133612. */
  133613. getDescription(): string;
  133614. /**
  133615. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133616. * @param scene defines the current scene where to apply this optimization
  133617. * @param optimizer defines the current optimizer
  133618. * @returns true if everything that can be done was applied
  133619. */
  133620. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133621. }
  133622. /**
  133623. * Defines an optimization used to turn post-processes off
  133624. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133625. */
  133626. export class PostProcessesOptimization extends SceneOptimization {
  133627. /**
  133628. * Gets a string describing the action executed by the current optimization
  133629. * @return description string
  133630. */
  133631. getDescription(): string;
  133632. /**
  133633. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133634. * @param scene defines the current scene where to apply this optimization
  133635. * @param optimizer defines the current optimizer
  133636. * @returns true if everything that can be done was applied
  133637. */
  133638. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133639. }
  133640. /**
  133641. * Defines an optimization used to turn lens flares off
  133642. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133643. */
  133644. export class LensFlaresOptimization extends SceneOptimization {
  133645. /**
  133646. * Gets a string describing the action executed by the current optimization
  133647. * @return description string
  133648. */
  133649. getDescription(): string;
  133650. /**
  133651. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133652. * @param scene defines the current scene where to apply this optimization
  133653. * @param optimizer defines the current optimizer
  133654. * @returns true if everything that can be done was applied
  133655. */
  133656. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133657. }
  133658. /**
  133659. * Defines an optimization based on user defined callback.
  133660. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133661. */
  133662. export class CustomOptimization extends SceneOptimization {
  133663. /**
  133664. * Callback called to apply the custom optimization.
  133665. */
  133666. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  133667. /**
  133668. * Callback called to get custom description
  133669. */
  133670. onGetDescription: () => string;
  133671. /**
  133672. * Gets a string describing the action executed by the current optimization
  133673. * @returns description string
  133674. */
  133675. getDescription(): string;
  133676. /**
  133677. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133678. * @param scene defines the current scene where to apply this optimization
  133679. * @param optimizer defines the current optimizer
  133680. * @returns true if everything that can be done was applied
  133681. */
  133682. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133683. }
  133684. /**
  133685. * Defines an optimization used to turn particles off
  133686. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133687. */
  133688. export class ParticlesOptimization extends SceneOptimization {
  133689. /**
  133690. * Gets a string describing the action executed by the current optimization
  133691. * @return description string
  133692. */
  133693. getDescription(): string;
  133694. /**
  133695. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133696. * @param scene defines the current scene where to apply this optimization
  133697. * @param optimizer defines the current optimizer
  133698. * @returns true if everything that can be done was applied
  133699. */
  133700. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133701. }
  133702. /**
  133703. * Defines an optimization used to turn render targets off
  133704. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133705. */
  133706. export class RenderTargetsOptimization extends SceneOptimization {
  133707. /**
  133708. * Gets a string describing the action executed by the current optimization
  133709. * @return description string
  133710. */
  133711. getDescription(): string;
  133712. /**
  133713. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133714. * @param scene defines the current scene where to apply this optimization
  133715. * @param optimizer defines the current optimizer
  133716. * @returns true if everything that can be done was applied
  133717. */
  133718. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133719. }
  133720. /**
  133721. * Defines an optimization used to merge meshes with compatible materials
  133722. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133723. */
  133724. export class MergeMeshesOptimization extends SceneOptimization {
  133725. private static _UpdateSelectionTree;
  133726. /**
  133727. * Gets or sets a boolean which defines if optimization octree has to be updated
  133728. */
  133729. /**
  133730. * Gets or sets a boolean which defines if optimization octree has to be updated
  133731. */
  133732. static UpdateSelectionTree: boolean;
  133733. /**
  133734. * Gets a string describing the action executed by the current optimization
  133735. * @return description string
  133736. */
  133737. getDescription(): string;
  133738. private _canBeMerged;
  133739. /**
  133740. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133741. * @param scene defines the current scene where to apply this optimization
  133742. * @param optimizer defines the current optimizer
  133743. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  133744. * @returns true if everything that can be done was applied
  133745. */
  133746. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  133747. }
  133748. /**
  133749. * Defines a list of options used by SceneOptimizer
  133750. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133751. */
  133752. export class SceneOptimizerOptions {
  133753. /**
  133754. * Defines the target frame rate to reach (60 by default)
  133755. */
  133756. targetFrameRate: number;
  133757. /**
  133758. * Defines the interval between two checkes (2000ms by default)
  133759. */
  133760. trackerDuration: number;
  133761. /**
  133762. * Gets the list of optimizations to apply
  133763. */
  133764. optimizations: SceneOptimization[];
  133765. /**
  133766. * Creates a new list of options used by SceneOptimizer
  133767. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  133768. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  133769. */
  133770. constructor(
  133771. /**
  133772. * Defines the target frame rate to reach (60 by default)
  133773. */
  133774. targetFrameRate?: number,
  133775. /**
  133776. * Defines the interval between two checkes (2000ms by default)
  133777. */
  133778. trackerDuration?: number);
  133779. /**
  133780. * Add a new optimization
  133781. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  133782. * @returns the current SceneOptimizerOptions
  133783. */
  133784. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  133785. /**
  133786. * Add a new custom optimization
  133787. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  133788. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  133789. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  133790. * @returns the current SceneOptimizerOptions
  133791. */
  133792. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  133793. /**
  133794. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  133795. * @param targetFrameRate defines the target frame rate (60 by default)
  133796. * @returns a SceneOptimizerOptions object
  133797. */
  133798. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  133799. /**
  133800. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  133801. * @param targetFrameRate defines the target frame rate (60 by default)
  133802. * @returns a SceneOptimizerOptions object
  133803. */
  133804. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  133805. /**
  133806. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  133807. * @param targetFrameRate defines the target frame rate (60 by default)
  133808. * @returns a SceneOptimizerOptions object
  133809. */
  133810. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  133811. }
  133812. /**
  133813. * Class used to run optimizations in order to reach a target frame rate
  133814. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133815. */
  133816. export class SceneOptimizer implements IDisposable {
  133817. private _isRunning;
  133818. private _options;
  133819. private _scene;
  133820. private _currentPriorityLevel;
  133821. private _targetFrameRate;
  133822. private _trackerDuration;
  133823. private _currentFrameRate;
  133824. private _sceneDisposeObserver;
  133825. private _improvementMode;
  133826. /**
  133827. * Defines an observable called when the optimizer reaches the target frame rate
  133828. */
  133829. onSuccessObservable: Observable<SceneOptimizer>;
  133830. /**
  133831. * Defines an observable called when the optimizer enables an optimization
  133832. */
  133833. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  133834. /**
  133835. * Defines an observable called when the optimizer is not able to reach the target frame rate
  133836. */
  133837. onFailureObservable: Observable<SceneOptimizer>;
  133838. /**
  133839. * Gets a boolean indicating if the optimizer is in improvement mode
  133840. */
  133841. readonly isInImprovementMode: boolean;
  133842. /**
  133843. * Gets the current priority level (0 at start)
  133844. */
  133845. readonly currentPriorityLevel: number;
  133846. /**
  133847. * Gets the current frame rate checked by the SceneOptimizer
  133848. */
  133849. readonly currentFrameRate: number;
  133850. /**
  133851. * Gets or sets the current target frame rate (60 by default)
  133852. */
  133853. /**
  133854. * Gets or sets the current target frame rate (60 by default)
  133855. */
  133856. targetFrameRate: number;
  133857. /**
  133858. * Gets or sets the current interval between two checks (every 2000ms by default)
  133859. */
  133860. /**
  133861. * Gets or sets the current interval between two checks (every 2000ms by default)
  133862. */
  133863. trackerDuration: number;
  133864. /**
  133865. * Gets the list of active optimizations
  133866. */
  133867. readonly optimizations: SceneOptimization[];
  133868. /**
  133869. * Creates a new SceneOptimizer
  133870. * @param scene defines the scene to work on
  133871. * @param options defines the options to use with the SceneOptimizer
  133872. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  133873. * @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)
  133874. */
  133875. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  133876. /**
  133877. * Stops the current optimizer
  133878. */
  133879. stop(): void;
  133880. /**
  133881. * Reset the optimizer to initial step (current priority level = 0)
  133882. */
  133883. reset(): void;
  133884. /**
  133885. * Start the optimizer. By default it will try to reach a specific framerate
  133886. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  133887. */
  133888. start(): void;
  133889. private _checkCurrentState;
  133890. /**
  133891. * Release all resources
  133892. */
  133893. dispose(): void;
  133894. /**
  133895. * Helper function to create a SceneOptimizer with one single line of code
  133896. * @param scene defines the scene to work on
  133897. * @param options defines the options to use with the SceneOptimizer
  133898. * @param onSuccess defines a callback to call on success
  133899. * @param onFailure defines a callback to call on failure
  133900. * @returns the new SceneOptimizer object
  133901. */
  133902. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  133903. }
  133904. }
  133905. declare module BABYLON {
  133906. /**
  133907. * Class used to serialize a scene into a string
  133908. */
  133909. export class SceneSerializer {
  133910. /**
  133911. * Clear cache used by a previous serialization
  133912. */
  133913. static ClearCache(): void;
  133914. /**
  133915. * Serialize a scene into a JSON compatible object
  133916. * @param scene defines the scene to serialize
  133917. * @returns a JSON compatible object
  133918. */
  133919. static Serialize(scene: Scene): any;
  133920. /**
  133921. * Serialize a mesh into a JSON compatible object
  133922. * @param toSerialize defines the mesh to serialize
  133923. * @param withParents defines if parents must be serialized as well
  133924. * @param withChildren defines if children must be serialized as well
  133925. * @returns a JSON compatible object
  133926. */
  133927. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  133928. }
  133929. }
  133930. declare module BABYLON {
  133931. /**
  133932. * Class used to host texture specific utilities
  133933. */
  133934. export class TextureTools {
  133935. /**
  133936. * Uses the GPU to create a copy texture rescaled at a given size
  133937. * @param texture Texture to copy from
  133938. * @param width defines the desired width
  133939. * @param height defines the desired height
  133940. * @param useBilinearMode defines if bilinear mode has to be used
  133941. * @return the generated texture
  133942. */
  133943. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  133944. }
  133945. }
  133946. declare module BABYLON {
  133947. /**
  133948. * This represents the different options available for the video capture.
  133949. */
  133950. export interface VideoRecorderOptions {
  133951. /** Defines the mime type of the video. */
  133952. mimeType: string;
  133953. /** Defines the FPS the video should be recorded at. */
  133954. fps: number;
  133955. /** Defines the chunk size for the recording data. */
  133956. recordChunckSize: number;
  133957. /** The audio tracks to attach to the recording. */
  133958. audioTracks?: MediaStreamTrack[];
  133959. }
  133960. /**
  133961. * This can help with recording videos from BabylonJS.
  133962. * This is based on the available WebRTC functionalities of the browser.
  133963. *
  133964. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  133965. */
  133966. export class VideoRecorder {
  133967. private static readonly _defaultOptions;
  133968. /**
  133969. * Returns whether or not the VideoRecorder is available in your browser.
  133970. * @param engine Defines the Babylon Engine.
  133971. * @returns true if supported otherwise false.
  133972. */
  133973. static IsSupported(engine: Engine): boolean;
  133974. private readonly _options;
  133975. private _canvas;
  133976. private _mediaRecorder;
  133977. private _recordedChunks;
  133978. private _fileName;
  133979. private _resolve;
  133980. private _reject;
  133981. /**
  133982. * True when a recording is already in progress.
  133983. */
  133984. readonly isRecording: boolean;
  133985. /**
  133986. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  133987. * @param engine Defines the BabylonJS Engine you wish to record.
  133988. * @param options Defines options that can be used to customize the capture.
  133989. */
  133990. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  133991. /**
  133992. * Stops the current recording before the default capture timeout passed in the startRecording function.
  133993. */
  133994. stopRecording(): void;
  133995. /**
  133996. * Starts recording the canvas for a max duration specified in parameters.
  133997. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  133998. * If null no automatic download will start and you can rely on the promise to get the data back.
  133999. * @param maxDuration Defines the maximum recording time in seconds.
  134000. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  134001. * @return A promise callback at the end of the recording with the video data in Blob.
  134002. */
  134003. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  134004. /**
  134005. * Releases internal resources used during the recording.
  134006. */
  134007. dispose(): void;
  134008. private _handleDataAvailable;
  134009. private _handleError;
  134010. private _handleStop;
  134011. }
  134012. }
  134013. declare module BABYLON {
  134014. /**
  134015. * Class containing a set of static utilities functions for screenshots
  134016. */
  134017. export class ScreenshotTools {
  134018. /**
  134019. * Captures a screenshot of the current rendering
  134020. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  134021. * @param engine defines the rendering engine
  134022. * @param camera defines the source camera
  134023. * @param size This parameter can be set to a single number or to an object with the
  134024. * following (optional) properties: precision, width, height. If a single number is passed,
  134025. * it will be used for both width and height. If an object is passed, the screenshot size
  134026. * will be derived from the parameters. The precision property is a multiplier allowing
  134027. * rendering at a higher or lower resolution
  134028. * @param successCallback defines the callback receives a single parameter which contains the
  134029. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  134030. * src parameter of an <img> to display it
  134031. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  134032. * Check your browser for supported MIME types
  134033. */
  134034. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  134035. /**
  134036. * Captures a screenshot of the current rendering
  134037. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  134038. * @param engine defines the rendering engine
  134039. * @param camera defines the source camera
  134040. * @param size This parameter can be set to a single number or to an object with the
  134041. * following (optional) properties: precision, width, height. If a single number is passed,
  134042. * it will be used for both width and height. If an object is passed, the screenshot size
  134043. * will be derived from the parameters. The precision property is a multiplier allowing
  134044. * rendering at a higher or lower resolution
  134045. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  134046. * Check your browser for supported MIME types
  134047. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  134048. * to the src parameter of an <img> to display it
  134049. */
  134050. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  134051. /**
  134052. * Generates an image screenshot from the specified camera.
  134053. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  134054. * @param engine The engine to use for rendering
  134055. * @param camera The camera to use for rendering
  134056. * @param size This parameter can be set to a single number or to an object with the
  134057. * following (optional) properties: precision, width, height. If a single number is passed,
  134058. * it will be used for both width and height. If an object is passed, the screenshot size
  134059. * will be derived from the parameters. The precision property is a multiplier allowing
  134060. * rendering at a higher or lower resolution
  134061. * @param successCallback The callback receives a single parameter which contains the
  134062. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  134063. * src parameter of an <img> to display it
  134064. * @param mimeType The MIME type of the screenshot image (default: image/png).
  134065. * Check your browser for supported MIME types
  134066. * @param samples Texture samples (default: 1)
  134067. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  134068. * @param fileName A name for for the downloaded file.
  134069. */
  134070. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  134071. /**
  134072. * Generates an image screenshot from the specified camera.
  134073. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  134074. * @param engine The engine to use for rendering
  134075. * @param camera The camera to use for rendering
  134076. * @param size This parameter can be set to a single number or to an object with the
  134077. * following (optional) properties: precision, width, height. If a single number is passed,
  134078. * it will be used for both width and height. If an object is passed, the screenshot size
  134079. * will be derived from the parameters. The precision property is a multiplier allowing
  134080. * rendering at a higher or lower resolution
  134081. * @param mimeType The MIME type of the screenshot image (default: image/png).
  134082. * Check your browser for supported MIME types
  134083. * @param samples Texture samples (default: 1)
  134084. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  134085. * @param fileName A name for for the downloaded file.
  134086. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  134087. * to the src parameter of an <img> to display it
  134088. */
  134089. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  134090. /**
  134091. * Gets height and width for screenshot size
  134092. * @private
  134093. */
  134094. private static _getScreenshotSize;
  134095. }
  134096. }
  134097. declare module BABYLON {
  134098. /**
  134099. * Interface for a data buffer
  134100. */
  134101. export interface IDataBuffer {
  134102. /**
  134103. * Reads bytes from the data buffer.
  134104. * @param byteOffset The byte offset to read
  134105. * @param byteLength The byte length to read
  134106. * @returns A promise that resolves when the bytes are read
  134107. */
  134108. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  134109. /**
  134110. * The byte length of the buffer.
  134111. */
  134112. readonly byteLength: number;
  134113. }
  134114. /**
  134115. * Utility class for reading from a data buffer
  134116. */
  134117. export class DataReader {
  134118. /**
  134119. * The data buffer associated with this data reader.
  134120. */
  134121. readonly buffer: IDataBuffer;
  134122. /**
  134123. * The current byte offset from the beginning of the data buffer.
  134124. */
  134125. byteOffset: number;
  134126. private _dataView;
  134127. private _dataByteOffset;
  134128. /**
  134129. * Constructor
  134130. * @param buffer The buffer to read
  134131. */
  134132. constructor(buffer: IDataBuffer);
  134133. /**
  134134. * Loads the given byte length.
  134135. * @param byteLength The byte length to load
  134136. * @returns A promise that resolves when the load is complete
  134137. */
  134138. loadAsync(byteLength: number): Promise<void>;
  134139. /**
  134140. * Read a unsigned 32-bit integer from the currently loaded data range.
  134141. * @returns The 32-bit integer read
  134142. */
  134143. readUint32(): number;
  134144. /**
  134145. * Read a byte array from the currently loaded data range.
  134146. * @param byteLength The byte length to read
  134147. * @returns The byte array read
  134148. */
  134149. readUint8Array(byteLength: number): Uint8Array;
  134150. /**
  134151. * Read a string from the currently loaded data range.
  134152. * @param byteLength The byte length to read
  134153. * @returns The string read
  134154. */
  134155. readString(byteLength: number): string;
  134156. /**
  134157. * Skips the given byte length the currently loaded data range.
  134158. * @param byteLength The byte length to skip
  134159. */
  134160. skipBytes(byteLength: number): void;
  134161. }
  134162. }
  134163. declare module BABYLON {
  134164. /**
  134165. * A cursor which tracks a point on a path
  134166. */
  134167. export class PathCursor {
  134168. private path;
  134169. /**
  134170. * Stores path cursor callbacks for when an onchange event is triggered
  134171. */
  134172. private _onchange;
  134173. /**
  134174. * The value of the path cursor
  134175. */
  134176. value: number;
  134177. /**
  134178. * The animation array of the path cursor
  134179. */
  134180. animations: Animation[];
  134181. /**
  134182. * Initializes the path cursor
  134183. * @param path The path to track
  134184. */
  134185. constructor(path: Path2);
  134186. /**
  134187. * Gets the cursor point on the path
  134188. * @returns A point on the path cursor at the cursor location
  134189. */
  134190. getPoint(): Vector3;
  134191. /**
  134192. * Moves the cursor ahead by the step amount
  134193. * @param step The amount to move the cursor forward
  134194. * @returns This path cursor
  134195. */
  134196. moveAhead(step?: number): PathCursor;
  134197. /**
  134198. * Moves the cursor behind by the step amount
  134199. * @param step The amount to move the cursor back
  134200. * @returns This path cursor
  134201. */
  134202. moveBack(step?: number): PathCursor;
  134203. /**
  134204. * Moves the cursor by the step amount
  134205. * If the step amount is greater than one, an exception is thrown
  134206. * @param step The amount to move the cursor
  134207. * @returns This path cursor
  134208. */
  134209. move(step: number): PathCursor;
  134210. /**
  134211. * Ensures that the value is limited between zero and one
  134212. * @returns This path cursor
  134213. */
  134214. private ensureLimits;
  134215. /**
  134216. * Runs onchange callbacks on change (used by the animation engine)
  134217. * @returns This path cursor
  134218. */
  134219. private raiseOnChange;
  134220. /**
  134221. * Executes a function on change
  134222. * @param f A path cursor onchange callback
  134223. * @returns This path cursor
  134224. */
  134225. onchange(f: (cursor: PathCursor) => void): PathCursor;
  134226. }
  134227. }
  134228. declare module BABYLON {
  134229. /** @hidden */
  134230. export var blurPixelShader: {
  134231. name: string;
  134232. shader: string;
  134233. };
  134234. }
  134235. declare module BABYLON {
  134236. /** @hidden */
  134237. export var pointCloudVertexDeclaration: {
  134238. name: string;
  134239. shader: string;
  134240. };
  134241. }
  134242. // Mixins
  134243. interface Window {
  134244. mozIndexedDB: IDBFactory;
  134245. webkitIndexedDB: IDBFactory;
  134246. msIndexedDB: IDBFactory;
  134247. webkitURL: typeof URL;
  134248. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  134249. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  134250. WebGLRenderingContext: WebGLRenderingContext;
  134251. MSGesture: MSGesture;
  134252. CANNON: any;
  134253. AudioContext: AudioContext;
  134254. webkitAudioContext: AudioContext;
  134255. PointerEvent: any;
  134256. Math: Math;
  134257. Uint8Array: Uint8ArrayConstructor;
  134258. Float32Array: Float32ArrayConstructor;
  134259. mozURL: typeof URL;
  134260. msURL: typeof URL;
  134261. VRFrameData: any; // WebVR, from specs 1.1
  134262. DracoDecoderModule: any;
  134263. setImmediate(handler: (...args: any[]) => void): number;
  134264. }
  134265. interface HTMLCanvasElement {
  134266. requestPointerLock(): void;
  134267. msRequestPointerLock?(): void;
  134268. mozRequestPointerLock?(): void;
  134269. webkitRequestPointerLock?(): void;
  134270. /** Track wether a record is in progress */
  134271. isRecording: boolean;
  134272. /** Capture Stream method defined by some browsers */
  134273. captureStream(fps?: number): MediaStream;
  134274. }
  134275. interface CanvasRenderingContext2D {
  134276. msImageSmoothingEnabled: boolean;
  134277. }
  134278. interface MouseEvent {
  134279. mozMovementX: number;
  134280. mozMovementY: number;
  134281. webkitMovementX: number;
  134282. webkitMovementY: number;
  134283. msMovementX: number;
  134284. msMovementY: number;
  134285. }
  134286. interface Navigator {
  134287. mozGetVRDevices: (any: any) => any;
  134288. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  134289. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  134290. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  134291. webkitGetGamepads(): Gamepad[];
  134292. msGetGamepads(): Gamepad[];
  134293. webkitGamepads(): Gamepad[];
  134294. }
  134295. interface HTMLVideoElement {
  134296. mozSrcObject: any;
  134297. }
  134298. interface Math {
  134299. fround(x: number): number;
  134300. imul(a: number, b: number): number;
  134301. }
  134302. interface WebGLRenderingContext {
  134303. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  134304. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  134305. vertexAttribDivisor(index: number, divisor: number): void;
  134306. createVertexArray(): any;
  134307. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  134308. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  134309. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  134310. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  134311. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  134312. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  134313. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  134314. // Queries
  134315. createQuery(): WebGLQuery;
  134316. deleteQuery(query: WebGLQuery): void;
  134317. beginQuery(target: number, query: WebGLQuery): void;
  134318. endQuery(target: number): void;
  134319. getQueryParameter(query: WebGLQuery, pname: number): any;
  134320. getQuery(target: number, pname: number): any;
  134321. MAX_SAMPLES: number;
  134322. RGBA8: number;
  134323. READ_FRAMEBUFFER: number;
  134324. DRAW_FRAMEBUFFER: number;
  134325. UNIFORM_BUFFER: number;
  134326. HALF_FLOAT_OES: number;
  134327. RGBA16F: number;
  134328. RGBA32F: number;
  134329. R32F: number;
  134330. RG32F: number;
  134331. RGB32F: number;
  134332. R16F: number;
  134333. RG16F: number;
  134334. RGB16F: number;
  134335. RED: number;
  134336. RG: number;
  134337. R8: number;
  134338. RG8: number;
  134339. UNSIGNED_INT_24_8: number;
  134340. DEPTH24_STENCIL8: number;
  134341. MIN: number;
  134342. MAX: number;
  134343. /* Multiple Render Targets */
  134344. drawBuffers(buffers: number[]): void;
  134345. readBuffer(src: number): void;
  134346. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  134347. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  134348. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  134349. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  134350. // Occlusion Query
  134351. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  134352. ANY_SAMPLES_PASSED: number;
  134353. QUERY_RESULT_AVAILABLE: number;
  134354. QUERY_RESULT: number;
  134355. }
  134356. interface WebGLProgram {
  134357. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  134358. }
  134359. interface EXT_disjoint_timer_query {
  134360. QUERY_COUNTER_BITS_EXT: number;
  134361. TIME_ELAPSED_EXT: number;
  134362. TIMESTAMP_EXT: number;
  134363. GPU_DISJOINT_EXT: number;
  134364. QUERY_RESULT_EXT: number;
  134365. QUERY_RESULT_AVAILABLE_EXT: number;
  134366. queryCounterEXT(query: WebGLQuery, target: number): void;
  134367. createQueryEXT(): WebGLQuery;
  134368. beginQueryEXT(target: number, query: WebGLQuery): void;
  134369. endQueryEXT(target: number): void;
  134370. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  134371. deleteQueryEXT(query: WebGLQuery): void;
  134372. }
  134373. interface WebGLUniformLocation {
  134374. _currentState: any;
  134375. }
  134376. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  134377. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  134378. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  134379. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  134380. interface WebGLRenderingContext {
  134381. readonly RASTERIZER_DISCARD: number;
  134382. readonly DEPTH_COMPONENT24: number;
  134383. readonly TEXTURE_3D: number;
  134384. readonly TEXTURE_2D_ARRAY: number;
  134385. readonly TEXTURE_COMPARE_FUNC: number;
  134386. readonly TEXTURE_COMPARE_MODE: number;
  134387. readonly COMPARE_REF_TO_TEXTURE: number;
  134388. readonly TEXTURE_WRAP_R: number;
  134389. readonly HALF_FLOAT: number;
  134390. readonly RGB8: number;
  134391. readonly RED_INTEGER: number;
  134392. readonly RG_INTEGER: number;
  134393. readonly RGB_INTEGER: number;
  134394. readonly RGBA_INTEGER: number;
  134395. readonly R8_SNORM: number;
  134396. readonly RG8_SNORM: number;
  134397. readonly RGB8_SNORM: number;
  134398. readonly RGBA8_SNORM: number;
  134399. readonly R8I: number;
  134400. readonly RG8I: number;
  134401. readonly RGB8I: number;
  134402. readonly RGBA8I: number;
  134403. readonly R8UI: number;
  134404. readonly RG8UI: number;
  134405. readonly RGB8UI: number;
  134406. readonly RGBA8UI: number;
  134407. readonly R16I: number;
  134408. readonly RG16I: number;
  134409. readonly RGB16I: number;
  134410. readonly RGBA16I: number;
  134411. readonly R16UI: number;
  134412. readonly RG16UI: number;
  134413. readonly RGB16UI: number;
  134414. readonly RGBA16UI: number;
  134415. readonly R32I: number;
  134416. readonly RG32I: number;
  134417. readonly RGB32I: number;
  134418. readonly RGBA32I: number;
  134419. readonly R32UI: number;
  134420. readonly RG32UI: number;
  134421. readonly RGB32UI: number;
  134422. readonly RGBA32UI: number;
  134423. readonly RGB10_A2UI: number;
  134424. readonly R11F_G11F_B10F: number;
  134425. readonly RGB9_E5: number;
  134426. readonly RGB10_A2: number;
  134427. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  134428. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  134429. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  134430. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  134431. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  134432. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  134433. 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;
  134434. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  134435. readonly TRANSFORM_FEEDBACK: number;
  134436. readonly INTERLEAVED_ATTRIBS: number;
  134437. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  134438. createTransformFeedback(): WebGLTransformFeedback;
  134439. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  134440. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  134441. beginTransformFeedback(primitiveMode: number): void;
  134442. endTransformFeedback(): void;
  134443. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  134444. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  134445. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  134446. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  134447. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  134448. }
  134449. interface ImageBitmap {
  134450. readonly width: number;
  134451. readonly height: number;
  134452. close(): void;
  134453. }
  134454. interface WebGLQuery extends WebGLObject {
  134455. }
  134456. declare var WebGLQuery: {
  134457. prototype: WebGLQuery;
  134458. new(): WebGLQuery;
  134459. };
  134460. interface WebGLSampler extends WebGLObject {
  134461. }
  134462. declare var WebGLSampler: {
  134463. prototype: WebGLSampler;
  134464. new(): WebGLSampler;
  134465. };
  134466. interface WebGLSync extends WebGLObject {
  134467. }
  134468. declare var WebGLSync: {
  134469. prototype: WebGLSync;
  134470. new(): WebGLSync;
  134471. };
  134472. interface WebGLTransformFeedback extends WebGLObject {
  134473. }
  134474. declare var WebGLTransformFeedback: {
  134475. prototype: WebGLTransformFeedback;
  134476. new(): WebGLTransformFeedback;
  134477. };
  134478. interface WebGLVertexArrayObject extends WebGLObject {
  134479. }
  134480. declare var WebGLVertexArrayObject: {
  134481. prototype: WebGLVertexArrayObject;
  134482. new(): WebGLVertexArrayObject;
  134483. };
  134484. // Type definitions for WebVR API
  134485. // Project: https://w3c.github.io/webvr/
  134486. // Definitions by: six a <https://github.com/lostfictions>
  134487. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  134488. interface VRDisplay extends EventTarget {
  134489. /**
  134490. * Dictionary of capabilities describing the VRDisplay.
  134491. */
  134492. readonly capabilities: VRDisplayCapabilities;
  134493. /**
  134494. * z-depth defining the far plane of the eye view frustum
  134495. * enables mapping of values in the render target depth
  134496. * attachment to scene coordinates. Initially set to 10000.0.
  134497. */
  134498. depthFar: number;
  134499. /**
  134500. * z-depth defining the near plane of the eye view frustum
  134501. * enables mapping of values in the render target depth
  134502. * attachment to scene coordinates. Initially set to 0.01.
  134503. */
  134504. depthNear: number;
  134505. /**
  134506. * An identifier for this distinct VRDisplay. Used as an
  134507. * association point in the Gamepad API.
  134508. */
  134509. readonly displayId: number;
  134510. /**
  134511. * A display name, a user-readable name identifying it.
  134512. */
  134513. readonly displayName: string;
  134514. readonly isConnected: boolean;
  134515. readonly isPresenting: boolean;
  134516. /**
  134517. * If this VRDisplay supports room-scale experiences, the optional
  134518. * stage attribute contains details on the room-scale parameters.
  134519. */
  134520. readonly stageParameters: VRStageParameters | null;
  134521. /**
  134522. * Passing the value returned by `requestAnimationFrame` to
  134523. * `cancelAnimationFrame` will unregister the callback.
  134524. * @param handle Define the hanle of the request to cancel
  134525. */
  134526. cancelAnimationFrame(handle: number): void;
  134527. /**
  134528. * Stops presenting to the VRDisplay.
  134529. * @returns a promise to know when it stopped
  134530. */
  134531. exitPresent(): Promise<void>;
  134532. /**
  134533. * Return the current VREyeParameters for the given eye.
  134534. * @param whichEye Define the eye we want the parameter for
  134535. * @returns the eye parameters
  134536. */
  134537. getEyeParameters(whichEye: string): VREyeParameters;
  134538. /**
  134539. * Populates the passed VRFrameData with the information required to render
  134540. * the current frame.
  134541. * @param frameData Define the data structure to populate
  134542. * @returns true if ok otherwise false
  134543. */
  134544. getFrameData(frameData: VRFrameData): boolean;
  134545. /**
  134546. * Get the layers currently being presented.
  134547. * @returns the list of VR layers
  134548. */
  134549. getLayers(): VRLayer[];
  134550. /**
  134551. * Return a VRPose containing the future predicted pose of the VRDisplay
  134552. * when the current frame will be presented. The value returned will not
  134553. * change until JavaScript has returned control to the browser.
  134554. *
  134555. * The VRPose will contain the position, orientation, velocity,
  134556. * and acceleration of each of these properties.
  134557. * @returns the pose object
  134558. */
  134559. getPose(): VRPose;
  134560. /**
  134561. * Return the current instantaneous pose of the VRDisplay, with no
  134562. * prediction applied.
  134563. * @returns the current instantaneous pose
  134564. */
  134565. getImmediatePose(): VRPose;
  134566. /**
  134567. * The callback passed to `requestAnimationFrame` will be called
  134568. * any time a new frame should be rendered. When the VRDisplay is
  134569. * presenting the callback will be called at the native refresh
  134570. * rate of the HMD. When not presenting this function acts
  134571. * identically to how window.requestAnimationFrame acts. Content should
  134572. * make no assumptions of frame rate or vsync behavior as the HMD runs
  134573. * asynchronously from other displays and at differing refresh rates.
  134574. * @param callback Define the eaction to run next frame
  134575. * @returns the request handle it
  134576. */
  134577. requestAnimationFrame(callback: FrameRequestCallback): number;
  134578. /**
  134579. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  134580. * Repeat calls while already presenting will update the VRLayers being displayed.
  134581. * @param layers Define the list of layer to present
  134582. * @returns a promise to know when the request has been fulfilled
  134583. */
  134584. requestPresent(layers: VRLayer[]): Promise<void>;
  134585. /**
  134586. * Reset the pose for this display, treating its current position and
  134587. * orientation as the "origin/zero" values. VRPose.position,
  134588. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  134589. * updated when calling resetPose(). This should be called in only
  134590. * sitting-space experiences.
  134591. */
  134592. resetPose(): void;
  134593. /**
  134594. * The VRLayer provided to the VRDisplay will be captured and presented
  134595. * in the HMD. Calling this function has the same effect on the source
  134596. * canvas as any other operation that uses its source image, and canvases
  134597. * created without preserveDrawingBuffer set to true will be cleared.
  134598. * @param pose Define the pose to submit
  134599. */
  134600. submitFrame(pose?: VRPose): void;
  134601. }
  134602. declare var VRDisplay: {
  134603. prototype: VRDisplay;
  134604. new(): VRDisplay;
  134605. };
  134606. interface VRLayer {
  134607. leftBounds?: number[] | Float32Array | null;
  134608. rightBounds?: number[] | Float32Array | null;
  134609. source?: HTMLCanvasElement | null;
  134610. }
  134611. interface VRDisplayCapabilities {
  134612. readonly canPresent: boolean;
  134613. readonly hasExternalDisplay: boolean;
  134614. readonly hasOrientation: boolean;
  134615. readonly hasPosition: boolean;
  134616. readonly maxLayers: number;
  134617. }
  134618. interface VREyeParameters {
  134619. /** @deprecated */
  134620. readonly fieldOfView: VRFieldOfView;
  134621. readonly offset: Float32Array;
  134622. readonly renderHeight: number;
  134623. readonly renderWidth: number;
  134624. }
  134625. interface VRFieldOfView {
  134626. readonly downDegrees: number;
  134627. readonly leftDegrees: number;
  134628. readonly rightDegrees: number;
  134629. readonly upDegrees: number;
  134630. }
  134631. interface VRFrameData {
  134632. readonly leftProjectionMatrix: Float32Array;
  134633. readonly leftViewMatrix: Float32Array;
  134634. readonly pose: VRPose;
  134635. readonly rightProjectionMatrix: Float32Array;
  134636. readonly rightViewMatrix: Float32Array;
  134637. readonly timestamp: number;
  134638. }
  134639. interface VRPose {
  134640. readonly angularAcceleration: Float32Array | null;
  134641. readonly angularVelocity: Float32Array | null;
  134642. readonly linearAcceleration: Float32Array | null;
  134643. readonly linearVelocity: Float32Array | null;
  134644. readonly orientation: Float32Array | null;
  134645. readonly position: Float32Array | null;
  134646. readonly timestamp: number;
  134647. }
  134648. interface VRStageParameters {
  134649. sittingToStandingTransform?: Float32Array;
  134650. sizeX?: number;
  134651. sizeY?: number;
  134652. }
  134653. interface Navigator {
  134654. getVRDisplays(): Promise<VRDisplay[]>;
  134655. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  134656. }
  134657. interface Window {
  134658. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  134659. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  134660. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  134661. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  134662. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  134663. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  134664. }
  134665. interface Gamepad {
  134666. readonly displayId: number;
  134667. }
  134668. type XRSessionMode =
  134669. | "inline"
  134670. | "immersive-vr"
  134671. | "immersive-ar";
  134672. type XRReferenceSpaceType =
  134673. | "viewer"
  134674. | "local"
  134675. | "local-floor"
  134676. | "bounded-floor"
  134677. | "unbounded";
  134678. type XREnvironmentBlendMode =
  134679. | "opaque"
  134680. | "additive"
  134681. | "alpha-blend";
  134682. type XRVisibilityState =
  134683. | "visible"
  134684. | "visible-blurred"
  134685. | "hidden";
  134686. type XRHandedness =
  134687. | "none"
  134688. | "left"
  134689. | "right";
  134690. type XRTargetRayMode =
  134691. | "gaze"
  134692. | "tracked-pointer"
  134693. | "screen";
  134694. type XREye =
  134695. | "none"
  134696. | "left"
  134697. | "right";
  134698. interface XRSpace extends EventTarget {
  134699. }
  134700. interface XRRenderState {
  134701. depthNear?: number;
  134702. depthFar?: number;
  134703. inlineVerticalFieldOfView?: number;
  134704. baseLayer?: XRWebGLLayer;
  134705. }
  134706. interface XRInputSource {
  134707. handedness: XRHandedness;
  134708. targetRayMode: XRTargetRayMode;
  134709. targetRaySpace: XRSpace;
  134710. gripSpace: XRSpace | undefined;
  134711. gamepad: Gamepad | undefined;
  134712. profiles: Array<string>;
  134713. }
  134714. interface XRSession {
  134715. addEventListener: Function;
  134716. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  134717. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  134718. requestAnimationFrame: Function;
  134719. end(): Promise<void>;
  134720. renderState: XRRenderState;
  134721. inputSources: Array<XRInputSource>;
  134722. }
  134723. interface XRReferenceSpace extends XRSpace {
  134724. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  134725. onreset: any;
  134726. }
  134727. interface XRFrame {
  134728. session: XRSession;
  134729. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  134730. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  134731. }
  134732. interface XRViewerPose extends XRPose {
  134733. views: Array<XRView>;
  134734. }
  134735. interface XRPose {
  134736. transform: XRRigidTransform;
  134737. emulatedPosition: boolean;
  134738. }
  134739. interface XRWebGLLayerOptions {
  134740. antialias ?: boolean;
  134741. depth ?: boolean;
  134742. stencil ?: boolean;
  134743. alpha ?: boolean;
  134744. multiview ?: boolean;
  134745. framebufferScaleFactor ?: number;
  134746. }
  134747. declare var XRWebGLLayer: {
  134748. prototype: XRWebGLLayer;
  134749. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  134750. };
  134751. interface XRWebGLLayer {
  134752. framebuffer: WebGLFramebuffer;
  134753. framebufferWidth: number;
  134754. framebufferHeight: number;
  134755. getViewport: Function;
  134756. }
  134757. interface XRRigidTransform {
  134758. position: DOMPointReadOnly;
  134759. orientation: DOMPointReadOnly;
  134760. matrix: Float32Array;
  134761. inverse: XRRigidTransform;
  134762. }
  134763. interface XRView {
  134764. eye: XREye;
  134765. projectionMatrix: Float32Array;
  134766. transform: XRRigidTransform;
  134767. }
  134768. interface XRInputSourceChangeEvent {
  134769. session: XRSession;
  134770. removed: Array<XRInputSource>;
  134771. added: Array<XRInputSource>;
  134772. }